Skip to content

Commit 18eba53

Browse files
committed
fix doc test for set_tsc_khz
The documentation test from set_tsc_khz() was failing if KVM_CAP_TSC_CONTROL or KVM_CAP_GET_TSC_KHZ was missing. Signed-off-by: Laura Loghin <[email protected]>
1 parent 495fdbe commit 18eba53

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/ioctls/vcpu.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,18 +1376,20 @@ impl VcpuFd {
13761376
///
13771377
/// # Arguments
13781378
///
1379-
/// * `freq` - The frequency unit is KHz as per the the KVM API documentation
1379+
/// * `freq` - The frequency unit is KHz as per the KVM API documentation
13801380
/// for `KVM_SET_TSC_KHZ`.
13811381
///
13821382
/// # Example
13831383
///
13841384
/// ```rust
13851385
/// # extern crate kvm_ioctls;
1386-
/// # use kvm_ioctls::Kvm;
1386+
/// # use kvm_ioctls::{Cap, Kvm};
13871387
/// let kvm = Kvm::new().unwrap();
13881388
/// let vm = kvm.create_vm().unwrap();
13891389
/// let vcpu = vm.create_vcpu(0).unwrap();
1390-
/// vcpu.set_tsc_khz(1000).unwrap();
1390+
/// if kvm.check_extension(Cap::GetTscKhz) && kvm.check_extension(Cap::TscControl) {
1391+
/// vcpu.set_tsc_khz(1000).unwrap();
1392+
/// }
13911393
/// ```
13921394
///
13931395
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]

0 commit comments

Comments
 (0)