From: Glauber Costa <glommer@redhat.com>
To: qemu-devel@nongnu.org
Cc: jan.kiszka@siemens.com, aliguori@us.ibm.com
Subject: [Qemu-devel] [PATCH] create kvm-shared-all.c and kvm-shared.h
Date: Tue, 9 Jun 2009 12:04:26 -0400 [thread overview]
Message-ID: <1244563466-32598-1-git-send-email-glommer@redhat.com> (raw)
Following a suggestion given by Jan, the idea here is to
move shared pieces between qemu and qemu-kvm.git into a common
file, so we can do sharing while avoid clashes.
In the future, this files should disappear.
Signed-off-by: Glauber Costa <glommer@redhat.com>
---
Makefile.target | 3 +-
kvm-all.c | 73 ------------------------------------------------------
kvm-shared-all.c | 58 ++++++++++++++++++++++++++++++++++++++++++
kvm-shared.h | 38 ++++++++++++++++++++++++++++
kvm.h | 10 +------
5 files changed, 99 insertions(+), 83 deletions(-)
create mode 100644 kvm-shared-all.c
create mode 100644 kvm-shared.h
diff --git a/Makefile.target b/Makefile.target
index 27de4b9..d78db27 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -126,6 +126,7 @@ endif
kvm.o: CFLAGS+=$(KVM_CFLAGS)
kvm-all.o: CFLAGS+=$(KVM_CFLAGS)
+kvm-shared-all.o: CFLAGS+=$(KVM_CFLAGS)
all: $(PROGS)
# Dummy command so that make thinks it has done something
@@ -499,7 +500,7 @@ OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o \
# need to fix this properly
OBJS+=virtio-blk.o virtio-balloon.o virtio-net.o virtio-console.o
ifdef CONFIG_KVM
-OBJS+=kvm.o kvm-all.o
+OBJS+=kvm.o kvm-all.o kvm-shared-all.o
endif
LIBS+=-lz
diff --git a/kvm-all.c b/kvm-all.c
index b24d876..258d41a 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -39,32 +39,10 @@
do { } while (0)
#endif
-typedef struct KVMSlot
-{
- target_phys_addr_t start_addr;
- ram_addr_t memory_size;
- ram_addr_t phys_offset;
- int slot;
- int flags;
-} KVMSlot;
-
typedef struct kvm_dirty_log KVMDirtyLog;
int kvm_allowed = 0;
-struct KVMState
-{
- KVMSlot slots[32];
- int fd;
- int vmfd;
- int coalesced_mmio;
- int broken_set_mem_region;
- int migration_log;
-#ifdef KVM_CAP_SET_GUEST_DEBUG
- struct kvm_sw_breakpoint_head kvm_sw_breakpoints;
-#endif
-};
-
static KVMState *kvm_state;
static KVMSlot *kvm_alloc_slot(KVMState *s)
@@ -803,57 +781,6 @@ void kvm_set_phys_mem(target_phys_addr_t start_addr,
}
}
-int kvm_ioctl(KVMState *s, int type, ...)
-{
- int ret;
- void *arg;
- va_list ap;
-
- va_start(ap, type);
- arg = va_arg(ap, void *);
- va_end(ap);
-
- ret = ioctl(s->fd, type, arg);
- if (ret == -1)
- ret = -errno;
-
- return ret;
-}
-
-int kvm_vm_ioctl(KVMState *s, int type, ...)
-{
- int ret;
- void *arg;
- va_list ap;
-
- va_start(ap, type);
- arg = va_arg(ap, void *);
- va_end(ap);
-
- ret = ioctl(s->vmfd, type, arg);
- if (ret == -1)
- ret = -errno;
-
- return ret;
-}
-
-int kvm_vcpu_ioctl(CPUState *env, int type, ...)
-{
- int ret;
- void *arg;
- va_list ap;
-
- va_start(ap, type);
- arg = va_arg(ap, void *);
- va_end(ap);
-
- ret = ioctl(env->kvm_fd, type, arg);
- if (ret == -1)
- ret = -errno;
-
- return ret;
-}
-
int kvm_has_sync_mmu(void)
{
#ifdef KVM_CAP_SYNC_MMU
diff --git a/kvm-shared-all.c b/kvm-shared-all.c
new file mode 100644
index 0000000..ca94155
--- /dev/null
+++ b/kvm-shared-all.c
@@ -0,0 +1,58 @@
+
+#include <sys/ioctl.h>
+
+#include "sysemu.h"
+#include "kvm.h"
+
+int kvm_ioctl(KVMState *s, int type, ...)
+{
+ int ret;
+ void *arg;
+ va_list ap;
+
+ va_start(ap, type);
+ arg = va_arg(ap, void *);
+ va_end(ap);
+
+ ret = ioctl(s->fd, type, arg);
+ if (ret == -1)
+ ret = -errno;
+
+ return ret;
+}
+
+int kvm_vm_ioctl(KVMState *s, int type, ...)
+{
+ int ret;
+ void *arg;
+ va_list ap;
+
+ va_start(ap, type);
+ arg = va_arg(ap, void *);
+ va_end(ap);
+
+ ret = ioctl(s->vmfd, type, arg);
+ if (ret == -1)
+ ret = -errno;
+
+ return ret;
+}
+
+int kvm_vcpu_ioctl(CPUState *env, int type, ...)
+{
+ int ret;
+ void *arg;
+ va_list ap;
+
+ va_start(ap, type);
+ arg = va_arg(ap, void *);
+ va_end(ap);
+
+ ret = ioctl(env->kvm_fd, type, arg);
+ if (ret == -1)
+ ret = -errno;
+
+ return ret;
+}
+
+
diff --git a/kvm-shared.h b/kvm-shared.h
new file mode 100644
index 0000000..c8364ff
--- /dev/null
+++ b/kvm-shared.h
@@ -0,0 +1,38 @@
+/* This file is temporary by nature. It exists to aid merging of
+ * qemu-kvm.git, and should go away once it is in
+ */
+#ifndef QEMU_KVM_SHARED_H
+#define QEMU_KVM_SHARED_H
+
+typedef struct KVMSlot
+{
+ target_phys_addr_t start_addr;
+ ram_addr_t memory_size;
+ ram_addr_t phys_offset;
+ int slot;
+ int flags;
+} KVMSlot;
+
+struct kvm_sw_breakpoint {
+ target_ulong pc;
+ target_ulong saved_insn;
+ int use_count;
+ TAILQ_ENTRY(kvm_sw_breakpoint) entry;
+};
+
+TAILQ_HEAD(kvm_sw_breakpoint_head, kvm_sw_breakpoint);
+
+struct KVMState
+{
+ KVMSlot slots[32];
+ int fd;
+ int vmfd;
+ int coalesced_mmio;
+ int broken_set_mem_region;
+ int migration_log;
+#ifdef KVM_CAP_SET_GUEST_DEBUG
+ struct kvm_sw_breakpoint_head kvm_sw_breakpoints;
+#endif
+};
+
+#endif
diff --git a/kvm.h b/kvm.h
index 560aef3..9cc64ac 100644
--- a/kvm.h
+++ b/kvm.h
@@ -16,6 +16,7 @@
#include "config.h"
#include "sys-queue.h"
+#include "kvm-shared.h"
#ifdef CONFIG_KVM
extern int kvm_allowed;
@@ -94,15 +95,6 @@ int kvm_arch_init_vcpu(CPUState *env);
struct kvm_guest_debug;
struct kvm_debug_exit_arch;
-struct kvm_sw_breakpoint {
- target_ulong pc;
- target_ulong saved_insn;
- int use_count;
- TAILQ_ENTRY(kvm_sw_breakpoint) entry;
-};
-
-TAILQ_HEAD(kvm_sw_breakpoint_head, kvm_sw_breakpoint);
-
int kvm_arch_debug(struct kvm_debug_exit_arch *arch_info);
struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *env,
--
1.5.6.6
next reply other threads:[~2009-06-09 16:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-09 16:04 Glauber Costa [this message]
2009-06-09 16:17 ` [Qemu-devel] Re: [PATCH] create kvm-shared-all.c and kvm-shared.h Jan Kiszka
2009-06-09 16:26 ` Avi Kivity
2009-06-09 16:39 ` Glauber Costa
2009-06-09 16:42 ` Avi Kivity
2009-06-09 16:42 ` Jan Kiszka
2009-06-09 16:51 ` Glauber Costa
2009-06-09 16:51 ` Jan Kiszka
2009-06-09 16:37 ` Glauber Costa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1244563466-32598-1-git-send-email-glommer@redhat.com \
--to=glommer@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=jan.kiszka@siemens.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).