[libvirt] [PREPOST 13/17] src/xenxs:Refactor code formating event actions config
Jim Fehlig
jfehlig at suse.com
Mon Jul 14 22:29:58 UTC 2014
David Kiarie wrote:
> From: Kiarie Kahurani <davidkiarie4 at gmail.com>
>
> Introduce function
> xenFormatXMEventActions(.....)
> which formats actions following certain events
>
Looks good with exception of my tiring whitespace comments :-).
Regards,
Jim
> signed-off-by:David Kiarie<davidkiarie4 at gmail.com>
> ---
> src/xenxs/xen_xm.c | 60 ++++++++++++++++++++++++++++++------------------------
> 1 file changed, 33 insertions(+), 27 deletions(-)
>
> diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
> index c91fa73..367a8cd 100644
> --- a/src/xenxs/xen_xm.c
> +++ b/src/xenxs/xen_xm.c
> @@ -1710,6 +1710,38 @@ static int xenFormatXMTimeOffset(virConfPtr conf, virDomainDefPtr def,
>
> return 0;
> }
> +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;
> +
> +
> + 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;
> +
> +
> + 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)
> @@ -1718,7 +1750,6 @@ virConfPtr xenFormatXM(virConnectPtr conn,
> int hvm = 0;
> size_t i;
> char *cpus = NULL;
> - const char *lifecycle;
> virConfValuePtr diskVal = NULL;
> virConfValuePtr netVal = NULL;
>
> @@ -1857,33 +1888,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)
> - goto cleanup;
> -
> -
> - if (!(lifecycle = virDomainLifecycleCrashTypeToString(def->onCrash))) {
> - virReportError(VIR_ERR_INTERNAL_ERROR,
> - _("unexpected lifecycle action %d"), def->onCrash);
> + if (xenFormatXMEventActions(conf, def) < 0)
> goto cleanup;
> - }
> - if (xenXMConfigSetString(conf, "on_crash", lifecycle) < 0)
> - goto cleanup;
> -
> -
>
> if (hvm) {
> if (def->emulator &&
>
More information about the libvir-list
mailing list