From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M6qed-0003hT-AP for qemu-devel@nongnu.org; Wed, 20 May 2009 14:36:39 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M6qeY-0003gJ-Ln for qemu-devel@nongnu.org; Wed, 20 May 2009 14:36:39 -0400 Received: from [199.232.76.173] (port=40828 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M6qeY-0003gG-HF for qemu-devel@nongnu.org; Wed, 20 May 2009 14:36:34 -0400 Received: from mx2.redhat.com ([66.187.237.31]:44652) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M6qeX-0006ST-S2 for qemu-devel@nongnu.org; Wed, 20 May 2009 14:36:34 -0400 From: Glauber Costa Date: Wed, 20 May 2009 15:36:18 -0300 Message-Id: <1242844578-2647-8-git-send-email-glommer@redhat.com> In-Reply-To: <1242844578-2647-7-git-send-email-glommer@redhat.com> References: <1242844578-2647-1-git-send-email-glommer@redhat.com> <1242844578-2647-2-git-send-email-glommer@redhat.com> <1242844578-2647-3-git-send-email-glommer@redhat.com> <1242844578-2647-4-git-send-email-glommer@redhat.com> <1242844578-2647-5-git-send-email-glommer@redhat.com> <1242844578-2647-6-git-send-email-glommer@redhat.com> <1242844578-2647-7-git-send-email-glommer@redhat.com> Subject: [Qemu-devel] [PATCH STABLE 7/7] kvm: work around supported cpuid ioctl() brokenness List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Mark McLoughlin , aliguori@us.ibm.com From: Mark McLoughlin 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 Signed-off-by: Glauber Costa --- target-i386/kvm.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 5b52de3..eb61598 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); -- 1.6.2.2