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