All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] get rid of libkvm-common.h
@ 2009-06-09 16:43 Glauber Costa
  2009-06-09 16:43 ` [PATCH 1/2] " Glauber Costa
  2009-06-11  9:13 ` [PATCH 0/2] get rid of libkvm-common.h Avi Kivity
  0 siblings, 2 replies; 4+ messages in thread
From: Glauber Costa @ 2009-06-09 16:43 UTC (permalink / raw)
  To: kvm; +Cc: avi

There is no place in the world for this sad header.
This is part of the patch series I sent the other day (about KVMState),
but it is an independent cleanup.

Since that was not merged, I'm sending this part separetedly.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] get rid of libkvm-common.h
  2009-06-09 16:43 [PATCH 0/2] get rid of libkvm-common.h Glauber Costa
@ 2009-06-09 16:43 ` Glauber Costa
  2009-06-09 16:43   ` [PATCH 2/2] pull qemu headers into libkvm Glauber Costa
  2009-06-11  9:13 ` [PATCH 0/2] get rid of libkvm-common.h Avi Kivity
  1 sibling, 1 reply; 4+ messages in thread
From: Glauber Costa @ 2009-06-09 16:43 UTC (permalink / raw)
  To: kvm; +Cc: avi

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 --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;
 
-- 
1.5.6.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] pull qemu headers into libkvm
  2009-06-09 16:43 ` [PATCH 1/2] " Glauber Costa
@ 2009-06-09 16:43   ` Glauber Costa
  0 siblings, 0 replies; 4+ messages in thread
From: Glauber Costa @ 2009-06-09 16:43 UTC (permalink / raw)
  To: kvm; +Cc: avi

Those headers define qemu specific things like ram_addr_t.
This will allow us to start using them in libkvm.

Signed-off-by: Glauber Costa <glommer@redhat.com>
---
 libkvm-all.c         |    2 +-
 libkvm-all.h         |    1 +
 target-i386/libkvm.c |    2 ++
 3 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/libkvm-all.c b/libkvm-all.c
index dd56498..45679fb 100644
--- a/libkvm-all.c
+++ b/libkvm-all.c
@@ -26,6 +26,7 @@
 #error libkvm: userspace and kernel version mismatch
 #endif
 
+#include "sysemu.h"
 #include <unistd.h>
 #include <fcntl.h>
 #include <stdio.h>
@@ -47,7 +48,6 @@
 #define DPRINTF(fmt, args...) do {} while (0)
 #endif
 
-#define MIN(x,y) ((x) < (y) ? (x) : (y))
 #define ALIGN(x, y) (((x)+(y)-1) & ~((y)-1))
 
 int kvm_abi = EXPECTED_KVM_API_VERSION;
diff --git a/libkvm-all.h b/libkvm-all.h
index 03b98df..d647ef1 100644
--- a/libkvm-all.h
+++ b/libkvm-all.h
@@ -82,6 +82,7 @@ struct kvm_vcpu_context
 typedef struct kvm_context *kvm_context_t;
 typedef struct kvm_vcpu_context *kvm_vcpu_context_t;
 
+#include "kvm.h"
 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,
diff --git a/target-i386/libkvm.c b/target-i386/libkvm.c
index f88102e..0f4e009 100644
--- a/target-i386/libkvm.c
+++ b/target-i386/libkvm.c
@@ -1,3 +1,5 @@
+#include "sysemu.h"
+
 #include "libkvm-all.h"
 #include "libkvm.h"
 #include <errno.h>
-- 
1.5.6.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] get rid of libkvm-common.h
  2009-06-09 16:43 [PATCH 0/2] get rid of libkvm-common.h Glauber Costa
  2009-06-09 16:43 ` [PATCH 1/2] " Glauber Costa
@ 2009-06-11  9:13 ` Avi Kivity
  1 sibling, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2009-06-11  9:13 UTC (permalink / raw)
  To: Glauber Costa; +Cc: kvm

Glauber Costa wrote:
> There is no place in the world for this sad header.
> This is part of the patch series I sent the other day (about KVMState),
> but it is an independent cleanup.
>
> Since that was not merged, I'm sending this part separetedly.
>   

Applied, thanks.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-06-11  9:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-09 16:43 [PATCH 0/2] get rid of libkvm-common.h Glauber Costa
2009-06-09 16:43 ` [PATCH 1/2] " Glauber Costa
2009-06-09 16:43   ` [PATCH 2/2] pull qemu headers into libkvm Glauber Costa
2009-06-11  9:13 ` [PATCH 0/2] get rid of libkvm-common.h Avi Kivity

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.