qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 8/9] vmstate: Create optional sections


From: Dr. David Alan Gilbert
Subject: Re: [Qemu-devel] [PATCH 8/9] vmstate: Create optional sections
Date: Tue, 19 May 2015 10:17:09 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

* Juan Quintela (address@hidden) wrote:
> To make sections optional, we need to do it at the beggining of the code.
> 
> Signed-off-by: Juan Quintela <address@hidden>

Do you also need to add this test to qemu_save_device_state ?

Dave

> ---
>  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;
> +        }
> +
>          trace_savevm_section_start(se->idstr, se->section_id);
> 
>          json_start_object(vmdesc, NULL);
> -- 
> 2.4.0
> 
> 
--
Dr. David Alan Gilbert / address@hidden / Manchester, UK



reply via email to

[Prev in Thread] Current Thread [Next in Thread]