aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2009-05-19 18:55:21 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2009-05-20 09:12:57 -0500
commit76ae317f7c16aec6b469604b1764094870a75470 (patch)
tree41a937d49a1fce0c4face186de07fecb24766fee
parente561a2809fc63b77b05075b10b713749edf93e25 (diff)
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>
-rw-r--r--target-i386/kvm.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index fe67eed0a2..7cdcf31cab 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -45,6 +45,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);