mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-22 07:51:16 +00:00
hypervisor: Add get/set clock API
Add the hypervisor wrappers to expose KVM_GET_CLOCK and KVM_SET_CLOCK from the KVM API. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
4b64f2a027
commit
68ec0eb7a8
@ -57,8 +57,8 @@ pub use kvm_ioctls::{Cap, Kvm};
|
|||||||
/// Export generically-named wrappers of kvm-bindings for Unix-based platforms
|
/// Export generically-named wrappers of kvm-bindings for Unix-based platforms
|
||||||
///
|
///
|
||||||
pub use {
|
pub use {
|
||||||
kvm_bindings::kvm_create_device as CreateDevice, kvm_bindings::kvm_irq_routing as IrqRouting,
|
kvm_bindings::kvm_clock_data as ClockData, kvm_bindings::kvm_create_device as CreateDevice,
|
||||||
kvm_bindings::kvm_mp_state as MpState,
|
kvm_bindings::kvm_irq_routing as IrqRouting, kvm_bindings::kvm_mp_state as MpState,
|
||||||
kvm_bindings::kvm_userspace_memory_region as MemoryRegion,
|
kvm_bindings::kvm_userspace_memory_region as MemoryRegion,
|
||||||
kvm_bindings::kvm_vcpu_events as VcpuEvents, kvm_ioctls::DeviceFd, kvm_ioctls::IoEventAddress,
|
kvm_bindings::kvm_vcpu_events as VcpuEvents, kvm_ioctls::DeviceFd, kvm_ioctls::IoEventAddress,
|
||||||
kvm_ioctls::VcpuExit,
|
kvm_ioctls::VcpuExit,
|
||||||
@ -211,6 +211,20 @@ impl vm::Vm for KvmVm {
|
|||||||
.map_err(|e| vm::HypervisorVmError::EnableSplitIrq(e.into()))?;
|
.map_err(|e| vm::HypervisorVmError::EnableSplitIrq(e.into()))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
/// Retrieve guest clock.
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
fn get_clock(&self) -> vm::Result<ClockData> {
|
||||||
|
self.fd
|
||||||
|
.get_clock()
|
||||||
|
.map_err(|e| vm::HypervisorVmError::GetClock(e.into()))
|
||||||
|
}
|
||||||
|
/// Set guest clock.
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
fn set_clock(&self, data: &ClockData) -> vm::Result<()> {
|
||||||
|
self.fd
|
||||||
|
.set_clock(data)
|
||||||
|
.map_err(|e| vm::HypervisorVmError::SetClock(e.into()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// Wrapper over KVM system ioctls.
|
/// Wrapper over KVM system ioctls.
|
||||||
pub struct KvmHyperVisor {
|
pub struct KvmHyperVisor {
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
use crate::aarch64::VcpuInit;
|
use crate::aarch64::VcpuInit;
|
||||||
use crate::cpu::Vcpu;
|
use crate::cpu::Vcpu;
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
use crate::ClockData;
|
||||||
use crate::{CreateDevice, DeviceFd, IoEventAddress, IrqRouting, MemoryRegion};
|
use crate::{CreateDevice, DeviceFd, IoEventAddress, IrqRouting, MemoryRegion};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
@ -97,6 +99,16 @@ pub enum HypervisorVmError {
|
|||||||
///
|
///
|
||||||
#[error("Failed to enable split Irq: {0}")]
|
#[error("Failed to enable split Irq: {0}")]
|
||||||
EnableSplitIrq(#[source] anyhow::Error),
|
EnableSplitIrq(#[source] anyhow::Error),
|
||||||
|
///
|
||||||
|
/// Get clock error
|
||||||
|
///
|
||||||
|
#[error("Failed to get clock: {0}")]
|
||||||
|
GetClock(#[source] anyhow::Error),
|
||||||
|
///
|
||||||
|
/// Set clock error
|
||||||
|
///
|
||||||
|
#[error("Failed to set clock: {0}")]
|
||||||
|
SetClock(#[source] anyhow::Error),
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
/// Result type for returning from a function
|
/// Result type for returning from a function
|
||||||
@ -141,4 +153,10 @@ pub trait Vm: Send + Sync {
|
|||||||
/// Enable split Irq capability
|
/// Enable split Irq capability
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
fn enable_split_irq(&self) -> Result<()>;
|
fn enable_split_irq(&self) -> Result<()>;
|
||||||
|
/// Retrieve guest clock.
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
fn get_clock(&self) -> Result<ClockData>;
|
||||||
|
/// Set guest clock.
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
fn set_clock(&self, data: &ClockData) -> Result<()>;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user