Am Dienstag, 29. Juli 2008 schrieb Avi Kivity:
> They all start with 0 AFAIK (kvm also starts with 0, it just wants it to 
> be a special slot).

Now my brain hurts....
Ok, so I read this as: ppc, ia64 and s390 can start with slot 0 and it is not a 
special slot.
On x86 slot 0 is special, if
* KVM_CAP_SET_TSS_ADDR is not available
or
* The ioctl VM_CAP_SET_TSS_ADDR returns <=0

Since my opteron box died recently I cannot test that on x86 at the moment.
What do you think about the following patch

Signed-off-by: Christian Borntraeger <[EMAIL PROTECTED]>

---
 libkvm/libkvm.c |   28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

Index: kvm-userspace/libkvm/libkvm.c
===================================================================
--- kvm-userspace.orig/libkvm/libkvm.c
+++ kvm-userspace/libkvm/libkvm.c
@@ -75,25 +75,21 @@ void init_slots(void)
 
 int get_free_slot(kvm_context_t kvm)
 {
-       int i;
-       int tss_ext;
-
-#if defined(KVM_CAP_SET_TSS_ADDR) && !defined(__s390__)
-       tss_ext = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_SET_TSS_ADDR);
-#else
-       tss_ext = 0;
-#endif
+       int i = 0;
 
        /*
-        * on older kernels where the set tss ioctl is not supprted we must save
-        * slot 0 to hold the extended memory, as the vmx will use the last 3
-        * pages of this slot.
+        * on older x86 kernels where the set tss ioctl is not supported we
+        * must save slot 0 to hold the extended memory, as the vmx will
+        * use the last 3 pages of this slot.
         */
-       if (tss_ext > 0)
-               i = 0;
-       else
-               i = 1;
-
+#if defined(__x86_64__) || defined(__i386__)
+#if defined(KVM_CAP_SET_TSS_ADDR)
+       if (ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_SET_TSS_ADDR) > 0)
+               i++;
+#else
+       i++;
+#endif
+#endif
        for (; i < KVM_MAX_NUM_MEM_REGIONS; ++i)
                if (!slots[i].len)
                        return i;
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to