diff --git a/src/agent/src/device.rs b/src/agent/src/device.rs index 813c4d5692..ad181141cd 100644 --- a/src/agent/src/device.rs +++ b/src/agent/src/device.rs @@ -765,7 +765,6 @@ pub async fn add_devices( sandbox: &Arc>, ) -> Result<()> { let mut dev_updates = HashMap::<&str, DevUpdate>::with_capacity(devices.len()); - let mut pci_updates = HashMap::::new(); for device in devices.iter() { let update = add_device(device, sandbox).await?; @@ -780,8 +779,9 @@ pub async fn add_devices( )); } + let mut sb = sandbox.lock().await; for (host, guest) in update.pci { - if let Some(other_guest) = pci_updates.insert(host, guest) { + if let Some(other_guest) = sb.pcimap.insert(host, guest) { return Err(anyhow!( "Conflicting guest address for host device {} ({} versus {})", host, diff --git a/src/agent/src/sandbox.rs b/src/agent/src/sandbox.rs index 4dfb2eda58..3edbe7ea02 100644 --- a/src/agent/src/sandbox.rs +++ b/src/agent/src/sandbox.rs @@ -8,6 +8,7 @@ use crate::mount::{get_mount_fs_type, remove_mounts, TYPE_ROOTFS}; use crate::namespace::Namespace; use crate::netlink::Handle; use crate::network::Network; +use crate::pci; use crate::uevent::{Uevent, UeventMatcher}; use crate::watcher::BindWatcher; use anyhow::{anyhow, Context, Result}; @@ -56,6 +57,7 @@ pub struct Sandbox { pub event_rx: Arc>>, pub event_tx: Option>, pub bind_watcher: BindWatcher, + pub pcimap: HashMap, } impl Sandbox { @@ -88,6 +90,7 @@ impl Sandbox { event_rx, event_tx: Some(tx), bind_watcher: BindWatcher::new(), + pcimap: HashMap::new(), }) }