mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-11-04 19:11:11 +00:00
vmm: Propagate the set of memory slots to FDs received in migration
Create the VM using the FDs (wrapped in Files) that have been received during the migration process. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
735658a49d
commit
1daef5e8c9
@ -29,6 +29,7 @@ use memory_manager::MemoryManagerSnapshotData;
|
||||
use pci::PciBdf;
|
||||
use seccompiler::{apply_filter, SeccompAction};
|
||||
use serde::ser::{Serialize, SerializeStruct, Serializer};
|
||||
use std::collections::HashMap;
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
use std::io::{Read, Write};
|
||||
@ -753,6 +754,7 @@ impl Vmm {
|
||||
&mut self,
|
||||
req: &Request,
|
||||
socket: &mut T,
|
||||
existing_memory_files: Option<HashMap<u32, File>>,
|
||||
) -> std::result::Result<Vm, MigratableError>
|
||||
where
|
||||
T: Read + Write,
|
||||
@ -794,6 +796,7 @@ impl Vmm {
|
||||
self.hypervisor.clone(),
|
||||
activate_evt,
|
||||
&vm_migration_config.memory_manager_data,
|
||||
existing_memory_files,
|
||||
)
|
||||
.map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!("Error creating VM from snapshot: {:?}", e))
|
||||
@ -886,7 +889,7 @@ impl Vmm {
|
||||
|
||||
let mut started = false;
|
||||
let mut vm: Option<Vm> = None;
|
||||
|
||||
let mut existing_memory_files = None;
|
||||
loop {
|
||||
let req = Request::read_from(&mut socket)?;
|
||||
match req.command() {
|
||||
@ -905,7 +908,11 @@ impl Vmm {
|
||||
Response::error().write_to(&mut socket)?;
|
||||
continue;
|
||||
}
|
||||
vm = Some(self.vm_receive_config(&req, &mut socket)?);
|
||||
vm = Some(self.vm_receive_config(
|
||||
&req,
|
||||
&mut socket,
|
||||
existing_memory_files.take(),
|
||||
)?);
|
||||
}
|
||||
Command::State => {
|
||||
info!("State Command Received");
|
||||
|
@ -867,6 +867,7 @@ impl Vm {
|
||||
)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new_from_migration(
|
||||
config: Arc<Mutex<VmConfig>>,
|
||||
exit_evt: EventFd,
|
||||
@ -875,6 +876,7 @@ impl Vm {
|
||||
hypervisor: Arc<dyn hypervisor::Hypervisor>,
|
||||
activate_evt: EventFd,
|
||||
memory_manager_data: &MemoryManagerSnapshotData,
|
||||
existing_memory_files: Option<HashMap<u32, File>>,
|
||||
) -> Result<Self> {
|
||||
hypervisor.check_required_extensions().unwrap();
|
||||
let vm = hypervisor.create_vm().unwrap();
|
||||
@ -897,7 +899,7 @@ impl Vm {
|
||||
#[cfg(feature = "tdx")]
|
||||
false,
|
||||
Some(memory_manager_data),
|
||||
None,
|
||||
existing_memory_files,
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
None,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user