Skip to contentSkip to conversation

use KVMState, as upstream do

PATCH In review Glauber Costa 4 participants 9 messages Jun 4, 2009 – Jun 7, 2009 2 messages not in the archive KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 use KVMState, as upstream do

This is a pretty mechanical change. To make code look closer to upstream qemu, I'm renaming kvm_context_t to KVMState. Mid term goal here is to start sharing code whereas possible.

Avi, please apply, or I'll send you a video of myself dancing naked.

---
 kvm/user/main-ppc.c  |    2 +-
 kvm/user/main.c      |    4 +-
 libkvm-all.c         |  164 ++++++++++++++++++++++----------------------
 libkvm-all.h         |  186 +++++++++++++++++++++++++-------------------------
 libkvm-common.h      |   24 +++---
 qemu-kvm-x86.c       |    2 +-
 qemu-kvm.c           |    2 +-
 qemu-kvm.h           |    2 +-
 target-i386/libkvm.c |   62 ++++++++--------
 target-i386/libkvm.h |    2 +-
 target-ia64/libkvm.c |   12 ++--
 target-ppc/libkvm.c  |   10 ++--
 12 files changed, 236 insertions(+), 236 deletions(-)
kvm/user/main-ppc.c +1 -1
index 5af59f8..fbfd721 100644
@@ -44,7 +44,7 @@ static int gettid(void)
 	return syscall(__NR_gettid);
 }
 
-kvm_context_t kvm;
+KVMState *kvm;
 
 #define IPI_SIGNAL (SIGRTMIN + 4)
 
kvm/user/main.c +2 -2
index 1530ae2..ecd1b28 100644
@@ -50,7 +50,7 @@ static int tkill(int pid, int sig)
 	return syscall(__NR_tkill, pid, sig);
 }
 
-kvm_context_t kvm;
+KVMState *kvm;
 
 #define MAX_VCPUS 4
 
@@ -406,7 +406,7 @@ static void load_file(void *mem, const char *fname)
 	}
 }
 
-static void enter_32(kvm_context_t kvm)
+static void enter_32(KVMState *kvm)
 {
 	struct kvm_regs regs = {
 		.rsp = 0x80000,  /* 512KB */
libkvm-all.c +82 -82

615 lines not on this page · raw message

libkvm-all.h +93 -93

596 lines not on this page · raw message

libkvm-common.h +12 -12
index c95c591..ad981b3 100644
@@ -71,24 +71,24 @@ struct kvm_context {
 	int max_gsi;
 };
 
-int kvm_alloc_kernel_memory(kvm_context_t kvm, unsigned long memory,
+int kvm_alloc_kernel_memory(KVMState *kvm, unsigned long memory,
 								void **vm_mem);
-int kvm_alloc_userspace_memory(kvm_context_t kvm, unsigned long memory,
+int kvm_alloc_userspace_memory(KVMState *kvm, unsigned long memory,
 								void **vm_mem);
 
-int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes,
+int kvm_arch_create(KVMState *kvm, unsigned long phys_mem_bytes,
                         void **vm_mem);
-int kvm_arch_run(struct kvm_run *run, kvm_context_t kvm, int vcpu);
+int kvm_arch_run(struct kvm_run *run, KVMState *kvm, int vcpu);
 
 
-void kvm_show_code(kvm_context_t kvm, int vcpu);
+void kvm_show_code(KVMState *kvm, int vcpu);
 
-int handle_halt(kvm_context_t kvm, int 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_context_t kvm, int vcpu, void *env);
-int try_push_interrupts(kvm_context_t kvm);
+int handle_halt(KVMState *kvm, int vcpu);
+int handle_shutdown(KVMState *kvm, void *env);
+void post_kvm_run(KVMState *kvm, void *env);
+int pre_kvm_run(KVMState *kvm, void *env);
+int handle_io_window(KVMState *kvm);
+int handle_debug(KVMState *kvm, int vcpu, void *env);
+int try_push_interrupts(KVMState *kvm);
 
 #endif
qemu-kvm-x86.c +1 -1
index 1096e65..9e8810a 100644
@@ -498,7 +498,7 @@ struct kvm_para_features {
 	{ -1, -1 }
 };
 
-static int get_para_features(kvm_context_t kvm_context)
+static int get_para_features(KVMState *kvm_context)
 {
 	int i, features = 0;
 
qemu-kvm.c +1 -1
index 68d3b92..a0846e8 100644
@@ -33,7 +33,7 @@ int kvm_irqchip = 1;
 int kvm_pit = 1;
 int kvm_pit_reinject = 1;
 int kvm_nested = 0;
-kvm_context_t kvm_context;
+KVMState *kvm_context;
 
 pthread_mutex_t qemu_mutex = PTHREAD_MUTEX_INITIALIZER;
 pthread_cond_t qemu_vcpu_cond = PTHREAD_COND_INITIALIZER;
qemu-kvm.h +1 -1
index 725589b..a470f3c 100644
@@ -154,7 +154,7 @@ extern int kvm_irqchip;
 extern int kvm_pit;
 extern int kvm_pit_reinject;
 extern int kvm_nested;
-extern kvm_context_t kvm_context;
+extern KVMState *kvm_context;
 
 struct ioperm_data {
     unsigned long start_port;
target-i386/libkvm.c +31 -31

244 lines not on this page · raw message

target-i386/libkvm.h +1 -1
index 081e010..26a4597 100644
@@ -23,7 +23,7 @@
 #define PAGE_SIZE 4096ul
 #define PAGE_MASK (~(PAGE_SIZE - 1))
 
-int kvm_set_tss_addr(kvm_context_t kvm, unsigned long addr);
+int kvm_set_tss_addr(KVMState *kvm, unsigned long addr);
 
 #define smp_wmb()   asm volatile("" ::: "memory")
 
target-ia64/libkvm.c +6 -6
index 48669de..bcd9750 100644
@@ -33,7 +33,7 @@
 #include <fcntl.h>
 #include <stdlib.h>
 
-int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes,
+int kvm_arch_create(KVMState *kvm, unsigned long phys_mem_bytes,
 			void **vm_mem)
 {
 	int r;
@@ -45,7 +45,7 @@ int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes,
 	return 0;
 }
 
-int kvm_arch_run(struct kvm_run *run,kvm_context_t kvm, int vcpu)
+int kvm_arch_run(struct kvm_run *run,KVMState *kvm, int vcpu)
 {
 	int r = 0;
 
@@ -58,17 +58,17 @@ int kvm_arch_run(struct kvm_run *run,kvm_context_t kvm, int vcpu)
 	return r;
 }
 
-void kvm_show_code(kvm_context_t kvm, int vcpu)
+void kvm_show_code(KVMState *kvm, int vcpu)
 {
 	fprintf(stderr, "kvm_show_code not supported yet!\n");
 }
 
-void kvm_show_regs(kvm_context_t kvm, int vcpu)
+void kvm_show_regs(KVMState *kvm, int vcpu)
 {
 	fprintf(stderr,"kvm_show_regs not supportted today!\n");
 }
 
-int kvm_create_memory_alias(kvm_context_t kvm,
+int kvm_create_memory_alias(KVMState *kvm,
 			    uint64_t phys_start,
 			    uint64_t len,
 			    uint64_t target_phys)
@@ -76,7 +76,7 @@ int kvm_create_memory_alias(kvm_context_t kvm,
     return 0;
 }
 
-int kvm_destroy_memory_alias(kvm_context_t kvm, uint64_t phys_start)
+int kvm_destroy_memory_alias(KVMState *kvm, uint64_t phys_start)
 {
 	return 0;
 }
target-ppc/libkvm.c +5 -5
index 2dfff3b..b5c59e8 100644
@@ -23,7 +23,7 @@
 #include <stdio.h>
 #include <inttypes.h>
 
-int handle_dcr(struct kvm_run *run,  kvm_context_t kvm, int vcpu)
+int handle_dcr(struct kvm_run *run,  KVMState *kvm, int vcpu)
 {
 	int ret = 0;
 
@@ -39,12 +39,12 @@ int handle_dcr(struct kvm_run *run,  kvm_context_t kvm, int vcpu)
 	return ret;
 }
 
-void kvm_show_code(kvm_context_t kvm, int vcpu)
+void kvm_show_code(KVMState *kvm, int vcpu)
 {
 	fprintf(stderr, "%s: Operation not supported\n", __FUNCTION__);
 }
 
-void kvm_show_regs(kvm_context_t kvm, int vcpu)
+void kvm_show_regs(KVMState *kvm, int vcpu)
 {
 	struct kvm_regs regs;
 	int i;
@@ -72,7 +72,7 @@ void kvm_show_regs(kvm_context_t kvm, int vcpu)
 	fflush(stdout);
 }
 
-int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes,
+int kvm_arch_create(KVMState *kvm, unsigned long phys_mem_bytes,
 			 void **vm_mem)
 {
 	int r;
@@ -84,7 +84,7 @@ int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes,
 	return 0;
 }
 
-int kvm_arch_run(struct kvm_run *run, kvm_context_t kvm, int vcpu)
+int kvm_arch_run(struct kvm_run *run, KVMState *kvm, int vcpu)
 {
 	int ret = 0;
 
Signature · 1 line
1.5.6.6

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 17 lines · Glauber Costa
Quoted 9 lines · Gleb Natapov
Quoted 8 lines · Glauber Costa

This is a pretty mechanical change. To make code look closer to upstream qemu, I'm renaming kvm_context_t to KVMState. Mid term goal here is to start sharing code whereas possible.

Avi, please apply, or I'll send you a video of myself dancing naked.

Quoted 6 lines

You can start recording it since I doubt this patch will apply cleanly to today's master (other mechanical change was applied). Regardless, I think trying to use bits of qemu kvm is dangerous. It has similar function with same names, but with different assumptions about conditional they can be executed in (look at commit a5ddb119). I actually prefer to be different enough to not call upstream qemu function by mistake.

Quoted 8 lines

I did it against today's master. If new patches came in, is just a matter of regenerating this, since it is, as I said, mechanical.

Also, as we don't compile in upstream functions yet (kvm-all.c and kvm.c are not included in the final object), there is no such risk. Of course, I am aiming towards it, but the first step will be to change the name of conflicting functions until we can pick qemu's implementation, in which case the former will just go away.

That is the point. We can't just pick qemu's implementation most of the times.

Quoted 4 lines

If we are serious about merging qemu-kvm into qemu, I don't see a way out of it. We should start changing things this way to accomodate it. Different enough won't do.

I don't really like the idea to morph working implementation to look like non-working one. I do agree that qemu-kvm should be cleaned substantially before going upstream. Upstream qemu kvm should go away than. I don't see much work done to enhance it anyway.

--
Gleb.

#4 lore raw
Quoted 21 lines · Gleb Natapov
Quoted 20 lines · Glauber Costa
Quoted 9 lines · Gleb Natapov
Quoted 8 lines · Glauber Costa

This is a pretty mechanical change. To make code look closer to upstream qemu, I'm renaming kvm_context_t to KVMState. Mid term goal here is to start sharing code whereas possible.

Avi, please apply, or I'll send you a video of myself dancing naked.

Quoted 6 lines

You can start recording it since I doubt this patch will apply cleanly to today's master (other mechanical change was applied). Regardless, I think trying to use bits of qemu kvm is dangerous. It has similar function with same names, but with different assumptions about conditional they can be executed in (look at commit a5ddb119). I actually prefer to be different enough to not call upstream qemu function by mistake.

I did it against today's master. If new patches came in, is just a matter of regenerating this, since it is, as I said, mechanical.

Quoted 7 lines
Quoted 5 lines

Also, as we don't compile in upstream functions yet (kvm-all.c and kvm.c are not included in the final object), there is no such risk. Of course, I am aiming towards it, but the first step will be to change the name of conflicting functions until we can pick qemu's implementation, in which case the former will just go away.

That is the point. We can't just pick qemu's implementation most of the times.

"until we can pick up qemu's implementation" potentially involves replacing that particular piece with upstream version first.

Quoted 10 lines
Quoted 5 lines

If we are serious about merging qemu-kvm into qemu, I don't see a way out of it. We should start changing things this way to accomodate it. Different enough won't do.

I don't really like the idea to morph working implementation to look like non-working one. I do agree that qemu-kvm should be cleaned substantially before going upstream. Upstream qemu kvm should go away than. I don't see much work done to enhance it anyway.

this first phase has nothing to do with functionality. To begin with, KVMState is qemu style, kvm_context_t is not, like it or not (I don't).

I don't plan to introduce regressions, you can rest assured. But we _do_ have to make things look much more qemuer, and that's what this patch aims at.

#5 lore raw
Quoted 37 lines · Glauber Costa
Quoted 21 lines · Gleb Natapov
Quoted 20 lines · Glauber Costa
Quoted 9 lines · Gleb Natapov
Quoted 8 lines · Glauber Costa

This is a pretty mechanical change. To make code look closer to upstream qemu, I'm renaming kvm_context_t to KVMState. Mid term goal here is to start sharing code whereas possible.

Avi, please apply, or I'll send you a video of myself dancing naked.

Quoted 6 lines

You can start recording it since I doubt this patch will apply cleanly to today's master (other mechanical change was applied). Regardless, I think trying to use bits of qemu kvm is dangerous. It has similar function with same names, but with different assumptions about conditional they can be executed in (look at commit a5ddb119). I actually prefer to be different enough to not call upstream qemu function by mistake.

I did it against today's master. If new patches came in, is just a matter of regenerating this, since it is, as I said, mechanical.

Quoted 7 lines
Quoted 5 lines

Also, as we don't compile in upstream functions yet (kvm-all.c and kvm.c are not included in the final object), there is no such risk. Of course, I am aiming towards it, but the first step will be to change the name of conflicting functions until we can pick qemu's implementation, in which case the former will just go away.

That is the point. We can't just pick qemu's implementation most of the times.

"until we can pick up qemu's implementation" potentially involves replacing that particular piece with upstream version first.

Quoted 5 lines
Quoted 5 lines

If we are serious about merging qemu-kvm into qemu, I don't see a way out of it. We should start changing things this way to accomodate it. Different enough won't do.

Quoted 9 lines
Quoted 5 lines

I don't really like the idea to morph working implementation to look like non-working one. I do agree that qemu-kvm should be cleaned substantially before going upstream. Upstream qemu kvm should go away than. I don't see much work done to enhance it anyway.

this first phase has nothing to do with functionality. To begin with, KVMState is qemu style, kvm_context_t is not, like it or not (I don't).

I am not against this mechanical change at all, don't get me wrong. I don't want to mix two kvm implementation together in strange ways.

Quoted 3 lines

I don't plan to introduce regressions, you can rest assured. But we _do_ have to make things look much more qemuer, and that's what this patch aims at.

--
Gleb.

#6 lore raw
Quoted 44 lines · Gleb Natapov
Quoted 43 lines · Glauber Costa
Quoted 21 lines · Gleb Natapov
Quoted 20 lines · Glauber Costa
Quoted 9 lines · Gleb Natapov
Quoted 8 lines · Glauber Costa

This is a pretty mechanical change. To make code look closer to upstream qemu, I'm renaming kvm_context_t to KVMState. Mid term goal here is to start sharing code whereas possible.

Avi, please apply, or I'll send you a video of myself dancing naked.

Quoted 6 lines

You can start recording it since I doubt this patch will apply cleanly to today's master (other mechanical change was applied). Regardless, I think trying to use bits of qemu kvm is dangerous. It has similar function with same names, but with different assumptions about conditional they can be executed in (look at commit a5ddb119). I actually prefer to be different enough to not call upstream qemu function by mistake.

I did it against today's master. If new patches came in, is just a matter of regenerating this, since it is, as I said, mechanical.

Quoted 7 lines
Quoted 5 lines

Also, as we don't compile in upstream functions yet (kvm-all.c and kvm.c are not included in the final object), there is no such risk. Of course, I am aiming towards it, but the first step will be to change the name of conflicting functions until we can pick qemu's implementation, in which case the former will just go away.

That is the point. We can't just pick qemu's implementation most of the times.

"until we can pick up qemu's implementation" potentially involves replacing that particular piece with upstream version first.

Quoted 10 lines
Quoted 5 lines

If we are serious about merging qemu-kvm into qemu, I don't see a way out of it. We should start changing things this way to accomodate it. Different enough won't do.

I don't really like the idea to morph working implementation to look like non-working one. I do agree that qemu-kvm should be cleaned substantially before going upstream. Upstream qemu kvm should go away than. I don't see much work done to enhance it anyway.

Quoted 6 lines
Quoted 3 lines

this first phase has nothing to do with functionality. To begin with, KVMState is qemu style, kvm_context_t is not, like it or not (I don't).

I am not against this mechanical change at all, don't get me wrong. I don't want to mix two kvm implementation together in strange ways.

too late for not wanting anything strange to happen ;-)

But I do believe this is the way to turn qemu-kvm.git into something that feeds qemu.git. And that's what we all want.

#7 lore raw
Quoted 8 lines · Glauber Costa
Quoted 6 lines
Quoted 3 lines

this first phase has nothing to do with functionality. To begin with, KVMState is qemu style, kvm_context_t is not, like it or not (I don't).

I am not against this mechanical change at all, don't get me wrong. I don't want to mix two kvm implementation together in strange ways.

too late for not wanting anything strange to happen ;-)

You are right, I should have said "in stranger ways".

Quoted 2 lines

But I do believe this is the way to turn qemu-kvm.git into something that feeds qemu.git. And that's what we all want.

Disagree with first part, agree with second :)

--
Gleb.

#8 lore raw
In reply to Glauber Costa
Quoted 5 lines · Glauber Costa

This is a pretty mechanical change. To make code look closer to upstream qemu, I'm renaming kvm_context_t to KVMState. Mid term goal here is to start sharing code whereas possible.

Doesn't apply.

Also, it's a little fishy. We now have two KVMState types, but they're pretty different.

What we could do is embed a kvm_context_t variable in the real KVMState, and start using that. Then, we could, function by function, use the upstream KVMState functionality and remove the corresponding kvm_context_t functionality.

Quoted 3 lines

Avi, please apply, or I'll send you a video of myself dancing naked.

The list has a size limit, so don't attach a huge video. Post a URL instead.

Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
#9 lore raw
Quoted 9 lines · Avi Kivity
Quoted 5 lines · Glauber Costa

This is a pretty mechanical change. To make code look closer to upstream qemu, I'm renaming kvm_context_t to KVMState. Mid term goal here is to start sharing code whereas possible.

Doesn't apply.

Quoted 7 lines

Also, it's a little fishy. We now have two KVMState types, but they're pretty different.

What we could do is embed a kvm_context_t variable in the real KVMState, and start using that. Then, we could, function by function, use the upstream KVMState functionality and remove the corresponding kvm_context_t functionality.

That would be great and was also what I had vaguely in mind. Likely there are already fields that can be used from KVMState (fd and vmfd?).

Quoted 8 lines
Quoted 4 lines

Avi, please apply, or I'll send you a video of myself dancing naked.

The list has a size limit, so don't attach a huge video. Post a URL instead.

But only after 22:00 - in case underages are reading.

Jan

#10 lore raw
Quoted 9 lines · Jan Kiszka
Quoted 5 lines

What we could do is embed a kvm_context_t variable in the real KVMState, and start using that. Then, we could, function by function, use the upstream KVMState functionality and remove the corresponding kvm_context_t functionality.

That would be great and was also what I had vaguely in mind. Likely there are already fields that can be used from KVMState (fd and vmfd?).

Obvious candidates are to start using kvm_*_ioctl() everywhere.

Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.