mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: config: Switch UserDeviceConfig to use PciDeviceCommonConfig
Switch UserDeviceConfig 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 VFIO user devices do not support being placed behind an IOMMU an error is now raised if iommu is set. This can't happen via the CLI but could via the JSON/API. Signed-off-by: Rob Bradford <rbradford@meta.com>
This commit is contained in:
@@ -4120,16 +4120,16 @@ impl DeviceManager {
|
||||
&mut self,
|
||||
device_cfg: &mut UserDeviceConfig,
|
||||
) -> DeviceManagerResult<(PciBdf, String)> {
|
||||
let vfio_user_name = if let Some(id) = &device_cfg.id {
|
||||
let vfio_user_name = if let Some(id) = &device_cfg.pci_common.id {
|
||||
id.clone()
|
||||
} else {
|
||||
let id = self.next_device_name(VFIO_USER_DEVICE_NAME_PREFIX)?;
|
||||
device_cfg.id = Some(id.clone());
|
||||
device_cfg.pci_common.id = Some(id.clone());
|
||||
id
|
||||
};
|
||||
|
||||
let (pci_segment_id, pci_device_bdf, resources) =
|
||||
self.pci_resources(&vfio_user_name, device_cfg.pci_segment)?;
|
||||
self.pci_resources(&vfio_user_name, device_cfg.pci_common.pci_segment)?;
|
||||
|
||||
let legacy_interrupt_group =
|
||||
if let Some(legacy_interrupt_manager) = &self.legacy_interrupt_manager {
|
||||
@@ -4653,12 +4653,13 @@ impl DeviceManager {
|
||||
&mut self,
|
||||
device_cfg: &mut UserDeviceConfig,
|
||||
) -> DeviceManagerResult<PciDeviceInfo> {
|
||||
self.validate_identifier(&device_cfg.id)?;
|
||||
self.validate_identifier(&device_cfg.pci_common.id)?;
|
||||
|
||||
let (bdf, device_name) = self.add_vfio_user_device(device_cfg)?;
|
||||
|
||||
// Update the PCIU bitmap
|
||||
self.pci_segments[device_cfg.pci_segment as usize].pci_devices_up |= 1 << bdf.device();
|
||||
self.pci_segments[device_cfg.pci_common.pci_segment as usize].pci_devices_up |=
|
||||
1 << bdf.device();
|
||||
|
||||
Ok(PciDeviceInfo {
|
||||
id: device_name,
|
||||
|
||||
Reference in New Issue
Block a user