From patchwork Wed Oct 31 09:39:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 195801 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 82FE72C00A5 for ; Wed, 31 Oct 2012 20:43:26 +1100 (EST) Received: from localhost ([::1]:43701 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTUpW-0004NU-PK for incoming@patchwork.ozlabs.org; Wed, 31 Oct 2012 05:43:22 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49880) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTUmq-0007t9-9D for qemu-devel@nongnu.org; Wed, 31 Oct 2012 05:40:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TTUmj-00036Y-Cu for qemu-devel@nongnu.org; Wed, 31 Oct 2012 05:40:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8557) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTUmj-000351-3V for qemu-devel@nongnu.org; Wed, 31 Oct 2012 05:40:29 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9V9eSki023336 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 31 Oct 2012 05:40:28 -0400 Received: from amt.cnet (vpn1-4-142.gru2.redhat.com [10.97.4.142]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9V9eQQZ019815; Wed, 31 Oct 2012 05:40:27 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id E88EB65228E; Wed, 31 Oct 2012 07:40:10 -0200 (BRST) Received: (from marcelo@localhost) by amt.cnet (8.14.5/8.14.5/Submit) id q9V9eAEL025071; Wed, 31 Oct 2012 07:40:10 -0200 From: Marcelo Tosatti To: Anthony Liguori Date: Wed, 31 Oct 2012 07:39:40 -0200 Message-Id: <8c723b7958127b8f204dd4b278ad3c8f6f48ae17.1351676405.git.mtosatti@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Marcelo Tosatti , qemu-devel@nongnu.org, kvm@vger.kernel.org, Eduardo Habkost Subject: [Qemu-devel] [PATCH 02/28] i386: kvm: kvm_arch_get_supported_cpuid: clean up has_kvm_features check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Eduardo Habkost Instead of a function-specific has_kvm_features variable, simply use a "found" variable that will be checked in case we have to use the legacy get_para_features() interface. No behavior change, just code cleanup. Signed-off-by: Eduardo Habkost Signed-off-by: Marcelo Tosatti --- target-i386/kvm.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-) diff --git a/target-i386/kvm.c b/target-i386/kvm.c index b7490f9..56addf1 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -130,7 +130,7 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function, int i, max; uint32_t ret = 0; uint32_t cpuid_1_edx; - int has_kvm_features = 0; + bool found = false; max = 1; while ((cpuid = try_get_cpuid(s, max)) == NULL) { @@ -140,9 +140,7 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function, for (i = 0; i < cpuid->nent; ++i) { if (cpuid->entries[i].function == function && cpuid->entries[i].index == index) { - if (cpuid->entries[i].function == KVM_CPUID_FEATURES) { - has_kvm_features = 1; - } + found = true; switch (reg) { case R_EAX: ret = cpuid->entries[i].eax; @@ -181,7 +179,7 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function, g_free(cpuid); /* fallback for older kernels */ - if (!has_kvm_features && (function == KVM_CPUID_FEATURES)) { + if ((function == KVM_CPUID_FEATURES) && !found) { ret = get_para_features(s); }