diff --git a/aarch64/src/lib.rs b/aarch64/src/lib.rs index 043a5b5091..1cfe38c0eb 100644 --- a/aarch64/src/lib.rs +++ b/aarch64/src/lib.rs @@ -444,13 +444,14 @@ impl arch::LinuxArch for AArch64 { .into_iter() .map(|(dev, jail_orig)| (*(dev.into_platform_device().unwrap()), jail_orig)) .collect(); - let mut platform_pid_debug_label_map = arch::sys::unix::generate_platform_bus( - platform_devices, - irq_chip.as_irq_chip_mut(), - &mmio_bus, - system_allocator, - ) - .map_err(Error::CreatePlatformBus)?; + let (platform_devices, mut platform_pid_debug_label_map) = + arch::sys::unix::generate_platform_bus( + platform_devices, + irq_chip.as_irq_chip_mut(), + &mmio_bus, + system_allocator, + ) + .map_err(Error::CreatePlatformBus)?; pid_debug_label_map.append(&mut platform_pid_debug_label_map); Self::add_arch_devs( @@ -595,6 +596,7 @@ impl arch::LinuxArch for AArch64 { pm: None, resume_notify_devices: Vec::new(), root_config: pci_root, + platform_devices, hotplug_bus: BTreeMap::new(), }) } diff --git a/arch/src/lib.rs b/arch/src/lib.rs index 69a2709b23..f865068c3a 100644 --- a/arch/src/lib.rs +++ b/arch/src/lib.rs @@ -188,6 +188,8 @@ pub struct RunnableLinuxVm { pub mmio_bus: Arc, pub no_smt: bool, pub pid_debug_label_map: BTreeMap, + #[cfg(unix)] + pub platform_devices: Vec>>, pub pm: Option>>, /// Devices to be notified before the system resumes from the S3 suspended state. pub resume_notify_devices: Vec>>, diff --git a/arch/src/sys/unix.rs b/arch/src/sys/unix.rs index b0d0622771..99657a3b6e 100644 --- a/arch/src/sys/unix.rs +++ b/arch/src/sys/unix.rs @@ -139,7 +139,8 @@ pub fn generate_platform_bus( irq_chip: &mut dyn IrqChip, mmio_bus: &Bus, resources: &mut SystemAllocator, -) -> Result, DeviceRegistrationError> { +) -> Result<(Vec>>, BTreeMap), DeviceRegistrationError> { + let mut platform_devices = Vec::new(); let mut pid_labels = BTreeMap::new(); // Allocate ranges that may need to be in the Platform MMIO region (MmioType::Platform). @@ -199,11 +200,12 @@ pub fn generate_platform_bus( device.on_sandboxed(); Arc::new(Mutex::new(device)) }; + platform_devices.push(arced_dev.clone()); for range in &ranges { mmio_bus .insert(arced_dev.clone(), range.0, range.1) .map_err(DeviceRegistrationError::MmioInsert)?; } } - Ok(pid_labels) + Ok((platform_devices, pid_labels)) } diff --git a/x86_64/src/lib.rs b/x86_64/src/lib.rs index 12baf02375..0d2ae91698 100644 --- a/x86_64/src/lib.rs +++ b/x86_64/src/lib.rs @@ -854,6 +854,8 @@ impl arch::LinuxArch for X8664arch { gdb: components.gdb, pm: Some(acpi_dev_resource.pm), root_config: pci, + #[cfg(unix)] + platform_devices: Vec::new(), hotplug_bus: BTreeMap::new(), }) }