@@ -66,6 +66,7 @@ struct kvm_context {
#ifdef KVM_CAP_IRQ_ROUTING
struct kvm_irq_routing *irq_routes;
int nr_allocated_irq_routes;
+ int max_used_gsi;
#endif
};
@@ -1256,6 +1256,9 @@ int kvm_add_routing_entry(kvm_context_t kvm,
new->type = entry->type;
new->flags = entry->flags;
new->u = entry->u;
+
+ if (entry->gsi > kvm->max_used_gsi)
+ kvm->max_used_gsi = entry->gsi;
return 0;
#else
return -ENOSYS;
@@ -1359,3 +1362,10 @@ int kvm_commit_irq_routes(kvm_context_t kvm)
return -ENOSYS;
#endif
}
+
+int kvm_get_irq_route_gsi(kvm_context_t kvm)
+{
+ return (kvm->max_used_gsi >= KVM_IOAPIC_NUM_PINS) ?
+ (kvm->max_used_gsi + 1) : KVM_IOAPIC_NUM_PINS;
+}
+
@@ -833,4 +833,12 @@ int kvm_del_routing_entry(kvm_context_t kvm,
*/
int kvm_commit_irq_routes(kvm_context_t kvm);
+/*!
+ * \brief Get unused GSI number for irq routing table
+ *
+ * Get unused GSI number for irq routing table
+ *
+ * \param kvm Pointer to the current kvm_context
+ */
+int kvm_get_irq_route_gsi(kvm_context_t kvm);
#endif
Notice here is a simple solution, can be replaced later. Signed-off-by: Sheng Yang <sheng@linux.intel.com> --- libkvm/kvm-common.h | 1 + libkvm/libkvm.c | 10 ++++++++++ libkvm/libkvm.h | 8 ++++++++ 3 files changed, 19 insertions(+), 0 deletions(-)