public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: kvm@vger.kernel.org
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Subject: [patch 6/6] qemu-kvm: use reset handler for vcpus
Date: Tue, 23 Mar 2010 13:53:39 -0300	[thread overview]
Message-ID: <20100323165347.689886209@amt.cnet> (raw)
In-Reply-To: 20100323165333.062022913@amt.cnet

[-- Attachment #1: register-reset-vcpu --]
[-- Type: text/plain, Size: 1978 bytes --]

Hook into the reset handlers instead of using custom code in
qemu_kvm_system_reset.

Also move kvm_arch_init_vcpu to kvm_create_vcpu.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: qemu-kvm-cleanups/qemu-kvm.c
===================================================================
--- qemu-kvm-cleanups.orig/qemu-kvm.c
+++ qemu-kvm-cleanups/qemu-kvm.c
@@ -439,6 +439,13 @@ void kvm_disable_pit_creation(kvm_contex
     kvm->no_pit_creation = 1;
 }
 
+static void kvm_reset_vcpu(void *opaque)
+{
+    CPUState *env = opaque;
+
+    kvm_arch_cpu_reset(env);
+}
+
 static void kvm_create_vcpu(CPUState *env, int id)
 {
     long mmap_size;
@@ -473,6 +480,11 @@ static void kvm_create_vcpu(CPUState *en
                s->coalesced_mmio * PAGE_SIZE;
 #endif
 
+    r = kvm_arch_init_vcpu(env);
+    if (r == 0) {
+        qemu_register_reset(kvm_reset_vcpu, env);
+    }
+
     return;
   err_fd:
     close(env->kvm_fd);
@@ -1777,17 +1789,10 @@ static void setup_kernel_sigmask(CPUStat
 
 static void qemu_kvm_system_reset(void)
 {
-    CPUState *penv = first_cpu;
-
     pause_all_threads();
 
     qemu_system_reset();
 
-    while (penv) {
-        kvm_arch_cpu_reset(penv);
-        penv = (CPUState *) penv->next_cpu;
-    }
-
     resume_all_threads();
 }
 
@@ -1829,7 +1834,6 @@ static void *ap_main_loop(void *_env)
     env->thread_id = kvm_get_thread_id();
     sigfillset(&signals);
     sigprocmask(SIG_BLOCK, &signals, NULL);
-    kvm_create_vcpu(env, env->cpu_index);
 
 #ifdef CONFIG_KVM_DEVICE_ASSIGNMENT
     /* do ioperm for io ports of assigned devices */
@@ -1837,12 +1841,11 @@ static void *ap_main_loop(void *_env)
         on_vcpu(env, kvm_arch_do_ioperm, data);
 #endif
 
-    setup_kernel_sigmask(env);
-
     pthread_mutex_lock(&qemu_mutex);
     cpu_single_env = env;
 
-    kvm_arch_init_vcpu(env);
+    kvm_create_vcpu(env, env->cpu_index);
+    setup_kernel_sigmask(env);
 
     /* signal VCPU creation */
     current_env->created = 1;



  parent reply	other threads:[~2010-03-23 16:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-23 16:53 [patch 0/6] misc qemu-kvm cleanups Marcelo Tosatti
2010-03-23 16:53 ` [patch 1/6] remove kvm_update_dirty_pages_log call from ram_save_block Marcelo Tosatti
2010-03-23 16:53 ` [patch 2/6] make cpu_physical_memory_set_dirty_tracking equal to upstream Marcelo Tosatti
2010-03-23 16:53 ` [patch 3/6] remove unused bios_mem variable Marcelo Tosatti
2010-03-23 16:53 ` [patch 4/6] qemu-kvm: use upstream kvm_flush_coalesced_mmio_buffer Marcelo Tosatti
2010-03-23 16:53 ` [patch 5/6] qemu-kvm: remove unused qemu_kvm_get_dirty_pages Marcelo Tosatti
2010-03-23 16:53 ` Marcelo Tosatti [this message]
2010-03-24  9:42 ` [patch 0/6] misc qemu-kvm cleanups Avi Kivity

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=20100323165347.689886209@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=kvm@vger.kernel.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