diff mbox series

[1/3] migration: Allow ram_save_cleanup to be called with empty state

Message ID 20170915054404.19914-2-famz@redhat.com
State New
Headers show
Series [1/3] migration: Allow ram_save_cleanup to be called with empty state | expand

Commit Message

Fam Zheng Sept. 15, 2017, 5:44 a.m. UTC
So that we can do cleanup unconditionally at the end of main().

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 migration/ram.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Peter Xu Sept. 15, 2017, 6:41 a.m. UTC | #1
On Fri, Sep 15, 2017 at 01:44:02PM +0800, Fam Zheng wrote:
> So that we can do cleanup unconditionally at the end of main().
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  migration/ram.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/migration/ram.c b/migration/ram.c
> index e18b3e2d4f..37e6a71241 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -1365,6 +1365,9 @@ static void ram_save_cleanup(void *opaque)
>      RAMState **rsp = opaque;
>      RAMBlock *block;
>  
> +    if (!rsp || !*rsp) {
> +        return;
> +    }
>      /* caller have hold iothread lock or is in a bh, so there is
>       * no writing race against this migration_bitmap
>       */
> -- 
> 2.13.5
> 

Instead of take special care on RAM, how about check in
migrate_fd_cancel(), and return directly if migration_is_idle()?
Fam Zheng Sept. 15, 2017, 6:49 a.m. UTC | #2
On Fri, 09/15 14:41, Peter Xu wrote:
> On Fri, Sep 15, 2017 at 01:44:02PM +0800, Fam Zheng wrote:
> > So that we can do cleanup unconditionally at the end of main().
> > 
> > Signed-off-by: Fam Zheng <famz@redhat.com>
> > ---
> >  migration/ram.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/migration/ram.c b/migration/ram.c
> > index e18b3e2d4f..37e6a71241 100644
> > --- a/migration/ram.c
> > +++ b/migration/ram.c
> > @@ -1365,6 +1365,9 @@ static void ram_save_cleanup(void *opaque)
> >      RAMState **rsp = opaque;
> >      RAMBlock *block;
> >  
> > +    if (!rsp || !*rsp) {
> > +        return;
> > +    }
> >      /* caller have hold iothread lock or is in a bh, so there is
> >       * no writing race against this migration_bitmap
> >       */
> > -- 
> > 2.13.5
> > 
> 
> Instead of take special care on RAM, how about check in
> migrate_fd_cancel(), and return directly if migration_is_idle()?

This is not from migrate_fd_cancel(), but from qemu_savevm_state_cleanup(), so
that doesn't work.

Fam
Peter Xu Sept. 15, 2017, 6:56 a.m. UTC | #3
On Fri, Sep 15, 2017 at 02:49:07PM +0800, Fam Zheng wrote:
> On Fri, 09/15 14:41, Peter Xu wrote:
> > On Fri, Sep 15, 2017 at 01:44:02PM +0800, Fam Zheng wrote:
> > > So that we can do cleanup unconditionally at the end of main().
> > > 
> > > Signed-off-by: Fam Zheng <famz@redhat.com>
> > > ---
> > >  migration/ram.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > > 
> > > diff --git a/migration/ram.c b/migration/ram.c
> > > index e18b3e2d4f..37e6a71241 100644
> > > --- a/migration/ram.c
> > > +++ b/migration/ram.c
> > > @@ -1365,6 +1365,9 @@ static void ram_save_cleanup(void *opaque)
> > >      RAMState **rsp = opaque;
> > >      RAMBlock *block;
> > >  
> > > +    if (!rsp || !*rsp) {
> > > +        return;
> > > +    }
> > >      /* caller have hold iothread lock or is in a bh, so there is
> > >       * no writing race against this migration_bitmap
> > >       */
> > > -- 
> > > 2.13.5
> > > 
> > 
> > Instead of take special care on RAM, how about check in
> > migrate_fd_cancel(), and return directly if migration_is_idle()?
> 
> This is not from migrate_fd_cancel(), but from qemu_savevm_state_cleanup(), so
> that doesn't work.

Yeh I see the point.  But my logic still stands - we don't need to
cleanup anything if the migration is not really there.

I'm thinking whether we can put qemu_savevm_state_cleanup() into
migrate_fd_cancel() in some way, though I am still not 100% sure on
the colo part.  Anyway, I feel like a bit confusing we have two
cleanup functions.
Fam Zheng Sept. 15, 2017, 7:02 a.m. UTC | #4
On Fri, 09/15 14:56, Peter Xu wrote:
> On Fri, Sep 15, 2017 at 02:49:07PM +0800, Fam Zheng wrote:
> > On Fri, 09/15 14:41, Peter Xu wrote:
> > > On Fri, Sep 15, 2017 at 01:44:02PM +0800, Fam Zheng wrote:
> > > > So that we can do cleanup unconditionally at the end of main().
> > > > 
> > > > Signed-off-by: Fam Zheng <famz@redhat.com>
> > > > ---
> > > >  migration/ram.c | 3 +++
> > > >  1 file changed, 3 insertions(+)
> > > > 
> > > > diff --git a/migration/ram.c b/migration/ram.c
> > > > index e18b3e2d4f..37e6a71241 100644
> > > > --- a/migration/ram.c
> > > > +++ b/migration/ram.c
> > > > @@ -1365,6 +1365,9 @@ static void ram_save_cleanup(void *opaque)
> > > >      RAMState **rsp = opaque;
> > > >      RAMBlock *block;
> > > >  
> > > > +    if (!rsp || !*rsp) {
> > > > +        return;
> > > > +    }
> > > >      /* caller have hold iothread lock or is in a bh, so there is
> > > >       * no writing race against this migration_bitmap
> > > >       */
> > > > -- 
> > > > 2.13.5
> > > > 
> > > 
> > > Instead of take special care on RAM, how about check in
> > > migrate_fd_cancel(), and return directly if migration_is_idle()?
> > 
> > This is not from migrate_fd_cancel(), but from qemu_savevm_state_cleanup(), so
> > that doesn't work.
> 
> Yeh I see the point.  But my logic still stands - we don't need to
> cleanup anything if the migration is not really there.
> 
> I'm thinking whether we can put qemu_savevm_state_cleanup() into
> migrate_fd_cancel() in some way, though I am still not 100% sure on
> the colo part.  Anyway, I feel like a bit confusing we have two
> cleanup functions.

I agree, but I don't know what is the best way to clean this up: savevm and
migration seem a little independent from each other.

Fam
Peter Xu Sept. 15, 2017, 7:58 a.m. UTC | #5
On Fri, Sep 15, 2017 at 03:02:32PM +0800, Fam Zheng wrote:
> On Fri, 09/15 14:56, Peter Xu wrote:
> > On Fri, Sep 15, 2017 at 02:49:07PM +0800, Fam Zheng wrote:
> > > On Fri, 09/15 14:41, Peter Xu wrote:
> > > > On Fri, Sep 15, 2017 at 01:44:02PM +0800, Fam Zheng wrote:
> > > > > So that we can do cleanup unconditionally at the end of main().
> > > > > 
> > > > > Signed-off-by: Fam Zheng <famz@redhat.com>
> > > > > ---
> > > > >  migration/ram.c | 3 +++
> > > > >  1 file changed, 3 insertions(+)
> > > > > 
> > > > > diff --git a/migration/ram.c b/migration/ram.c
> > > > > index e18b3e2d4f..37e6a71241 100644
> > > > > --- a/migration/ram.c
> > > > > +++ b/migration/ram.c
> > > > > @@ -1365,6 +1365,9 @@ static void ram_save_cleanup(void *opaque)
> > > > >      RAMState **rsp = opaque;
> > > > >      RAMBlock *block;
> > > > >  
> > > > > +    if (!rsp || !*rsp) {
> > > > > +        return;
> > > > > +    }
> > > > >      /* caller have hold iothread lock or is in a bh, so there is
> > > > >       * no writing race against this migration_bitmap
> > > > >       */
> > > > > -- 
> > > > > 2.13.5
> > > > > 
> > > > 
> > > > Instead of take special care on RAM, how about check in
> > > > migrate_fd_cancel(), and return directly if migration_is_idle()?
> > > 
> > > This is not from migrate_fd_cancel(), but from qemu_savevm_state_cleanup(), so
> > > that doesn't work.
> > 
> > Yeh I see the point.  But my logic still stands - we don't need to
> > cleanup anything if the migration is not really there.
> > 
> > I'm thinking whether we can put qemu_savevm_state_cleanup() into
> > migrate_fd_cancel() in some way, though I am still not 100% sure on
> > the colo part.  Anyway, I feel like a bit confusing we have two
> > cleanup functions.
> 
> I agree, but I don't know what is the best way to clean this up: savevm and
> migration seem a little independent from each other.

After a 2nd thought I think this single patch is ok, at least it
allows qemu_savevm_state_cleanup() to be run without caring much about
migration state.  So:

Reviewed-by: Peter Xu <peterx@redhat.com>

Thanks,
diff mbox series

Patch

diff --git a/migration/ram.c b/migration/ram.c
index e18b3e2d4f..37e6a71241 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1365,6 +1365,9 @@  static void ram_save_cleanup(void *opaque)
     RAMState **rsp = opaque;
     RAMBlock *block;
 
+    if (!rsp || !*rsp) {
+        return;
+    }
     /* caller have hold iothread lock or is in a bh, so there is
      * no writing race against this migration_bitmap
      */