objc2_virtualization/generated/
VZVirtualMachineConfiguration.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11    /// Virtual machine configuration.
12    ///
13    /// VZVirtualMachineConfiguration defines the configuration of a VZVirtualMachine.
14    ///
15    /// The configuration of devices is often done in two parts:
16    /// - Device configuration
17    /// - Device attachment
18    ///
19    /// The device configuration defines the characteristics of the emulated hardware device.
20    /// For example, for a network device, the device configuration defines the type of network adapter present
21    /// in the virtual machine and its MAC address.
22    ///
23    /// The device attachment defines the host machine's resources that are exposed by the virtual device.
24    /// For example, for a network device, the device attachment can be virtual network interface with a NAT
25    /// to the real network.
26    ///
27    /// Creating a virtual machine using the Virtualization framework requires the app to have the "com.apple.security.virtualization" entitlement.
28    /// A VZVirtualMachineConfiguration is considered invalid if the application does not have the entitlement.
29    ///
30    /// ## Configuring a virtual machine to run macOS
31    ///
32    /// To configure a virtual machine running macOS:
33    /// - Set up a platform configuration of type VZMacPlatformConfiguration and set it on the `platform` property.
34    /// - Set up a VZMacOSBootLoader on the `bootLoader` property.
35    /// - Set the CPUCount and memorySize based on the guest's VZMacOSConfigurationRequirements.
36    /// - Set up the main storage device as first device on `storageDevices`. Additional storage devices can be set up after the main storage.
37    /// - Set up the `keyboards`, `pointingDevices` and `graphicsDevices` devices.
38    /// - Set up any additional device as needed.
39    ///
40    /// ## Configuring a virtual machine to run Linux
41    ///
42    /// To configure a virtual machine running Linux:
43    /// - Set up a VZLinuxBootLoader on the `bootLoader` property.
44    /// - Set the CPUCount and memorySize.
45    /// - Set up any additional device as needed.
46    ///
47    ///
48    /// See: VZVirtualMachine
49    ///
50    /// See also [Apple's documentation](https://developer.apple.com/documentation/virtualization/vzvirtualmachineconfiguration?language=objc)
51    #[unsafe(super(NSObject))]
52    #[derive(Debug, PartialEq, Eq, Hash)]
53    pub struct VZVirtualMachineConfiguration;
54);
55
56extern_conformance!(
57    unsafe impl NSCopying for VZVirtualMachineConfiguration {}
58);
59
60unsafe impl CopyingHelper for VZVirtualMachineConfiguration {
61    type Result = Self;
62}
63
64extern_conformance!(
65    unsafe impl NSObjectProtocol for VZVirtualMachineConfiguration {}
66);
67
68impl VZVirtualMachineConfiguration {
69    extern_methods!(
70        #[cfg(feature = "VZBootLoader")]
71        /// Boot loader used when the virtual machine starts.
72        ///
73        /// See: VZLinuxBootLoader
74        ///
75        /// See: VZMacOSBootLoader
76        #[unsafe(method(bootLoader))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn bootLoader(&self) -> Option<Retained<VZBootLoader>>;
79
80        #[cfg(feature = "VZBootLoader")]
81        /// Setter for [`bootLoader`][Self::bootLoader].
82        #[unsafe(method(setBootLoader:))]
83        #[unsafe(method_family = none)]
84        pub unsafe fn setBootLoader(&self, boot_loader: Option<&VZBootLoader>);
85
86        /// Virtual machine memory size in bytes.
87        ///
88        /// The memory size must be a multiple of a 1 megabyte (1024 * 1024 bytes) between VZVirtualMachineConfiguration.minimumAllowedMemorySize
89        /// and VZVirtualMachineConfiguration.maximumAllowedMemorySize.
90        ///
91        /// The memorySize represents the total physical memory seen by a guest OS running in the virtual machine.
92        /// Not all memory is allocated on start, the virtual machine allocates memory on demand.
93        ///
94        /// See: VZVirtualMachineConfiguration.minimumAllowedMemorySize
95        ///
96        /// See: VZVirtualMachineConfiguration.maximumAllowedMemorySize
97        #[unsafe(method(memorySize))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn memorySize(&self) -> u64;
100
101        /// Setter for [`memorySize`][Self::memorySize].
102        #[unsafe(method(setMemorySize:))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn setMemorySize(&self, memory_size: u64);
105
106        /// Number of CPUs.
107        ///
108        /// The number of CPUs must be a value between VZVirtualMachineConfiguration.minimumAllowedCPUCount
109        /// and VZVirtualMachineConfiguration.maximumAllowedCPUCount.
110        ///
111        ///
112        /// See: VZVirtualMachineConfiguration.minimumAllowedCPUCount
113        ///
114        /// See: VZVirtualMachineConfiguration.maximumAllowedCPUCount
115        #[unsafe(method(CPUCount))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn CPUCount(&self) -> NSUInteger;
118
119        /// Setter for [`CPUCount`][Self::CPUCount].
120        #[unsafe(method(setCPUCount:))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn setCPUCount(&self, cpu_count: NSUInteger);
123
124        #[cfg(feature = "VZPlatformConfiguration")]
125        /// The hardware platform to use.
126        ///
127        /// Can be an instance of a VZGenericPlatformConfiguration or VZMacPlatformConfiguration. Defaults to VZGenericPlatformConfiguration.
128        /// When restoring from saved state you must ensure your configuration matches that of the saved virtual machine.
129        ///
130        ///
131        /// See: VZGenericPlatformConfiguration
132        ///
133        /// See: VZMacPlatformConfiguration
134        #[unsafe(method(platform))]
135        #[unsafe(method_family = none)]
136        pub unsafe fn platform(&self) -> Retained<VZPlatformConfiguration>;
137
138        #[cfg(feature = "VZPlatformConfiguration")]
139        /// Setter for [`platform`][Self::platform].
140        #[unsafe(method(setPlatform:))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn setPlatform(&self, platform: &VZPlatformConfiguration);
143
144        #[cfg(feature = "VZAudioDeviceConfiguration")]
145        /// List of audio devices. Empty by default.
146        ///
147        /// See: VZVirtioSoundDeviceConfiguration
148        #[unsafe(method(audioDevices))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn audioDevices(&self) -> Retained<NSArray<VZAudioDeviceConfiguration>>;
151
152        #[cfg(feature = "VZAudioDeviceConfiguration")]
153        /// Setter for [`audioDevices`][Self::audioDevices].
154        ///
155        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
156        #[unsafe(method(setAudioDevices:))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn setAudioDevices(&self, audio_devices: &NSArray<VZAudioDeviceConfiguration>);
159
160        #[cfg(feature = "VZConsoleDeviceConfiguration")]
161        /// List of console devices. Empty by default.
162        ///
163        /// See: VZVirtioConsoleDeviceConfiguration
164        #[unsafe(method(consoleDevices))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn consoleDevices(&self) -> Retained<NSArray<VZConsoleDeviceConfiguration>>;
167
168        #[cfg(feature = "VZConsoleDeviceConfiguration")]
169        /// Setter for [`consoleDevices`][Self::consoleDevices].
170        ///
171        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
172        #[unsafe(method(setConsoleDevices:))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn setConsoleDevices(
175            &self,
176            console_devices: &NSArray<VZConsoleDeviceConfiguration>,
177        );
178
179        #[cfg(feature = "VZDirectorySharingDeviceConfiguration")]
180        /// List of directory sharing devices. Empty by default.
181        ///
182        /// See: VZVirtioFileSystemDeviceConfiguration
183        #[unsafe(method(directorySharingDevices))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn directorySharingDevices(
186            &self,
187        ) -> Retained<NSArray<VZDirectorySharingDeviceConfiguration>>;
188
189        #[cfg(feature = "VZDirectorySharingDeviceConfiguration")]
190        /// Setter for [`directorySharingDevices`][Self::directorySharingDevices].
191        ///
192        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
193        #[unsafe(method(setDirectorySharingDevices:))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn setDirectorySharingDevices(
196            &self,
197            directory_sharing_devices: &NSArray<VZDirectorySharingDeviceConfiguration>,
198        );
199
200        #[cfg(feature = "VZEntropyDeviceConfiguration")]
201        /// List of entropy devices. Empty by default.
202        ///
203        /// See: VZVirtioEntropyDeviceConfiguration
204        #[unsafe(method(entropyDevices))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn entropyDevices(&self) -> Retained<NSArray<VZEntropyDeviceConfiguration>>;
207
208        #[cfg(feature = "VZEntropyDeviceConfiguration")]
209        /// Setter for [`entropyDevices`][Self::entropyDevices].
210        ///
211        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
212        #[unsafe(method(setEntropyDevices:))]
213        #[unsafe(method_family = none)]
214        pub unsafe fn setEntropyDevices(
215            &self,
216            entropy_devices: &NSArray<VZEntropyDeviceConfiguration>,
217        );
218
219        #[cfg(feature = "VZMemoryBalloonDeviceConfiguration")]
220        /// List of memory balloon devices. Empty by default.
221        ///
222        /// See: VZVirtioTraditionalMemoryBalloonDeviceConfiguration
223        #[unsafe(method(memoryBalloonDevices))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn memoryBalloonDevices(
226            &self,
227        ) -> Retained<NSArray<VZMemoryBalloonDeviceConfiguration>>;
228
229        #[cfg(feature = "VZMemoryBalloonDeviceConfiguration")]
230        /// Setter for [`memoryBalloonDevices`][Self::memoryBalloonDevices].
231        ///
232        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
233        #[unsafe(method(setMemoryBalloonDevices:))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn setMemoryBalloonDevices(
236            &self,
237            memory_balloon_devices: &NSArray<VZMemoryBalloonDeviceConfiguration>,
238        );
239
240        #[cfg(feature = "VZNetworkDeviceConfiguration")]
241        /// List of network adapters. Empty by default.
242        ///
243        /// See: VZVirtioNetworkDeviceConfiguration
244        #[unsafe(method(networkDevices))]
245        #[unsafe(method_family = none)]
246        pub unsafe fn networkDevices(&self) -> Retained<NSArray<VZNetworkDeviceConfiguration>>;
247
248        #[cfg(feature = "VZNetworkDeviceConfiguration")]
249        /// Setter for [`networkDevices`][Self::networkDevices].
250        ///
251        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
252        #[unsafe(method(setNetworkDevices:))]
253        #[unsafe(method_family = none)]
254        pub unsafe fn setNetworkDevices(
255            &self,
256            network_devices: &NSArray<VZNetworkDeviceConfiguration>,
257        );
258
259        #[cfg(feature = "VZSerialPortConfiguration")]
260        /// List of serial ports. Empty by default.
261        ///
262        /// See: VZVirtioConsoleDeviceSerialPortConfiguration
263        #[unsafe(method(serialPorts))]
264        #[unsafe(method_family = none)]
265        pub unsafe fn serialPorts(&self) -> Retained<NSArray<VZSerialPortConfiguration>>;
266
267        #[cfg(feature = "VZSerialPortConfiguration")]
268        /// Setter for [`serialPorts`][Self::serialPorts].
269        ///
270        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
271        #[unsafe(method(setSerialPorts:))]
272        #[unsafe(method_family = none)]
273        pub unsafe fn setSerialPorts(&self, serial_ports: &NSArray<VZSerialPortConfiguration>);
274
275        #[cfg(feature = "VZSocketDeviceConfiguration")]
276        /// List of socket devices. Empty by default.
277        ///
278        /// See: VZVirtioSocketDeviceConfiguration
279        #[unsafe(method(socketDevices))]
280        #[unsafe(method_family = none)]
281        pub unsafe fn socketDevices(&self) -> Retained<NSArray<VZSocketDeviceConfiguration>>;
282
283        #[cfg(feature = "VZSocketDeviceConfiguration")]
284        /// Setter for [`socketDevices`][Self::socketDevices].
285        ///
286        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
287        #[unsafe(method(setSocketDevices:))]
288        #[unsafe(method_family = none)]
289        pub unsafe fn setSocketDevices(
290            &self,
291            socket_devices: &NSArray<VZSocketDeviceConfiguration>,
292        );
293
294        #[cfg(feature = "VZStorageDeviceConfiguration")]
295        /// List of disk devices. Empty by default.
296        ///
297        /// See: VZNVMExpressControllerDeviceConfiguration
298        ///
299        /// See: VZUSBMassStorageDeviceConfiguration
300        ///
301        /// See: VZVirtioBlockDeviceConfiguration
302        #[unsafe(method(storageDevices))]
303        #[unsafe(method_family = none)]
304        pub unsafe fn storageDevices(&self) -> Retained<NSArray<VZStorageDeviceConfiguration>>;
305
306        #[cfg(feature = "VZStorageDeviceConfiguration")]
307        /// Setter for [`storageDevices`][Self::storageDevices].
308        ///
309        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
310        #[unsafe(method(setStorageDevices:))]
311        #[unsafe(method_family = none)]
312        pub unsafe fn setStorageDevices(
313            &self,
314            storage_devices: &NSArray<VZStorageDeviceConfiguration>,
315        );
316
317        #[cfg(feature = "VZKeyboardConfiguration")]
318        /// List of keyboards. Empty by default.
319        ///
320        /// See: VZUSBKeyboardConfiguration
321        ///
322        /// See: VZMacKeyboardConfiguration
323        #[unsafe(method(keyboards))]
324        #[unsafe(method_family = none)]
325        pub unsafe fn keyboards(&self) -> Retained<NSArray<VZKeyboardConfiguration>>;
326
327        #[cfg(feature = "VZKeyboardConfiguration")]
328        /// Setter for [`keyboards`][Self::keyboards].
329        ///
330        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
331        #[unsafe(method(setKeyboards:))]
332        #[unsafe(method_family = none)]
333        pub unsafe fn setKeyboards(&self, keyboards: &NSArray<VZKeyboardConfiguration>);
334
335        #[cfg(feature = "VZPointingDeviceConfiguration")]
336        /// List of pointing devices. Empty by default.
337        ///
338        /// See: VZUSBScreenCoordinatePointingDeviceConfiguration
339        ///
340        /// See: VZMacTrackpadConfiguration
341        #[unsafe(method(pointingDevices))]
342        #[unsafe(method_family = none)]
343        pub unsafe fn pointingDevices(&self) -> Retained<NSArray<VZPointingDeviceConfiguration>>;
344
345        #[cfg(feature = "VZPointingDeviceConfiguration")]
346        /// Setter for [`pointingDevices`][Self::pointingDevices].
347        ///
348        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
349        #[unsafe(method(setPointingDevices:))]
350        #[unsafe(method_family = none)]
351        pub unsafe fn setPointingDevices(
352            &self,
353            pointing_devices: &NSArray<VZPointingDeviceConfiguration>,
354        );
355
356        #[cfg(feature = "VZGraphicsDeviceConfiguration")]
357        /// List of graphics devices. Empty by default.
358        ///
359        /// See: VZMacGraphicsDeviceConfiguration
360        #[unsafe(method(graphicsDevices))]
361        #[unsafe(method_family = none)]
362        pub unsafe fn graphicsDevices(&self) -> Retained<NSArray<VZGraphicsDeviceConfiguration>>;
363
364        #[cfg(feature = "VZGraphicsDeviceConfiguration")]
365        /// Setter for [`graphicsDevices`][Self::graphicsDevices].
366        ///
367        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
368        #[unsafe(method(setGraphicsDevices:))]
369        #[unsafe(method_family = none)]
370        pub unsafe fn setGraphicsDevices(
371            &self,
372            graphics_devices: &NSArray<VZGraphicsDeviceConfiguration>,
373        );
374
375        #[cfg(feature = "VZUSBControllerConfiguration")]
376        /// List of USB Controllers. Empty by default.
377        ///
378        /// This list represents a set of USB controllers that the virtual machine will start with.
379        /// For each entry in this list, there will be a corresponding runtime object created in VZVirtualMachine.usbControllers property.
380        ///
381        /// See: VZUSBControllerConfiguration
382        #[unsafe(method(usbControllers))]
383        #[unsafe(method_family = none)]
384        pub unsafe fn usbControllers(&self) -> Retained<NSArray<VZUSBControllerConfiguration>>;
385
386        #[cfg(feature = "VZUSBControllerConfiguration")]
387        /// Setter for [`usbControllers`][Self::usbControllers].
388        ///
389        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
390        #[unsafe(method(setUsbControllers:))]
391        #[unsafe(method_family = none)]
392        pub unsafe fn setUsbControllers(
393            &self,
394            usb_controllers: &NSArray<VZUSBControllerConfiguration>,
395        );
396    );
397}
398
399/// Methods declared on superclass `NSObject`.
400impl VZVirtualMachineConfiguration {
401    extern_methods!(
402        #[unsafe(method(init))]
403        #[unsafe(method_family = init)]
404        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
405
406        #[unsafe(method(new))]
407        #[unsafe(method_family = new)]
408        pub unsafe fn new() -> Retained<Self>;
409    );
410}
411
412/// VZVirtualMachineConfigurationValidation.
413///
414/// Virtual machine configuration runtime validation.
415impl VZVirtualMachineConfiguration {
416    extern_methods!(
417        /// Validate the configuration.
418        ///
419        /// Parameter `error`: If not nil, assigned with the validation error if the validation failed.
420        ///
421        /// Returns: YES if the configuration is valid.
422        #[unsafe(method(validateWithError:_))]
423        #[unsafe(method_family = none)]
424        pub unsafe fn validateWithError(&self) -> Result<(), Retained<NSError>>;
425
426        /// Validate the configuration is savable.
427        ///
428        /// Verify that a virtual machine with this configuration is savable.
429        /// Not all configuration options can be safely saved and restored from file.
430        /// If this evaluates to NO, the caller should expect future calls to saveMachineStateToURL:completionHandler: to fail.
431        ///
432        /// Parameter `error`: If not nil, assigned with an error describing the unsupported configuration option.
433        ///
434        /// Returns: YES if the configuration is savable.
435        #[unsafe(method(validateSaveRestoreSupportWithError:_))]
436        #[unsafe(method_family = none)]
437        pub unsafe fn validateSaveRestoreSupportWithError(&self) -> Result<(), Retained<NSError>>;
438
439        /// Minimum amount of memory required by virtual machines.
440        ///
441        /// See: VZVirtualMachineConfiguration.memorySize
442        #[unsafe(method(minimumAllowedMemorySize))]
443        #[unsafe(method_family = none)]
444        pub unsafe fn minimumAllowedMemorySize() -> u64;
445
446        /// Maximum amount of memory allowed for a virtual machine.
447        ///
448        /// See: VZVirtualMachineConfiguration.memorySize
449        #[unsafe(method(maximumAllowedMemorySize))]
450        #[unsafe(method_family = none)]
451        pub unsafe fn maximumAllowedMemorySize() -> u64;
452
453        /// Minimum number of CPUs for a virtual machine.
454        ///
455        /// See: VZVirtualMachineConfiguration.CPUCount
456        #[unsafe(method(minimumAllowedCPUCount))]
457        #[unsafe(method_family = none)]
458        pub unsafe fn minimumAllowedCPUCount() -> NSUInteger;
459
460        /// Maximum number of CPUs for a virtual machine.
461        ///
462        /// See: VZVirtualMachineConfiguration.CPUCount
463        #[unsafe(method(maximumAllowedCPUCount))]
464        #[unsafe(method_family = none)]
465        pub unsafe fn maximumAllowedCPUCount() -> NSUInteger;
466    );
467}