[libvirt] [PATCH v2 17/25] src/xenxs:Refactor code formating event actions config

Jim Fehlig jfehlig at suse.com
Mon Aug 4 20:32:00 UTC 2014


David Kiarie wrote:
> From: Kiarie Kahurani <davidkiarie4 at gmail.com>
>
> introduce function
>   xenFormatXMEventActions(virConfPtr conf, .......);
> which formats event actions config instead
>
> signed-off-by: David Kiarie<davidkiarie4 at gmail.com>
> ---
>  src/xenxs/xen_xm.c | 64 ++++++++++++++++++++++++++++++------------------------
>  1 file changed, 36 insertions(+), 28 deletions(-)
>
> diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
> index 9d868d7..bb7979d 100644
> --- a/src/xenxs/xen_xm.c
> +++ b/src/xenxs/xen_xm.c
> @@ -1768,6 +1768,41 @@ int xenFormatXMTimeOffset(virConfPtr conf, virDomainDefPtr def,
>  }
>  
>  
> +static
> +int xenFormatXMEventActions(virConfPtr conf, virDomainDefPtr def)
> +{
> +    const char *lifecycle = NULL;
> +
> +    if (!(lifecycle = virDomainLifecycleTypeToString(def->onPoweroff))) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       _("unexpected lifecycle action %d"), def->onPoweroff);
> +        return -1;
> +    }
> +    if (xenXMConfigSetString(conf, "on_poweroff", lifecycle) < 0)
> +        return -1;
> +
> +
>   

One blank line too many.

> +    if (!(lifecycle = virDomainLifecycleTypeToString(def->onReboot))) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       _("unexpected lifecycle action %d"), def->onReboot);
> +        return -1;
> +    }
> +    if (xenXMConfigSetString(conf, "on_reboot", lifecycle) < 0)
> +        return -1;
> +
> +
>   

Same here.

> +    if (!(lifecycle = virDomainLifecycleCrashTypeToString(def->onCrash))) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       _("unexpected lifecycle action %d"), def->onCrash);
> +        return -1;
> +    }
> +    if (xenXMConfigSetString(conf, "on_crash", lifecycle) < 0)
> +        return -1;
> +
> +    return 0;
> +}
> +
> +
>  virConfPtr xenFormatXM(virConnectPtr conn,
>                                     virDomainDefPtr def,
>                                     int xendConfigVersion)
> @@ -1776,7 +1811,6 @@ virConfPtr xenFormatXM(virConnectPtr conn,
>      int hvm = 0;
>      size_t i;
>      char *cpus = NULL;
> -    const char *lifecycle;
>      virConfValuePtr diskVal = NULL;
>      virConfValuePtr netVal = NULL;
>  
> @@ -1911,34 +1945,8 @@ virConfPtr xenFormatXM(virConnectPtr conn,
>  
>      if (xenFormatXMTimeOffset(conf, def, xendConfigVersion) < 0)
>          goto cleanup;
> -    if (!(lifecycle = virDomainLifecycleTypeToString(def->onPoweroff))) {
> -        virReportError(VIR_ERR_INTERNAL_ERROR,
> -                       _("unexpected lifecycle action %d"), def->onPoweroff);
> -        goto cleanup;
> -    }
> -    if (xenXMConfigSetString(conf, "on_poweroff", lifecycle) < 0)
> -        goto cleanup;
> -
> -
> -    if (!(lifecycle = virDomainLifecycleTypeToString(def->onReboot))) {
> -        virReportError(VIR_ERR_INTERNAL_ERROR,
> -                       _("unexpected lifecycle action %d"), def->onReboot);
> -        goto cleanup;
> -    }
> -    if (xenXMConfigSetString(conf, "on_reboot", lifecycle) < 0)
> +    if (xenFormatXMEventActions(conf, def) < 0)
>          goto cleanup;
> -
> -
> -    if (!(lifecycle = virDomainLifecycleCrashTypeToString(def->onCrash))) {
> -        virReportError(VIR_ERR_INTERNAL_ERROR,
> -                       _("unexpected lifecycle action %d"), def->onCrash);
> -        goto cleanup;
> -    }
> -    if (xenXMConfigSetString(conf, "on_crash", lifecycle) < 0)
> -        goto cleanup;
> -
> -
> -
>   

And look like too much whitespace stripped here.

Regards,
Jim

>      if (hvm) {
>          if (def->emulator &&
>              xenXMConfigSetString(conf, "device_model", def->emulator) < 0)
>   




More information about the libvir-list mailing list