[libvirt] [PATCH v2 14/25] src/xenxs:Refactor code formating general config

Jim Fehlig jfehlig at suse.com
Mon Aug 4 20:26:01 UTC 2014


David Kiarie wrote:
> From: Kiarie Kahurani <davidkiarie4 at gmail.com>
>
> introduce function
>  xenFormatXMGeneralMeta(virConfPtr conf, .......);
> which formats UUID and name instead
>
> signed-off-by: David Kiarie<davidkiarie4 at gmail.com>
> ---
>  src/xenxs/xen_xm.c | 24 +++++++++++++++---------
>  1 file changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
> index 289f0ad..ae474a4 100644
> --- a/src/xenxs/xen_xm.c
> +++ b/src/xenxs/xen_xm.c
> @@ -1655,6 +1655,20 @@ xenFormatXMPCI(virConfPtr conf,
>  /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
>     either 32, or 64 on a platform where long is big enough.  */
>  verify(MAX_VIRT_CPUS <= sizeof(1UL) * CHAR_BIT);
> +static
> +int xenFormatXMGeneralMeta(virConfPtr conf, virDomainDefPtr def)
> +{
> +    char uuid[VIR_UUID_STRING_BUFLEN];
> +
> +    if (xenXMConfigSetString(conf, "name", def->name) < 0)
> +        return -1;
> +
> +    virUUIDFormat(def->uuid, uuid);
> +    if (xenXMConfigSetString(conf, "uuid", uuid) < 0)
> +        return -1;
> +
> +    return 0;
> +}
>  
>  virConfPtr xenFormatXM(virConnectPtr conn,
>                                     virDomainDefPtr def,
> @@ -1665,21 +1679,13 @@ virConfPtr xenFormatXM(virConnectPtr conn,
>      size_t i;
>      char *cpus = NULL;
>      const char *lifecycle;
> -    char uuid[VIR_UUID_STRING_BUFLEN];
>      virConfValuePtr diskVal = NULL;
>      virConfValuePtr netVal = NULL;
>  
>      if (!(conf = virConfNew()))
>          goto cleanup;
> -
> -
>   

For readability and consistency, I'd leave one of these blank lines.

> -    if (xenXMConfigSetString(conf, "name", def->name) < 0)
> +    if (xenFormatXMGeneralMeta(conf, def) < 0)
>          goto cleanup;
> -
>   

And this one.

> -    virUUIDFormat(def->uuid, uuid);
> -    if (xenXMConfigSetString(conf, "uuid", uuid) < 0)
> -        goto cleanup;
> -
>   

And this one too.

Regards,
Jim

>      if (xenXMConfigSetInt(conf, "maxmem",
>                            VIR_DIV_UP(def->mem.max_balloon, 1024)) < 0)
>          goto cleanup;
>   




More information about the libvir-list mailing list