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 <rbradford@meta.com>
This commit is contained in:
Rob Bradford
2026-04-03 16:46:46 +01:00
parent 2148f2e0bc
commit 4f7ff8fe48

View File

@@ -273,6 +273,16 @@ pub struct VirtQueueAffinity {
pub host_cpus: Vec<usize>,
}
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, Default)]
pub struct PciDeviceCommonConfig {
#[serde(default)]
pub id: Option<String>,
#[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<PathBuf>,