From mboxrd@z Thu Jan 1 00:00:00 1970 From: Juan Quintela Subject: Re: [PATCH] kvm: Add helpers for checking and requiring kvm extensions Date: Mon, 04 May 2009 08:49:05 +0200 Message-ID: References: <1241350448-2340-1-git-send-email-avi@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org To: Avi Kivity Return-path: In-Reply-To: <1241350448-2340-1-git-send-email-avi@redhat.com> (Avi Kivity's message of "Sun\, 3 May 2009 14\:34\:08 +0300") List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org Errors-To: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org List-Id: kvm.vger.kernel.org Avi Kivity wrote: Hi > diff --git a/kvm-all.c b/kvm-all.c > index 36659a9..1642a2a 100644 > --- a/kvm-all.c > +++ b/kvm-all.c > @@ -64,6 +64,30 @@ struct KVMState > > static KVMState *kvm_state; > > +int kvm_check_extension(int extension) > +{ > + int ret; > + > + ret = kvm_ioctl(kvm_state, KVM_CHECK_EXTENSION, extension); > + if (ret < 0) { > + fprintf(stderr, "KVM_CHECK_EXTENSION failed: %s\n", strerror(errno)); > + exit(1); > + } > + return ret; > +} > Are you sure you want the exit(1) in this case? With the exit() call, you are unable to check if one extension is present at all. And you check the return of the following code. > s->coalesced_mmio = 0; > #ifdef KVM_CAP_COALESCED_MMIO > - ret = kvm_ioctl(s, KVM_CHECK_EXTENSION, KVM_CAP_COALESCED_MMIO); > - if (ret > 0) > - s->coalesced_mmio = ret; > + s->coalesced_mmio = kvm_check_extension(KVM_CAP_COALESCED_MMIO); > #endif You can remove the ifdef at this point. Later, Juan. From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M0rzy-0006Lz-Ar for qemu-devel@nongnu.org; Mon, 04 May 2009 02:49:58 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M0rzw-0006L9-Bm for qemu-devel@nongnu.org; Mon, 04 May 2009 02:49:57 -0400 Received: from [199.232.76.173] (port=34067 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M0rzw-0006L5-2q for qemu-devel@nongnu.org; Mon, 04 May 2009 02:49:56 -0400 Received: from trasno.trasno.org ([91.117.31.254]:42038) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M0rzv-000336-4Q for qemu-devel@nongnu.org; Mon, 04 May 2009 02:49:55 -0400 Subject: Re: [Qemu-devel] [PATCH] kvm: Add helpers for checking and requiring kvm extensions From: Juan Quintela In-Reply-To: <1241350448-2340-1-git-send-email-avi@redhat.com> (Avi Kivity's message of "Sun\, 3 May 2009 14\:34\:08 +0300") References: <1241350448-2340-1-git-send-email-avi@redhat.com> Date: Mon, 04 May 2009 08:49:05 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org Avi Kivity wrote: Hi > diff --git a/kvm-all.c b/kvm-all.c > index 36659a9..1642a2a 100644 > --- a/kvm-all.c > +++ b/kvm-all.c > @@ -64,6 +64,30 @@ struct KVMState > > static KVMState *kvm_state; > > +int kvm_check_extension(int extension) > +{ > + int ret; > + > + ret = kvm_ioctl(kvm_state, KVM_CHECK_EXTENSION, extension); > + if (ret < 0) { > + fprintf(stderr, "KVM_CHECK_EXTENSION failed: %s\n", strerror(errno)); > + exit(1); > + } > + return ret; > +} > Are you sure you want the exit(1) in this case? With the exit() call, you are unable to check if one extension is present at all. And you check the return of the following code. > s->coalesced_mmio = 0; > #ifdef KVM_CAP_COALESCED_MMIO > - ret = kvm_ioctl(s, KVM_CHECK_EXTENSION, KVM_CAP_COALESCED_MMIO); > - if (ret > 0) > - s->coalesced_mmio = ret; > + s->coalesced_mmio = kvm_check_extension(KVM_CAP_COALESCED_MMIO); > #endif You can remove the ifdef at this point. Later, Juan.