mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: tdx: Error out early for TD migration
Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
@@ -1669,7 +1669,12 @@ impl Vmm {
|
|||||||
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
||||||
let common_cpuid = {
|
let common_cpuid = {
|
||||||
#[cfg(feature = "tdx")]
|
#[cfg(feature = "tdx")]
|
||||||
let tdx = 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 amx = vm_config.lock().unwrap().cpus.features.amx;
|
let amx = vm_config.lock().unwrap().cpus.features.amx;
|
||||||
let phys_bits =
|
let phys_bits =
|
||||||
vm::physical_bits(&hypervisor, vm_config.lock().unwrap().cpus.max_phys_bits);
|
vm::physical_bits(&hypervisor, vm_config.lock().unwrap().cpus.max_phys_bits);
|
||||||
@@ -1680,7 +1685,7 @@ impl Vmm {
|
|||||||
phys_bits,
|
phys_bits,
|
||||||
kvm_hyperv: vm_config.lock().unwrap().cpus.kvm_hyperv,
|
kvm_hyperv: vm_config.lock().unwrap().cpus.kvm_hyperv,
|
||||||
#[cfg(feature = "tdx")]
|
#[cfg(feature = "tdx")]
|
||||||
tdx,
|
tdx: false,
|
||||||
amx,
|
amx,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -1859,6 +1864,13 @@ impl Vmm {
|
|||||||
src_vm_config: &Arc<Mutex<VmConfig>>,
|
src_vm_config: &Arc<Mutex<VmConfig>>,
|
||||||
src_vm_cpuid: &[hypervisor::arch::x86::CpuIdEntry],
|
src_vm_cpuid: &[hypervisor::arch::x86::CpuIdEntry],
|
||||||
) -> result::Result<(), MigratableError> {
|
) -> 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
|
// 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.
|
// mostly about feature compatibility and "topology/sgx" leaves are not relevant.
|
||||||
let dest_cpuid = &{
|
let dest_cpuid = &{
|
||||||
@@ -1872,7 +1884,7 @@ impl Vmm {
|
|||||||
phys_bits,
|
phys_bits,
|
||||||
kvm_hyperv: vm_config.cpus.kvm_hyperv,
|
kvm_hyperv: vm_config.cpus.kvm_hyperv,
|
||||||
#[cfg(feature = "tdx")]
|
#[cfg(feature = "tdx")]
|
||||||
tdx: vm_config.is_tdx_enabled(),
|
tdx: false,
|
||||||
amx: vm_config.cpus.features.amx,
|
amx: vm_config.cpus.features.amx,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2441,12 +2441,9 @@ impl Snapshottable for Vm {
|
|||||||
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
|
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
|
||||||
event!("vm", "snapshotting");
|
event!("vm", "snapshotting");
|
||||||
|
|
||||||
#[cfg(feature = "tdx")]
|
|
||||||
let tdx_enabled = self.config.lock().unwrap().is_tdx_enabled();
|
|
||||||
|
|
||||||
#[cfg(feature = "tdx")]
|
#[cfg(feature = "tdx")]
|
||||||
{
|
{
|
||||||
if tdx_enabled {
|
if self.config.lock().unwrap().is_tdx_enabled() {
|
||||||
return Err(MigratableError::Snapshot(anyhow!(
|
return Err(MigratableError::Snapshot(anyhow!(
|
||||||
"Snapshot not possible with TDX VM"
|
"Snapshot not possible with TDX VM"
|
||||||
)));
|
)));
|
||||||
@@ -2474,7 +2471,7 @@ impl Snapshottable for Vm {
|
|||||||
phys_bits,
|
phys_bits,
|
||||||
kvm_hyperv: self.config.lock().unwrap().cpus.kvm_hyperv,
|
kvm_hyperv: self.config.lock().unwrap().cpus.kvm_hyperv,
|
||||||
#[cfg(feature = "tdx")]
|
#[cfg(feature = "tdx")]
|
||||||
tdx: tdx_enabled,
|
tdx: false,
|
||||||
amx,
|
amx,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user