Blame qemu-fix-cpuid-trimming.patch

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