Skip to content

Commit fa1530a

Browse files
committed
pci: support snapshotting VirtIO PCI devices
Support serializing the device-specific and transport state of a VirtIO device that uses the PCI transport. Signed-off-by: Babis Chalios <[email protected]>
1 parent 7ec44b8 commit fa1530a

File tree

5 files changed

+627
-64
lines changed

5 files changed

+627
-64
lines changed

src/vmm/src/builder.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,8 @@ pub fn build_microvm_from_snapshot(
451451
// Restore the boot source config paths.
452452
vm_resources.boot_source.config = microvm_state.vm_info.boot_source;
453453

454+
let vm = Arc::new(vm);
455+
454456
// Restore devices states.
455457
// Restoring VMGenID injects an interrupt in the guest to notify it about the new generation
456458
// ID. As a result, we need to restore DeviceManager after restoring the KVM state, otherwise
@@ -473,7 +475,7 @@ pub fn build_microvm_from_snapshot(
473475
instance_info: instance_info.clone(),
474476
shutdown_exit_code: None,
475477
kvm,
476-
vm: Arc::new(vm),
478+
vm,
477479
uffd,
478480
vcpus_handles: Vec::new(),
479481
vcpus_exit_evt,

src/vmm/src/device_manager/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ pub enum DevicePersistError {
309309

310310
pub struct DeviceRestoreArgs<'a> {
311311
pub mem: &'a GuestMemoryMmap,
312-
pub vm: &'a Vm,
312+
pub vm: &'a Arc<Vm>,
313313
pub event_manager: &'a mut EventManager,
314314
pub vcpus_exit_evt: &'a EventFd,
315315
pub vm_resources: &'a mut VmResources,
@@ -375,6 +375,11 @@ impl<'a> Persist<'a> for DeviceManager {
375375
// Restore PCI devices
376376
let pci_ctor_args = PciDevicesConstructorArgs {
377377
resource_allocator: &resource_allocator,
378+
vm: constructor_args.vm.clone(),
379+
mem: constructor_args.mem,
380+
vm_resources: constructor_args.vm_resources,
381+
instance_id: constructor_args.instance_id,
382+
restored_from_file: constructor_args.restored_from_file,
378383
};
379384
let pci_devices = PciDevices::restore(pci_ctor_args, &state.pci_state)?;
380385

0 commit comments

Comments
 (0)