62fb375
From: Mark McLoughlin <markmc@redhat.com>
62fb375
Subject: [PATCH] Work around supported cpuid ioctl() brokenness
62fb375
62fb375
KVM_GET_SUPPORTED_CPUID has been known to fail to return -E2BIG
62fb375
when it runs out of entries. Detect this by always trying again
62fb375
with a bigger table if the ioctl() fills the table.
62fb375
62fb375
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
62fb375
Signed-off-by: Avi Kivity <avi@redhat.com>
62fb375
---
62fb375
 kvm/libkvm/libkvm-x86.c |    2 ++
62fb375
 1 files changed, 2 insertions(+), 0 deletions(-)
62fb375
62fb375
diff --git a/kvm/libkvm/libkvm-x86.c b/kvm/libkvm/libkvm-x86.c
62fb375
index a2f6320..4f9539a 100644
62fb375
--- a/kvm/libkvm/libkvm-x86.c
62fb375
+++ b/kvm/libkvm/libkvm-x86.c
62fb375
@@ -575,6 +575,8 @@ static struct kvm_cpuid2 *try_get_cpuid(kvm_context_t kvm, int max)
62fb375
 	r = ioctl(kvm->fd, KVM_GET_SUPPORTED_CPUID, cpuid);
62fb375
 	if (r == -1)
62fb375
 		r = -errno;
62fb375
+	else if (r == 0 && cpuid->nent >= max)
62fb375
+		r = -E2BIG;
62fb375
 	if (r < 0) {
62fb375
 		if (r == -E2BIG) {
62fb375
 			free(cpuid);
62fb375
-- 
62fb375
1.6.0.6
62fb375