Skip to content

Commit 6705a61

Browse files
michael2012zlauralt
authored andcommitted
Expose Kvm::check_extension_int()
The function is useful for checking the capabilities that return numbers rather than booleans. Signed-off-by: Michael Zhao <[email protected]>
1 parent 202c2d4 commit 6705a61

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/ioctls/system.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,22 @@ impl Kvm {
121121
/// Wrapper over `KVM_CHECK_EXTENSION`.
122122
///
123123
/// Returns 0 if the capability is not available and a positive integer otherwise.
124-
fn check_extension_int(&self, c: Cap) -> i32 {
124+
/// See the documentation for `KVM_CHECK_EXTENSION`.
125+
///
126+
/// # Arguments
127+
///
128+
/// * `c` - KVM capability to check.
129+
///
130+
/// # Example
131+
///
132+
/// ```
133+
/// # use kvm_ioctls::Kvm;
134+
/// use kvm_ioctls::Cap;
135+
///
136+
/// let kvm = Kvm::new().unwrap();
137+
/// assert!(kvm.check_extension_int(Cap::MaxVcpuId) > 0);
138+
/// ```
139+
pub fn check_extension_int(&self, c: Cap) -> i32 {
125140
// Safe because we know that our file is a KVM fd and that the extension is one of the ones
126141
// defined by kernel.
127142
unsafe { ioctl_with_val(self, KVM_CHECK_EXTENSION(), c as c_ulong) }

0 commit comments

Comments
 (0)