Patchwork [PATCHv2,2/6] cpus: flush all requests on each vm stop

login
register
mail settings
Submitter Michael S. Tsirkin
Date Nov. 24, 2010, 3:52 p.m.
Message ID <732b3c1a27c2d274989328218bb5e831b28686dd.1290613959.git.mst@redhat.com>
Download mbox | patch
Permalink /patch/72915/
State New
Headers show

Comments

Michael S. Tsirkin - Nov. 24, 2010, 3:52 p.m.
Make sure disk is in consistent state.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Jason Wang <jasowang@redhat.com>
---
 cpus.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Marcelo Tosatti - Nov. 30, 2010, 12:45 p.m.
On Wed, Nov 24, 2010 at 05:52:58PM +0200, Michael S. Tsirkin wrote:
> Make sure disk is in consistent state.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> Tested-by: Jason Wang <jasowang@redhat.com>
> ---
>  cpus.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/cpus.c b/cpus.c
> index 91a0fb1..d421a96 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -110,6 +110,8 @@ static void do_vm_stop(int reason)
>          cpu_disable_ticks();
>          vm_running = 0;
>          pause_all_vcpus();
> +        qemu_aio_flush();
> +        bdrv_flush_all();

Can you move these after vm_state_notify? qemu-kvm stops vcpus there.

>          vm_state_notify(0, reason);
>          monitor_protocol_event(QEVENT_STOP, NULL);
>      }
Michael S. Tsirkin - Nov. 30, 2010, 1:14 p.m.
On Tue, Nov 30, 2010 at 10:45:40AM -0200, Marcelo Tosatti wrote:
> On Wed, Nov 24, 2010 at 05:52:58PM +0200, Michael S. Tsirkin wrote:
> > Make sure disk is in consistent state.
> > 
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > Tested-by: Jason Wang <jasowang@redhat.com>
> > ---
> >  cpus.c |    2 ++
> >  1 files changed, 2 insertions(+), 0 deletions(-)
> > 
> > diff --git a/cpus.c b/cpus.c
> > index 91a0fb1..d421a96 100644
> > --- a/cpus.c
> > +++ b/cpus.c
> > @@ -110,6 +110,8 @@ static void do_vm_stop(int reason)
> >          cpu_disable_ticks();
> >          vm_running = 0;
> >          pause_all_vcpus();
> > +        qemu_aio_flush();
> > +        bdrv_flush_all();
> 
> Can you move these after vm_state_notify? qemu-kvm stops vcpus there.

Right. Other devices might do the same. Will do.

> >          vm_state_notify(0, reason);
> >          monitor_protocol_event(QEVENT_STOP, NULL);
> >      }
> 
>
Marcelo Tosatti - Nov. 30, 2010, 1:46 p.m.
On Tue, Nov 30, 2010 at 03:34:29PM +0200, Michael S. Tsirkin wrote:
> On Tue, Nov 30, 2010 at 10:45:40AM -0200, Marcelo Tosatti wrote:
> > On Wed, Nov 24, 2010 at 05:52:58PM +0200, Michael S. Tsirkin wrote:
> > > Make sure disk is in consistent state.
> > > 
> > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > > Tested-by: Jason Wang <jasowang@redhat.com>
> > > ---
> > >  cpus.c |    2 ++
> > >  1 files changed, 2 insertions(+), 0 deletions(-)
> > > 
> > > diff --git a/cpus.c b/cpus.c
> > > index 91a0fb1..d421a96 100644
> > > --- a/cpus.c
> > > +++ b/cpus.c
> > > @@ -110,6 +110,8 @@ static void do_vm_stop(int reason)
> > >          cpu_disable_ticks();
> > >          vm_running = 0;
> > >          pause_all_vcpus();
> > > +        qemu_aio_flush();
> > > +        bdrv_flush_all();
> > 
> > Can you move these after vm_state_notify? qemu-kvm stops vcpus there.
> > 
> > >          vm_state_notify(0, reason);
> > >          monitor_protocol_event(QEVENT_STOP, NULL);
> > >      }
> 
> Like this:
> 
> cpus: flush all requests on each vm stop
> 
> Make sure disk is in consistent state.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> Tested-by: Jason Wang <jasowang@redhat.com>
> 
> ---
> 
> diff --git a/cpus.c b/cpus.c
> index 91a0fb1..d421a96 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -110,6 +110,8 @@ static void do_vm_stop(int reason)
>          cpu_disable_ticks();
>          vm_running = 0;
>          pause_all_vcpus();
> +        qemu_aio_flush();
> +        bdrv_flush_all();
>          vm_state_notify(0, reason);
>          monitor_protocol_event(QEVENT_STOP, NULL);
>      }

No, after vm_state_notify.

Patch

diff --git a/cpus.c b/cpus.c
index 91a0fb1..d421a96 100644
--- a/cpus.c
+++ b/cpus.c
@@ -110,6 +110,8 @@  static void do_vm_stop(int reason)
         cpu_disable_ticks();
         vm_running = 0;
         pause_all_vcpus();
+        qemu_aio_flush();
+        bdrv_flush_all();
         vm_state_notify(0, reason);
         monitor_protocol_event(QEVENT_STOP, NULL);
     }