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
56unsafe impl NSCopying for VZVirtualMachineConfiguration {}
57
58unsafe impl CopyingHelper for VZVirtualMachineConfiguration {
59    type Result = Self;
60}
61
62unsafe impl NSObjectProtocol for VZVirtualMachineConfiguration {}
63
64impl VZVirtualMachineConfiguration {
65    extern_methods!(
66        #[cfg(feature = "VZBootLoader")]
67        /// Boot loader used when the virtual machine starts.
68        ///
69        /// See: VZLinuxBootLoader
70        ///
71        /// See: VZMacOSBootLoader
72        #[unsafe(method(bootLoader))]
73        #[unsafe(method_family = none)]
74        pub unsafe fn bootLoader(&self) -> Option<Retained<VZBootLoader>>;
75
76        #[cfg(feature = "VZBootLoader")]
77        /// Setter for [`bootLoader`][Self::bootLoader].
78        #[unsafe(method(setBootLoader:))]
79        #[unsafe(method_family = none)]
80        pub unsafe fn setBootLoader(&self, boot_loader: Option<&VZBootLoader>);
81
82        /// Virtual machine memory size in bytes.
83        ///
84        /// The memory size must be a multiple of a 1 megabyte (1024 * 1024 bytes) between VZVirtualMachineConfiguration.minimumAllowedMemorySize
85        /// and VZVirtualMachineConfiguration.maximumAllowedMemorySize.
86        ///
87        /// The memorySize represents the total physical memory seen by a guest OS running in the virtual machine.
88        /// Not all memory is allocated on start, the virtual machine allocates memory on demand.
89        ///
90        /// See: VZVirtualMachineConfiguration.minimumAllowedMemorySize
91        ///
92        /// See: VZVirtualMachineConfiguration.maximumAllowedMemorySize
93        #[unsafe(method(memorySize))]
94        #[unsafe(method_family = none)]
95        pub unsafe fn memorySize(&self) -> u64;
96
97        /// Setter for [`memorySize`][Self::memorySize].
98        #[unsafe(method(setMemorySize:))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn setMemorySize(&self, memory_size: u64);
101
102        /// Number of CPUs.
103        ///
104        /// The number of CPUs must be a value between VZVirtualMachineConfiguration.minimumAllowedCPUCount
105        /// and VZVirtualMachineConfiguration.maximumAllowedCPUCount.
106        ///
107        ///
108        /// See: VZVirtualMachineConfiguration.minimumAllowedCPUCount
109        ///
110        /// See: VZVirtualMachineConfiguration.maximumAllowedCPUCount
111        #[unsafe(method(CPUCount))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn CPUCount(&self) -> NSUInteger;
114
115        /// Setter for [`CPUCount`][Self::CPUCount].
116        #[unsafe(method(setCPUCount:))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn setCPUCount(&self, cpu_count: NSUInteger);
119
120        #[cfg(feature = "VZPlatformConfiguration")]
121        /// The hardware platform to use.
122        ///
123        /// Can be an instance of a VZGenericPlatformConfiguration or VZMacPlatformConfiguration. Defaults to VZGenericPlatformConfiguration.
124        /// When restoring from saved state you must ensure your configuration matches that of the saved virtual machine.
125        ///
126        ///
127        /// See: VZGenericPlatformConfiguration
128        ///
129        /// See: VZMacPlatformConfiguration
130        #[unsafe(method(platform))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn platform(&self) -> Retained<VZPlatformConfiguration>;
133
134        #[cfg(feature = "VZPlatformConfiguration")]
135        /// Setter for [`platform`][Self::platform].
136        #[unsafe(method(setPlatform:))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn setPlatform(&self, platform: &VZPlatformConfiguration);
139
140        #[cfg(feature = "VZAudioDeviceConfiguration")]
141        /// List of audio devices. Empty by default.
142        ///
143        /// See: VZVirtioSoundDeviceConfiguration
144        #[unsafe(method(audioDevices))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn audioDevices(&self) -> Retained<NSArray<VZAudioDeviceConfiguration>>;
147
148        #[cfg(feature = "VZAudioDeviceConfiguration")]
149        /// Setter for [`audioDevices`][Self::audioDevices].
150        #[unsafe(method(setAudioDevices:))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn setAudioDevices(&self, audio_devices: &NSArray<VZAudioDeviceConfiguration>);
153
154        #[cfg(feature = "VZConsoleDeviceConfiguration")]
155        /// List of console devices. Empty by default.
156        ///
157        /// See: VZVirtioConsoleDeviceConfiguration
158        #[unsafe(method(consoleDevices))]
159        #[unsafe(method_family = none)]
160        pub unsafe fn consoleDevices(&self) -> Retained<NSArray<VZConsoleDeviceConfiguration>>;
161
162        #[cfg(feature = "VZConsoleDeviceConfiguration")]
163        /// Setter for [`consoleDevices`][Self::consoleDevices].
164        #[unsafe(method(setConsoleDevices:))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn setConsoleDevices(
167            &self,
168            console_devices: &NSArray<VZConsoleDeviceConfiguration>,
169        );
170
171        #[cfg(feature = "VZDirectorySharingDeviceConfiguration")]
172        /// List of directory sharing devices. Empty by default.
173        ///
174        /// See: VZVirtioFileSystemDeviceConfiguration
175        #[unsafe(method(directorySharingDevices))]
176        #[unsafe(method_family = none)]
177        pub unsafe fn directorySharingDevices(
178            &self,
179        ) -> Retained<NSArray<VZDirectorySharingDeviceConfiguration>>;
180
181        #[cfg(feature = "VZDirectorySharingDeviceConfiguration")]
182        /// Setter for [`directorySharingDevices`][Self::directorySharingDevices].
183        #[unsafe(method(setDirectorySharingDevices:))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn setDirectorySharingDevices(
186            &self,
187            directory_sharing_devices: &NSArray<VZDirectorySharingDeviceConfiguration>,
188        );
189
190        #[cfg(feature = "VZEntropyDeviceConfiguration")]
191        /// List of entropy devices. Empty by default.
192        ///
193        /// See: VZVirtioEntropyDeviceConfiguration
194        #[unsafe(method(entropyDevices))]
195        #[unsafe(method_family = none)]
196        pub unsafe fn entropyDevices(&self) -> Retained<NSArray<VZEntropyDeviceConfiguration>>;
197
198        #[cfg(feature = "VZEntropyDeviceConfiguration")]
199        /// Setter for [`entropyDevices`][Self::entropyDevices].
200        #[unsafe(method(setEntropyDevices:))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn setEntropyDevices(
203            &self,
204            entropy_devices: &NSArray<VZEntropyDeviceConfiguration>,
205        );
206
207        #[cfg(feature = "VZMemoryBalloonDeviceConfiguration")]
208        /// List of memory balloon devices. Empty by default.
209        ///
210        /// See: VZVirtioTraditionalMemoryBalloonDeviceConfiguration
211        #[unsafe(method(memoryBalloonDevices))]
212        #[unsafe(method_family = none)]
213        pub unsafe fn memoryBalloonDevices(
214            &self,
215        ) -> Retained<NSArray<VZMemoryBalloonDeviceConfiguration>>;
216
217        #[cfg(feature = "VZMemoryBalloonDeviceConfiguration")]
218        /// Setter for [`memoryBalloonDevices`][Self::memoryBalloonDevices].
219        #[unsafe(method(setMemoryBalloonDevices:))]
220        #[unsafe(method_family = none)]
221        pub unsafe fn setMemoryBalloonDevices(
222            &self,
223            memory_balloon_devices: &NSArray<VZMemoryBalloonDeviceConfiguration>,
224        );
225
226        #[cfg(feature = "VZNetworkDeviceConfiguration")]
227        /// List of network adapters. Empty by default.
228        ///
229        /// See: VZVirtioNetworkDeviceConfiguration
230        #[unsafe(method(networkDevices))]
231        #[unsafe(method_family = none)]
232        pub unsafe fn networkDevices(&self) -> Retained<NSArray<VZNetworkDeviceConfiguration>>;
233
234        #[cfg(feature = "VZNetworkDeviceConfiguration")]
235        /// Setter for [`networkDevices`][Self::networkDevices].
236        #[unsafe(method(setNetworkDevices:))]
237        #[unsafe(method_family = none)]
238        pub unsafe fn setNetworkDevices(
239            &self,
240            network_devices: &NSArray<VZNetworkDeviceConfiguration>,
241        );
242
243        #[cfg(feature = "VZSerialPortConfiguration")]
244        /// List of serial ports. Empty by default.
245        ///
246        /// See: VZVirtioConsoleDeviceSerialPortConfiguration
247        #[unsafe(method(serialPorts))]
248        #[unsafe(method_family = none)]
249        pub unsafe fn serialPorts(&self) -> Retained<NSArray<VZSerialPortConfiguration>>;
250
251        #[cfg(feature = "VZSerialPortConfiguration")]
252        /// Setter for [`serialPorts`][Self::serialPorts].
253        #[unsafe(method(setSerialPorts:))]
254        #[unsafe(method_family = none)]
255        pub unsafe fn setSerialPorts(&self, serial_ports: &NSArray<VZSerialPortConfiguration>);
256
257        #[cfg(feature = "VZSocketDeviceConfiguration")]
258        /// List of socket devices. Empty by default.
259        ///
260        /// See: VZVirtioSocketDeviceConfiguration
261        #[unsafe(method(socketDevices))]
262        #[unsafe(method_family = none)]
263        pub unsafe fn socketDevices(&self) -> Retained<NSArray<VZSocketDeviceConfiguration>>;
264
265        #[cfg(feature = "VZSocketDeviceConfiguration")]
266        /// Setter for [`socketDevices`][Self::socketDevices].
267        #[unsafe(method(setSocketDevices:))]
268        #[unsafe(method_family = none)]
269        pub unsafe fn setSocketDevices(
270            &self,
271            socket_devices: &NSArray<VZSocketDeviceConfiguration>,
272        );
273
274        #[cfg(feature = "VZStorageDeviceConfiguration")]
275        /// List of disk devices. Empty by default.
276        ///
277        /// See: VZNVMExpressControllerDeviceConfiguration
278        ///
279        /// See: VZUSBMassStorageDeviceConfiguration
280        ///
281        /// See: VZVirtioBlockDeviceConfiguration
282        #[unsafe(method(storageDevices))]
283        #[unsafe(method_family = none)]
284        pub unsafe fn storageDevices(&self) -> Retained<NSArray<VZStorageDeviceConfiguration>>;
285
286        #[cfg(feature = "VZStorageDeviceConfiguration")]
287        /// Setter for [`storageDevices`][Self::storageDevices].
288        #[unsafe(method(setStorageDevices:))]
289        #[unsafe(method_family = none)]
290        pub unsafe fn setStorageDevices(
291            &self,
292            storage_devices: &NSArray<VZStorageDeviceConfiguration>,
293        );
294
295        #[cfg(feature = "VZKeyboardConfiguration")]
296        /// List of keyboards. Empty by default.
297        ///
298        /// See: VZUSBKeyboardConfiguration
299        ///
300        /// See: VZMacKeyboardConfiguration
301        #[unsafe(method(keyboards))]
302        #[unsafe(method_family = none)]
303        pub unsafe fn keyboards(&self) -> Retained<NSArray<VZKeyboardConfiguration>>;
304
305        #[cfg(feature = "VZKeyboardConfiguration")]
306        /// Setter for [`keyboards`][Self::keyboards].
307        #[unsafe(method(setKeyboards:))]
308        #[unsafe(method_family = none)]
309        pub unsafe fn setKeyboards(&self, keyboards: &NSArray<VZKeyboardConfiguration>);
310
311        #[cfg(feature = "VZPointingDeviceConfiguration")]
312        /// List of pointing devices. Empty by default.
313        ///
314        /// See: VZUSBScreenCoordinatePointingDeviceConfiguration
315        ///
316        /// See: VZMacTrackpadConfiguration
317        #[unsafe(method(pointingDevices))]
318        #[unsafe(method_family = none)]
319        pub unsafe fn pointingDevices(&self) -> Retained<NSArray<VZPointingDeviceConfiguration>>;
320
321        #[cfg(feature = "VZPointingDeviceConfiguration")]
322        /// Setter for [`pointingDevices`][Self::pointingDevices].
323        #[unsafe(method(setPointingDevices:))]
324        #[unsafe(method_family = none)]
325        pub unsafe fn setPointingDevices(
326            &self,
327            pointing_devices: &NSArray<VZPointingDeviceConfiguration>,
328        );
329
330        #[cfg(feature = "VZGraphicsDeviceConfiguration")]
331        /// List of graphics devices. Empty by default.
332        ///
333        /// See: VZMacGraphicsDeviceConfiguration
334        #[unsafe(method(graphicsDevices))]
335        #[unsafe(method_family = none)]
336        pub unsafe fn graphicsDevices(&self) -> Retained<NSArray<VZGraphicsDeviceConfiguration>>;
337
338        #[cfg(feature = "VZGraphicsDeviceConfiguration")]
339        /// Setter for [`graphicsDevices`][Self::graphicsDevices].
340        #[unsafe(method(setGraphicsDevices:))]
341        #[unsafe(method_family = none)]
342        pub unsafe fn setGraphicsDevices(
343            &self,
344            graphics_devices: &NSArray<VZGraphicsDeviceConfiguration>,
345        );
346
347        #[cfg(feature = "VZUSBControllerConfiguration")]
348        /// List of USB Controllers. Empty by default.
349        ///
350        /// This list represents a set of USB controllers that the virtual machine will start with.
351        /// For each entry in this list, there will be a corresponding runtime object created in VZVirtualMachine.usbControllers property.
352        ///
353        /// See: VZUSBControllerConfiguration
354        #[unsafe(method(usbControllers))]
355        #[unsafe(method_family = none)]
356        pub unsafe fn usbControllers(&self) -> Retained<NSArray<VZUSBControllerConfiguration>>;
357
358        #[cfg(feature = "VZUSBControllerConfiguration")]
359        /// Setter for [`usbControllers`][Self::usbControllers].
360        #[unsafe(method(setUsbControllers:))]
361        #[unsafe(method_family = none)]
362        pub unsafe fn setUsbControllers(
363            &self,
364            usb_controllers: &NSArray<VZUSBControllerConfiguration>,
365        );
366    );
367}
368
369/// Methods declared on superclass `NSObject`.
370impl VZVirtualMachineConfiguration {
371    extern_methods!(
372        #[unsafe(method(init))]
373        #[unsafe(method_family = init)]
374        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
375
376        #[unsafe(method(new))]
377        #[unsafe(method_family = new)]
378        pub unsafe fn new() -> Retained<Self>;
379    );
380}
381
382/// VZVirtualMachineConfigurationValidation.
383/// Virtual machine configuration runtime validation.
384impl VZVirtualMachineConfiguration {
385    extern_methods!(
386        /// Validate the configuration.
387        ///
388        /// Parameter `error`: If not nil, assigned with the validation error if the validation failed.
389        ///
390        /// Returns: YES if the configuration is valid.
391        #[unsafe(method(validateWithError:_))]
392        #[unsafe(method_family = none)]
393        pub unsafe fn validateWithError(&self) -> Result<(), Retained<NSError>>;
394
395        /// Validate the configuration is savable.
396        ///
397        /// Verify that a virtual machine with this configuration is savable.
398        /// Not all configuration options can be safely saved and restored from file.
399        /// If this evaluates to NO, the caller should expect future calls to saveMachineStateToURL:completionHandler: to fail.
400        ///
401        /// Parameter `error`: If not nil, assigned with an error describing the unsupported configuration option.
402        ///
403        /// Returns: YES if the configuration is savable.
404        #[unsafe(method(validateSaveRestoreSupportWithError:_))]
405        #[unsafe(method_family = none)]
406        pub unsafe fn validateSaveRestoreSupportWithError(&self) -> Result<(), Retained<NSError>>;
407
408        /// : Minimum amount of memory required by virtual machines.
409        ///
410        /// See: VZVirtualMachineConfiguration.memorySize
411        #[unsafe(method(minimumAllowedMemorySize))]
412        #[unsafe(method_family = none)]
413        pub unsafe fn minimumAllowedMemorySize() -> u64;
414
415        /// : Maximum amount of memory allowed for a virtual machine.
416        ///
417        /// See: VZVirtualMachineConfiguration.memorySize
418        #[unsafe(method(maximumAllowedMemorySize))]
419        #[unsafe(method_family = none)]
420        pub unsafe fn maximumAllowedMemorySize() -> u64;
421
422        /// : Minimum number of CPUs for a virtual machine.
423        ///
424        /// See: VZVirtualMachineConfiguration.CPUCount
425        #[unsafe(method(minimumAllowedCPUCount))]
426        #[unsafe(method_family = none)]
427        pub unsafe fn minimumAllowedCPUCount() -> NSUInteger;
428
429        /// : Maximum number of CPUs for a virtual machine.
430        ///
431        /// See: VZVirtualMachineConfiguration.CPUCount
432        #[unsafe(method(maximumAllowedCPUCount))]
433        #[unsafe(method_family = none)]
434        pub unsafe fn maximumAllowedCPUCount() -> NSUInteger;
435    );
436}