Commit 76ae317f7c16aec6b469604b1764094870a75470

Authored by Mark McLoughlin
Committed by Anthony Liguori
1 parent e561a280

kvm: work around supported cpuid ioctl() brokenness

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>
Showing 1 changed file with 3 additions and 0 deletions
target-i386/kvm.c
@@ -45,6 +45,9 @@ static struct kvm_cpuid2 *try_get_cpuid(KVMState *s, int max) @@ -45,6 +45,9 @@ static struct kvm_cpuid2 *try_get_cpuid(KVMState *s, int max)
45 cpuid = (struct kvm_cpuid2 *)qemu_mallocz(size); 45 cpuid = (struct kvm_cpuid2 *)qemu_mallocz(size);
46 cpuid->nent = max; 46 cpuid->nent = max;
47 r = kvm_ioctl(s, KVM_GET_SUPPORTED_CPUID, cpuid); 47 r = kvm_ioctl(s, KVM_GET_SUPPORTED_CPUID, cpuid);
  48 + if (r == 0 && cpuid->nent >= max) {
  49 + r = -E2BIG;
  50 + }
48 if (r < 0) { 51 if (r < 0) {
49 if (r == -E2BIG) { 52 if (r == -E2BIG) {
50 qemu_free(cpuid); 53 qemu_free(cpuid);