objc2_virtualization/generated/VZVirtioTraditionalMemoryBalloonDevice.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::*;
6
7use crate::*;
8
9extern_class!(
10 /// Virtio Traditional Memory Balloon Device
11 ///
12 /// This is a primitive device for managing guest memory.
13 /// This device enables memory transfer between the host and the guest as specified by the Virtio specification, which allows the guest to adapt changes
14 /// in allowance of underlying physical memory.
15 ///
16 /// To request a memory balloon device operation for the memory transfer, write the targeted memory size for the virtual machine to the targetVirtualMachineMemorySize property.
17 /// When the value written to targetVirtualMachineMemorySize is less than the current value, memory will be taken away from the guest and given to the host by the amount
18 /// determined by the difference between those two values. Similarly, when the value written to targetVirtualMachineMemorySize is greater than the current value, memory will be
19 /// given back to the guest by the amount determined by the difference between those two values.
20 ///
21 /// Note that any changes to targetVirtualMachineMemorySize is a request to trigger a memory balloon operation. The actual changes in memory only happen after the guest operating
22 /// system handles the request, if at all.
23 ///
24 /// The targetVirtualMachineMemorySize property is initialized to VZVirtualMachineConfiguration.memorySize. The acceptable values for the targetVirtualMachineMemorySize
25 /// property range from VZVirtualMachineConfiguration.minimumAllowedMemorySize to VZVirtualMachineConfiguration.memorySize, and must be a multiple of 1 megabyte
26 /// (1024 * 1024 bytes). If those constraints aren't satisfied, targetVirtualMachineMemorySize will be rounded down to the nearest multiple of 1 megabyte, clamped to
27 /// VZVirtualMachineConfiguration.minimumAllowedMemorySize and VZVirtualMachineConfiguration.memorySize respectively.
28 ///
29 /// For optimal performance, it is strongly recommended to perform a memory compaction operation in the guest (e.g. echo 1 > /proc/sys/vm/compact_memory) before invoking the device.
30 /// This helps to minimize memory fragmentation in order for the memory allocation/deallocation process to be more effective.
31 ///
32 /// This device is created through instantiating a VZVirtioTraditionalMemoryBalloonDeviceConfiguration in a VZVirtualMachineConfiguration and is available in the
33 /// VZVirtualMachine.memoryBalloonDevices property.
34 ///
35 /// See: VZVirtioTraditionalMemoryBalloonDeviceConfiguration
36 ///
37 /// See also [Apple's documentation](https://developer.apple.com/documentation/virtualization/vzvirtiotraditionalmemoryballoondevice?language=objc)
38 #[unsafe(super(VZMemoryBalloonDevice, NSObject))]
39 #[derive(Debug, PartialEq, Eq, Hash)]
40 #[cfg(feature = "VZMemoryBalloonDevice")]
41 pub struct VZVirtioTraditionalMemoryBalloonDevice;
42);
43
44#[cfg(feature = "VZMemoryBalloonDevice")]
45extern_conformance!(
46 unsafe impl NSObjectProtocol for VZVirtioTraditionalMemoryBalloonDevice {}
47);
48
49#[cfg(feature = "VZMemoryBalloonDevice")]
50impl VZVirtioTraditionalMemoryBalloonDevice {
51 extern_methods!(
52 #[unsafe(method(new))]
53 #[unsafe(method_family = new)]
54 pub unsafe fn new() -> Retained<Self>;
55
56 #[unsafe(method(init))]
57 #[unsafe(method_family = init)]
58 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
59
60 /// Target memory size for the virtual machine in bytes.
61 ///
62 /// The targetVirtualMachineMemorySize must be a multiple of 1 megabyte (1024 * 1024 bytes) between VZVirtualMachineConfiguration.minimumAllowedMemorySize
63 /// and VZVirtualMachineConfiguration.memorySize. If those constraints aren't satisfied, targetVirtualMachineMemorySize will be rounded down to the nearest multiple of
64 /// 1 megabyte, clamped to VZVirtualMachineConfiguration.minimumAllowedMemorySize and VZVirtualMachineConfiguration.memorySize respectively.
65 ///
66 /// The targetVirtualMachineMemorySize represents the amount of physical memory to be made available to the guest.
67 ///
68 /// See: VZVirtualMachineConfiguration.minimumAllowedMemorySize
69 ///
70 /// See: VZVirtualMachineConfiguration.memorySize
71 #[unsafe(method(targetVirtualMachineMemorySize))]
72 #[unsafe(method_family = none)]
73 pub unsafe fn targetVirtualMachineMemorySize(&self) -> u64;
74
75 /// Setter for [`targetVirtualMachineMemorySize`][Self::targetVirtualMachineMemorySize].
76 #[unsafe(method(setTargetVirtualMachineMemorySize:))]
77 #[unsafe(method_family = none)]
78 pub unsafe fn setTargetVirtualMachineMemorySize(
79 &self,
80 target_virtual_machine_memory_size: u64,
81 );
82 );
83}