diff mbox

[1/2] get rid of libkvm-common.h

Message ID 1244565799-616-2-git-send-email-glommer@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Glauber Costa June 9, 2009, 4:43 p.m. UTC
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 <glommer@redhat.com>
---
 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 mbox

Patch

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 <signal.h>
 
-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   <avi@qumranet.com>
- *	Yaniv Kamay  <yaniv@qumranet.com>
- *
- *   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 <sys/utsname.h>
 #include <linux/kvm_para.h>
 
+#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 <signal.h>
 
-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;