mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-23 16:31:16 +00:00
vmm: Move devices creation to Vm creation
This moves the devices creation out of the dedicated restore function which will be eventually removed. This factorizes the creation of all devices into a single location. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
bccfa81368
commit
1c36065754
@ -5845,12 +5845,20 @@ mod common_parallel {
|
|||||||
event: "starting".to_string(),
|
event: "starting".to_string(),
|
||||||
device_id: None,
|
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 {
|
&MetaEvent {
|
||||||
event: "restoring".to_string(),
|
event: "restoring".to_string(),
|
||||||
device_id: None,
|
device_id: None,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
assert!(check_sequential_events_exact(
|
assert!(check_sequential_events(
|
||||||
&expected_events,
|
&expected_events,
|
||||||
&event_path_restored
|
&event_path_restored
|
||||||
));
|
));
|
||||||
|
@ -1253,6 +1253,9 @@ impl Vmm {
|
|||||||
activate_evt,
|
activate_evt,
|
||||||
true,
|
true,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
Some(&snapshot),
|
Some(&snapshot),
|
||||||
)
|
)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
|
@ -476,6 +476,9 @@ impl Vm {
|
|||||||
activate_evt: EventFd,
|
activate_evt: EventFd,
|
||||||
restoring: bool,
|
restoring: bool,
|
||||||
timestamp: Instant,
|
timestamp: Instant,
|
||||||
|
serial_pty: Option<PtyPair>,
|
||||||
|
console_pty: Option<PtyPair>,
|
||||||
|
console_resize_pipe: Option<File>,
|
||||||
snapshot: Option<&Snapshot>,
|
snapshot: Option<&Snapshot>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
trace_scoped!("Vm::new_from_memory_manager");
|
trace_scoped!("Vm::new_from_memory_manager");
|
||||||
@ -573,6 +576,12 @@ impl Vm {
|
|||||||
)
|
)
|
||||||
.map_err(Error::DeviceManager)?;
|
.map_err(Error::DeviceManager)?;
|
||||||
|
|
||||||
|
device_manager
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.create_devices(serial_pty, console_pty, console_resize_pipe)
|
||||||
|
.map_err(Error::DeviceManager)?;
|
||||||
|
|
||||||
// SAFETY: trivially safe
|
// SAFETY: trivially safe
|
||||||
let on_tty = unsafe { libc::isatty(libc::STDIN_FILENO) } != 0;
|
let on_tty = unsafe { libc::isatty(libc::STDIN_FILENO) } != 0;
|
||||||
|
|
||||||
@ -754,7 +763,7 @@ impl Vm {
|
|||||||
)
|
)
|
||||||
.map_err(Error::MemoryManager)?;
|
.map_err(Error::MemoryManager)?;
|
||||||
|
|
||||||
let new_vm = Vm::new_from_memory_manager(
|
Vm::new_from_memory_manager(
|
||||||
config,
|
config,
|
||||||
memory_manager,
|
memory_manager,
|
||||||
vm,
|
vm,
|
||||||
@ -767,18 +776,11 @@ impl Vm {
|
|||||||
activate_evt,
|
activate_evt,
|
||||||
false,
|
false,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
serial_pty,
|
||||||
|
console_pty,
|
||||||
|
console_resize_pipe,
|
||||||
None,
|
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)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
@ -834,6 +836,9 @@ impl Vm {
|
|||||||
activate_evt,
|
activate_evt,
|
||||||
true,
|
true,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
Some(snapshot),
|
Some(snapshot),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -2619,12 +2624,6 @@ impl Snapshottable for Vm {
|
|||||||
MigratableError::Restore(anyhow!("Could not restore VM state: {:#?}", e))
|
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")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
self.restore_vgic_and_enable_interrupt(&_snapshot)?;
|
self.restore_vgic_and_enable_interrupt(&_snapshot)?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user