From patchwork Wed Jul 15 16:31:42 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 35728 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n6FGW0gI008046 for ; Wed, 15 Jul 2009 16:32:00 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932164AbZGOQb4 (ORCPT ); Wed, 15 Jul 2009 12:31:56 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932129AbZGOQbz (ORCPT ); Wed, 15 Jul 2009 12:31:55 -0400 Received: from mx2.redhat.com ([66.187.237.31]:56664 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932151AbZGOQbq (ORCPT ); Wed, 15 Jul 2009 12:31:46 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n6FGVk1Q005444 for ; Wed, 15 Jul 2009 12:31:46 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n6FGVjAs023965; Wed, 15 Jul 2009 12:31:45 -0400 Received: from localhost.localdomain (virtlab1.virt.bos.redhat.com [10.16.72.21]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n6FGVhrL015940; Wed, 15 Jul 2009 12:31:45 -0400 From: Glauber Costa To: kvm@vger.kernel.org Cc: avi@redhat.com Subject: [PATCH 4/5] check extension Date: Wed, 15 Jul 2009 12:31:42 -0400 Message-Id: <1247675503-7106-5-git-send-email-glommer@redhat.com> In-Reply-To: <1247675503-7106-4-git-send-email-glommer@redhat.com> References: <1247675503-7106-1-git-send-email-glommer@redhat.com> <1247675503-7106-2-git-send-email-glommer@redhat.com> <1247675503-7106-3-git-send-email-glommer@redhat.com> <1247675503-7106-4-git-send-email-glommer@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org use upstream check_extension code Signed-off-by: Glauber Costa --- hw/device-assignment.c | 2 +- kvm-all.c | 2 ++ qemu-kvm-x86.c | 6 +++--- qemu-kvm.c | 18 ++++-------------- qemu-kvm.h | 2 +- 5 files changed, 11 insertions(+), 19 deletions(-) diff --git a/hw/device-assignment.c b/hw/device-assignment.c index 88c3baf..75db546 100644 --- a/hw/device-assignment.c +++ b/hw/device-assignment.c @@ -639,7 +639,7 @@ static int assign_device(AssignedDevInfo *adev) /* We always enable the IOMMU if present * (or when not disabled on the command line) */ - r = kvm_check_extension(kvm_context, KVM_CAP_IOMMU); + r = kvm_check_extension(kvm_state, KVM_CAP_IOMMU); if (r && !adev->disable_iommu) assigned_dev_data.flags |= KVM_DEV_ASSIGN_ENABLE_IOMMU; #endif diff --git a/kvm-all.c b/kvm-all.c index 0ec6475..b4b5a35 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -383,6 +383,7 @@ int kvm_uncoalesce_mmio_region(target_phys_addr_t start, ram_addr_t size) return ret; } +#endif int kvm_check_extension(KVMState *s, unsigned int extension) { int ret; @@ -394,6 +395,7 @@ int kvm_check_extension(KVMState *s, unsigned int extension) return ret; } +#ifdef KVM_UPSTREAM int kvm_init(int smp_cpus) { diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c index fb3ac9a..128a792 100644 --- a/qemu-kvm-x86.c +++ b/qemu-kvm-x86.c @@ -328,7 +328,7 @@ int kvm_has_pit_state2(kvm_context_t kvm) int r = 0; #ifdef KVM_CAP_PIT_STATE2 - r = kvm_check_extension(kvm, KVM_CAP_PIT_STATE2); + r = kvm_check_extension(kvm_state, KVM_CAP_PIT_STATE2); #endif return r; } @@ -652,7 +652,7 @@ uint32_t kvm_get_supported_cpuid(kvm_context_t kvm, uint32_t function, int reg) uint32_t ret = 0; uint32_t cpuid_1_edx; - if (!kvm_check_extension(kvm, KVM_CAP_EXT_CPUID)) { + if (!kvm_check_extension(kvm_state, KVM_CAP_EXT_CPUID)) { return -1U; } @@ -1184,7 +1184,7 @@ static int get_para_features(kvm_context_t kvm_context) int i, features = 0; for (i = 0; i < ARRAY_SIZE(para_features)-1; i++) { - if (kvm_check_extension(kvm_context, para_features[i].cap)) + if (kvm_check_extension(kvm_state, para_features[i].cap)) features |= (1 << para_features[i].feature); } diff --git a/qemu-kvm.c b/qemu-kvm.c index 2654f91..d5f8464 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -590,16 +590,6 @@ static int kvm_create_default_phys_mem(kvm_context_t kvm, return -1; } -int kvm_check_extension(kvm_context_t kvm, int ext) -{ - int ret; - - ret = kvm_ioctl(kvm_state, KVM_CHECK_EXTENSION, ext); - if (ret > 0) - return ret; - return 0; -} - void kvm_create_irqchip(kvm_context_t kvm) { int r; @@ -1378,7 +1368,7 @@ int kvm_has_gsi_routing(kvm_context_t kvm) int r = 0; #ifdef KVM_CAP_IRQ_ROUTING - r = kvm_check_extension(kvm, KVM_CAP_IRQ_ROUTING); + r = kvm_check_extension(kvm_state, KVM_CAP_IRQ_ROUTING); #endif return r; } @@ -1386,7 +1376,7 @@ int kvm_has_gsi_routing(kvm_context_t kvm) int kvm_get_gsi_count(kvm_context_t kvm) { #ifdef KVM_CAP_IRQ_ROUTING - return kvm_check_extension(kvm, KVM_CAP_IRQ_ROUTING); + return kvm_check_extension(kvm_state, KVM_CAP_IRQ_ROUTING); #else return -EINVAL; #endif @@ -1660,7 +1650,7 @@ int kvm_irqfd(kvm_context_t kvm, int gsi, int flags) int r; int fd; - if (!kvm_check_extension(kvm, KVM_CAP_IRQFD)) + if (!kvm_check_extension(kvm_state, KVM_CAP_IRQFD)) return -ENOENT; fd = eventfd(0, 0); @@ -2431,7 +2421,7 @@ int kvm_setup_guest_memory(void *area, unsigned long size) int kvm_qemu_check_extension(int ext) { - return kvm_check_extension(kvm_context, ext); + return kvm_check_extension(kvm_state, ext); } int kvm_qemu_init_env(CPUState *cenv) diff --git a/qemu-kvm.h b/qemu-kvm.h index a6261fd..afb6fef 100644 --- a/qemu-kvm.h +++ b/qemu-kvm.h @@ -163,7 +163,6 @@ int kvm_create(kvm_context_t kvm, unsigned long phys_mem_bytes, void **phys_mem); int kvm_create_vm(kvm_context_t kvm); -int kvm_check_extension(kvm_context_t kvm, int ext); void kvm_create_irqchip(kvm_context_t kvm); /*! @@ -1179,5 +1178,6 @@ extern KVMState *kvm_state; int kvm_ioctl(KVMState *s, int type, ...); int kvm_vm_ioctl(KVMState *s, int type, ...); +int kvm_check_extension(KVMState *s, unsigned int ext); #endif