From: Peter Xu <peterx@redhat.com>
To: Juan Quintela <quintela@redhat.com>
Cc: qemu-devel@nongnu.org, dgilbert@redhat.com, lvivier@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2] migration: Allow unregister of save_live handlers
Date: Wed, 24 May 2017 19:24:12 +0800 [thread overview]
Message-ID: <20170524112412.GK3873@pxdev.xzpeter.org> (raw)
In-Reply-To: <20170524112152.23226-1-quintela@redhat.com>
On Wed, May 24, 2017 at 01:21:52PM +0200, Juan Quintela wrote:
> Migration non save_live handlers have an ops member that is
> dinamically allocated by migration code. Save_live handlers have it
> passed as argument and are responsability of the caller. Add a new
> member is_allocated that remembers if ops has to be freed. This
> allows unregister_savevm() to work with save_live handlers.
>
> Signed-off-by: Juan Quintela <quintela@redhat.com>
I thought Laurent will prepare one patch that will directly remove
existing register_savevm() callers, no?
>
> ---
>
> check that se->ops is not NULL (thanks peterx)
> ---
> include/migration/vmstate.h | 2 ++
> migration/savevm.c | 5 ++++-
> 2 files changed, 6 insertions(+), 1 deletion(-)
>
> 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..569add3 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 && se->ops->is_allocated) {
> + g_free(se->ops);
> + }
> g_free(se);
> }
> }
> --
> 2.9.3
>
--
Peter Xu
next prev parent reply other threads:[~2017-05-24 11:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-24 11:21 [Qemu-devel] [PATCH v2] migration: Allow unregister of save_live handlers Juan Quintela
2017-05-24 11:24 ` Peter Xu [this message]
2017-05-24 11:33 ` Juan Quintela
2017-05-30 14:47 ` Dr. David Alan Gilbert
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=20170524112412.GK3873@pxdev.xzpeter.org \
--to=peterx@redhat.com \
--cc=dgilbert@redhat.com \
--cc=lvivier@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.