From: Kiarie Kahurani <davidkiarie4(a)gmail.com>
Introduce the functions
xenParseXMTimeOffset(.......);
xenParseXMEventActions(......);
These parse the time config and Event actions configs
respectively
signed-off-by:David Kiarie<davidkiarie4(a)gmail.com>
---
src/xenxs/xen_xm.c | 128 ++++++++++++++++++++++++++++++-----------------------
1 file changed, 72 insertions(+), 56 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 26ebd5a..e30ab9c 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -462,6 +462,73 @@ cleanup:
VIR_FREE(script);
return -1;
}
+static int xenParseXMTimeOffset(virConfPtr conf, virDomainDefPtr def,
+ int xendConfigVersion)
+{
+ int vmlocaltime;
+
+ if (xenXMConfigGetBool(conf, "localtime", &vmlocaltime, 0) < 0)
+ return -1;
+
+ if (STREQ(def->os.type, "hvm")) {
+ /* only managed HVM domains since 3.1.0 have persistent rtc_timeoffset */
+ if (xendConfigVersion < XEND_CONFIG_VERSION_3_1_0) {
+ if (vmlocaltime)
+ def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME;
+ else
+ def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_UTC;
+ def->clock.data.utc_reset = true;
+ } else {
+ unsigned long rtc_timeoffset;
+ def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_VARIABLE;
+ if (xenXMConfigGetULong(conf, "rtc_timeoffset",
&rtc_timeoffset, 0) < 0)
+ return -1;
+ def->clock.data.variable.adjustment = (int)rtc_timeoffset;
+ def->clock.data.variable.basis = vmlocaltime ?
+ VIR_DOMAIN_CLOCK_BASIS_LOCALTIME :
+ VIR_DOMAIN_CLOCK_BASIS_UTC;
+ }
+ } else {
+ /* PV domains do not have an emulated RTC and the offset is fixed. */
+ def->clock.offset = vmlocaltime ?
+ VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME :
+ VIR_DOMAIN_CLOCK_OFFSET_UTC;
+ def->clock.data.utc_reset = true;
+ } /* !hvm */
+
+ return 0;
+}
+static int xenParseXMEventsActions(virConfPtr conf, virDomainDefPtr def)
+{
+ const char *str;
+
+ 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;
+
+}
virDomainDefPtr
xenParseXM(virConfPtr conf, int xendConfigVersion,
virCapsPtr caps)
@@ -476,7 +543,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
virDomainGraphicsDefPtr graphics = NULL;
virDomainHostdevDefPtr hostdev = NULL;
size_t i;
- int vmlocaltime = 0;
unsigned long count;
char *script = NULL;
char *listenAddr = NULL;
@@ -556,32 +622,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
if (str && (virBitmapParse(str, 0, &def->cpumask, 4096) < 0))
goto cleanup;
- if (xenXMConfigGetString(conf, "on_poweroff", &str,
"destroy") < 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)
goto cleanup;
@@ -621,35 +661,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
def->clock.timers[0] = timer;
}
}
- if (xenXMConfigGetBool(conf, "localtime", &vmlocaltime, 0) < 0)
- goto cleanup;
-
- if (hvm) {
- /* only managed HVM domains since 3.1.0 have persistent rtc_timeoffset */
- if (xendConfigVersion < XEND_CONFIG_VERSION_3_1_0) {
- if (vmlocaltime)
- def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME;
- else
- def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_UTC;
- def->clock.data.utc_reset = true;
- } else {
- unsigned long rtc_timeoffset;
- def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_VARIABLE;
- if (xenXMConfigGetULong(conf, "rtc_timeoffset",
&rtc_timeoffset, 0) < 0)
- goto cleanup;
- def->clock.data.variable.adjustment = (int)rtc_timeoffset;
- def->clock.data.variable.basis = vmlocaltime ?
- VIR_DOMAIN_CLOCK_BASIS_LOCALTIME :
- VIR_DOMAIN_CLOCK_BASIS_UTC;
- }
- } else {
- /* PV domains do not have an emulated RTC and the offset is fixed. */
- def->clock.offset = vmlocaltime ?
- VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME :
- VIR_DOMAIN_CLOCK_OFFSET_UTC;
- def->clock.data.utc_reset = true;
- } /* !hvm */
-
if (xenXMConfigCopyStringOpt(conf, "device_model", &def->emulator)
< 0)
goto cleanup;
@@ -833,6 +844,11 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
if (xenParseXMVif(conf, def) < 0)
goto cleanup;
+ if (xenParseXMTimeOffset(conf, def, xendConfigVersion) < 0)
+ goto cleanup;
+ if (xenParseXMEventsActions(conf, def) < 0)
+ goto cleanup;
+
list = virConfGetValue(conf, "pci");
if (list && list->type == VIR_CONF_LIST) {
list = list->list;
--
1.8.4.5