mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Support passing Net FDs to Restore
'NetConfig' FDs, when explicitly passed via SCM_RIGHTS during VM creation, are marked as invalid during snapshot. See: #6332. So, Restore should support input for the new net FDs. This patch adds new field 'net_fds' to 'RestoreConfig'. The FDs passed using this new field are replaced into the 'fds' field of NetConfig appropriately. The 'validate()' function ensures all net devices from 'VmConfig' backed by FDs have a corresponding 'RestoreNetConfig' with a matched 'id' and expected number of FDs. The unit tests provide different inputs to parse and validate functions to make sure parsing and error handling is as per expectation. Fixes #6286 Signed-off-by: Purna Pavan Chandra <paekkaladevi@linux.microsoft.com> Co-authored-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
committed by
Rob Bradford
parent
4fd5070f5d
commit
584784a0f8
@@ -1321,6 +1321,24 @@ impl RequestHandler for Vmm {
|
||||
let vm_config = Arc::new(Mutex::new(
|
||||
recv_vm_config(source_url).map_err(VmError::Restore)?,
|
||||
));
|
||||
restore_cfg
|
||||
.validate(&vm_config.lock().unwrap().clone())
|
||||
.map_err(VmError::ConfigValidation)?;
|
||||
|
||||
// Update VM's net configurations with new fds received for restore operation
|
||||
if let (Some(restored_nets), Some(vm_net_configs)) =
|
||||
(restore_cfg.net_fds, &mut vm_config.lock().unwrap().net)
|
||||
{
|
||||
for net in restored_nets.iter() {
|
||||
for net_config in vm_net_configs.iter_mut() {
|
||||
// update only if the net dev is backed by FDs
|
||||
if net_config.id == Some(net.id.clone()) && net_config.fds.is_some() {
|
||||
net_config.fds.clone_from(&net.fds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let snapshot = recv_vm_state(source_url).map_err(VmError::Restore)?;
|
||||
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
||||
let vm_snapshot = get_vm_snapshot(&snapshot).map_err(VmError::Restore)?;
|
||||
|
||||
Reference in New Issue
Block a user