diff mbox

[RFC,1/2] kvm: Allow querying free slots

Message ID 20110121234809.22262.3194.stgit@s20.home (mailing list archive)
State New, archived
Headers show

Commit Message

Alex Williamson Jan. 21, 2011, 11:48 p.m. UTC
None
diff mbox

Patch

diff --git a/kvm-all.c b/kvm-all.c
index 2f203dd..4fe3631 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -96,6 +96,22 @@  static KVMSlot *kvm_alloc_slot(KVMState *s)
     abort();
 }
 
+int kvm_free_slots(void)
+{
+    KVMState *s = kvm_state;
+    int i, j;
+
+    for (i = 0, j = 0; i < ARRAY_SIZE(s->slots); i++) {
+        /* KVM private memory slots and used slots */
+        if ((i >= 8 && i < 12) || s->slots[i].memory_size) {
+            continue;
+        }
+        j++;
+    }
+
+    return j;
+}
+
 static KVMSlot *kvm_lookup_matching_slot(KVMState *s,
                                          target_phys_addr_t start_addr,
                                          target_phys_addr_t end_addr)
diff --git a/kvm.h b/kvm.h
index 02280a6..93da155 100644
--- a/kvm.h
+++ b/kvm.h
@@ -221,4 +221,6 @@  int kvm_irqchip_in_kernel(void);
 
 int kvm_set_irq(int irq, int level, int *status);
 
+int kvm_free_slots(void);
+
 #endif