From 85012fbe5cb85aa793e23f75d2590c824f5fe0e0 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Sun, 26 Apr 2026 11:39:06 +0100 Subject: [PATCH] virtio-devices: Calculate number of msix interrupts in VirtioPciDevice Rather than calculate in the DeviceManager and pass it through do it in the device where it already has all the required information. Signed-off-by: Rob Bradford --- virtio-devices/src/transport/pci_device.rs | 6 +++++- vmm/src/device_manager.rs | 6 ------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/virtio-devices/src/transport/pci_device.rs b/virtio-devices/src/transport/pci_device.rs index 41743e419..12f689ab7 100644 --- a/virtio-devices/src/transport/pci_device.rs +++ b/virtio-devices/src/transport/pci_device.rs @@ -403,7 +403,6 @@ impl VirtioPciDevice { id: String, memory: GuestMemoryAtomic, device: Arc>, - msix_num: u16, access_platform: Option<&Arc>, interrupt_manager: &dyn InterruptManager, pci_device_bdf: u32, @@ -434,6 +433,11 @@ impl VirtioPciDevice { let pci_device_id = VIRTIO_PCI_DEVICE_ID_BASE + locked_device.device_type() as u16; + // Allows support for one MSI-X vector per interrupt needed by the device. + // It also adds 1 as we need to take into account the dedicated vector to notify + // about a virtio config change. + let msix_num = (locked_device.queue_max_sizes().len() + 1) as u16; + let interrupt_source_group: MaybeMutInterruptSourceGroup = { let config = MsiIrqGroupConfig { base: 0, diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 8a693c08f..45dc9a2ef 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -4172,11 +4172,6 @@ impl DeviceManager { return Err(DeviceManagerError::MissingNode); } - // Allows support for one MSI-X vector per interrupt needed by the device. - // It also adds 1 as we need to take into account the dedicated vector to notify - // about a virtio config change. - let msix_num = (virtio_device.lock().unwrap().queue_max_sizes().len() + 1) as u16; - // Create the AccessPlatform trait from the implementation IommuMapping. // This will provide address translation for any virtio device sitting // behind a vIOMMU. @@ -4245,7 +4240,6 @@ impl DeviceManager { id.clone(), memory, virtio_device, - msix_num, access_platform.as_ref(), self.msi_interrupt_manager.as_ref(), pci_device_bdf.into(),