Skip to content

Commit b05f41e

Browse files
committed
Manage generic MSI interrupts based on VFIO devices
Support generic MSI interrupts based on VFIO devices, this will be needed when enabling VFIO device passthrough. Signed-off-by: Liu Jiang <[email protected]>
1 parent 8824ead commit b05f41e

File tree

5 files changed

+424
-1
lines changed

5 files changed

+424
-1
lines changed

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ edition = "2018"
1010
libc = ">=0.2.39"
1111
kvm-bindings = { version = "~0", optional = true }
1212
kvm-ioctls = { version = "~0", optional = true }
13+
vfio-ioctls = { git = "https://github.com/cloud-hypervisor/vfio-ioctls.git", branch = "dragonball", optional = true }
1314
vmm-sys-util = "~0"
1415

1516
[features]
1617
legacy-irq = []
1718
msi-irq = []
19+
vfio-msi-irq = []
1820
kvm-irq = ["kvm-ioctls", "kvm-bindings"]
1921
kvm-msi-generic = ["msi-irq", "kvm-irq"]
2022
kvm-legacy-irq = ["legacy-irq", "kvm-irq"]
2123
kvm-msi-irq = ["kvm-msi-generic"]
24+
kvm-vfio-msi-irq = ["kvm-msi-generic", "vfio-ioctls", "vfio-msi-irq"]

src/interrupt/kvm/mod.rs

+17
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ mod msi_irq;
2727
#[cfg(feature = "kvm-msi-irq")]
2828
use self::msi_irq::MsiIrq;
2929

30+
#[cfg(feature = "kvm-vfio-msi-irq")]
31+
mod vfio_msi_irq;
32+
#[cfg(feature = "kvm-vfio-msi-irq")]
33+
use self::vfio_msi_irq::VfioMsiIrq;
34+
3035
/// Maximum number of global interrupt sources.
3136
pub const MAX_IRQS: InterruptIndex = 1024;
3237

@@ -130,6 +135,18 @@ impl KvmIrqManagerObj {
130135
self.vmfd.clone(),
131136
self.routes.clone(),
132137
)?)),
138+
#[cfg(feature = "kvm-vfio-msi-irq")]
139+
InterruptSourceType::VfioMsiIrq(vfio_device, vfio_index) => {
140+
Arc::new(Box::new(VfioMsiIrq::new(
141+
base,
142+
count,
143+
self.max_msi_irqs,
144+
self.vmfd.clone(),
145+
self.routes.clone(),
146+
vfio_device,
147+
vfio_index,
148+
)?))
149+
}
133150
_ => return Err(Error::from(ErrorKind::InvalidInput)),
134151
};
135152

0 commit comments

Comments
 (0)