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

Paolo Bonzini
2011-08-30T08:40:48Z

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