From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 1/2] KVM: Don't fail KVM_GET_SUPPORTED_CPUID if nent is just right Date: Thu, 24 Nov 2011 12:45:09 +0200 Message-ID: <4ECE2035.1070905@redhat.com> References: <1321525125-28966-1-git-send-email-levinsasha928@gmail.com> <20111124100931.GA16626@amt.cnet> <1322130680.4248.12.camel@lappy> <4ECE1D81.1000702@redhat.com> <1322131078.4248.15.camel@lappy> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , kvm@vger.kernel.org To: Sasha Levin Return-path: Received: from mx1.redhat.com ([209.132.183.28]:8575 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751659Ab1KXKpN (ORCPT ); Thu, 24 Nov 2011 05:45:13 -0500 In-Reply-To: <1322131078.4248.15.camel@lappy> Sender: kvm-owner@vger.kernel.org List-ID: On 11/24/2011 12:37 PM, Sasha Levin wrote: > On Thu, 2011-11-24 at 12:33 +0200, Avi Kivity wrote: > > On 11/24/2011 12:31 PM, Sasha Levin wrote: > > > > > > > > The protocol goes like "try size x, if it fails with -E2BIG, increase x, > > > > try again". Its awkward. > > > > > > We can set nent to be the amount of entries required like we do in the > > > opposite case where we passed too many entries. > > > > There's no point, since userspace will want to support older kernels. > > In the case of old kernels the cpuid->nent value will not be modified, > so userspace can handle both cases easily: > > - If KVM_GET_SUPPORTED_CPUID returned -E2BIG, check cpuid->nent > - If zero, do same -E2BIG loop as we do now. > - If not, allocate amount needed and pass it to the ioctl again. > What's the point? The code becomes more complicated. Something like 'while (try_get_cpuid(x) == -E2BIG) { x *= 2; }' is simple and works everywhere. -- error compiling committee.c: too many arguments to function