]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
kvm: work around supported cpuid ioctl() brokenness
authorMark McLoughlin <markmc@redhat.com>
Wed, 20 May 2009 18:36:18 +0000 (15:36 -0300)
committerAnthony Liguori <aliguori@us.ibm.com>
Wed, 20 May 2009 20:21:28 +0000 (15:21 -0500)
KVM_GET_SUPPORTED_CPUID has been known to fail to return -E2BIG
when it runs out of entries. Detect this by always trying again
with a bigger table if the ioctl() fills the table.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
target-i386/kvm.c

index 5b52de34dd677d427173d1f549b182a5bd9ff00e..eb615989ea02482ab742b3ab4ef96bd56ff3d0f5 100644 (file)
@@ -44,6 +44,9 @@ static struct kvm_cpuid2 *try_get_cpuid(KVMState *s, int max)
     cpuid = (struct kvm_cpuid2 *)qemu_mallocz(size);
     cpuid->nent = max;
     r = kvm_ioctl(s, KVM_GET_SUPPORTED_CPUID, cpuid);
+    if (r == 0 && cpuid->nent >= max) {
+        r = -E2BIG;
+    }
     if (r < 0) {
         if (r == -E2BIG) {
             qemu_free(cpuid);