vmm: config: Switch FsConfig to use PciDeviceCommonConfig

Switch FsConfig over to using the newly extracted struct members as used
by all PCI based devices. The use of #[serde(flatten)] means that this
change has no impact on the JSON format that the data is stored as.

As virtio-fs does not support being placed behind an IOMMU an error is
now raised if iommu is set. This option is not exposed via the CLI but
could happen with a miscontructed JSON/API call.

Signed-off-by: Rob Bradford <rbradford@meta.com>
This commit is contained in:
Rob Bradford
2026-04-03 11:56:41 -07:00
parent 92c2cf0103
commit 40150dd72d
3 changed files with 20 additions and 36 deletions

View File

@@ -3216,11 +3216,11 @@ impl DeviceManager {
&mut self,
fs_cfg: &mut FsConfig,
) -> DeviceManagerResult<MetaVirtioDevice> {
let id = if let Some(id) = &fs_cfg.id {
let id = if let Some(id) = &fs_cfg.pci_common.id {
id.clone()
} else {
let id = self.next_device_name(FS_DEVICE_NAME_PREFIX)?;
fs_cfg.id = Some(id.clone());
fs_cfg.pci_common.id = Some(id.clone());
id
};
@@ -3257,7 +3257,7 @@ impl DeviceManager {
as Arc<Mutex<dyn virtio_devices::VirtioDevice>>,
iommu: false,
id,
pci_segment: fs_cfg.pci_segment,
pci_segment: fs_cfg.pci_common.pci_segment,
dma_handler: None,
})
} else {
@@ -5039,7 +5039,7 @@ impl DeviceManager {
}
pub fn add_fs(&mut self, fs_cfg: &mut FsConfig) -> DeviceManagerResult<PciDeviceInfo> {
self.validate_identifier(&fs_cfg.id)?;
self.validate_identifier(&fs_cfg.pci_common.id)?;
let device = self.make_virtio_fs_device(fs_cfg)?;
self.hotplug_virtio_pci_device(device)