qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Juan Quintela <quintela@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 8/9] vmstate: Create optional sections
Date: Mon, 18 May 2015 12:23:49 +0100	[thread overview]
Message-ID: <20150518112349.GG2201@work-vm> (raw)
In-Reply-To: <1431620920-19710-9-git-send-email-quintela@redhat.com>

* Juan Quintela (quintela@redhat.com) wrote:
> To make sections optional, we need to do it at the beggining of the code.

I didn't quite understand your description; but I think the reasoning
here is that to make a top level section optional, you need
to do it in the top level to avoid sending the section header.

> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  include/migration/vmstate.h |  2 ++
>  migration/vmstate.c         | 11 +++++++++++
>  savevm.c                    |  4 ++++
>  3 files changed, 17 insertions(+)
> 
> diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> index fc5e643..a8b59eb 100644
> --- a/include/migration/vmstate.h
> +++ b/include/migration/vmstate.h
> @@ -813,6 +813,8 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
>  void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
>                          void *opaque, QJSON *vmdesc);
> 
> +bool vmstate_save_needed(const VMStateDescription *vmsd, void *opaque);
> +
>  int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
>                                     const VMStateDescription *vmsd,
>                                     void *base, int alias_id,
> diff --git a/migration/vmstate.c b/migration/vmstate.c
> index 108995e..36dab84 100644
> --- a/migration/vmstate.c
> +++ b/migration/vmstate.c
> @@ -276,6 +276,17 @@ static void vmsd_desc_field_end(const VMStateDescription *vmsd, QJSON *vmdesc,
>      json_end_object(vmdesc);
>  }
> 
> +
> +bool vmstate_save_needed(const VMStateDescription *vmsd, void *opaque)
> +{
> +    if (vmsd->needed && !vmsd->needed(opaque)) {
> +        /* optional section not needed */
> +        return false;
> +    }
> +    return true;
> +}
> +
> +
>  void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
>                          void *opaque, QJSON *vmdesc)
>  {
> diff --git a/savevm.c b/savevm.c
> index 01770cd..2b4e554 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -763,6 +763,10 @@ void qemu_savevm_state_complete(QEMUFile *f)
>          if ((!se->ops || !se->ops->save_state) && !se->vmsd) {
>              continue;
>          }
> +        if (se->vmsd && !vmstate_save_needed(se->vmsd, se->opaque)) {
> +            continue;
> +        }
> +

You might like to add a trace_ for when you skip this, but otherwise fine.

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

>          trace_savevm_section_start(se->idstr, se->section_id);
> 
>          json_start_object(vmdesc, NULL);
> -- 
> 2.4.0
> 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

  reply	other threads:[~2015-05-18 11:23 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-14 16:28 [Qemu-devel] [PATCH 0/9] Optional toplevel sections Juan Quintela
2015-05-14 16:28 ` [Qemu-devel] [PATCH 1/9] migration: create savevm_state Juan Quintela
2015-05-18  9:15   ` Dr. David Alan Gilbert
2015-05-14 16:28 ` [Qemu-devel] [PATCH 2/9] migration: Use normal VMStateDescriptions for Subsections Juan Quintela
2015-05-18  9:54   ` Dr. David Alan Gilbert
2015-05-14 16:28 ` [Qemu-devel] [PATCH 3/9] runstate: Add runstate store Juan Quintela
2015-05-18 10:35   ` Dr. David Alan Gilbert
2015-06-17  0:28     ` Juan Quintela
2015-05-18 10:38   ` Denis V. Lunev
2015-05-18 14:50     ` Eric Blake
2015-06-17  0:55     ` Juan Quintela
2015-05-14 16:28 ` [Qemu-devel] [PATCH 4/9] runstate: create runstate_index function Juan Quintela
2015-05-18  9:58   ` Dr. David Alan Gilbert
2015-05-18 14:55     ` Eric Blake
2015-06-17  0:31       ` Juan Quintela
2015-06-17  0:55     ` Juan Quintela
2015-05-14 16:28 ` [Qemu-devel] [PATCH 5/9] runstate: migration allows more transitions now Juan Quintela
2015-05-14 16:28 ` [Qemu-devel] [PATCH 6/9] migration: create new section to store global state Juan Quintela
2015-05-18 10:23   ` Dr. David Alan Gilbert
2015-06-17  1:10     ` Juan Quintela
2015-05-14 16:28 ` [Qemu-devel] [PATCH 7/9] global_state: Make section optional Juan Quintela
2015-05-18 11:03   ` Dr. David Alan Gilbert
2015-06-17  1:25     ` Juan Quintela
2015-05-14 16:28 ` [Qemu-devel] [PATCH 8/9] vmstate: Create optional sections Juan Quintela
2015-05-18 11:23   ` Dr. David Alan Gilbert [this message]
2015-05-19  9:17   ` Dr. David Alan Gilbert
2015-05-14 16:28 ` [Qemu-devel] [PATCH 9/9] migration: Add configuration section Juan Quintela
2015-05-18 11:39   ` Dr. David Alan Gilbert
2015-06-17  1:39     ` Juan Quintela

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=20150518112349.GG2201@work-vm \
    --to=dgilbert@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 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).