Skip to contentSkip to conversation

create kvm-shared-all.c and kvm-shared.h

PATCH In review Glauber Costa 3 participants 9 messages Jun 9, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 create kvm-shared-all.c and kvm-shared.h

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.

---
 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
Makefile.target +2 -1
index 27de4b9..d78db27 100644
@@ -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
kvm-all.c +0 -73

89 lines not on this page · raw message

kvm-shared-all.c new file +58 -0

58 lines not on this page · raw message

kvm-shared.h new file +38 -0
new file mode 100644
index 0000000..c8364ff
@@ -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
kvm.h +1 -9
index 560aef3..9cc64ac 100644
@@ -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,
Signature · 1 line
1.5.6.6
#1 lore raw
Quoted 6 lines · Glauber Costa

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.

OK for the header - but why do we have to push the ioctl services into a separate module? Will all functions qemu-kvm start to use from upstream have to be pushed around? Or what is special about the ioctls?

I rather think qemu-kvm should build kvm-all.c and #ifdef out those parts which collide with its own implementation. Moreover, when we morph qemu-kvm services for upstream, this could already happen where they shall once be located: in kvm-all.c or target-*/kvm.c.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
#2 lore raw
Quoted 10 lines · Jan Kiszka
Quoted 7 lines · Glauber Costa

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.

Quoted 9 lines

OK for the header - but why do we have to push the ioctl services into a separate module? Will all functions qemu-kvm start to use from upstream have to be pushed around? Or what is special about the ioctls?

I rather think qemu-kvm should build kvm-all.c and #ifdef out those parts which collide with its own implementation. Moreover, when we morph qemu-kvm services for upstream, this could already happen where they shall once be located: in kvm-all.c or target-*/kvm.c.

Yes, we could simply append libkvm-all.c and qemu-kvm.c to kvm-all.c, and gradually include more of kvm-all.c as we delete parts of libkvm.c and qemu-kvm.c.

Signature · 1 line
error compiling committee.c: too many arguments to function
#3 lore raw
Quoted 21 lines · Avi Kivity
Quoted 10 lines · Jan Kiszka
Quoted 7 lines · Glauber Costa

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.

Quoted 9 lines

OK for the header - but why do we have to push the ioctl services into a separate module? Will all functions qemu-kvm start to use from upstream have to be pushed around? Or what is special about the ioctls?

I rather think qemu-kvm should build kvm-all.c and #ifdef out those parts which collide with its own implementation. Moreover, when we morph qemu-kvm services for upstream, this could already happen where they shall once be located: in kvm-all.c or target-*/kvm.c.

Quoted 3 lines

Yes, we could simply append libkvm-all.c and qemu-kvm.c to kvm-all.c, and gradually include more of kvm-all.c as we delete parts of libkvm.c and qemu-kvm.c.

I tried it myself, and it generates tons of conflicts. So scary.
I'd prefer to do it in the way I propose, until there is nothing left on kvm-all.c

#4 lore raw
Quoted 5 lines · Glauber Costa
Quoted 2 lines

Yes, we could simply append libkvm-all.c and qemu-kvm.c to kvm-all.c, and gradually include more of kvm-all.c as we delete parts of libkvm.c and qemu-kvm.c.

I tried it myself, and it generates tons of conflicts. So scary.
I'd prefer to do it in the way I propose, until there is nothing left on kvm-all.c

There shouldn't be any conflicts, kvm-all is ifdefed out.

We'd enable bits one by one until everything is enabled.

Signature · 1 line
error compiling committee.c: too many arguments to function
#5 lore raw
In reply to Glauber Costa
Quoted 20 lines · Glauber Costa
Quoted 19 lines · Avi Kivity
Quoted 18 lines · Jan Kiszka
Quoted 7 lines · Glauber Costa

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.

OK for the header - but why do we have to push the ioctl services into a separate module? Will all functions qemu-kvm start to use from upstream have to be pushed around? Or what is special about the ioctls?

I rather think qemu-kvm should build kvm-all.c and #ifdef out those parts which collide with its own implementation. Moreover, when we morph qemu-kvm services for upstream, this could already happen where they shall once be located: in kvm-all.c or target-*/kvm.c.

Quoted 6 lines
Quoted 3 lines

Yes, we could simply append libkvm-all.c and qemu-kvm.c to kvm-all.c, and gradually include more of kvm-all.c as we delete parts of libkvm.c and qemu-kvm.c.

I tried it myself, and it generates tons of conflicts. So scary.
I'd prefer to do it in the way I propose, until there is nothing left on kvm-all.c

kvm-all.c:

#ifdef DONT_USE_UPSTREAM_YET
<upstream code>
#endif

int kvm_ioctl(KVMState *s, int type, ...)
...

#ifdef DONT_USE_UPSTREAM_YET
<some more upstream code>
#endif

<libkvm code>

Can't imagine that this is infeasible. And it would all happily live in qemu-kvm, so upstream would never see these hacks.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
#6 lore raw
Quoted 41 lines · Jan Kiszka
Quoted 20 lines · Glauber Costa
Quoted 19 lines · Avi Kivity
Quoted 18 lines · Jan Kiszka
Quoted 7 lines · Glauber Costa

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.

OK for the header - but why do we have to push the ioctl services into a separate module? Will all functions qemu-kvm start to use from upstream have to be pushed around? Or what is special about the ioctls?

I rather think qemu-kvm should build kvm-all.c and #ifdef out those parts which collide with its own implementation. Moreover, when we morph qemu-kvm services for upstream, this could already happen where they shall once be located: in kvm-all.c or target-*/kvm.c.

Quoted 6 lines
Quoted 3 lines

Yes, we could simply append libkvm-all.c and qemu-kvm.c to kvm-all.c, and gradually include more of kvm-all.c as we delete parts of libkvm.c and qemu-kvm.c.

I tried it myself, and it generates tons of conflicts. So scary.
I'd prefer to do it in the way I propose, until there is nothing left on kvm-all.c

kvm-all.c:

#ifdef DONT_USE_UPSTREAM_YET
<upstream code>
#endif

int kvm_ioctl(KVMState *s, int type, ...)
...

#ifdef DONT_USE_UPSTREAM_YET
<some more upstream code>
#endif

Quoted 5 lines

<libkvm code>

Can't imagine that this is infeasible. And it would all happily live in qemu-kvm, so upstream would never see these hacks.

yeah, if it is in fact ifdef'd this way, it of course works.

I can do that, definitely.
But by doing that, we probably does not even need the header part here too.

#7 lore raw
Quoted 44 lines · Glauber Costa
Quoted 43 lines · Jan Kiszka
Quoted 20 lines · Glauber Costa
Quoted 19 lines · Avi Kivity
Quoted 18 lines · Jan Kiszka
Quoted 7 lines · Glauber Costa

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.

OK for the header - but why do we have to push the ioctl services into a separate module? Will all functions qemu-kvm start to use from upstream have to be pushed around? Or what is special about the ioctls?

I rather think qemu-kvm should build kvm-all.c and #ifdef out those parts which collide with its own implementation. Moreover, when we morph qemu-kvm services for upstream, this could already happen where they shall once be located: in kvm-all.c or target-*/kvm.c.

Quoted 6 lines
Quoted 3 lines

Yes, we could simply append libkvm-all.c and qemu-kvm.c to kvm-all.c, and gradually include more of kvm-all.c as we delete parts of libkvm.c and qemu-kvm.c.

I tried it myself, and it generates tons of conflicts. So scary.
I'd prefer to do it in the way I propose, until there is nothing left on kvm-all.c

kvm-all.c:

#ifdef DONT_USE_UPSTREAM_YET
<upstream code>
#endif

int kvm_ioctl(KVMState *s, int type, ...)
...

#ifdef DONT_USE_UPSTREAM_YET
<some more upstream code>
#endif

<libkvm code>

Quoted 7 lines
Quoted 2 lines

Can't imagine that this is infeasible. And it would all happily live in qemu-kvm, so upstream would never see these hacks.

yeah, if it is in fact ifdef'd this way, it of course works.

I can do that, definitely.
But by doing that, we probably does not even need the header part here too.

I think we need it as long as qemu-kvm-<arch> fiddles with state fields directly. If that is easily resolvable, I'm all for doing that first and skipping the kvm-shared.h part in upstream!

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
#8 lore raw
In reply to Jan Kiszka
Quoted 8 lines · Jan Kiszka
Quoted 6 lines · Glauber Costa

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.

Quoted 8 lines

OK for the header - but why do we have to push the ioctl services into a separate module? Will all functions qemu-kvm start to use from upstream have to be pushed around? Or what is special about the ioctls?

I rather think qemu-kvm should build kvm-all.c and #ifdef out those parts which collide with its own implementation. Moreover, when we morph qemu-kvm services for upstream, this could already happen where they shall once be located: in kvm-all.c or target-*/kvm.c.

I also think qemu-kvm should build kvm-all.c. But right now, it is so full of conflicts, that it would be impossible. My go with the module, is, whenever we move all the code in kvm-all.c away, it should mean it is safe to go back to
it: qemu-kvm will be granted not to conflict with it.