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

Re: [libvirt] [PATCH 03/24] src/xenxs: Refactor code parsing event actions



Kiarie Kahurani wrote:
> introduce function
>   xenParseXMEventActions(virConfPtr conf,........)
> which parses events leading to certain actions
>
> signed-off-by: Kiarie Kahurani <davidkiarie gmail com>
> Signed-off-by: Kiarie Kahurani <davidkiarie4 gmail com>
> ---
>  src/xenxs/xen_xm.c | 61 +++++++++++++++++++++++++++++++++---------------------
>  1 file changed, 37 insertions(+), 24 deletions(-)
>   

ACK.  Will push after removing the first SOB.

Regards,
Jim

> diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
> index 0e0cf90..ecc8f52 100644
> --- a/src/xenxs/xen_xm.c
> +++ b/src/xenxs/xen_xm.c
> @@ -299,6 +299,42 @@ xenParseXMTimeOffset(virConfPtr conf, virDomainDefPtr def,
>  }
>  
>  
> +static int
> +xenParseXMEventsActions(virConfPtr conf, virDomainDefPtr def)
> +{
> +    const char *str = NULL;
> +
> +    if (xenXMConfigGetString(conf, "on_poweroff", &str, "destroy") < 0)
> +        return -1;
> +
> +    if ((def->onPoweroff = virDomainLifecycleTypeFromString(str)) < 0) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       _("unexpected value %s for on_poweroff"), str);
> +        return -1;
> +    }
> +
> +    if (xenXMConfigGetString(conf, "on_reboot", &str, "restart") < 0)
> +        return -1;
> +
> +    if ((def->onReboot = virDomainLifecycleTypeFromString(str)) < 0) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       _("unexpected value %s for on_reboot"), str);
> +        return -1;
> +    }
> +
> +    if (xenXMConfigGetString(conf, "on_crash", &str, "restart") < 0)
> +        return -1;
> +
> +    if ((def->onCrash = virDomainLifecycleCrashTypeFromString(str)) < 0) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       _("unexpected value %s for on_crash"), str);
> +        return -1;
> +    }
> +
> +    return 0;
> +}
> +
> +
>  #define MAX_VFB 1024
>  
>  /*
> @@ -431,31 +467,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
>      if (str && (virBitmapParse(str, 0, &def->cpumask, 4096) < 0))
>              goto cleanup;
>  
> -    if (xenXMConfigGetString(conf, "on_poweroff", &str, "destroy") < 0)
> +    if (xenParseXMEventsActions(conf, def) < 0)
>          goto cleanup;
> -    if ((def->onPoweroff = virDomainLifecycleTypeFromString(str)) < 0) {
> -        virReportError(VIR_ERR_INTERNAL_ERROR,
> -                       _("unexpected value %s for on_poweroff"), str);
> -        goto cleanup;
> -    }
> -
> -    if (xenXMConfigGetString(conf, "on_reboot", &str, "restart") < 0)
> -        goto cleanup;
> -    if ((def->onReboot = virDomainLifecycleTypeFromString(str)) < 0) {
> -        virReportError(VIR_ERR_INTERNAL_ERROR,
> -                       _("unexpected value %s for on_reboot"), str);
> -        goto cleanup;
> -    }
> -
> -    if (xenXMConfigGetString(conf, "on_crash", &str, "restart") < 0)
> -        goto cleanup;
> -    if ((def->onCrash = virDomainLifecycleCrashTypeFromString(str)) < 0) {
> -        virReportError(VIR_ERR_INTERNAL_ERROR,
> -                       _("unexpected value %s for on_crash"), str);
> -        goto cleanup;
> -    }
> -
> -
>  
>      if (hvm) {
>          if (xenXMConfigGetBool(conf, "pae", &val, 0) < 0)
>   


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