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
use crate::{PlatformX86, VboxError};
use crate::enums::{CPUPropertyType, HWVirtExPropertyType};
use crate::utility::macros::macros::{get_function_result_bool, get_function_result_unit};
impl PlatformX86 {
/// This attribute controls if High Precision Event Timer (HPET) is enabled in this VM.
///
/// # Returns
///
/// Returns bool on success, or a [`VboxError`] on failure.
///
/// # Example
///
/// ```no_run
///
/// use virtualbox_rs::VirtualBox;
///
/// let vbox = VirtualBox::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
/// let platform = machine.get_platform().unwrap();
/// let platform_x86 = platform.get_x86().unwrap();
/// let hpet_enabled = platform_x86.get_hpet_enabled().unwrap();
pub fn get_hpet_enabled(&self) -> Result<bool, VboxError> {
get_function_result_bool!(self.object, GetHPETEnabled)
}
/// This attribute controls if High Precision Event Timer (HPET) is enabled in this VM.
///
/// # Arguments
///
/// * `hpet_enabled` - This attribute controls if High Precision Event Timer (HPET) is enabled in this VM.
///
/// # Returns
///
/// Returns () on success, or a [`VboxError`] on failure.
///
/// # Example
///
/// ```no_run
///
/// use virtualbox_rs::{Session, VirtualBox};
/// use virtualbox_rs::enums::SessionType;
///
/// let vbox = VirtualBox::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
/// let mut session = Session::init().unwrap();
/// machine.lock_machine(&mut session, SessionType::Shared).unwrap();
/// let machine_mut = session.get_machine().unwrap();
/// let platform = machine_mut.get_platform().unwrap();
/// let platform_x86 = platform.get_x86().unwrap();
/// platform_x86.set_hpet_enabled(true).unwrap();
pub fn set_hpet_enabled(&self, hpet_enabled: bool) -> Result<(), VboxError> {
let hpet_enabled = if hpet_enabled { 1 } else { 0 };
get_function_result_unit!(self.object, SetHPETEnabled, hpet_enabled)
}
/// Returns the virtual CPU boolean value of the specified property.
///
/// # Arguments
///
/// * `property` - [`CPUPropertyType`]. Property type to query.
///
/// # Returns
///
/// Returns bool success, or a [`VboxError`] on failure.
///
/// # Example
///
/// ```no_run
///
/// use virtualbox_rs::{VirtualBox};
/// use virtualbox_rs::enums::CPUPropertyType;
///
/// let vbox = VirtualBox::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
/// let platform = machine.get_platform().unwrap();
/// let platform_x86 = platform.get_x86().unwrap();
/// let cpu_property = platform_x86.get_cpu_property(CPUPropertyType::APIC).unwrap();
pub fn get_cpu_property(&self, property: CPUPropertyType) -> Result<bool, VboxError> {
let property = property.into();
get_function_result_bool!(self.object, GetCPUProperty, property)
}
/// Sets the virtual CPU boolean value of the specified property.
///
/// # Arguments
///
/// * `property` - [`CPUPropertyType`]. Property type to query.
/// * `value` - bool. Property value.
///
/// # Returns
///
/// Returns () success, or a [`VboxError`] on failure.
///
/// # Example
///
/// ```no_run
///
/// use virtualbox_rs::{Session, VirtualBox};
/// use virtualbox_rs::enums::{CPUPropertyType, SessionType};
///
/// let vbox = VirtualBox::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
/// let mut session = Session::init().unwrap();
/// machine.lock_machine(&mut session, SessionType::Shared).unwrap();
/// let machine_mut = session.get_machine().unwrap();
/// let platform = machine_mut.get_platform().unwrap();
/// let platform_x86 = platform.get_x86().unwrap();
/// platform_x86.set_cpu_property(CPUPropertyType::APIC, true).unwrap();
pub fn set_cpu_property(
&self,
property: CPUPropertyType,
value: bool,
) -> Result<(), VboxError> {
let property = property.into();
let value = if value { 1 } else { 0 };
get_function_result_unit!(self.object, SetCPUProperty, property, value)
}
/// Returns the value of the specified hardware virtualization boolean property.
///
/// # Arguments
///
/// * `property` - [`HWVirtExPropertyType`]. Property type to query.
///
/// # Returns
///
/// Returns bool success, or a [`VboxError`] on failure.
///
/// # Example
///
/// ```no_run
///
/// use virtualbox_rs::{VirtualBox};
/// use virtualbox_rs::enums::HWVirtExPropertyType;
///
/// let vbox = VirtualBox::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
/// let platform = machine.get_platform().unwrap();
/// let platform_x86 = platform.get_x86().unwrap();
/// let property = platform_x86.get_hw_virt_ex_property(HWVirtExPropertyType::NestedPaging).unwrap();
pub fn get_hw_virt_ex_property(
&self,
property: HWVirtExPropertyType,
) -> Result<bool, VboxError> {
let property = property.into();
get_function_result_bool!(self.object, GetHWVirtExProperty, property)
}
/// Sets a new value for the specified hardware virtualization boolean property.
///
/// # Arguments
///
/// * `property` - [`HWVirtExPropertyType`]. Property type to set.
/// * `value` - bool. New property value.
///
/// # Returns
///
/// Returns () success, or a [`VboxError`] on failure.
///
/// # Example
///
/// ```no_run
///
/// use virtualbox_rs::{Session, VirtualBox};
/// use virtualbox_rs::enums::{HWVirtExPropertyType, SessionType};
///
/// let vbox = VirtualBox::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
/// let mut session = Session::init().unwrap();
/// machine.lock_machine(&mut session, SessionType::Shared).unwrap();
/// let machine_mut = session.get_machine().unwrap();
/// let platform = machine_mut.get_platform().unwrap();
/// let platform_x86 = platform.get_x86().unwrap();
/// platform_x86.set_hw_virt_ex_property(HWVirtExPropertyType::NestedPaging, true).unwrap();
pub fn set_hw_virt_ex_property(
&self,
property: HWVirtExPropertyType,
value: bool,
) -> Result<(), VboxError> {
let property = property.into();
let value = if value { 1 } else { 0 };
get_function_result_unit!(self.object, SetHWVirtExProperty, property, value)
}
}