mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-01 11:05:46 +00:00
vmm: memory_manager: Make the snapshot source directory an Option
This allows the code to be reused when creating the VM from a snapshot when doing VM migration. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
523029449e
commit
dfe2dadb3e
@ -397,7 +397,7 @@ impl Vmm {
|
|||||||
&snapshot,
|
&snapshot,
|
||||||
exit_evt,
|
exit_evt,
|
||||||
reset_evt,
|
reset_evt,
|
||||||
source_url,
|
Some(source_url),
|
||||||
restore_cfg.prefault,
|
restore_cfg.prefault,
|
||||||
&self.seccomp_action,
|
&self.seccomp_action,
|
||||||
self.hypervisor.clone(),
|
self.hypervisor.clone(),
|
||||||
|
@ -760,10 +760,13 @@ impl MemoryManager {
|
|||||||
snapshot: &Snapshot,
|
snapshot: &Snapshot,
|
||||||
vm: Arc<dyn hypervisor::Vm>,
|
vm: Arc<dyn hypervisor::Vm>,
|
||||||
config: &MemoryConfig,
|
config: &MemoryConfig,
|
||||||
source_url: &str,
|
source_url: Option<&str>,
|
||||||
prefault: bool,
|
prefault: bool,
|
||||||
phys_bits: u8,
|
phys_bits: u8,
|
||||||
) -> Result<Arc<Mutex<MemoryManager>>, Error> {
|
) -> Result<Arc<Mutex<MemoryManager>>, Error> {
|
||||||
|
let mm = MemoryManager::new(vm, config, prefault, phys_bits)?;
|
||||||
|
|
||||||
|
if let Some(source_url) = source_url {
|
||||||
let url = Url::parse(source_url).unwrap();
|
let url = Url::parse(source_url).unwrap();
|
||||||
/* url must be valid dir which is verified in recv_vm_snapshot() */
|
/* url must be valid dir which is verified in recv_vm_snapshot() */
|
||||||
let vm_snapshot_path = url.to_file_path().unwrap();
|
let vm_snapshot_path = url.to_file_path().unwrap();
|
||||||
@ -800,8 +803,8 @@ impl MemoryManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mm = MemoryManager::new(vm, config, prefault, phys_bits)?;
|
|
||||||
mm.lock().unwrap().fill_saved_regions(saved_regions)?;
|
mm.lock().unwrap().fill_saved_regions(saved_regions)?;
|
||||||
|
|
||||||
Ok(mm)
|
Ok(mm)
|
||||||
} else {
|
} else {
|
||||||
Err(Error::Restore(MigratableError::Restore(anyhow!(
|
Err(Error::Restore(MigratableError::Restore(anyhow!(
|
||||||
@ -809,6 +812,9 @@ impl MemoryManager {
|
|||||||
MEMORY_MANAGER_SNAPSHOT_ID
|
MEMORY_MANAGER_SNAPSHOT_ID
|
||||||
))))
|
))))
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Ok(mm)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn memfd_create(name: &ffi::CStr, flags: u32) -> Result<RawFd, io::Error> {
|
fn memfd_create(name: &ffi::CStr, flags: u32) -> Result<RawFd, io::Error> {
|
||||||
|
@ -680,7 +680,7 @@ impl Vm {
|
|||||||
snapshot: &Snapshot,
|
snapshot: &Snapshot,
|
||||||
exit_evt: EventFd,
|
exit_evt: EventFd,
|
||||||
reset_evt: EventFd,
|
reset_evt: EventFd,
|
||||||
source_url: &str,
|
source_url: Option<&str>,
|
||||||
prefault: bool,
|
prefault: bool,
|
||||||
seccomp_action: &SeccompAction,
|
seccomp_action: &SeccompAction,
|
||||||
hypervisor: Arc<dyn hypervisor::Hypervisor>,
|
hypervisor: Arc<dyn hypervisor::Hypervisor>,
|
||||||
|
Loading…
Reference in New Issue
Block a user