qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC PATCH v2 1/4] migration: Introduce unregister_save


From: David Gibson
Subject: Re: [Qemu-devel] [RFC PATCH v2 1/4] migration: Introduce unregister_savevm_live()
Date: Fri, 19 May 2017 17:33:03 +1000
User-agent: Mutt/1.8.0 (2017-02-23)

On Fri, May 19, 2017 at 11:10:36AM +0530, Bharata B Rao 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 <address@hidden>

Reviewed-by: David Gibson <address@hidden>

I could take this through my tree, but it would need an ACK from Dave
Gilbert or Juan Quintela.

> ---
>  include/migration/vmstate.h |  1 +
>  migration/savevm.c          | 17 +++++++++++++++--
>  2 files changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> index 8489659..02a1bac 100644
> --- a/include/migration/vmstate.h
> +++ b/include/migration/vmstate.h
> @@ -79,6 +79,7 @@ int register_savevm_live(DeviceState *dev,
>                           void *opaque);
>  
>  void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque);
> +void unregister_savevm_live(DeviceState *dev, const char *idstr, void 
> *opaque);
>  
>  typedef struct VMStateInfo VMStateInfo;
>  typedef struct VMStateDescription VMStateDescription;
> diff --git a/migration/savevm.c b/migration/savevm.c
> index f5e8194..4ef6fdc 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -630,7 +630,8 @@ int register_savevm(DeviceState *dev,
>                                  ops, opaque);
>  }
>  
> -void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque)
> +static void unregister_savevm_common(DeviceState *dev, const char *idstr,
> +                                     void *opaque, bool free_savevmhandlers)
>  {
>      SaveStateEntry *se, *new_se;
>      char id[256] = "";
> @@ -649,12 +650,24 @@ 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 (free_savevmhandlers) {
> +                g_free(se->ops);
> +            }
>              g_free(se);
>          }
>      }
>  }
>  
> +void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque)
> +{
> +    unregister_savevm_common(dev, idstr, opaque, true);
> +}
> +
> +void unregister_savevm_live(DeviceState *dev, const char *idstr, void 
> *opaque)
> +{
> +    unregister_savevm_common(dev, idstr, opaque, false);
> +}
> +
>  int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
>                                     const VMStateDescription *vmsd,
>                                     void *opaque, int alias_id,

-- 
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: signature.asc
Description: PGP signature


reply via email to

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