From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: Re: [PATCH 1/2] KVM: Don't fail KVM_GET_SUPPORTED_CPUID if nent is just right Date: Thu, 24 Nov 2011 12:37:58 +0200 Message-ID: <1322131078.4248.15.camel@lappy> References: <1321525125-28966-1-git-send-email-levinsasha928@gmail.com> <20111124100931.GA16626@amt.cnet> <1322130680.4248.12.camel@lappy> <4ECE1D81.1000702@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from mail-vw0-f46.google.com ([209.85.212.46]:33220 "EHLO mail-vw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752076Ab1KXKiD (ORCPT ); Thu, 24 Nov 2011 05:38:03 -0500 Received: by vbbfc26 with SMTP id fc26so1353694vbb.19 for ; Thu, 24 Nov 2011 02:38:02 -0800 (PST) In-Reply-To: <4ECE1D81.1000702@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 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. -- Sasha.