Skip to content

Commit 441a900

Browse files
Manciukicbchalios
authored andcommitted
fix(restore): fix net device rename of PCI devices
The device rename wasn't working on PCI devices because the code only checked the MMIO state. Fix the bug by looking for the device to rename in both the mmio and pci states. Signed-off-by: Riccardo Mancini <[email protected]> Signed-off-by: Babis Chalios <[email protected]>
1 parent a98d78a commit 441a900

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/vmm/src/persist.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -321,18 +321,23 @@ pub fn restore_from_snapshot(
321321
) -> Result<Arc<Mutex<Vmm>>, RestoreFromSnapshotError> {
322322
let mut microvm_state = snapshot_state_from_file(&params.snapshot_path)?;
323323
for entry in &params.network_overrides {
324-
let net_devices = &mut microvm_state.device_states.mmio_state.net_devices;
325-
if let Some(device) = net_devices
324+
microvm_state
325+
.device_states
326+
.mmio_state
327+
.net_devices
326328
.iter_mut()
327-
.find(|x| x.device_state.id == entry.iface_id)
328-
{
329-
device
330-
.device_state
331-
.tap_if_name
332-
.clone_from(&entry.host_dev_name);
333-
} else {
334-
return Err(SnapshotStateFromFileError::UnknownNetworkDevice.into());
335-
}
329+
.map(|device| &mut device.device_state)
330+
.chain(
331+
microvm_state
332+
.device_states
333+
.pci_state
334+
.net_devices
335+
.iter_mut()
336+
.map(|device| &mut device.device_state),
337+
)
338+
.find(|x| x.id == entry.iface_id)
339+
.map(|device_state| device_state.tap_if_name.clone_from(&entry.host_dev_name))
340+
.ok_or(SnapshotStateFromFileError::UnknownNetworkDevice)?;
336341
}
337342
let track_dirty_pages = params.track_dirty_pages;
338343

0 commit comments

Comments
 (0)