mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Propagate PCI device ID from the config
We pass the device ID from the config to the allocation routine, where it is then used as the preferred device ID alongside the existing PCI segment ID. Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de> On-behalf-of: SAP pascal.scholz@sap.com Signed-off-by: Rob Bradford <rbradford@meta.com>
This commit is contained in:
committed by
Rob Bradford
parent
7315a38a02
commit
aace90f270
@@ -1711,6 +1711,7 @@ impl DeviceManager {
|
||||
&id,
|
||||
handle.pci_common.pci_segment,
|
||||
handle.dma_handler,
|
||||
handle.pci_common.pci_device_id,
|
||||
)?;
|
||||
|
||||
// Track device BDF for Generic Initiator support
|
||||
@@ -1742,7 +1743,8 @@ impl DeviceManager {
|
||||
}
|
||||
|
||||
if let Some(iommu_device) = iommu_device {
|
||||
let dev_id = self.add_virtio_pci_device(iommu_device, &None, &iommu_id, 0, None)?;
|
||||
let dev_id =
|
||||
self.add_virtio_pci_device(iommu_device, &None, &iommu_id, 0, None, None)?;
|
||||
self.iommu_attached_devices = Some((dev_id, iommu_attached_devices));
|
||||
}
|
||||
}
|
||||
@@ -3656,7 +3658,7 @@ impl DeviceManager {
|
||||
let pci_segment_id = 0x0_u16;
|
||||
|
||||
let (pci_segment_id, pci_device_bdf, resources) =
|
||||
self.pci_resources(&id, pci_segment_id)?;
|
||||
self.pci_resources(&id, pci_segment_id, None)?;
|
||||
|
||||
info!("Creating pvmemcontrol device: id = {id}");
|
||||
let (pvmemcontrol_pci_device, pvmemcontrol_bus_device) =
|
||||
@@ -3922,8 +3924,11 @@ impl DeviceManager {
|
||||
id
|
||||
};
|
||||
|
||||
let (pci_segment_id, pci_device_bdf, resources) =
|
||||
self.pci_resources(&vfio_name, device_cfg.pci_common.pci_segment)?;
|
||||
let (pci_segment_id, pci_device_bdf, resources) = self.pci_resources(
|
||||
&vfio_name,
|
||||
device_cfg.pci_common.pci_segment,
|
||||
device_cfg.pci_common.pci_device_id,
|
||||
)?;
|
||||
|
||||
let mut needs_dma_mapping = false;
|
||||
|
||||
@@ -4184,8 +4189,11 @@ impl DeviceManager {
|
||||
id
|
||||
};
|
||||
|
||||
let (pci_segment_id, pci_device_bdf, resources) =
|
||||
self.pci_resources(&vfio_user_name, device_cfg.pci_common.pci_segment)?;
|
||||
let (pci_segment_id, pci_device_bdf, resources) = self.pci_resources(
|
||||
&vfio_user_name,
|
||||
device_cfg.pci_common.pci_segment,
|
||||
device_cfg.pci_common.pci_device_id,
|
||||
)?;
|
||||
|
||||
let legacy_interrupt_group =
|
||||
if let Some(legacy_interrupt_manager) = &self.legacy_interrupt_manager {
|
||||
@@ -4301,6 +4309,7 @@ impl DeviceManager {
|
||||
virtio_device_id: &str,
|
||||
pci_segment_id: u16,
|
||||
dma_handler: Option<Arc<dyn ExternalDmaMapping>>,
|
||||
pci_device_id: Option<u8>,
|
||||
) -> DeviceManagerResult<PciBdf> {
|
||||
let id = format!("{VIRTIO_PCI_DEVICE_NAME_PREFIX}-{virtio_device_id}");
|
||||
|
||||
@@ -4309,7 +4318,7 @@ impl DeviceManager {
|
||||
node.children = vec![virtio_device_id.to_string()];
|
||||
|
||||
let (pci_segment_id, pci_device_bdf, resources) =
|
||||
self.pci_resources(&id, pci_segment_id)?;
|
||||
self.pci_resources(&id, pci_segment_id, pci_device_id)?;
|
||||
|
||||
// Update the existing virtio node by setting the parent.
|
||||
if let Some(node) = self.device_tree.lock().unwrap().get_mut(virtio_device_id) {
|
||||
@@ -4446,7 +4455,7 @@ impl DeviceManager {
|
||||
info!("Creating pvpanic device {id}");
|
||||
|
||||
let (pci_segment_id, pci_device_bdf, resources) =
|
||||
self.pci_resources(&id, pci_segment_id)?;
|
||||
self.pci_resources(&id, pci_segment_id, None)?;
|
||||
|
||||
let snapshot = snapshot_from_id(self.snapshot.as_ref(), id.as_str());
|
||||
|
||||
@@ -4484,7 +4493,7 @@ impl DeviceManager {
|
||||
info!("Creating ivshmem device {id}");
|
||||
|
||||
let (pci_segment_id, pci_device_bdf, resources) =
|
||||
self.pci_resources(&id, pci_segment_id)?;
|
||||
self.pci_resources(&id, pci_segment_id, None)?;
|
||||
let snapshot = snapshot_from_id(self.snapshot.as_ref(), id.as_str());
|
||||
|
||||
let ivshmem_ops = Arc::new(Mutex::new(IvshmemHandler {
|
||||
@@ -4529,6 +4538,7 @@ impl DeviceManager {
|
||||
&self,
|
||||
id: &str,
|
||||
pci_segment_id: u16,
|
||||
pci_device_id: Option<u8>,
|
||||
) -> DeviceManagerResult<(u16, PciBdf, Option<Vec<Resource>>)> {
|
||||
// Look for the id in the device tree. If it can be found, that means
|
||||
// the device is being restored, otherwise it's created from scratch.
|
||||
@@ -4556,7 +4566,7 @@ impl DeviceManager {
|
||||
(pci_segment_id, pci_device_bdf, resources)
|
||||
} else {
|
||||
let pci_device_bdf =
|
||||
self.pci_segments[pci_segment_id as usize].allocate_device_id(None)?;
|
||||
self.pci_segments[pci_segment_id as usize].allocate_device_id(pci_device_id)?;
|
||||
|
||||
(pci_segment_id, pci_device_bdf, None)
|
||||
})
|
||||
@@ -5075,6 +5085,7 @@ impl DeviceManager {
|
||||
&id,
|
||||
handle.pci_common.pci_segment,
|
||||
handle.dma_handler,
|
||||
handle.pci_common.pci_device_id,
|
||||
)?;
|
||||
|
||||
// Update the PCIU bitmap
|
||||
|
||||
Reference in New Issue
Block a user