On 06/02/2017 12:25 PM, John Ferlan wrote:
> Move the function into nwfilterobj, rename it to virNWFilterObjSaveConfig,
> and alter the order of the arguments.
> 
> Signed-off-by: John Ferlan <jfer...@redhat.com>
> ---
>  src/conf/nwfilter_conf.c       | 27 ---------------------------
>  src/conf/nwfilter_conf.h       |  4 ----
>  src/conf/virnwfilterobj.c      | 30 +++++++++++++++++++++++++++++-
>  src/conf/virnwfilterobj.h      |  4 ++++
>  src/libvirt_private.syms       |  2 +-
>  src/nwfilter/nwfilter_driver.c |  2 +-
>  6 files changed, 35 insertions(+), 34 deletions(-)
> 
> diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
> index fba792a..bcff4b6 100644
> --- a/src/conf/nwfilter_conf.c
> +++ b/src/conf/nwfilter_conf.c
> @@ -2766,33 +2766,6 @@ virNWFilterDefParseFile(const char *filename)
>  }
>  
>  
> -int
> -virNWFilterSaveConfig(const char *configDir,
> -                      virNWFilterDefPtr def)
> -{
> -    int ret = -1;
> -    char *xml;
> -    char uuidstr[VIR_UUID_STRING_BUFLEN];
> -    char *configFile = NULL;
> -
> -    if (!(xml = virNWFilterDefFormat(def)))
> -        goto cleanup;
> -
> -    if (!(configFile = virFileBuildPath(configDir, def->name, ".xml")))
> -        goto cleanup;
> -
> -    virUUIDFormat(def->uuid, uuidstr);
> -    ret = virXMLSaveFile(configFile,
> -                         virXMLPickShellSafeComment(def->name, uuidstr),
> -                         "nwfilter-edit", xml);
> -
> - cleanup:
> -    VIR_FREE(configFile);
> -    VIR_FREE(xml);
> -    return ret;
> -}
> -
> -
>  int nCallbackDriver;
>  #define MAX_CALLBACK_DRIVER 10
>  static virNWFilterCallbackDriverPtr callbackDrvArray[MAX_CALLBACK_DRIVER];
> diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h
> index 4bf5b7c..ac6aee9 100644
> --- a/src/conf/nwfilter_conf.h
> +++ b/src/conf/nwfilter_conf.h
> @@ -580,10 +580,6 @@ virNWFilterDefParseNode(xmlDocPtr xml,
>  char *
>  virNWFilterDefFormat(const virNWFilterDef *def);
>  
> -int
> -virNWFilterSaveConfig(const char *configDir,
> -                      virNWFilterDefPtr def);
> -
>  virNWFilterDefPtr
>  virNWFilterDefParseString(const char *xml);
>  
> diff --git a/src/conf/virnwfilterobj.c b/src/conf/virnwfilterobj.c
> index 0343c0a..5834b9d 100644
> --- a/src/conf/virnwfilterobj.c
> +++ b/src/conf/virnwfilterobj.c
> @@ -478,6 +478,34 @@ virNWFilterObjListExport(virConnectPtr conn,
>  }
>  
>  
> +int
> +virNWFilterObjSaveConfig(virNWFilterObjPtr obj,
> +                         const char *configDir)
> +{
> +    virNWFilterDefPtr def = obj->def;
> +    int ret = -1;
> +    char *xml;
> +    char uuidstr[VIR_UUID_STRING_BUFLEN];
> +    char *configFile = NULL;
> +
> +    if (!(xml = virNWFilterDefFormat(def)))
> +        goto cleanup;
> +
> +    if (!(configFile = virFileBuildPath(configDir, def->name, ".xml")))
> +        goto cleanup;
> +
> +    virUUIDFormat(def->uuid, uuidstr);
> +    ret = virXMLSaveFile(configFile,
> +                         virXMLPickShellSafeComment(def->name, uuidstr),
> +                         "nwfilter-edit", xml);
> +
> + cleanup:
> +    VIR_FREE(configFile);
> +    VIR_FREE(xml);
> +    return ret;
> +}
> +
> +
>  static virNWFilterObjPtr
>  virNWFilterObjListLoadConfig(virNWFilterObjListPtr nwfilters,
>                               const char *configDir,
> @@ -512,7 +540,7 @@ virNWFilterObjListLoadConfig(virNWFilterObjListPtr 
> nwfilters,
>       * object as a future load would regenerate a UUID and try again,
>       * but the existing config would still exist and can be used. */
>      if (!objdef->uuid_specified &&
> -        virNWFilterSaveConfig(configDir, objdef) < 0)
> +        virNWFilterObjSaveConfig(objdef, configDir) < 0)

How can this work? objdef is pointer to def not obj. Anyway, since we
are not going to save config here:

ACK

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to