Skip to content

Commit 154523f

Browse files
committed
chore(vmm): prohibit restoring from a file if secret free
In a regular VM, we mmap the memory snapshot file and supply the address in the KVM memory slot. In Secret Free VMs, we provide guest_memfd in the memory slot instead. There is no way we can restore a Secret Free VM from a file, unless we prepopulate the guest_memfd with the file content, which is inefficient and is not practically useful. Signed-off-by: Nikita Kalyazin <kalyazin@amazon.com>
1 parent b400181 commit 154523f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/vmm/src/persist.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use crate::utils::u64_to_usize;
3434
use crate::vmm_config::boot_source::BootSourceConfig;
3535
use crate::vmm_config::instance_info::InstanceInfo;
3636
use crate::vmm_config::machine_config::{HugePageConfig, MachineConfigError, MachineConfigUpdate};
37-
use crate::vmm_config::snapshot::{CreateSnapshotParams, LoadSnapshotParams};
37+
use crate::vmm_config::snapshot::{CreateSnapshotParams, LoadSnapshotParams, MemBackendType};
3838
use crate::vstate::kvm::KvmState;
3939
use crate::vstate::memory::{
4040
self, GuestMemoryState, GuestRegionMmap, GuestRegionType, MemoryError,
@@ -401,6 +401,17 @@ pub fn restore_from_snapshot(
401401
vm_resources: &mut VmResources,
402402
) -> Result<Arc<Mutex<Vmm>>, RestoreFromSnapshotError> {
403403
let mut microvm_state = snapshot_state_from_file(&params.snapshot_path)?;
404+
405+
if microvm_state.vm_info.secret_free && params.mem_backend.backend_type == MemBackendType::File
406+
{
407+
return Err(RestoreFromSnapshotError::Build(
408+
BuildMicrovmFromSnapshotError::VmUpdateConfig(MachineConfigError::Incompatible(
409+
"secret freedom",
410+
"file memory backend",
411+
)),
412+
));
413+
}
414+
404415
for entry in &params.network_overrides {
405416
microvm_state
406417
.device_states

0 commit comments

Comments
 (0)