We need to query the entry later. Signed-off-by: Sheng Yang <sheng@xxxxxxxxxxxxxxx> --- include/linux/kvm_host.h | 2 ++ virt/kvm/irq_comm.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 0 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 7f9e4b7..30f83cd 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -614,6 +614,8 @@ int kvm_set_irq_routing(struct kvm *kvm, const struct kvm_irq_routing_entry *entries, unsigned nr, unsigned flags); +struct kvm_kernel_irq_routing_entry *kvm_get_irq_routing_entry(struct kvm *kvm, + int gsi); void kvm_free_irq_routing(struct kvm *kvm); #else diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c index 8edca91..80ced8c 100644 --- a/virt/kvm/irq_comm.c +++ b/virt/kvm/irq_comm.c @@ -421,6 +421,26 @@ out: return r; } +struct kvm_kernel_irq_routing_entry *kvm_get_irq_routing_entry(struct kvm *kvm, + int gsi) +{ + int count = 0; + struct kvm_kernel_irq_routing_entry *ei = NULL; + struct kvm_irq_routing_table *irq_rt; + struct hlist_node *n; + + rcu_read_lock(); + irq_rt = rcu_dereference(kvm->irq_routing); + if (gsi < irq_rt->nr_rt_entries) + hlist_for_each_entry(ei, n, &irq_rt->map[gsi], link) + count++; + rcu_read_unlock(); + if (count == 1) + return ei; + + return NULL; +} + #define IOAPIC_ROUTING_ENTRY(irq) \ { .gsi = irq, .type = KVM_IRQ_ROUTING_IRQCHIP, \ .u.irqchip.irqchip = KVM_IRQCHIP_IOAPIC, .u.irqchip.pin = (irq) } -- 1.7.0.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html