mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vm-allocator: free GSIs in GsiAllocator
The old implementation used an ever monotonically increasing u32 counter to allocate new GSIs. The counter increased every time a new GSI was allocated, and freeing GSIs was not possible. Thus, Cloud Hypervisor can run out of GSIs and panics. This currently happened at the 1024th GSI [0]. Further, this caused the `KVM_SET_GSI_ROUTING` ioctl to carry much more payload than needed. This new implementation uses a bitmap for proper tracking of resources and can gracefully free GSIs - this is abstracted in type InterruptAllocator. Please note that this commit only replaces the old mechanism. The next commit will introduce freeing used GSIs automatically when an InterruptRoute is dropped. While being on this, we also propagate the errors that the allocator may throw where necessary. Co-authored-by: Sebastian Eydam <sebastian.eydam@cyberus-technology.de> On-behalf-of: SAP sebastian.eydam@sap.com Signed-off-by: Sebastian Eydam <sebastian.eydam@cyberus-technology.de> On-behalf-of: Philipp Schuster@sap.com Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
This commit is contained in:
committed by
Rob Bradford
parent
7c4fa04ea3
commit
1ba2b34019
@@ -91,7 +91,7 @@ use virtio_devices::{
|
||||
AccessPlatformMapping, ActivateError, Block, Endpoint, IommuMapping, VdpaDmaMapping,
|
||||
VirtioMemMappingSource,
|
||||
};
|
||||
use vm_allocator::{AddressAllocator, SystemAllocator};
|
||||
use vm_allocator::{AddressAllocator, InterruptAllocError, SystemAllocator};
|
||||
use vm_device::dma_mapping::ExternalDmaMapping;
|
||||
use vm_device::interrupt::{
|
||||
InterruptIndex, InterruptManager, LegacyIrqGroupConfig, MsiIrqGroupConfig,
|
||||
@@ -272,7 +272,7 @@ pub enum DeviceManagerError {
|
||||
|
||||
/// Cannot allocate IRQ.
|
||||
#[error("Cannot allocate IRQ")]
|
||||
AllocateIrq,
|
||||
AllocateIrq(#[from] InterruptAllocError),
|
||||
|
||||
/// Cannot configure the IRQ.
|
||||
#[error("Cannot configure the IRQ")]
|
||||
|
||||
@@ -46,7 +46,7 @@ impl InterruptRoute {
|
||||
None => {
|
||||
let new_gsi = allocator
|
||||
.allocate_gsi()
|
||||
.ok_or_else(|| io::Error::other("Failed allocating new GSI"))?;
|
||||
.map_err(|e| io::Error::other(format!("Failed allocating new GSI: {e}")))?;
|
||||
self.gsi = Some(new_gsi);
|
||||
Ok(new_gsi)
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ impl PciSegment {
|
||||
.lock()
|
||||
.unwrap()
|
||||
.allocate_irq()
|
||||
.ok_or(DeviceManagerError::AllocateIrq)? as u8,
|
||||
.map_err(DeviceManagerError::AllocateIrq)? as u8,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user