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 #[unsafe(method(setAudioDevices:))]
155 #[unsafe(method_family = none)]
156 pub unsafe fn setAudioDevices(&self, audio_devices: &NSArray<VZAudioDeviceConfiguration>);
157
158 #[cfg(feature = "VZConsoleDeviceConfiguration")]
159 /// List of console devices. Empty by default.
160 ///
161 /// See: VZVirtioConsoleDeviceConfiguration
162 #[unsafe(method(consoleDevices))]
163 #[unsafe(method_family = none)]
164 pub unsafe fn consoleDevices(&self) -> Retained<NSArray<VZConsoleDeviceConfiguration>>;
165
166 #[cfg(feature = "VZConsoleDeviceConfiguration")]
167 /// Setter for [`consoleDevices`][Self::consoleDevices].
168 #[unsafe(method(setConsoleDevices:))]
169 #[unsafe(method_family = none)]
170 pub unsafe fn setConsoleDevices(
171 &self,
172 console_devices: &NSArray<VZConsoleDeviceConfiguration>,
173 );
174
175 #[cfg(feature = "VZDirectorySharingDeviceConfiguration")]
176 /// List of directory sharing devices. Empty by default.
177 ///
178 /// See: VZVirtioFileSystemDeviceConfiguration
179 #[unsafe(method(directorySharingDevices))]
180 #[unsafe(method_family = none)]
181 pub unsafe fn directorySharingDevices(
182 &self,
183 ) -> Retained<NSArray<VZDirectorySharingDeviceConfiguration>>;
184
185 #[cfg(feature = "VZDirectorySharingDeviceConfiguration")]
186 /// Setter for [`directorySharingDevices`][Self::directorySharingDevices].
187 #[unsafe(method(setDirectorySharingDevices:))]
188 #[unsafe(method_family = none)]
189 pub unsafe fn setDirectorySharingDevices(
190 &self,
191 directory_sharing_devices: &NSArray<VZDirectorySharingDeviceConfiguration>,
192 );
193
194 #[cfg(feature = "VZEntropyDeviceConfiguration")]
195 /// List of entropy devices. Empty by default.
196 ///
197 /// See: VZVirtioEntropyDeviceConfiguration
198 #[unsafe(method(entropyDevices))]
199 #[unsafe(method_family = none)]
200 pub unsafe fn entropyDevices(&self) -> Retained<NSArray<VZEntropyDeviceConfiguration>>;
201
202 #[cfg(feature = "VZEntropyDeviceConfiguration")]
203 /// Setter for [`entropyDevices`][Self::entropyDevices].
204 #[unsafe(method(setEntropyDevices:))]
205 #[unsafe(method_family = none)]
206 pub unsafe fn setEntropyDevices(
207 &self,
208 entropy_devices: &NSArray<VZEntropyDeviceConfiguration>,
209 );
210
211 #[cfg(feature = "VZMemoryBalloonDeviceConfiguration")]
212 /// List of memory balloon devices. Empty by default.
213 ///
214 /// See: VZVirtioTraditionalMemoryBalloonDeviceConfiguration
215 #[unsafe(method(memoryBalloonDevices))]
216 #[unsafe(method_family = none)]
217 pub unsafe fn memoryBalloonDevices(
218 &self,
219 ) -> Retained<NSArray<VZMemoryBalloonDeviceConfiguration>>;
220
221 #[cfg(feature = "VZMemoryBalloonDeviceConfiguration")]
222 /// Setter for [`memoryBalloonDevices`][Self::memoryBalloonDevices].
223 #[unsafe(method(setMemoryBalloonDevices:))]
224 #[unsafe(method_family = none)]
225 pub unsafe fn setMemoryBalloonDevices(
226 &self,
227 memory_balloon_devices: &NSArray<VZMemoryBalloonDeviceConfiguration>,
228 );
229
230 #[cfg(feature = "VZNetworkDeviceConfiguration")]
231 /// List of network adapters. Empty by default.
232 ///
233 /// See: VZVirtioNetworkDeviceConfiguration
234 #[unsafe(method(networkDevices))]
235 #[unsafe(method_family = none)]
236 pub unsafe fn networkDevices(&self) -> Retained<NSArray<VZNetworkDeviceConfiguration>>;
237
238 #[cfg(feature = "VZNetworkDeviceConfiguration")]
239 /// Setter for [`networkDevices`][Self::networkDevices].
240 #[unsafe(method(setNetworkDevices:))]
241 #[unsafe(method_family = none)]
242 pub unsafe fn setNetworkDevices(
243 &self,
244 network_devices: &NSArray<VZNetworkDeviceConfiguration>,
245 );
246
247 #[cfg(feature = "VZSerialPortConfiguration")]
248 /// List of serial ports. Empty by default.
249 ///
250 /// See: VZVirtioConsoleDeviceSerialPortConfiguration
251 #[unsafe(method(serialPorts))]
252 #[unsafe(method_family = none)]
253 pub unsafe fn serialPorts(&self) -> Retained<NSArray<VZSerialPortConfiguration>>;
254
255 #[cfg(feature = "VZSerialPortConfiguration")]
256 /// Setter for [`serialPorts`][Self::serialPorts].
257 #[unsafe(method(setSerialPorts:))]
258 #[unsafe(method_family = none)]
259 pub unsafe fn setSerialPorts(&self, serial_ports: &NSArray<VZSerialPortConfiguration>);
260
261 #[cfg(feature = "VZSocketDeviceConfiguration")]
262 /// List of socket devices. Empty by default.
263 ///
264 /// See: VZVirtioSocketDeviceConfiguration
265 #[unsafe(method(socketDevices))]
266 #[unsafe(method_family = none)]
267 pub unsafe fn socketDevices(&self) -> Retained<NSArray<VZSocketDeviceConfiguration>>;
268
269 #[cfg(feature = "VZSocketDeviceConfiguration")]
270 /// Setter for [`socketDevices`][Self::socketDevices].
271 #[unsafe(method(setSocketDevices:))]
272 #[unsafe(method_family = none)]
273 pub unsafe fn setSocketDevices(
274 &self,
275 socket_devices: &NSArray<VZSocketDeviceConfiguration>,
276 );
277
278 #[cfg(feature = "VZStorageDeviceConfiguration")]
279 /// List of disk devices. Empty by default.
280 ///
281 /// See: VZNVMExpressControllerDeviceConfiguration
282 ///
283 /// See: VZUSBMassStorageDeviceConfiguration
284 ///
285 /// See: VZVirtioBlockDeviceConfiguration
286 #[unsafe(method(storageDevices))]
287 #[unsafe(method_family = none)]
288 pub unsafe fn storageDevices(&self) -> Retained<NSArray<VZStorageDeviceConfiguration>>;
289
290 #[cfg(feature = "VZStorageDeviceConfiguration")]
291 /// Setter for [`storageDevices`][Self::storageDevices].
292 #[unsafe(method(setStorageDevices:))]
293 #[unsafe(method_family = none)]
294 pub unsafe fn setStorageDevices(
295 &self,
296 storage_devices: &NSArray<VZStorageDeviceConfiguration>,
297 );
298
299 #[cfg(feature = "VZKeyboardConfiguration")]
300 /// List of keyboards. Empty by default.
301 ///
302 /// See: VZUSBKeyboardConfiguration
303 ///
304 /// See: VZMacKeyboardConfiguration
305 #[unsafe(method(keyboards))]
306 #[unsafe(method_family = none)]
307 pub unsafe fn keyboards(&self) -> Retained<NSArray<VZKeyboardConfiguration>>;
308
309 #[cfg(feature = "VZKeyboardConfiguration")]
310 /// Setter for [`keyboards`][Self::keyboards].
311 #[unsafe(method(setKeyboards:))]
312 #[unsafe(method_family = none)]
313 pub unsafe fn setKeyboards(&self, keyboards: &NSArray<VZKeyboardConfiguration>);
314
315 #[cfg(feature = "VZPointingDeviceConfiguration")]
316 /// List of pointing devices. Empty by default.
317 ///
318 /// See: VZUSBScreenCoordinatePointingDeviceConfiguration
319 ///
320 /// See: VZMacTrackpadConfiguration
321 #[unsafe(method(pointingDevices))]
322 #[unsafe(method_family = none)]
323 pub unsafe fn pointingDevices(&self) -> Retained<NSArray<VZPointingDeviceConfiguration>>;
324
325 #[cfg(feature = "VZPointingDeviceConfiguration")]
326 /// Setter for [`pointingDevices`][Self::pointingDevices].
327 #[unsafe(method(setPointingDevices:))]
328 #[unsafe(method_family = none)]
329 pub unsafe fn setPointingDevices(
330 &self,
331 pointing_devices: &NSArray<VZPointingDeviceConfiguration>,
332 );
333
334 #[cfg(feature = "VZGraphicsDeviceConfiguration")]
335 /// List of graphics devices. Empty by default.
336 ///
337 /// See: VZMacGraphicsDeviceConfiguration
338 #[unsafe(method(graphicsDevices))]
339 #[unsafe(method_family = none)]
340 pub unsafe fn graphicsDevices(&self) -> Retained<NSArray<VZGraphicsDeviceConfiguration>>;
341
342 #[cfg(feature = "VZGraphicsDeviceConfiguration")]
343 /// Setter for [`graphicsDevices`][Self::graphicsDevices].
344 #[unsafe(method(setGraphicsDevices:))]
345 #[unsafe(method_family = none)]
346 pub unsafe fn setGraphicsDevices(
347 &self,
348 graphics_devices: &NSArray<VZGraphicsDeviceConfiguration>,
349 );
350
351 #[cfg(feature = "VZUSBControllerConfiguration")]
352 /// List of USB Controllers. Empty by default.
353 ///
354 /// This list represents a set of USB controllers that the virtual machine will start with.
355 /// For each entry in this list, there will be a corresponding runtime object created in VZVirtualMachine.usbControllers property.
356 ///
357 /// See: VZUSBControllerConfiguration
358 #[unsafe(method(usbControllers))]
359 #[unsafe(method_family = none)]
360 pub unsafe fn usbControllers(&self) -> Retained<NSArray<VZUSBControllerConfiguration>>;
361
362 #[cfg(feature = "VZUSBControllerConfiguration")]
363 /// Setter for [`usbControllers`][Self::usbControllers].
364 #[unsafe(method(setUsbControllers:))]
365 #[unsafe(method_family = none)]
366 pub unsafe fn setUsbControllers(
367 &self,
368 usb_controllers: &NSArray<VZUSBControllerConfiguration>,
369 );
370 );
371}
372
373/// Methods declared on superclass `NSObject`.
374impl VZVirtualMachineConfiguration {
375 extern_methods!(
376 #[unsafe(method(init))]
377 #[unsafe(method_family = init)]
378 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
379
380 #[unsafe(method(new))]
381 #[unsafe(method_family = new)]
382 pub unsafe fn new() -> Retained<Self>;
383 );
384}
385
386/// VZVirtualMachineConfigurationValidation.
387/// Virtual machine configuration runtime validation.
388impl VZVirtualMachineConfiguration {
389 extern_methods!(
390 /// Validate the configuration.
391 ///
392 /// Parameter `error`: If not nil, assigned with the validation error if the validation failed.
393 ///
394 /// Returns: YES if the configuration is valid.
395 #[unsafe(method(validateWithError:_))]
396 #[unsafe(method_family = none)]
397 pub unsafe fn validateWithError(&self) -> Result<(), Retained<NSError>>;
398
399 /// Validate the configuration is savable.
400 ///
401 /// Verify that a virtual machine with this configuration is savable.
402 /// Not all configuration options can be safely saved and restored from file.
403 /// If this evaluates to NO, the caller should expect future calls to saveMachineStateToURL:completionHandler: to fail.
404 ///
405 /// Parameter `error`: If not nil, assigned with an error describing the unsupported configuration option.
406 ///
407 /// Returns: YES if the configuration is savable.
408 #[unsafe(method(validateSaveRestoreSupportWithError:_))]
409 #[unsafe(method_family = none)]
410 pub unsafe fn validateSaveRestoreSupportWithError(&self) -> Result<(), Retained<NSError>>;
411
412 /// : Minimum amount of memory required by virtual machines.
413 ///
414 /// See: VZVirtualMachineConfiguration.memorySize
415 #[unsafe(method(minimumAllowedMemorySize))]
416 #[unsafe(method_family = none)]
417 pub unsafe fn minimumAllowedMemorySize() -> u64;
418
419 /// : Maximum amount of memory allowed for a virtual machine.
420 ///
421 /// See: VZVirtualMachineConfiguration.memorySize
422 #[unsafe(method(maximumAllowedMemorySize))]
423 #[unsafe(method_family = none)]
424 pub unsafe fn maximumAllowedMemorySize() -> u64;
425
426 /// : Minimum number of CPUs for a virtual machine.
427 ///
428 /// See: VZVirtualMachineConfiguration.CPUCount
429 #[unsafe(method(minimumAllowedCPUCount))]
430 #[unsafe(method_family = none)]
431 pub unsafe fn minimumAllowedCPUCount() -> NSUInteger;
432
433 /// : Maximum number of CPUs for a virtual machine.
434 ///
435 /// See: VZVirtualMachineConfiguration.CPUCount
436 #[unsafe(method(maximumAllowedCPUCount))]
437 #[unsafe(method_family = none)]
438 pub unsafe fn maximumAllowedCPUCount() -> NSUInteger;
439 );
440}