kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] remove kvm_init_ap from qemu code.
@ 2008-09-23 20:25 Glauber Costa
  2008-09-24  9:37 ` Avi Kivity
  0 siblings, 1 reply; 2+ messages in thread
From: Glauber Costa @ 2008-09-23 20:25 UTC (permalink / raw)
  To: kvm; +Cc: avi, aliguori

Call it as a special case for cpu 0 creation. This removes
a piece of kvm code from raw qemu.

Signed-off-by: Glauber Costa <glommer@redhat.com>
---
 qemu/qemu-kvm.c |   21 ++++++++++++---------
 qemu/qemu-kvm.h |    1 -
 qemu/vl.c       |    3 ---
 3 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index cfdf90f..62d797d 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -436,15 +436,7 @@ static void *ap_main_loop(void *_env)
     return NULL;
 }
 
-void kvm_init_new_ap(int cpu, CPUState *env)
-{
-    pthread_create(&vcpu_info[cpu].thread, NULL, ap_main_loop, env);
-
-    while (vcpu_info[cpu].created == 0)
-	qemu_cond_wait(&qemu_vcpu_cond);
-}
-
-int kvm_init_ap(void)
+static int kvm_init_ap(void)
 {
 #ifdef TARGET_I386
     kvm_tpr_opt_setup();
@@ -455,6 +447,17 @@ int kvm_init_ap(void)
     return 0;
 }
 
+void kvm_init_new_ap(int cpu, CPUState *env)
+{
+    if (!cpu)
+        kvm_init_ap();
+
+    pthread_create(&vcpu_info[cpu].thread, NULL, ap_main_loop, env);
+
+    while (vcpu_info[cpu].created == 0)
+	qemu_cond_wait(&qemu_vcpu_cond);
+}
+
 void qemu_kvm_notify_work(void)
 {
     uint64_t value = 1;
diff --git a/qemu/qemu-kvm.h b/qemu/qemu-kvm.h
index fd9d5d1..f8791b8 100644
--- a/qemu/qemu-kvm.h
+++ b/qemu/qemu-kvm.h
@@ -16,7 +16,6 @@ int kvm_main_loop(void);
 int kvm_qemu_init(void);
 int kvm_qemu_create_context(void);
 void kvm_init_new_ap(int cpu, CPUState *env);
-int kvm_init_ap(void);
 void kvm_qemu_destroy(void);
 void kvm_load_registers(CPUState *env);
 void kvm_save_registers(CPUState *env);
diff --git a/qemu/vl.c b/qemu/vl.c
index ad4d24b..9ec3c61 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -10080,9 +10080,6 @@ int main(int argc, char **argv)
         }
     }
 
-    if (kvm_enabled())
-	kvm_init_ap();
-
     machine->init(ram_size, vga_ram_size, boot_devices, ds,
                   kernel_filename, kernel_cmdline, initrd_filename, cpu_model);
 
-- 
1.5.5.1


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

* Re: [PATCH] remove kvm_init_ap from qemu code.
  2008-09-23 20:25 [PATCH] remove kvm_init_ap from qemu code Glauber Costa
@ 2008-09-24  9:37 ` Avi Kivity
  0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2008-09-24  9:37 UTC (permalink / raw)
  To: Glauber Costa; +Cc: kvm, aliguori

Glauber Costa wrote:
> Call it as a special case for cpu 0 creation. This removes
> a piece of kvm code from raw qemu.
>  
> +void kvm_init_new_ap(int cpu, CPUState *env)
> +{
> +    if (!cpu)
> +        kvm_init_ap();
> +
> +    pthread_create(&vcpu_info[cpu].thread, NULL, ap_main_loop, env);
> +
> +    while (vcpu_info[cpu].created == 0)
> +	qemu_cond_wait(&qemu_vcpu_cond);
> +}
> +
>   

kvm_init_ap() is machine-level initialization.  It's hacky to call it 
from cpu-level initialization.

Do we have a machine-level initialization hook?


[btw, !x makes sense when x is a boolean, pointer, or count.  Then it 
means "there is no x" or "there are no xs".  But when x is an index, !x 
means "x equals 0", so you may as well write that.

and don't get me started on !strcmp()]

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


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

end of thread, other threads:[~2008-09-24  9:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-23 20:25 [PATCH] remove kvm_init_ap from qemu code Glauber Costa
2008-09-24  9:37 ` Avi Kivity

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).