From patchwork Mon Jun 8 19:10:21 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 28686 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 n58JAU9c019607 for ; Mon, 8 Jun 2009 19:10:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751377AbZFHTK1 (ORCPT ); Mon, 8 Jun 2009 15:10:27 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751809AbZFHTKZ (ORCPT ); Mon, 8 Jun 2009 15:10:25 -0400 Received: from mx2.redhat.com ([66.187.237.31]:49065 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751190AbZFHTKY (ORCPT ); Mon, 8 Jun 2009 15:10:24 -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 n58JARTE025646 for ; Mon, 8 Jun 2009 15:10:27 -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 n58JAP87025703; Mon, 8 Jun 2009 15:10:26 -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 n58JAPS3029961; Mon, 8 Jun 2009 15:10:25 -0400 From: Glauber Costa To: kvm@vger.kernel.org Cc: avi@redhat.com Subject: [PATCH 1/4] get rid of libkvm-common.h Date: Mon, 8 Jun 2009 15:10:21 -0400 Message-Id: <1244488224-31171-2-git-send-email-glommer@redhat.com> In-Reply-To: <1244488224-31171-1-git-send-email-glommer@redhat.com> References: <1244488224-31171-1-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 This file has no purpose in life in new scheme of things. Move its contents to libkvm-all.h. There are some name clashes in qemu-kvm.c. Those function names are then changed. Signed-off-by: Glauber Costa --- kvm.h | 1 + libkvm-all.h | 82 ++++++++++++++++++++++++++++++++++++++++- libkvm-common.h | 100 -------------------------------------------------- qemu-kvm-x86.c | 2 + qemu-kvm.c | 12 +++--- target-i386/libkvm.h | 2 +- target-ia64/libkvm.h | 2 +- target-ppc/libkvm.h | 2 +- 8 files changed, 92 insertions(+), 111 deletions(-) delete mode 100644 libkvm-common.h diff --git a/kvm.h b/kvm.h index 0c3e7b1..e1c6eba 100644 --- a/kvm.h +++ b/kvm.h @@ -16,6 +16,7 @@ #include "config.h" #include "sys-queue.h" +#include "libkvm-all.h" #ifdef KVM_UPSTREAM diff --git a/libkvm-all.h b/libkvm-all.h index 2b18c00..03b98df 100644 --- a/libkvm-all.h +++ b/libkvm-all.h @@ -19,12 +19,90 @@ #include -struct kvm_context; -struct kvm_vcpu_context; +/* FIXME: share this number with kvm */ +/* FIXME: or dynamically alloc/realloc regions */ +#ifdef __s390__ +#define KVM_MAX_NUM_MEM_REGIONS 1u +#define MAX_VCPUS 64 +#define LIBKVM_S390_ORIGIN (0UL) +#elif defined(__ia64__) +#define KVM_MAX_NUM_MEM_REGIONS 32u +#define MAX_VCPUS 256 +#else +#define KVM_MAX_NUM_MEM_REGIONS 32u +#define MAX_VCPUS 16 +#endif + +/* kvm abi verison variable */ +extern int kvm_abi; + +/** + * \brief The KVM context + * + * The verbose KVM context + */ + +struct kvm_context { + /// Filedescriptor to /dev/kvm + int fd; + int vm_fd; + /// Callbacks that KVM uses to emulate various unvirtualizable functionality + struct kvm_callbacks *callbacks; + void *opaque; + /// is dirty pages logging enabled for all regions or not + int dirty_pages_log_all; + /// do not create in-kernel irqchip if set + int no_irqchip_creation; + /// in-kernel irqchip status + int irqchip_in_kernel; + /// ioctl to use to inject interrupts + int irqchip_inject_ioctl; + /// do not create in-kernel pit if set + int no_pit_creation; + /// in-kernel pit status + int pit_in_kernel; + /// in-kernel coalesced mmio + int coalesced_mmio; +#ifdef KVM_CAP_IRQ_ROUTING + struct kvm_irq_routing *irq_routes; + int nr_allocated_irq_routes; +#endif + void *used_gsi_bitmap; + int max_gsi; +}; + +struct kvm_vcpu_context +{ + int fd; + struct kvm_run *run; + struct kvm_context *kvm; + uint32_t id; +}; typedef struct kvm_context *kvm_context_t; typedef struct kvm_vcpu_context *kvm_vcpu_context_t; +int kvm_alloc_kernel_memory(kvm_context_t kvm, unsigned long memory, + void **vm_mem); +int kvm_alloc_userspace_memory(kvm_context_t kvm, unsigned long memory, + void **vm_mem); + +int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes, + void **vm_mem); +int kvm_arch_run(kvm_vcpu_context_t vcpu); + + +void kvm_show_code(kvm_vcpu_context_t vcpu); + +int handle_halt(kvm_vcpu_context_t vcpu); +int handle_shutdown(kvm_context_t kvm, void *env); +void post_kvm_run(kvm_context_t kvm, void *env); +int pre_kvm_run(kvm_context_t kvm, void *env); +int handle_io_window(kvm_context_t kvm); +int handle_debug(kvm_vcpu_context_t vcpu, void *env); +int try_push_interrupts(kvm_context_t kvm); + + #if defined(__x86_64__) || defined(__i386__) struct kvm_msr_list *kvm_get_msr_list(kvm_context_t); int kvm_get_msrs(kvm_vcpu_context_t, struct kvm_msr_entry *msrs, int n); diff --git a/libkvm-common.h b/libkvm-common.h deleted file mode 100644 index dc5b667..0000000 --- a/libkvm-common.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * This header is for functions & variables that will ONLY be - * used inside libkvm. - * - * derived from libkvm.c - * - * Copyright (C) 2006 Qumranet, Inc. - * - * Authors: - * Avi Kivity - * Yaniv Kamay - * - * This work is licensed under the GNU LGPL license, version 2. - */ - -#ifndef KVM_COMMON_H -#define KVM_COMMON_H - -/* FIXME: share this number with kvm */ -/* FIXME: or dynamically alloc/realloc regions */ -#ifdef __s390__ -#define KVM_MAX_NUM_MEM_REGIONS 1u -#define MAX_VCPUS 64 -#define LIBKVM_S390_ORIGIN (0UL) -#elif defined(__ia64__) -#define KVM_MAX_NUM_MEM_REGIONS 32u -#define MAX_VCPUS 256 -#else -#define KVM_MAX_NUM_MEM_REGIONS 32u -#define MAX_VCPUS 16 -#endif - - -/* kvm abi verison variable */ -extern int kvm_abi; - -/** - * \brief The KVM context - * - * The verbose KVM context - */ - -struct kvm_context { - /// Filedescriptor to /dev/kvm - int fd; - int vm_fd; - /// Callbacks that KVM uses to emulate various unvirtualizable functionality - struct kvm_callbacks *callbacks; - void *opaque; - /// is dirty pages logging enabled for all regions or not - int dirty_pages_log_all; - /// do not create in-kernel irqchip if set - int no_irqchip_creation; - /// in-kernel irqchip status - int irqchip_in_kernel; - /// ioctl to use to inject interrupts - int irqchip_inject_ioctl; - /// do not create in-kernel pit if set - int no_pit_creation; - /// in-kernel pit status - int pit_in_kernel; - /// in-kernel coalesced mmio - int coalesced_mmio; -#ifdef KVM_CAP_IRQ_ROUTING - struct kvm_irq_routing *irq_routes; - int nr_allocated_irq_routes; -#endif - void *used_gsi_bitmap; - int max_gsi; -}; - -struct kvm_vcpu_context -{ - int fd; - struct kvm_run *run; - struct kvm_context *kvm; - uint32_t id; -}; - -int kvm_alloc_kernel_memory(kvm_context_t kvm, unsigned long memory, - void **vm_mem); -int kvm_alloc_userspace_memory(kvm_context_t kvm, unsigned long memory, - void **vm_mem); - -int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes, - void **vm_mem); -int kvm_arch_run(kvm_vcpu_context_t vcpu); - - -void kvm_show_code(kvm_vcpu_context_t vcpu); - -int handle_halt(kvm_vcpu_context_t vcpu); -int handle_shutdown(kvm_context_t kvm, void *env); -void post_kvm_run(kvm_context_t kvm, void *env); -int pre_kvm_run(kvm_context_t kvm, void *env); -int handle_io_window(kvm_context_t kvm); -int handle_debug(kvm_vcpu_context_t vcpu, void *env); -int try_push_interrupts(kvm_context_t kvm); - -#endif diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c index 5526d8f..729d600 100644 --- a/qemu-kvm-x86.c +++ b/qemu-kvm-x86.c @@ -20,6 +20,8 @@ #include #include +#include "kvm.h" + #define MSR_IA32_TSC 0x10 static struct kvm_msr_list *kvm_msr_list; diff --git a/qemu-kvm.c b/qemu-kvm.c index 7acc0ef..2aeb17c 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -149,12 +149,12 @@ void kvm_apic_init(CPUState *env) #include -static int try_push_interrupts(void *opaque) +static int kvm_try_push_interrupts(void *opaque) { return kvm_arch_try_push_interrupts(opaque); } -static void post_kvm_run(void *opaque, void *data) +static void kvm_post_run(void *opaque, void *data) { CPUState *env = (CPUState *)data; @@ -162,7 +162,7 @@ static void post_kvm_run(void *opaque, void *data) kvm_arch_post_kvm_run(opaque, env); } -static int pre_kvm_run(void *opaque, void *data) +static int kvm_pre_run(void *opaque, void *data) { CPUState *env = (CPUState *)data; @@ -761,12 +761,12 @@ static struct kvm_callbacks qemu_kvm_ops = { .halt = kvm_halt, .shutdown = kvm_shutdown, .io_window = kvm_io_window, - .try_push_interrupts = try_push_interrupts, + .try_push_interrupts = kvm_try_push_interrupts, #ifdef KVM_CAP_USER_NMI .push_nmi = kvm_arch_push_nmi, #endif - .post_kvm_run = post_kvm_run, - .pre_kvm_run = pre_kvm_run, + .post_kvm_run = kvm_post_run, + .pre_kvm_run = kvm_pre_run, #ifdef TARGET_I386 .tpr_access = handle_tpr_access, #endif diff --git a/target-i386/libkvm.h b/target-i386/libkvm.h index 081e010..f3fc6dc 100644 --- a/target-i386/libkvm.h +++ b/target-i386/libkvm.h @@ -18,7 +18,7 @@ #ifndef KVM_X86_H #define KVM_X86_H -#include "libkvm-common.h" +#include "libkvm-all.h" #define PAGE_SIZE 4096ul #define PAGE_MASK (~(PAGE_SIZE - 1)) diff --git a/target-ia64/libkvm.h b/target-ia64/libkvm.h index f084420..417f7f1 100644 --- a/target-ia64/libkvm.h +++ b/target-ia64/libkvm.h @@ -18,7 +18,7 @@ #ifndef KVM_IA64_H #define KVM_IA64_H -#include "libkvm-common.h" +#include "libkvm-all.h" extern int kvm_page_size; diff --git a/target-ppc/libkvm.h b/target-ppc/libkvm.h index 95c314d..80b6b06 100644 --- a/target-ppc/libkvm.h +++ b/target-ppc/libkvm.h @@ -19,7 +19,7 @@ #ifndef KVM_POWERPC_H #define KVM_POWERPC_H -#include "libkvm-common.h" +#include "libkvm-all.h" extern int kvm_page_size;