qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Juan Quintela <quintela@redhat.com>
Cc: Bharata B Rao <bharata@linux.vnet.ibm.com>,
	qemu-devel@nongnu.org, qemu-ppc@nongnu.org,
	sam.bobroff@au1.ibm.com, rnsastry@linux.vnet.ibm.com,
	sjitindarsingh@gmail.com,
	"Dr . David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 1/3] migration: Introduce unregister_savevm_live()
Date: Wed, 24 May 2017 16:36:17 +1000	[thread overview]
Message-ID: <20170524063617.GX30246@umbus.fritz.box> (raw)
In-Reply-To: <87a8627opg.fsf@secure.mitica>

[-- Attachment #1: Type: text/plain, Size: 3426 bytes --]

On Wed, May 24, 2017 at 08:28:59AM +0200, Juan Quintela wrote:
> Bharata B Rao <bharata@linux.vnet.ibm.com> wrote:
> > Introduce a new function unregister_savevm_live() to unregister the vmstate
> > handlers registered via register_savevm_live().
> >
> > register_savevm() allocates SaveVMHandlers while register_savevm_live()
> > gets passed with SaveVMHandlers. During unregistration, we  want to
> > free SaveVMHandlers in the former case but not free in the latter case.
> > Hence this new API is needed to differentiate this.
> >
> > This new API will be needed by PowerPC to unregister the HTAB savevm
> > handlers.
> >
> > Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
> > Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> > Cc: Juan Quintela <quintela@redhat.com>
> > Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
> 
> Hi
> 
> How about this one?
> I just test compiled it.
> 
> Advantage from my point of view is that we always do the right thing.
> And as migration code already knows if it has to be freed or not, I
> think it is a better API.
> 
> What do you think?

I think this is a better approach.  Do you want to push this one
directly, Juan, or do you want me to take it through my tree?

> 
> Later, Juan.
> 
> commit 6e71fac7a9c29cef9625135c58ce59ccfbb3b86f
> Author: Juan Quintela <quintela@redhat.com>
> Date:   Wed May 24 08:25:06 2017 +0200
> 
>     migration: Allow to free save_live handlers
>     
>     Migration save_live handlers have an ops member that is not dynamic.
>     Add a new member is_allocated that remembers if ops has to be freed.
>     
>     Signed-off-by: Juan Quintela <quintela@redhat.com>
> 
> diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> index f97411d..1d20e30 100644
> --- a/include/migration/vmstate.h
> +++ b/include/migration/vmstate.h
> @@ -57,6 +57,8 @@ typedef struct SaveVMHandlers {
>                                uint64_t *non_postcopiable_pending,
>                                uint64_t *postcopiable_pending);
>      LoadStateHandler *load_state;
> +    /* Has been allocated by migratation code */
> +    bool is_allocated;
>  } SaveVMHandlers;
>  
>  int register_savevm(DeviceState *dev,
> diff --git a/migration/savevm.c b/migration/savevm.c
> index d971e5e..187f386 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -628,6 +628,7 @@ int register_savevm(DeviceState *dev,
>      SaveVMHandlers *ops = g_new0(SaveVMHandlers, 1);
>      ops->save_state = save_state;
>      ops->load_state = load_state;
> +    ops->is_allocated = true;
>      return register_savevm_live(dev, idstr, instance_id, version_id,
>                                  ops, opaque);
>  }
> @@ -651,7 +652,9 @@ void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque)
>          if (strcmp(se->idstr, id) == 0 && se->opaque == opaque) {
>              QTAILQ_REMOVE(&savevm_state.handlers, se, entry);
>              g_free(se->compat);
> -            g_free(se->ops);
> +            if (se->ops->is_allocated) {
> +                g_free(se->ops);
> +            }
>              g_free(se);
>          }
>      }
> 

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2017-05-24  6:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-24  4:53 [Qemu-devel] [PATCH v3 0/3] ppc/spapr: Fix migration of radix guests Bharata B Rao
2017-05-24  4:53 ` [Qemu-devel] [PATCH v3 1/3] migration: Introduce unregister_savevm_live() Bharata B Rao
2017-05-24  6:28   ` Juan Quintela
2017-05-24  6:36     ` David Gibson [this message]
2017-05-24  7:18       ` Juan Quintela
2017-05-24  4:53 ` [Qemu-devel] [PATCH v3 2/3] spapr: Unregister HPT savevm handlers for radix guests Bharata B Rao
2017-05-26  4:11   ` Bharata B Rao
2017-05-24  4:53 ` [Qemu-devel] [PATCH v3 3/3] spapr: Fix migration of Radix guests Bharata B Rao
2017-05-24  6:16   ` Suraj Jitindar Singh
2017-05-26  5:55 ` [Qemu-devel] [PATCH v3 0/3] ppc/spapr: Fix migration of radix guests David Gibson

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=20170524063617.GX30246@umbus.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=bharata@linux.vnet.ibm.com \
    --cc=dgilbert@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=rnsastry@linux.vnet.ibm.com \
    --cc=sam.bobroff@au1.ibm.com \
    --cc=sjitindarsingh@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).