diff --git a/tests/integration.rs b/tests/integration.rs index 148d6b2b6..d734ce8d9 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -5845,12 +5845,20 @@ mod common_parallel { event: "starting".to_string(), device_id: None, }, + &MetaEvent { + event: "activated".to_string(), + device_id: Some("__console".to_string()), + }, + &MetaEvent { + event: "activated".to_string(), + device_id: Some("__rng".to_string()), + }, &MetaEvent { event: "restoring".to_string(), device_id: None, }, ]; - assert!(check_sequential_events_exact( + assert!(check_sequential_events( &expected_events, &event_path_restored )); diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs index 509fe28b1..e2c11fecf 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -1253,6 +1253,9 @@ impl Vmm { activate_evt, true, timestamp, + None, + None, + None, Some(&snapshot), ) .map_err(|e| { diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 82e078163..afc854c35 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -476,6 +476,9 @@ impl Vm { activate_evt: EventFd, restoring: bool, timestamp: Instant, + serial_pty: Option, + console_pty: Option, + console_resize_pipe: Option, snapshot: Option<&Snapshot>, ) -> Result { trace_scoped!("Vm::new_from_memory_manager"); @@ -573,6 +576,12 @@ impl Vm { ) .map_err(Error::DeviceManager)?; + device_manager + .lock() + .unwrap() + .create_devices(serial_pty, console_pty, console_resize_pipe) + .map_err(Error::DeviceManager)?; + // SAFETY: trivially safe let on_tty = unsafe { libc::isatty(libc::STDIN_FILENO) } != 0; @@ -754,7 +763,7 @@ impl Vm { ) .map_err(Error::MemoryManager)?; - let new_vm = Vm::new_from_memory_manager( + Vm::new_from_memory_manager( config, memory_manager, vm, @@ -767,18 +776,11 @@ impl Vm { activate_evt, false, timestamp, + serial_pty, + console_pty, + console_resize_pipe, None, - )?; - - // The device manager must create the devices from here as it is part - // of the regular code path creating everything from scratch. - new_vm - .device_manager - .lock() - .unwrap() - .create_devices(serial_pty, console_pty, console_resize_pipe) - .map_err(Error::DeviceManager)?; - Ok(new_vm) + ) } #[allow(clippy::too_many_arguments)] @@ -834,6 +836,9 @@ impl Vm { activate_evt, true, timestamp, + None, + None, + None, Some(snapshot), ) } @@ -2619,12 +2624,6 @@ impl Snapshottable for Vm { MigratableError::Restore(anyhow!("Could not restore VM state: {:#?}", e)) })?; - self.device_manager - .lock() - .unwrap() - .create_devices(None, None, None) - .map_err(|e| MigratableError::Restore(anyhow!("Error restoring devices: {:#?}", e)))?; - #[cfg(target_arch = "aarch64")] self.restore_vgic_and_enable_interrupt(&_snapshot)?;