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
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
extern_class!(
/// Storage device attachment using a disk block device to store data.
///
/// The disk block device implements a storage attachment by using an actual disk rather than a disk image on a file system.
///
/// For example, a disk block device on the disk at `/dev/rdisk42` would execute the I/O operations directly on that disk
/// rather than through a file system.
///
/// Note that if the disk has a file system formatted on it, the guest is able to destroy data in a way that is not recoverable.
/// The disk passed to this attachment needs to be handled with caution.
///
/// An example use of this API is:
/// ```text
/// NSFileHandle *fileHandle = [NSFileHandle fileHandleForReadingAtPath:
/// "
/// /dev/rdisk42"];
/// if (!fileHandle) {
/// // Handle errors.
/// }
///
/// NSError *error;
/// VZDiskBlockDeviceStorageDeviceAttachment *attachment =
/// [[VZDiskBlockDeviceStorageDeviceAttachment alloc] initWithFileHandle:fileHandle
/// readOnly:YES
/// synchronizationMode:VZDiskSynchronizationModeFull
/// error:error];
/// if (!attachment) {
/// // Handle errors.
/// }
/// ```
///
/// Disk file handles are typically only accessible by the `root` user unless permission is explicitly granted.
/// Running virtual machines as root is not recommended. If `root` access is required to open the file descriptor, it is recommended to do that operation
/// in a separate process then pass the file descriptor to a less privileged process running Virtualization framework.
///
///
/// See: VZDiskImageStorageDeviceAttachment
///
/// See: VZNVMExpressControllerDeviceConfiguration
///
/// See: VZUSBMassStorageDeviceConfiguration
///
/// See: VZVirtioBlockDeviceConfiguration
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/virtualization/vzdiskblockdevicestoragedeviceattachment?language=objc)
#[unsafe(super(VZStorageDeviceAttachment, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "VZStorageDeviceAttachment")]
pub struct VZDiskBlockDeviceStorageDeviceAttachment;
);
#[cfg(feature = "VZStorageDeviceAttachment")]
extern_conformance!(
unsafe impl NSObjectProtocol for VZDiskBlockDeviceStorageDeviceAttachment {}
);
#[cfg(feature = "VZStorageDeviceAttachment")]
impl VZDiskBlockDeviceStorageDeviceAttachment {
extern_methods!(
#[cfg(feature = "VZDiskSynchronizationMode")]
/// Initialize the disk attachment from a file handle.
///
/// Parameter `fileHandle`: File handle to a block device.
///
/// Parameter `readOnly`: If YES, the disk attachment is read only, otherwise, if the file handle allows writes, the device can write data into it.
///
/// Parameter `synchronizationMode`: Defines how the disk synchronizes with the underlying storage when the guest operating system flushes data.
///
/// Parameter `error`: If not nil, assigned with the error if the initialization failed.
///
/// Returns: An initialized `VZDiskBlockDeviceStorageDeviceAttachment` or nil if there was an error.
///
/// The file handle is retained by the disk attachment.
/// The handle must be open when the virtual machine starts.
///
/// The `readOnly` parameter affects how the disk is exposed to the guest operating system
/// by the storage controller. If the disk is intended to be used read-only, it is also recommended
/// to open the file handle as read-only.
#[unsafe(method(initWithFileHandle:readOnly:synchronizationMode:error:_))]
#[unsafe(method_family = init)]
pub unsafe fn initWithFileHandle_readOnly_synchronizationMode_error(
this: Allocated<Self>,
file_handle: &NSFileHandle,
read_only: bool,
synchronization_mode: VZDiskSynchronizationMode,
) -> Result<Retained<Self>, Retained<NSError>>;
/// File handle to the underlying disk used for storage by the attachment.
#[unsafe(method(fileHandle))]
#[unsafe(method_family = none)]
pub unsafe fn fileHandle(&self) -> Retained<NSFileHandle>;
/// Whether the underlying disk attachment is read-only.
#[unsafe(method(isReadOnly))]
#[unsafe(method_family = none)]
pub unsafe fn isReadOnly(&self) -> bool;
#[cfg(feature = "VZDiskSynchronizationMode")]
/// The mode in which the disk image synchronizes data with the underlying storage device.
#[unsafe(method(synchronizationMode))]
#[unsafe(method_family = none)]
pub unsafe fn synchronizationMode(&self) -> VZDiskSynchronizationMode;
);
}
/// Methods declared on superclass `VZStorageDeviceAttachment`.
#[cfg(feature = "VZStorageDeviceAttachment")]
impl VZDiskBlockDeviceStorageDeviceAttachment {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
);
}