From 030d84eb08143f4471025d6fc9ca5e57c2e32795 Mon Sep 17 00:00:00 2001 From: Muminul Islam Date: Wed, 24 Apr 2024 16:44:53 -0700 Subject: [PATCH] vmm: make clock data independent of hypervisor As MSHV also implements set/get_clock data, this patch removes the KVM feature guard and make it x86_64 only and both for KVM and MSHV. Signed-off-by: Muminul Islam --- vmm/src/vm.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index c462f80db..559d51388 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -30,7 +30,7 @@ use crate::igvm::igvm_loader; use crate::memory_manager::{ Error as MemoryManagerError, MemoryManager, MemoryManagerSnapshotData, }; -#[cfg(all(feature = "kvm", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] use crate::migration::get_vm_snapshot; #[cfg(all(target_arch = "x86_64", feature = "guest_debug"))] use crate::migration::url_to_file; @@ -457,7 +457,7 @@ pub struct Vm { #[cfg_attr(any(not(feature = "kvm"), target_arch = "aarch64"), allow(dead_code))] // The hypervisor abstracted virtual machine. vm: Arc, - #[cfg(all(feature = "kvm", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] saved_clock: Option, numa_nodes: NumaNodes, #[cfg_attr(any(not(feature = "kvm"), target_arch = "aarch64"), allow(dead_code))] @@ -671,7 +671,7 @@ impl Vm { .transpose() .map_err(Error::InitramfsFile)?; - #[cfg(all(feature = "kvm", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] let saved_clock = if let Some(snapshot) = snapshot.as_ref() { let vm_snapshot = get_vm_snapshot(snapshot).map_err(Error::Restore)?; vm_snapshot.clock @@ -696,7 +696,7 @@ impl Vm { cpu_manager, memory_manager, vm, - #[cfg(all(feature = "kvm", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] saved_clock, numa_nodes, hypervisor, @@ -2468,7 +2468,7 @@ impl Pausable for Vm { .valid_transition(new_state) .map_err(|e| MigratableError::Pause(anyhow!("Invalid transition: {:?}", e)))?; - #[cfg(all(feature = "kvm", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] { let mut clock = self .vm @@ -2506,7 +2506,7 @@ impl Pausable for Vm { .map_err(|e| MigratableError::Resume(anyhow!("Invalid transition: {:?}", e)))?; self.cpu_manager.lock().unwrap().resume()?; - #[cfg(all(feature = "kvm", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] { if let Some(clock) = &self.saved_clock { self.vm.set_clock(clock).map_err(|e| { @@ -2525,7 +2525,7 @@ impl Pausable for Vm { #[derive(Serialize, Deserialize)] pub struct VmSnapshot { - #[cfg(all(feature = "kvm", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub clock: Option, #[cfg(all(feature = "kvm", target_arch = "x86_64"))] pub common_cpuid: Vec, @@ -2580,7 +2580,7 @@ impl Snapshottable for Vm { }; let vm_snapshot_state = VmSnapshot { - #[cfg(all(feature = "kvm", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] clock: self.saved_clock, #[cfg(all(feature = "kvm", target_arch = "x86_64"))] common_cpuid,