From 4f7ff8fe48bd7c6eb2d257920873378c71fdfa8e Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 3 Apr 2026 16:46:46 +0100 Subject: [PATCH] vmm: Introduce a PciDeviceCommonConfig struct Introduce a common struct that can encompass all the config fields used by devices that are PCI based. The use of `skip_serializing_if` means that the iommu field will only be included if set (otherwise falling back to default false). This neatly handles the devices that don't support an iommu. Signed-off-by: Rob Bradford --- vmm/src/vm_config.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vmm/src/vm_config.rs b/vmm/src/vm_config.rs index 541f6f21b..1b20d76da 100644 --- a/vmm/src/vm_config.rs +++ b/vmm/src/vm_config.rs @@ -273,6 +273,16 @@ pub struct VirtQueueAffinity { pub host_cpus: Vec, } +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, Default)] +pub struct PciDeviceCommonConfig { + #[serde(default)] + pub id: Option, + #[serde(default, skip_serializing_if = "<&bool as std::ops::Not>::not")] + pub iommu: bool, + #[serde(default)] + pub pci_segment: u16, +} + #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] pub struct DiskConfig { pub path: Option,