diff mbox

[1/5] Support for vm_stop from the migration thread

Message ID 2e43e3a409b7fa5f4781e30f3d7b7e56aa5d1fb0.1314398066.git.udeshpan@redhat.com
State New
Headers show

Commit Message

Umesh Deshpande Aug. 27, 2011, 6:09 p.m. UTC
Currently, when any thread other than iothread calls vm_stop, it is scheduled to
be executed later by the iothread. This patch allows the execution of vm_stop
from threads other than iothread. This is especially helpful when the migration is
moved into a separate thread.

Signed-off-by: Umesh Deshpande <udeshpan@redhat.com>
---
 cpus.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Comments

Marcelo Tosatti Aug. 29, 2011, 4:56 p.m. UTC | #1
On Sat, Aug 27, 2011 at 02:09:44PM -0400, Umesh Deshpande wrote:
> Currently, when any thread other than iothread calls vm_stop, it is scheduled to
> be executed later by the iothread. This patch allows the execution of vm_stop
> from threads other than iothread. This is especially helpful when the migration is
> moved into a separate thread.
> 
> Signed-off-by: Umesh Deshpande <udeshpan@redhat.com>
> ---
>  cpus.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/cpus.c b/cpus.c
> index de70e02..f35f683 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -122,8 +122,8 @@ static void do_vm_stop(int reason)
>  {
>      if (vm_running) {
>          cpu_disable_ticks();
> -        vm_running = 0;
>          pause_all_vcpus();
> +        vm_running = 0;
>          vm_state_notify(0, reason);
>          qemu_aio_flush();
>          bdrv_flush_all();

Why this change?
Paolo Bonzini Aug. 30, 2011, 8:40 a.m. UTC | #2
On 08/29/2011 06:56 PM, Marcelo Tosatti wrote:
>> >  diff --git a/cpus.c b/cpus.c
>> >  index de70e02..f35f683 100644
>> >  --- a/cpus.c
>> >  +++ b/cpus.c
>> >  @@ -122,8 +122,8 @@ static void do_vm_stop(int reason)
>> >    {
>> >        if (vm_running) {
>> >            cpu_disable_ticks();
>> >  -        vm_running = 0;
>> >            pause_all_vcpus();
>> >  +        vm_running = 0;
>> >            vm_state_notify(0, reason);
>> >            qemu_aio_flush();
>> >            bdrv_flush_all();
> Why this change?

Without it, you could have two threads calling into do_vm_stop and the 
second would not wait for all CPUs to be paused.  Still not perfect as 
you'd get double notifications, you would need a condition variable or 
QemuEvent (from the RCU series) for that.

Paolo
diff mbox

Patch

diff --git a/cpus.c b/cpus.c
index de70e02..f35f683 100644
--- a/cpus.c
+++ b/cpus.c
@@ -122,8 +122,8 @@  static void do_vm_stop(int reason)
 {
     if (vm_running) {
         cpu_disable_ticks();
-        vm_running = 0;
         pause_all_vcpus();
+        vm_running = 0;
         vm_state_notify(0, reason);
         qemu_aio_flush();
         bdrv_flush_all();
@@ -1027,7 +1027,7 @@  void cpu_stop_current(void)
 
 void vm_stop(int reason)
 {
-    if (!qemu_thread_is_self(&io_thread)) {
+    if (cpu_single_env) {
         qemu_system_vmstop_request(reason);
         /*
          * FIXME: should not return to device code in case