diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs index afa2cc7ab..828d3d4a1 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -1472,7 +1472,11 @@ impl Vmm { #[cfg(all(feature = "kvm", target_arch = "x86_64"))] let common_cpuid = { #[cfg(feature = "tdx")] - let tdx_enabled = vm_config.lock().unwrap().is_tdx_enabled(); + if vm_config.lock().unwrap().is_tdx_enabled() { + return Err(MigratableError::MigrateSend(anyhow!( + "Live Migration is not supported when TDX is enabled" + ))); + }; let phys_bits = vm::physical_bits(vm_config.lock().unwrap().cpus.max_phys_bits); arch::generate_common_cpuid( hypervisor, @@ -1481,7 +1485,7 @@ impl Vmm { phys_bits, vm_config.lock().unwrap().cpus.kvm_hyperv, #[cfg(feature = "tdx")] - tdx_enabled, + false, ) .map_err(|e| { MigratableError::MigrateReceive(anyhow!("Error generating common cpuid': {:?}", e)) @@ -1658,6 +1662,13 @@ impl Vmm { src_vm_config: &Arc>, src_vm_cpuid: &[hypervisor::arch::x86::CpuIdEntry], ) -> result::Result<(), MigratableError> { + #[cfg(feature = "tdx")] + if src_vm_config.lock().unwrap().is_tdx_enabled() { + return Err(MigratableError::MigrateReceive(anyhow!( + "Live Migration is not supported when TDX is enabled" + ))); + }; + // We check the `CPUID` compatibility of between the source vm and destination, which is // mostly about feature compatibility and "topology/sgx" leaves are not relevant. let dest_cpuid = &{ @@ -1671,7 +1682,7 @@ impl Vmm { phys_bits, vm_config.cpus.kvm_hyperv, #[cfg(feature = "tdx")] - vm_config.is_tdx_enabled(), + false, ) .map_err(|e| { MigratableError::MigrateReceive(anyhow!("Error generating common cpuid: {:?}", e)) diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index b5d4a222a..b1bcb23b7 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -2605,12 +2605,9 @@ impl Snapshottable for Vm { fn snapshot(&mut self) -> std::result::Result { event!("vm", "snapshotting"); - #[cfg(feature = "tdx")] - let tdx_enabled = self.config.lock().unwrap().is_tdx_enabled(); - #[cfg(feature = "tdx")] { - if tdx_enabled { + if self.config.lock().unwrap().is_tdx_enabled() { return Err(MigratableError::Snapshot(anyhow!( "Snapshot not possible with TDX VM" ))); @@ -2634,7 +2631,7 @@ impl Snapshottable for Vm { phys_bits, self.config.lock().unwrap().cpus.kvm_hyperv, #[cfg(feature = "tdx")] - tdx_enabled, + false, ) .map_err(|e| { MigratableError::MigrateReceive(anyhow!("Error generating common cpuid: {:?}", e))