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>
master
Mark McLoughlin 2009-05-19 18:55:21 +01:00 committed by Anthony Liguori
parent e561a2809f
commit 76ae317f7c
1 changed files with 3 additions and 0 deletions

View File

@ -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);