[libvirt] [PATCH v2 15/25] src/xenxs:Refactor code formating memory config

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


David Kiarie wrote:
> From: Kiarie Kahurani <davidkiarie4 at gmail.com>
>
> introduce function
>  xenFormatXMMem(virConfPtr conf, .......);
> which formats mem and max-mem instead.This could be joined into
> XenFormatXMGeneralMeta but I separated them for consistency
>
> signed-off-by: David Kiarie<davidkiarie4 at gmail.com>
> ---
>  src/xenxs/xen_xm.c | 24 +++++++++++++++++-------
>  1 file changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
> index ae474a4..78dc949 100644
> --- a/src/xenxs/xen_xm.c
> +++ b/src/xenxs/xen_xm.c
> @@ -1670,6 +1670,22 @@ int xenFormatXMGeneralMeta(virConfPtr conf, virDomainDefPtr def)
>      return 0;
>  }
>  
> +
> +static
> +int xenFormatXMMem(virConfPtr conf, virDomainDefPtr def)
> +{
> +    if (xenXMConfigSetInt(conf, "maxmem",
> +                          VIR_DIV_UP(def->mem.max_balloon, 1024)) < 0)
> +        return -1;
> +
> +    if (xenXMConfigSetInt(conf, "memory",
> +                          VIR_DIV_UP(def->mem.cur_balloon, 1024)) < 0)
> +        return -1;
> +
> +    return 0;
> +}
> +
> +
>  virConfPtr xenFormatXM(virConnectPtr conn,
>                                     virDomainDefPtr def,
>                                     int xendConfigVersion)
> @@ -1686,14 +1702,8 @@ virConfPtr xenFormatXM(virConnectPtr conn,
>          goto cleanup;
>      if (xenFormatXMGeneralMeta(conf, def) < 0)
>          goto cleanup;
> -    if (xenXMConfigSetInt(conf, "maxmem",
> -                          VIR_DIV_UP(def->mem.max_balloon, 1024)) < 0)
> +    if (xenFormatXMMem(conf, def) < 0)
>          goto cleanup;
> -
> -    if (xenXMConfigSetInt(conf, "memory",
> -                          VIR_DIV_UP(def->mem.cur_balloon, 1024)) < 0)
> -        goto cleanup;
> -
>   

Same comment here about preserving the whitespace.

Regards,
Jim

>      if (xenXMConfigSetInt(conf, "vcpus", def->maxvcpus) < 0)
>          goto cleanup;
>      /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
>   




More information about the libvir-list mailing list