Skip to content

Commit 3850279

Browse files
kalyazinroypat
authored andcommitted
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 <[email protected]>
1 parent ce8e99f commit 3850279

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
use crate::vstate::memory::{GuestMemoryState, GuestRegionMmap, MemoryError};
@@ -384,6 +384,17 @@ pub fn restore_from_snapshot(
384384
vm_resources: &mut VmResources,
385385
) -> Result<Arc<Mutex<Vmm>>, RestoreFromSnapshotError> {
386386
let mut microvm_state = snapshot_state_from_file(&params.snapshot_path)?;
387+
388+
if microvm_state.vm_info.secret_free && params.mem_backend.backend_type == MemBackendType::File
389+
{
390+
return Err(RestoreFromSnapshotError::Build(
391+
BuildMicrovmFromSnapshotError::VmUpdateConfig(MachineConfigError::Incompatible(
392+
"secret freedom",
393+
"file memory backend",
394+
)),
395+
));
396+
}
397+
387398
for entry in &params.network_overrides {
388399
let net_devices = &mut microvm_state.device_states.net_devices;
389400
if let Some(device) = net_devices

0 commit comments

Comments
 (0)