aboutsummaryrefslogtreecommitdiff
path: root/target-i386
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2009-05-20 15:36:18 -0300
committerAnthony Liguori <aliguori@us.ibm.com>2009-05-20 15:21:28 -0500
commit0926c7a4e5abd3cfebec3a6e35617730577ce932 (patch)
treeed21db957f74aa0f0c9fbd8612ef495bdaf6c299 /target-i386
parenta02ba54eed0bcb588a4746a2702f1337cbfe54f8 (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> Signed-off-by: Glauber Costa <glommer@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'target-i386')
-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 5b52de34dd..eb615989ea 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -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);