mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
migration: Use MemoryManager restore code path
Instead of creating a MemoryManager from scratch, let's reuse the same code path used by snapshot/restore, so that memory regions are created identically to what they were on the source VM. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
+9
-2
@@ -20,7 +20,9 @@ use crate::config::{
|
||||
use crate::cpu;
|
||||
use crate::device_manager::{self, Console, DeviceManager, DeviceManagerError, PtyPair};
|
||||
use crate::device_tree::DeviceTree;
|
||||
use crate::memory_manager::{Error as MemoryManagerError, MemoryManager};
|
||||
use crate::memory_manager::{
|
||||
Error as MemoryManagerError, MemoryManager, MemoryManagerSnapshotData,
|
||||
};
|
||||
use crate::migration::{get_vm_snapshot, url_to_path, VM_SNAPSHOT_FILE};
|
||||
use crate::seccomp_filters::{get_seccomp_filter, Thread};
|
||||
use crate::GuestMemoryMmap;
|
||||
@@ -853,6 +855,7 @@ impl Vm {
|
||||
seccomp_action: &SeccompAction,
|
||||
hypervisor: Arc<dyn hypervisor::Hypervisor>,
|
||||
activate_evt: EventFd,
|
||||
memory_manager_data: &MemoryManagerSnapshotData,
|
||||
) -> Result<Self> {
|
||||
hypervisor.check_required_extensions().unwrap();
|
||||
let vm = hypervisor.create_vm().unwrap();
|
||||
@@ -867,7 +870,7 @@ impl Vm {
|
||||
phys_bits,
|
||||
#[cfg(feature = "tdx")]
|
||||
false,
|
||||
None,
|
||||
Some(memory_manager_data),
|
||||
)
|
||||
.map_err(Error::MemoryManager)?;
|
||||
|
||||
@@ -2269,6 +2272,10 @@ impl Vm {
|
||||
.notify_power_button()
|
||||
.map_err(Error::PowerButton)
|
||||
}
|
||||
|
||||
pub fn memory_manager_data(&self) -> MemoryManagerSnapshotData {
|
||||
self.memory_manager.lock().unwrap().snapshot_data()
|
||||
}
|
||||
}
|
||||
|
||||
impl Pausable for Vm {
|
||||
|
||||
Reference in New Issue
Block a user