mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Allow for device ID allocation on a segment
Allocating a device ID is crucial for assigning a specific ID to a device. We need this to implement configurable PCI device 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
afd155d578
commit
34f08002e1
+10
-3
@@ -164,15 +164,22 @@ impl PciSegment {
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn next_device_bdf(&self) -> DeviceManagerResult<PciBdf> {
|
||||
/// Allocates a device's ID on this PCI segment.
|
||||
///
|
||||
/// - `device_id`: Device ID to request for allocation
|
||||
///
|
||||
/// ## Errors
|
||||
/// * [`DeviceManagerError::AllocatePciDeviceId`] if device ID
|
||||
/// allocation on the bus fails.
|
||||
pub(crate) fn allocate_device_id(&self, device_id: Option<u8>) -> DeviceManagerResult<PciBdf> {
|
||||
Ok(PciBdf::new(
|
||||
self.id,
|
||||
0,
|
||||
self.pci_bus
|
||||
.lock()
|
||||
.unwrap()
|
||||
.next_device_id()
|
||||
.map_err(DeviceManagerError::NextPciDeviceId)? as u8,
|
||||
.allocate_device_id(device_id)
|
||||
.map_err(DeviceManagerError::AllocatePciDeviceId)?,
|
||||
0,
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user