vmm: tdx: Error out early for TD migration

Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
Bo Chen
2023-12-11 20:04:55 +00:00
committed by Bo Chen
parent ceb1be9f50
commit e64b66054e
2 changed files with 17 additions and 8 deletions

View File

@@ -2441,12 +2441,9 @@ impl Snapshottable for Vm {
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
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"
)));
@@ -2474,7 +2471,7 @@ impl Snapshottable for Vm {
phys_bits,
kvm_hyperv: self.config.lock().unwrap().cpus.kvm_hyperv,
#[cfg(feature = "tdx")]
tdx: tdx_enabled,
tdx: false,
amx,
},
)