From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark McLoughlin Subject: [PATCH] Work around supported cpuid ioctl() brokenness Date: Tue, 12 May 2009 12:42:42 +0100 Message-ID: <1242128562-19414-1-git-send-email-markmc@redhat.com> Cc: kvm@vger.kernel.org, Mark McLoughlin To: Avi Kivity Return-path: Received: from mail04.svc.cra.dublin.eircom.net ([159.134.118.20]:48702 "HELO mail04.svc.cra.dublin.eircom.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751270AbZELLtY (ORCPT ); Tue, 12 May 2009 07:49:24 -0400 Sender: kvm-owner@vger.kernel.org List-ID: 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 --- kvm/libkvm/libkvm-x86.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/kvm/libkvm/libkvm-x86.c b/kvm/libkvm/libkvm-x86.c index a2f6320..4f9539a 100644 --- a/kvm/libkvm/libkvm-x86.c +++ b/kvm/libkvm/libkvm-x86.c @@ -575,6 +575,8 @@ static struct kvm_cpuid2 *try_get_cpuid(kvm_context_t kvm, int max) r = ioctl(kvm->fd, KVM_GET_SUPPORTED_CPUID, cpuid); if (r == -1) r = -errno; + else if (r == 0 && cpuid->nent >= max) + r = -E2BIG; if (r < 0) { if (r == -E2BIG) { free(cpuid); -- 1.6.0.6