mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-07-07 10:15:45 +00:00
vmm: interrupt: generify KvmRoutingEntry and KvmMsiInterruptGroup
The observation is that only the route field is hypervisor specific. Provide a new function in blanket implementation. Also redefine KvmRoutingEntry with RoutingEntry to avoid code churn. Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
parent
637f58bcd9
commit
d5149e95cb
@ -103,30 +103,36 @@ impl InterruptRoute {
|
||||
}
|
||||
}
|
||||
|
||||
struct KvmRoutingEntry {
|
||||
kvm_route: kvm_irq_routing_entry,
|
||||
struct RoutingEntry<E> {
|
||||
route: E,
|
||||
masked: bool,
|
||||
}
|
||||
|
||||
struct KvmMsiInterruptGroup {
|
||||
type KvmRoutingEntry = RoutingEntry<kvm_irq_routing_entry>;
|
||||
|
||||
struct MsiInterruptGroup<E> {
|
||||
vm_fd: Arc<dyn hypervisor::Vm>,
|
||||
gsi_msi_routes: Arc<Mutex<HashMap<u32, KvmRoutingEntry>>>,
|
||||
gsi_msi_routes: Arc<Mutex<HashMap<u32, RoutingEntry<E>>>>,
|
||||
irq_routes: HashMap<InterruptIndex, InterruptRoute>,
|
||||
}
|
||||
|
||||
impl KvmMsiInterruptGroup {
|
||||
impl<E> MsiInterruptGroup<E> {
|
||||
fn new(
|
||||
vm_fd: Arc<dyn hypervisor::Vm>,
|
||||
gsi_msi_routes: Arc<Mutex<HashMap<u32, KvmRoutingEntry>>>,
|
||||
gsi_msi_routes: Arc<Mutex<HashMap<u32, RoutingEntry<E>>>>,
|
||||
irq_routes: HashMap<InterruptIndex, InterruptRoute>,
|
||||
) -> Self {
|
||||
KvmMsiInterruptGroup {
|
||||
MsiInterruptGroup {
|
||||
vm_fd,
|
||||
gsi_msi_routes,
|
||||
irq_routes,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type KvmMsiInterruptGroup = MsiInterruptGroup<kvm_irq_routing_entry>;
|
||||
|
||||
impl KvmMsiInterruptGroup {
|
||||
fn set_kvm_gsi_routes(&self) -> Result<()> {
|
||||
let gsi_msi_routes = self.gsi_msi_routes.lock().unwrap();
|
||||
let mut entry_vec: Vec<kvm_irq_routing_entry> = Vec::new();
|
||||
@ -135,7 +141,7 @@ impl KvmMsiInterruptGroup {
|
||||
continue;
|
||||
}
|
||||
|
||||
entry_vec.push(entry.kvm_route);
|
||||
entry_vec.push(entry.route);
|
||||
}
|
||||
|
||||
let mut irq_routing =
|
||||
@ -229,7 +235,7 @@ impl InterruptSourceGroup for KvmMsiInterruptGroup {
|
||||
kvm_route.u.msi.data = cfg.data;
|
||||
|
||||
let kvm_entry = KvmRoutingEntry {
|
||||
kvm_route,
|
||||
route: kvm_route,
|
||||
masked: false,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user