diff options
author | Sheng Yang <sheng@linux.intel.com> | 2009-05-21 17:08:45 -0700 |
---|---|---|
committer | Eduardo Habkost <ehabkost@redhat.com> | 2009-05-28 19:37:44 -0300 |
commit | 6edf7f15532fb2d5dcfb0aeb14b60e4f48ee0960 (patch) | |
tree | 7aebd4de0e3e08b9d799e326b29a8333d2a558e6 /libkvm | |
parent | fc23bb7b4b73e22400bfacdd4a98221f00e679d7 (diff) |
kvm: libkvm: allocate unused gsi for irq routing
Notice here is a simple solution, can be replaced later.
Signed-off-by: Sheng Yang <sheng@linux.intel.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
(cherry picked from commit d50932ff61cf84bf9dc3688fd34e4d8e7384f184)
Signed-off-by: Chris Wright <chrisw@redhat.com>
Bugzilla: 498085
Message-Id: <1242950943-30180-8-git-send-email-chrisw@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
RH-Upstream-status: applied
Acked-by: Marcelo Tosatti <mtosatti@redhat.com>
Acked-by: Juan Quintela <quintela@redhat.com>
Acked-by: Don Dutile <ddutile@redhat.com>
Diffstat (limited to 'libkvm')
-rw-r--r-- | libkvm/kvm-common.h | 1 | ||||
-rw-r--r-- | libkvm/libkvm.c | 17 | ||||
-rw-r--r-- | libkvm/libkvm.h | 8 |
3 files changed, 25 insertions, 1 deletions
diff --git a/libkvm/kvm-common.h b/libkvm/kvm-common.h index 976e6bd9..b3441060 100644 --- a/libkvm/kvm-common.h +++ b/libkvm/kvm-common.h @@ -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 }; diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c index c2ce0466..83dfa801 100644 --- a/libkvm/libkvm.c +++ b/libkvm/libkvm.c @@ -421,7 +421,7 @@ int kvm_check_extension(kvm_context_t kvm, int ext) ret = ioctl(kvm->fd, KVM_CHECK_EXTENSION, ext); if (ret > 0) - return 1; + return ret; return 0; } @@ -1292,6 +1292,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; @@ -1395,3 +1398,15 @@ int kvm_commit_irq_routes(kvm_context_t kvm) return -ENOSYS; #endif } + +int kvm_get_irq_route_gsi(kvm_context_t kvm) +{ + if (kvm->max_used_gsi >= KVM_IOAPIC_NUM_PINS) { + if (kvm->max_used_gsi <= kvm_get_gsi_count(kvm)) + return kvm->max_used_gsi + 1; + else + return -ENOSPC; + } else + return KVM_IOAPIC_NUM_PINS; +} + diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h index c20ae47c..49163eb6 100644 --- a/libkvm/libkvm.h +++ b/libkvm/libkvm.h @@ -830,4 +830,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 |