[libvirt] [PATCH v2 00/25] Refactor the xm parser

Kiarie Kahurani (25): src/xenxs:Refactor code parsing memory config src/xenxs:Refactor code parsing event actions config src/xenxs:Refactor code parsing virtual time controls config src/xenxs:Refactor code parsing PCI devices config src/xenxs:Refactor code parsing CPU features config src/xenxs:Refactor code parsing disk config src/xenxs:Refactor code parsing Vfb config src/xenxs:Refactor code parsing OS related config src/xenxs:Refactor code parsing Char device related config src/xenxs:Refactor code parsing Vif src/xenxs:Refactor code parsing emulated hardware config src/xenxs:Refactor code parsing general config src/xenxs:Organise functions to avoid duplication src/xenxs:Refactor code formating general config src/xenxs:Refactor code formating memory config src/xenxs:Reafactor code formating virtual time config src/xenxs:Refactor code formating event actions config src/xenxs:Refactor code formating Vif config src/xenxs:Refactor code formating Vfb config src/xenxs:Refactor code formating CPU config and features src/xenxs:Refactor code formating disk list src/xenxs:Refactor code formating emulated devices config src/xenxs:Refactor char devices formating code src/xenxs:Refactor code formating OS config src/xenxs:Export code to be reused src/xenxs/xen_xm.c | 2009 ++++++++++++-------- src/xenxs/xen_xm.h | 6 +- tests/xmconfigdata/test-escape-paths.cfg | 14 +- tests/xmconfigdata/test-fullvirt-force-hpet.cfg | 12 +- tests/xmconfigdata/test-fullvirt-force-nohpet.cfg | 12 +- tests/xmconfigdata/test-fullvirt-localtime.cfg | 12 +- tests/xmconfigdata/test-fullvirt-net-ioemu.cfg | 12 +- tests/xmconfigdata/test-fullvirt-net-netfront.cfg | 12 +- tests/xmconfigdata/test-fullvirt-new-cdrom.cfg | 12 +- tests/xmconfigdata/test-fullvirt-old-cdrom.cfg | 12 +- tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg | 12 +- .../test-fullvirt-serial-dev-2-ports.cfg | 12 +- .../test-fullvirt-serial-dev-2nd-port.cfg | 12 +- tests/xmconfigdata/test-fullvirt-serial-file.cfg | 12 +- tests/xmconfigdata/test-fullvirt-serial-null.cfg | 12 +- tests/xmconfigdata/test-fullvirt-serial-pipe.cfg | 12 +- tests/xmconfigdata/test-fullvirt-serial-pty.cfg | 12 +- tests/xmconfigdata/test-fullvirt-serial-stdio.cfg | 12 +- .../test-fullvirt-serial-tcp-telnet.cfg | 12 +- tests/xmconfigdata/test-fullvirt-serial-tcp.cfg | 12 +- tests/xmconfigdata/test-fullvirt-serial-udp.cfg | 12 +- tests/xmconfigdata/test-fullvirt-serial-unix.cfg | 12 +- tests/xmconfigdata/test-fullvirt-sound.cfg | 14 +- tests/xmconfigdata/test-fullvirt-usbmouse.cfg | 12 +- tests/xmconfigdata/test-fullvirt-usbtablet.cfg | 12 +- tests/xmconfigdata/test-fullvirt-utc.cfg | 12 +- tests/xmconfigdata/test-no-source-cdrom.cfg | 12 +- tests/xmconfigdata/test-pci-devs.cfg | 12 +- 28 files changed, 1326 insertions(+), 1005 deletions(-) This patches try to refactor the code for the xen-xm parser since much of the code can be reused when writing the xen-xl parser. changes since Prepost I have finished refactoring all the code Fixed numerous memory leaks I have also changed the layout of the tests since they depend on the layout of the code which I have changed I would also like to hear some comment on what configs I should support in the new xen-xl parser. Regards, David -- 1.8.4.5

From: Kiarie Kahurani <davidkiarie4@gmail.com> Introduce function xenParseXMMem(virConfPtr conf,......); which parses memory config instead signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index f6492b5..5e26e5e 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -244,6 +244,23 @@ xenXMConfigGetUUID(virConfPtr conf, const char *name, unsigned char *uuid) return 0; } + +static +int xenParseXMMem(virConfPtr conf, virDomainDefPtr def) +{ + if (xenXMConfigGetULongLong(conf, "memory", &def->mem.cur_balloon, + MIN_XEN_GUEST_SIZE * 2) < 0) + return -1; + + if (xenXMConfigGetULongLong(conf, "maxmem", &def->mem.max_balloon, + def->mem.cur_balloon) < 0) + return -1; + + def->mem.cur_balloon *= 1024; + def->mem.max_balloon *= 1024; + + return 0; +} #define MAX_VFB 1024 /* * Turn a config record into a lump of XML describing the @@ -360,17 +377,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, } } - if (xenXMConfigGetULongLong(conf, "memory", &def->mem.cur_balloon, - MIN_XEN_GUEST_SIZE * 2) < 0) + if (xenParseXMMem(conf, def) < 0) goto cleanup; - - if (xenXMConfigGetULongLong(conf, "maxmem", &def->mem.max_balloon, - def->mem.cur_balloon) < 0) - goto cleanup; - - def->mem.cur_balloon *= 1024; - def->mem.max_balloon *= 1024; - if (xenXMConfigGetULong(conf, "vcpus", &count, 1) < 0 || MAX_VIRT_CPUS < count) goto cleanup; -- 1.8.4.5

David Kiarie wrote:
From: Kiarie Kahurani <davidkiarie4@gmail.com>
Introduce function xenParseXMMem(virConfPtr conf,......); which parses memory config instead
Since you mentioned off-list that a V3 is in the works, I'll point out a nit below you can address.
signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index f6492b5..5e26e5e 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -244,6 +244,23 @@ xenXMConfigGetUUID(virConfPtr conf, const char *name, unsigned char *uuid) return 0; }
+
Since most functions in this file have 2 blank lines of whitespace between them, this addition is fine.
+static +int xenParseXMMem(virConfPtr conf, virDomainDefPtr def) +{ + if (xenXMConfigGetULongLong(conf, "memory", &def->mem.cur_balloon, + MIN_XEN_GUEST_SIZE * 2) < 0) + return -1; + + if (xenXMConfigGetULongLong(conf, "maxmem", &def->mem.max_balloon, + def->mem.cur_balloon) < 0) + return -1; + + def->mem.cur_balloon *= 1024; + def->mem.max_balloon *= 1024; + + return 0; +}
But you should do the same here. Regards, Jim
#define MAX_VFB 1024 /* * Turn a config record into a lump of XML describing the @@ -360,17 +377,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, } }
- if (xenXMConfigGetULongLong(conf, "memory", &def->mem.cur_balloon, - MIN_XEN_GUEST_SIZE * 2) < 0) + if (xenParseXMMem(conf, def) < 0) goto cleanup; - - if (xenXMConfigGetULongLong(conf, "maxmem", &def->mem.max_balloon, - def->mem.cur_balloon) < 0) - goto cleanup; - - def->mem.cur_balloon *= 1024; - def->mem.max_balloon *= 1024; - if (xenXMConfigGetULong(conf, "vcpus", &count, 1) < 0 || MAX_VIRT_CPUS < count) goto cleanup;

From: Kiarie Kahurani <davidkiarie4@gmail.com> Introduce function xenParseXMEventActions(virConfPtr conf,......); which parses events config instead signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 65 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 5e26e5e..d0a166d 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -266,6 +266,42 @@ int xenParseXMMem(virConfPtr conf, virDomainDefPtr def) * Turn a config record into a lump of XML describing the * domain, suitable for later feeding for virDomainCreateXML */ +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) @@ -379,6 +415,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, if (xenParseXMMem(conf, def) < 0) goto cleanup; + if (xenParseXMEventsActions(conf, def) < 0) + goto cleanup; if (xenXMConfigGetULong(conf, "vcpus", &count, 1) < 0 || MAX_VIRT_CPUS < count) goto cleanup; @@ -391,33 +429,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, goto cleanup; 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; -- 1.8.4.5

David Kiarie wrote:
From: Kiarie Kahurani <davidkiarie4@gmail.com>
Introduce function xenParseXMEventActions(virConfPtr conf,......); which parses events config instead
signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 65 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 27 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 5e26e5e..d0a166d 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -266,6 +266,42 @@ int xenParseXMMem(virConfPtr conf, virDomainDefPtr def) * Turn a config record into a lump of XML describing the * domain, suitable for later feeding for virDomainCreateXML */
This existing comment refers to xenParseXM() and should be retained with its definition. Add this new function before the comment. Regards, Jim
+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) @@ -379,6 +415,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
if (xenParseXMMem(conf, def) < 0) goto cleanup; + if (xenParseXMEventsActions(conf, def) < 0) + goto cleanup; if (xenXMConfigGetULong(conf, "vcpus", &count, 1) < 0 || MAX_VIRT_CPUS < count) goto cleanup; @@ -391,33 +429,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, goto cleanup; 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;

From: Kiarie Kahurani <davidkiarie4@gmail.com> Introduce function xenParseXMTimeOffset(virConfPtr conf,......); which parses virtual config instead signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 73 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 29 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index d0a166d..c816198 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -266,6 +266,48 @@ int xenParseXMMem(virConfPtr conf, virDomainDefPtr def) * Turn a config record into a lump of XML describing the * domain, suitable for later feeding for virDomainCreateXML */ + + +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) { @@ -317,7 +359,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, virDomainHostdevDefPtr hostdev = NULL; size_t i; const char *defaultMachine; - int vmlocaltime = 0; unsigned long count; char *script = NULL; char *listenAddr = NULL; @@ -468,35 +509,9 @@ 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 (xenParseXMTimeOffset(conf, def, xendConfigVersion) < 0) + goto cleanup; if (xenXMConfigCopyStringOpt(conf, "device_model", &def->emulator) < 0) goto cleanup; -- 1.8.4.5

David Kiarie wrote:
From: Kiarie Kahurani <davidkiarie4@gmail.com>
Introduce function xenParseXMTimeOffset(virConfPtr conf,......); which parses virtual config instead
signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 73 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 29 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index d0a166d..c816198 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -266,6 +266,48 @@ int xenParseXMMem(virConfPtr conf, virDomainDefPtr def) * Turn a config record into a lump of XML describing the * domain, suitable for later feeding for virDomainCreateXML */
As mentioned in 2/25, this comment should stay with xenParseXM(). Regards, Jim
+ + +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) { @@ -317,7 +359,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, virDomainHostdevDefPtr hostdev = NULL; size_t i; const char *defaultMachine; - int vmlocaltime = 0; unsigned long count; char *script = NULL; char *listenAddr = NULL; @@ -468,35 +509,9 @@ 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 (xenParseXMTimeOffset(conf, def, xendConfigVersion) < 0) + goto cleanup; if (xenXMConfigCopyStringOpt(conf, "device_model", &def->emulator) < 0) goto cleanup;

From: Kiarie Kahurani <davidkiarie4@gmail.com> Introduce function xenParseXMPCI(virConfPtr conf,......); which parses PCI config instead signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 185 +++++++++++++++++++++++++++-------------------------- 1 file changed, 94 insertions(+), 91 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index c816198..2fb3a4c 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -344,6 +344,98 @@ int xenParseXMEventsActions(virConfPtr conf, virDomainDefPtr def) } +static +int xenParseXMPCI(virConfPtr conf, virDomainDefPtr def) +{ + virConfValuePtr list = virConfGetValue(conf, "pci"); + virDomainHostdevDefPtr hostdev = NULL; + if (list && list->type == VIR_CONF_LIST) { + list = list->list; + while (list) { + char domain[5]; + char bus[3]; + char slot[3]; + char func[2]; + char *key, *nextkey; + int domainID; + int busID; + int slotID; + int funcID; + + domain[0] = bus[0] = slot[0] = func[0] = '\0'; + + if ((list->type != VIR_CONF_STRING) || (list->str == NULL)) + goto skippci; + /* pci=['0000:00:1b.0','0000:00:13.0'] */ + if (!(key = list->str)) + goto skippci; + if (!(nextkey = strchr(key, ':'))) + goto skippci; + if (virStrncpy(domain, key, (nextkey - key), sizeof(domain)) == NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Domain %s too big for destination"), key); + goto skippci; + } + + key = nextkey + 1; + if (!(nextkey = strchr(key, ':'))) + goto skippci; + if (virStrncpy(bus, key, (nextkey - key), sizeof(bus)) == NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Bus %s too big for destination"), key); + goto skippci; + } + + key = nextkey + 1; + if (!(nextkey = strchr(key, '.'))) + goto skippci; + if (virStrncpy(slot, key, (nextkey - key), sizeof(slot)) == NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Slot %s too big for destination"), key); + goto skippci; + } + + key = nextkey + 1; + if (strlen(key) != 1) + goto skippci; + if (virStrncpy(func, key, 1, sizeof(func)) == NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Function %s too big for destination"), key); + goto skippci; + } + + if (virStrToLong_i(domain, NULL, 16, &domainID) < 0) + goto skippci; + if (virStrToLong_i(bus, NULL, 16, &busID) < 0) + goto skippci; + if (virStrToLong_i(slot, NULL, 16, &slotID) < 0) + goto skippci; + if (virStrToLong_i(func, NULL, 16, &funcID) < 0) + goto skippci; + if (!(hostdev = virDomainHostdevDefAlloc())) + return -1; + + hostdev->managed = false; + hostdev->source.subsys.type = VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI; + hostdev->source.subsys.u.pci.addr.domain = domainID; + hostdev->source.subsys.u.pci.addr.bus = busID; + hostdev->source.subsys.u.pci.addr.slot = slotID; + hostdev->source.subsys.u.pci.addr.function = funcID; + + if (VIR_APPEND_ELEMENT(def->hostdevs, def->nhostdevs, hostdev) < 0) { + virDomainHostdevDefFree(hostdev); + return -1; + } + + skippci: + list = list->next; + } + } + + return 0; +} + + virDomainDefPtr xenParseXM(virConfPtr conf, int xendConfigVersion, virCapsPtr caps) @@ -356,7 +448,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, virDomainDiskDefPtr disk = NULL; virDomainNetDefPtr net = NULL; virDomainGraphicsDefPtr graphics = NULL; - virDomainHostdevDefPtr hostdev = NULL; size_t i; const char *defaultMachine; unsigned long count; @@ -836,96 +927,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, } } - list = virConfGetValue(conf, "pci"); - if (list && list->type == VIR_CONF_LIST) { - list = list->list; - while (list) { - char domain[5]; - char bus[3]; - char slot[3]; - char func[2]; - char *key, *nextkey; - int domainID; - int busID; - int slotID; - int funcID; - - domain[0] = bus[0] = slot[0] = func[0] = '\0'; - - if ((list->type != VIR_CONF_STRING) || (list->str == NULL)) - goto skippci; - - /* pci=['0000:00:1b.0','0000:00:13.0'] */ - if (!(key = list->str)) - goto skippci; - if (!(nextkey = strchr(key, ':'))) - goto skippci; - - if (virStrncpy(domain, key, (nextkey - key), sizeof(domain)) == NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Domain %s too big for destination"), key); - goto skippci; - } - - key = nextkey + 1; - if (!(nextkey = strchr(key, ':'))) - goto skippci; - - if (virStrncpy(bus, key, (nextkey - key), sizeof(bus)) == NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Bus %s too big for destination"), key); - goto skippci; - } - - key = nextkey + 1; - if (!(nextkey = strchr(key, '.'))) - goto skippci; - - if (virStrncpy(slot, key, (nextkey - key), sizeof(slot)) == NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Slot %s too big for destination"), key); - goto skippci; - } - - key = nextkey + 1; - if (strlen(key) != 1) - goto skippci; - - if (virStrncpy(func, key, 1, sizeof(func)) == NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Function %s too big for destination"), key); - goto skippci; - } - - if (virStrToLong_i(domain, NULL, 16, &domainID) < 0) - goto skippci; - if (virStrToLong_i(bus, NULL, 16, &busID) < 0) - goto skippci; - if (virStrToLong_i(slot, NULL, 16, &slotID) < 0) - goto skippci; - if (virStrToLong_i(func, NULL, 16, &funcID) < 0) - goto skippci; - - if (!(hostdev = virDomainHostdevDefAlloc())) - goto cleanup; - - hostdev->managed = false; - hostdev->source.subsys.type = VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI; - hostdev->source.subsys.u.pci.addr.domain = domainID; - hostdev->source.subsys.u.pci.addr.bus = busID; - hostdev->source.subsys.u.pci.addr.slot = slotID; - hostdev->source.subsys.u.pci.addr.function = funcID; - - if (VIR_APPEND_ELEMENT(def->hostdevs, def->nhostdevs, hostdev) < 0) { - virDomainHostdevDefFree(hostdev); - goto cleanup; - } - - skippci: - list = list->next; - } - } - + if (xenParseXMPCI(conf, def) < 0) + goto cleanup; if (hvm) { if (xenXMConfigGetString(conf, "usbdevice", &str, NULL) < 0) goto cleanup; -- 1.8.4.5

From: Kiarie Kahurani <davidkiarie4@gmail.com> Introduce function xenParseXMPCI(virConfPtr conf,......); which parses CPU Features and allocation config instead signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 126 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 73 insertions(+), 53 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 2fb3a4c..66d7b44 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -436,6 +436,77 @@ int xenParseXMPCI(virConfPtr conf, virDomainDefPtr def) } +static +int xenParseXMCPUFeatures(virConfPtr conf, virDomainDefPtr def) +{ + unsigned long count; + const char *str; + int val; + + if (xenXMConfigGetULong(conf, "vcpus", &count, 1) < 0 || + MAX_VIRT_CPUS < count) + return -1; + + def->maxvcpus = count; + if (xenXMConfigGetULong(conf, "vcpu_avail", &count, -1) < 0) + return -1; + + def->vcpus = MIN(count_one_bits_l(count), def->maxvcpus); + if (xenXMConfigGetString(conf, "cpus", &str, NULL) < 0) + return -1; + + if (str && (virBitmapParse(str, 0, &def->cpumask, 4096) < 0)) + return -1; + + if (STREQ(def->os.type, "hvm")) { + if (xenXMConfigGetBool(conf, "pae", &val, 0) < 0) + return -1; + + else if (val) + def->features[VIR_DOMAIN_FEATURE_PAE] = VIR_DOMAIN_FEATURE_STATE_ON; + if (xenXMConfigGetBool(conf, "acpi", &val, 0) < 0) + return -1; + + else if (val) + def->features[VIR_DOMAIN_FEATURE_ACPI] = VIR_DOMAIN_FEATURE_STATE_ON; + if (xenXMConfigGetBool(conf, "apic", &val, 0) < 0) + return -1; + + else if (val) + def->features[VIR_DOMAIN_FEATURE_APIC] = VIR_DOMAIN_FEATURE_STATE_ON; + if (xenXMConfigGetBool(conf, "hap", &val, 0) < 0) + return -1; + + else if (val) + def->features[VIR_DOMAIN_FEATURE_HAP] = VIR_DOMAIN_FEATURE_STATE_ON; + if (xenXMConfigGetBool(conf, "viridian", &val, 0) < 0) + return -1; + + else if (val) + def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] = VIR_DOMAIN_FEATURE_STATE_ON; + if (xenXMConfigGetBool(conf, "hpet", &val, -1) < 0) + return -1; + + else if (val != -1) { + virDomainTimerDefPtr timer; + + if (VIR_ALLOC_N(def->clock.timers, 1) < 0 || + VIR_ALLOC(timer) < 0) + return -1; + + timer->name = VIR_DOMAIN_TIMER_NAME_HPET; + timer->present = val; + timer->tickpolicy = -1; + + def->clock.ntimers = 1; + def->clock.timers[0] = timer; + } + } + + return 0; +} + + virDomainDefPtr xenParseXM(virConfPtr conf, int xendConfigVersion, virCapsPtr caps) @@ -450,7 +521,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, virDomainGraphicsDefPtr graphics = NULL; size_t i; const char *defaultMachine; - unsigned long count; char *script = NULL; char *listenAddr = NULL; @@ -549,60 +619,10 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, goto cleanup; if (xenParseXMEventsActions(conf, def) < 0) goto cleanup; - if (xenXMConfigGetULong(conf, "vcpus", &count, 1) < 0 || - MAX_VIRT_CPUS < count) - goto cleanup; - def->maxvcpus = count; - if (xenXMConfigGetULong(conf, "vcpu_avail", &count, -1) < 0) - goto cleanup; - def->vcpus = MIN(count_one_bits_l(count), def->maxvcpus); - - if (xenXMConfigGetString(conf, "cpus", &str, NULL) < 0) - goto cleanup; - if (str && (virBitmapParse(str, 0, &def->cpumask, 4096) < 0)) - goto cleanup; - if (hvm) { - if (xenXMConfigGetBool(conf, "pae", &val, 0) < 0) - goto cleanup; - else if (val) - def->features[VIR_DOMAIN_FEATURE_PAE] = VIR_DOMAIN_FEATURE_STATE_ON; - if (xenXMConfigGetBool(conf, "acpi", &val, 0) < 0) - goto cleanup; - else if (val) - def->features[VIR_DOMAIN_FEATURE_ACPI] = VIR_DOMAIN_FEATURE_STATE_ON; - if (xenXMConfigGetBool(conf, "apic", &val, 0) < 0) - goto cleanup; - else if (val) - def->features[VIR_DOMAIN_FEATURE_APIC] = VIR_DOMAIN_FEATURE_STATE_ON; - if (xenXMConfigGetBool(conf, "hap", &val, 0) < 0) - goto cleanup; - else if (val) - def->features[VIR_DOMAIN_FEATURE_HAP] = VIR_DOMAIN_FEATURE_STATE_ON; - if (xenXMConfigGetBool(conf, "viridian", &val, 0) < 0) - goto cleanup; - else if (val) - def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] = VIR_DOMAIN_FEATURE_STATE_ON; - - if (xenXMConfigGetBool(conf, "hpet", &val, -1) < 0) - goto cleanup; - else if (val != -1) { - virDomainTimerDefPtr timer; - - if (VIR_ALLOC_N(def->clock.timers, 1) < 0 || - VIR_ALLOC(timer) < 0) - goto cleanup; - - timer->name = VIR_DOMAIN_TIMER_NAME_HPET; - timer->present = val; - timer->tickpolicy = -1; - - def->clock.ntimers = 1; - def->clock.timers[0] = timer; - } - } - if (xenParseXMTimeOffset(conf, def, xendConfigVersion) < 0) goto cleanup; + if (xenParseXMCPUFeatures(conf, def) < 0) + goto cleanup; if (xenXMConfigCopyStringOpt(conf, "device_model", &def->emulator) < 0) goto cleanup; -- 1.8.4.5

From: Kiarie Kahurani <davidkiarie4@gmail.com> Introduce function xenParseXMDisk(virConfPtr conf,......); which parses XM disk config instead signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 302 ++++++++++++++++++++++++++++------------------------- 1 file changed, 157 insertions(+), 145 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 66d7b44..2c36c1b 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -507,126 +507,15 @@ int xenParseXMCPUFeatures(virConfPtr conf, virDomainDefPtr def) } -virDomainDefPtr -xenParseXM(virConfPtr conf, int xendConfigVersion, - virCapsPtr caps) +static +int xenParseXMDisk(virConfPtr conf, virDomainDefPtr def, + int xendConfigVersion) { - const char *str; - int hvm = 0; - int val; - virConfValuePtr list; - virDomainDefPtr def = NULL; + const char *str = NULL; virDomainDiskDefPtr disk = NULL; - virDomainNetDefPtr net = NULL; - virDomainGraphicsDefPtr graphics = NULL; - size_t i; - const char *defaultMachine; - char *script = NULL; - char *listenAddr = NULL; - - if (VIR_ALLOC(def) < 0) - return NULL; - - def->virtType = VIR_DOMAIN_VIRT_XEN; - def->id = -1; - - if (xenXMConfigCopyString(conf, "name", &def->name) < 0) - goto cleanup; - if (xenXMConfigGetUUID(conf, "uuid", def->uuid) < 0) - goto cleanup; - - - if ((xenXMConfigGetString(conf, "builder", &str, "linux") == 0) && - STREQ(str, "hvm")) - hvm = 1; - - if (VIR_STRDUP(def->os.type, hvm ? "hvm" : "xen") < 0) - goto cleanup; - - def->os.arch = - virCapabilitiesDefaultGuestArch(caps, - def->os.type, - virDomainVirtTypeToString(def->virtType)); - if (!def->os.arch) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("no supported architecture for os type '%s'"), - def->os.type); - goto cleanup; - } - - defaultMachine = virCapabilitiesDefaultGuestMachine(caps, - def->os.type, - def->os.arch, - virDomainVirtTypeToString(def->virtType)); - if (defaultMachine != NULL) { - if (VIR_STRDUP(def->os.machine, defaultMachine) < 0) - goto cleanup; - } - - if (hvm) { - const char *boot; - if (xenXMConfigCopyString(conf, "kernel", &def->os.loader) < 0) - goto cleanup; - - if (xenXMConfigGetString(conf, "boot", &boot, "c") < 0) - goto cleanup; - - for (i = 0; i < VIR_DOMAIN_BOOT_LAST && boot[i]; i++) { - switch (*boot) { - case 'a': - def->os.bootDevs[i] = VIR_DOMAIN_BOOT_FLOPPY; - break; - case 'd': - def->os.bootDevs[i] = VIR_DOMAIN_BOOT_CDROM; - break; - case 'n': - def->os.bootDevs[i] = VIR_DOMAIN_BOOT_NET; - break; - case 'c': - default: - def->os.bootDevs[i] = VIR_DOMAIN_BOOT_DISK; - break; - } - def->os.nBootDevs++; - } - } else { - const char *extra, *root; - - if (xenXMConfigCopyStringOpt(conf, "bootloader", &def->os.bootloader) < 0) - goto cleanup; - if (xenXMConfigCopyStringOpt(conf, "bootargs", &def->os.bootloaderArgs) < 0) - goto cleanup; - - if (xenXMConfigCopyStringOpt(conf, "kernel", &def->os.kernel) < 0) - goto cleanup; - if (xenXMConfigCopyStringOpt(conf, "ramdisk", &def->os.initrd) < 0) - goto cleanup; - if (xenXMConfigGetString(conf, "extra", &extra, NULL) < 0) - goto cleanup; - if (xenXMConfigGetString(conf, "root", &root, NULL) < 0) - goto cleanup; - - if (root) { - if (virAsprintf(&def->os.cmdline, "root=%s %s", root, extra) < 0) - goto cleanup; - } else { - if (VIR_STRDUP(def->os.cmdline, extra) < 0) - goto cleanup; - } - } - - if (xenParseXMMem(conf, def) < 0) - goto cleanup; - if (xenParseXMEventsActions(conf, def) < 0) - goto cleanup; - if (xenParseXMTimeOffset(conf, def, xendConfigVersion) < 0) - goto cleanup; - if (xenParseXMCPUFeatures(conf, def) < 0) - goto cleanup; - if (xenXMConfigCopyStringOpt(conf, "device_model", &def->emulator) < 0) - goto cleanup; + int hvm = STREQ(def->os.type, "hvm"); + virConfValuePtr list = virConfGetValue(conf, "disk"); - list = virConfGetValue(conf, "disk"); if (list && list->type == VIR_CONF_LIST) { list = list->list; while (list) { @@ -638,9 +527,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, if ((list->type != VIR_CONF_STRING) || (list->str == NULL)) goto skipdisk; head = list->str; - if (!(disk = virDomainDiskDefNew())) - goto cleanup; + return -1; /* * Disks have 3 components, SOURCE,DEST-DEVICE,MODE @@ -653,38 +541,39 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, /* Extract the source file path*/ if (!(offset = strchr(head, ','))) goto skipdisk; - if (offset == head) { /* No source file given, eg CDROM with no media */ ignore_value(virDomainDiskSetSource(disk, NULL)); } else { if (VIR_STRNDUP(tmp, head, offset - head) < 0) - goto cleanup; + return -1; + if (virDomainDiskSetSource(disk, tmp) < 0) { VIR_FREE(tmp); - goto cleanup; + return -1; } + VIR_FREE(tmp); } - head = offset + 1; + head = offset + 1; /* Remove legacy ioemu: junk */ if (STRPREFIX(head, "ioemu:")) head = head + 6; - /* Extract the dest device name */ if (!(offset = strchr(head, ','))) goto skipdisk; if (VIR_ALLOC_N(disk->dst, (offset - head) + 1) < 0) - goto cleanup; + return -1; + if (virStrncpy(disk->dst, head, offset - head, (offset - head) + 1) == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Dest file %s too big for destination"), head); - goto cleanup; + return -1; } - head = offset + 1; + head = offset + 1; /* Extract source driver type */ src = virDomainDiskGetSource(disk); if (src) { @@ -693,29 +582,31 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, if ((tmp = strchr(src, ':')) != NULL) { len = tmp - src; if (VIR_STRNDUP(tmp, src, len) < 0) - goto cleanup; + return -1; + if (virDomainDiskSetDriver(disk, tmp) < 0) { VIR_FREE(tmp); - goto cleanup; + return -1; } + VIR_FREE(tmp); /* Strip the prefix we found off the source file name */ if (virDomainDiskSetSource(disk, src + len + 1) < 0) - goto cleanup; + return -1; + src = virDomainDiskGetSource(disk); } /* And the sub-type for tap:XXX: type */ if (STREQ_NULLABLE(virDomainDiskGetDriver(disk), "tap")) { char *driverType; - if (!(tmp = strchr(src, ':'))) goto skipdisk; len = tmp - src; - if (VIR_STRNDUP(driverType, src, len) < 0) - goto cleanup; + return -1; + if (STREQ(driverType, "aio")) virDomainDiskSetFormat(disk, VIR_STORAGE_FILE_RAW); else @@ -726,12 +617,12 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown driver type %s"), src); - goto cleanup; + return -1; } /* Strip the prefix we found off the source file name */ if (virDomainDiskSetSource(disk, src + len + 1) < 0) - goto cleanup; + return -1; src = virDomainDiskGetSource(disk); } } @@ -739,15 +630,13 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, /* No source, or driver name, so fix to phy: */ if (!virDomainDiskGetDriver(disk) && virDomainDiskSetDriver(disk, "phy") < 0) - goto cleanup; - + return -1; /* phy: type indicates a block device */ virDomainDiskSetType(disk, STREQ(virDomainDiskGetDriver(disk), "phy") ? VIR_STORAGE_TYPE_BLOCK : VIR_STORAGE_TYPE_FILE); - /* Check for a :cdrom/:disk postfix */ disk->device = VIR_DOMAIN_DISK_DEVICE_DISK; if ((tmp = strchr(disk->dst, ':')) != NULL) { @@ -770,10 +659,9 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, else if ((STREQ(head, "w!")) || (STREQ(head, "!"))) disk->src->shared = true; - /* Maintain list in sorted order according to target device name */ if (VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk) < 0) - goto cleanup; + return -1; skipdisk: list = list->next; @@ -783,27 +671,151 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, if (hvm && xendConfigVersion == XEND_CONFIG_VERSION_3_0_2) { if (xenXMConfigGetString(conf, "cdrom", &str, NULL) < 0) - goto cleanup; + return -1; if (str) { if (!(disk = virDomainDiskDefNew())) - goto cleanup; + return -1; virDomainDiskSetType(disk, VIR_STORAGE_TYPE_FILE); disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM; if (virDomainDiskSetDriver(disk, "file") < 0) - goto cleanup; + return -1; if (virDomainDiskSetSource(disk, str) < 0) - goto cleanup; + return -1; if (VIR_STRDUP(disk->dst, "hdc") < 0) - goto cleanup; + return -1; disk->bus = VIR_DOMAIN_DISK_BUS_IDE; disk->src->readonly = true; if (VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk) < 0) + return -1; + } + } + + return 0; +} + + +virDomainDefPtr +xenParseXM(virConfPtr conf, int xendConfigVersion, + virCapsPtr caps) +{ + const char *str; + int hvm = 0; + int val; + virConfValuePtr list; + virDomainDefPtr def = NULL; + virDomainDiskDefPtr disk = NULL; + virDomainNetDefPtr net = NULL; + virDomainGraphicsDefPtr graphics = NULL; + size_t i; + const char *defaultMachine; + char *script = NULL; + char *listenAddr = NULL; + + if (VIR_ALLOC(def) < 0) + return NULL; + + def->virtType = VIR_DOMAIN_VIRT_XEN; + def->id = -1; + + if (xenXMConfigCopyString(conf, "name", &def->name) < 0) + goto cleanup; + if (xenXMConfigGetUUID(conf, "uuid", def->uuid) < 0) + goto cleanup; + + + if ((xenXMConfigGetString(conf, "builder", &str, "linux") == 0) && + STREQ(str, "hvm")) + hvm = 1; + + if (VIR_STRDUP(def->os.type, hvm ? "hvm" : "xen") < 0) + goto cleanup; + + def->os.arch = + virCapabilitiesDefaultGuestArch(caps, + def->os.type, + virDomainVirtTypeToString(def->virtType)); + if (!def->os.arch) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("no supported architecture for os type '%s'"), + def->os.type); + goto cleanup; + } + + defaultMachine = virCapabilitiesDefaultGuestMachine(caps, + def->os.type, + def->os.arch, + virDomainVirtTypeToString(def->virtType)); + if (defaultMachine != NULL) { + if (VIR_STRDUP(def->os.machine, defaultMachine) < 0) + goto cleanup; + } + + if (hvm) { + const char *boot; + if (xenXMConfigCopyString(conf, "kernel", &def->os.loader) < 0) + goto cleanup; + + if (xenXMConfigGetString(conf, "boot", &boot, "c") < 0) + goto cleanup; + + for (i = 0; i < VIR_DOMAIN_BOOT_LAST && boot[i]; i++) { + switch (*boot) { + case 'a': + def->os.bootDevs[i] = VIR_DOMAIN_BOOT_FLOPPY; + break; + case 'd': + def->os.bootDevs[i] = VIR_DOMAIN_BOOT_CDROM; + break; + case 'n': + def->os.bootDevs[i] = VIR_DOMAIN_BOOT_NET; + break; + case 'c': + default: + def->os.bootDevs[i] = VIR_DOMAIN_BOOT_DISK; + break; + } + def->os.nBootDevs++; + } + } else { + const char *extra, *root; + + if (xenXMConfigCopyStringOpt(conf, "bootloader", &def->os.bootloader) < 0) + goto cleanup; + if (xenXMConfigCopyStringOpt(conf, "bootargs", &def->os.bootloaderArgs) < 0) + goto cleanup; + + if (xenXMConfigCopyStringOpt(conf, "kernel", &def->os.kernel) < 0) + goto cleanup; + if (xenXMConfigCopyStringOpt(conf, "ramdisk", &def->os.initrd) < 0) + goto cleanup; + if (xenXMConfigGetString(conf, "extra", &extra, NULL) < 0) + goto cleanup; + if (xenXMConfigGetString(conf, "root", &root, NULL) < 0) + goto cleanup; + + if (root) { + if (virAsprintf(&def->os.cmdline, "root=%s %s", root, extra) < 0) + goto cleanup; + } else { + if (VIR_STRDUP(def->os.cmdline, extra) < 0) goto cleanup; } } + if (xenParseXMMem(conf, def) < 0) + goto cleanup; + if (xenParseXMEventsActions(conf, def) < 0) + goto cleanup; + if (xenParseXMTimeOffset(conf, def, xendConfigVersion) < 0) + goto cleanup; + if (xenParseXMCPUFeatures(conf, def) < 0) + goto cleanup; + if (xenParseXMDisk(conf, def, xendConfigVersion) < 0) + goto cleanup; + if (xenXMConfigCopyStringOpt(conf, "device_model", &def->emulator) < 0) + goto cleanup; list = virConfGetValue(conf, "vif"); if (list && list->type == VIR_CONF_LIST) { list = list->list; -- 1.8.4.5

David Kiarie wrote:
From: Kiarie Kahurani <davidkiarie4@gmail.com>
Introduce function xenParseXMDisk(virConfPtr conf,......); which parses XM disk config instead
signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 302 ++++++++++++++++++++++++++++------------------------- 1 file changed, 157 insertions(+), 145 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 66d7b44..2c36c1b 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -507,126 +507,15 @@ int xenParseXMCPUFeatures(virConfPtr conf, virDomainDefPtr def) }
-virDomainDefPtr -xenParseXM(virConfPtr conf, int xendConfigVersion, - virCapsPtr caps) +static +int xenParseXMDisk(virConfPtr conf, virDomainDefPtr def, + int xendConfigVersion)
libvirt style is to have function return type and name on separate lines, e.g. static int xenParseXMDisk(...)
{ - const char *str; - int hvm = 0; - int val; - virConfValuePtr list; - virDomainDefPtr def = NULL; + const char *str = NULL; virDomainDiskDefPtr disk = NULL; - virDomainNetDefPtr net = NULL; - virDomainGraphicsDefPtr graphics = NULL; - size_t i; - const char *defaultMachine; - char *script = NULL; - char *listenAddr = NULL; - - if (VIR_ALLOC(def) < 0) - return NULL; - - def->virtType = VIR_DOMAIN_VIRT_XEN; - def->id = -1; - - if (xenXMConfigCopyString(conf, "name", &def->name) < 0) - goto cleanup; - if (xenXMConfigGetUUID(conf, "uuid", def->uuid) < 0) - goto cleanup; - - - if ((xenXMConfigGetString(conf, "builder", &str, "linux") == 0) && - STREQ(str, "hvm")) - hvm = 1; - - if (VIR_STRDUP(def->os.type, hvm ? "hvm" : "xen") < 0) - goto cleanup; - - def->os.arch = - virCapabilitiesDefaultGuestArch(caps, - def->os.type, - virDomainVirtTypeToString(def->virtType)); - if (!def->os.arch) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("no supported architecture for os type '%s'"), - def->os.type); - goto cleanup; - } - - defaultMachine = virCapabilitiesDefaultGuestMachine(caps, - def->os.type, - def->os.arch, - virDomainVirtTypeToString(def->virtType)); - if (defaultMachine != NULL) { - if (VIR_STRDUP(def->os.machine, defaultMachine) < 0) - goto cleanup; - } - - if (hvm) { - const char *boot; - if (xenXMConfigCopyString(conf, "kernel", &def->os.loader) < 0) - goto cleanup; - - if (xenXMConfigGetString(conf, "boot", &boot, "c") < 0) - goto cleanup; - - for (i = 0; i < VIR_DOMAIN_BOOT_LAST && boot[i]; i++) { - switch (*boot) { - case 'a': - def->os.bootDevs[i] = VIR_DOMAIN_BOOT_FLOPPY; - break; - case 'd': - def->os.bootDevs[i] = VIR_DOMAIN_BOOT_CDROM; - break; - case 'n': - def->os.bootDevs[i] = VIR_DOMAIN_BOOT_NET; - break; - case 'c': - default: - def->os.bootDevs[i] = VIR_DOMAIN_BOOT_DISK; - break; - } - def->os.nBootDevs++; - } - } else { - const char *extra, *root; - - if (xenXMConfigCopyStringOpt(conf, "bootloader", &def->os.bootloader) < 0) - goto cleanup; - if (xenXMConfigCopyStringOpt(conf, "bootargs", &def->os.bootloaderArgs) < 0) - goto cleanup; - - if (xenXMConfigCopyStringOpt(conf, "kernel", &def->os.kernel) < 0) - goto cleanup; - if (xenXMConfigCopyStringOpt(conf, "ramdisk", &def->os.initrd) < 0) - goto cleanup; - if (xenXMConfigGetString(conf, "extra", &extra, NULL) < 0) - goto cleanup; - if (xenXMConfigGetString(conf, "root", &root, NULL) < 0) - goto cleanup; - - if (root) { - if (virAsprintf(&def->os.cmdline, "root=%s %s", root, extra) < 0) - goto cleanup; - } else { - if (VIR_STRDUP(def->os.cmdline, extra) < 0) - goto cleanup; - } - } - - if (xenParseXMMem(conf, def) < 0) - goto cleanup; - if (xenParseXMEventsActions(conf, def) < 0) - goto cleanup; - if (xenParseXMTimeOffset(conf, def, xendConfigVersion) < 0) - goto cleanup; - if (xenParseXMCPUFeatures(conf, def) < 0) - goto cleanup; - if (xenXMConfigCopyStringOpt(conf, "device_model", &def->emulator) < 0) - goto cleanup; + int hvm = STREQ(def->os.type, "hvm"); + virConfValuePtr list = virConfGetValue(conf, "disk");
- list = virConfGetValue(conf, "disk"); if (list && list->type == VIR_CONF_LIST) { list = list->list; while (list) { @@ -638,9 +527,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, if ((list->type != VIR_CONF_STRING) || (list->str == NULL)) goto skipdisk; head = list->str; -
Spurious whitespace change.
if (!(disk = virDomainDiskDefNew())) - goto cleanup; + return -1;
/* * Disks have 3 components, SOURCE,DEST-DEVICE,MODE @@ -653,38 +541,39 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, /* Extract the source file path*/ if (!(offset = strchr(head, ','))) goto skipdisk; -
More whitespace change, again removing a blank line.
if (offset == head) { /* No source file given, eg CDROM with no media */ ignore_value(virDomainDiskSetSource(disk, NULL)); } else { if (VIR_STRNDUP(tmp, head, offset - head) < 0) - goto cleanup; + return -1; +
But here you are adding a blank line. I think these types of changes are fine as long as you are consistent and in the end the code is more readable. Regards, Jim

From: Kiarie Kahurani <davidkiarie4@gmail.com> introduce function xenParseXMVfb(virConfPtr conf,.......) which parses Vfb config signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 296 ++++++++++++++++++++++++++++------------------------- 1 file changed, 154 insertions(+), 142 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 2c36c1b..38434be 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -695,6 +695,158 @@ int xenParseXMDisk(virConfPtr conf, virDomainDefPtr def, return 0; } +static +int xenParseXMVfb(virConfPtr conf, virDomainDefPtr def, + int xendConfigVersion) +{ + int val; + char *listenAddr = NULL; + //const char *str = NULL; + int hvm = STREQ(def->os.type, "hvm"); + virConfValuePtr list; + virDomainGraphicsDefPtr graphics = NULL; + + if (hvm || xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) { + if (xenXMConfigGetBool(conf, "vnc", &val, 0) < 0) + goto cleanup; + if (val) { + if (VIR_ALLOC(graphics) < 0) + goto cleanup; + graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC; + if (xenXMConfigGetBool(conf, "vncunused", &val, 1) < 0) + goto cleanup; + graphics->data.vnc.autoport = val ? 1 : 0; + if (!graphics->data.vnc.autoport) { + unsigned long vncdisplay; + if (xenXMConfigGetULong(conf, "vncdisplay", &vncdisplay, 0) < 0) + goto cleanup; + graphics->data.vnc.port = (int)vncdisplay + 5900; + } + + if (xenXMConfigCopyStringOpt(conf, "vnclisten", &listenAddr) < 0) + goto cleanup; + if (listenAddr && + virDomainGraphicsListenSetAddress(graphics, 0, listenAddr, + -1, true) < 0) { + goto cleanup; + } + + VIR_FREE(listenAddr); + if (xenXMConfigCopyStringOpt(conf, "vncpasswd", &graphics->data.vnc.auth.passwd) < 0) + goto cleanup; + if (xenXMConfigCopyStringOpt(conf, "keymap", &graphics->data.vnc.keymap) < 0) + goto cleanup; + if (VIR_ALLOC_N(def->graphics, 1) < 0) + goto cleanup; + def->graphics[0] = graphics; + def->ngraphics = 1; + graphics = NULL; + } else { + if (xenXMConfigGetBool(conf, "sdl", &val, 0) < 0) + goto cleanup; + if (val) { + if (VIR_ALLOC(graphics) < 0) + goto cleanup; + graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SDL; + if (xenXMConfigCopyStringOpt(conf, "display", &graphics->data.sdl.display) < 0) + goto cleanup; + if (xenXMConfigCopyStringOpt(conf, "xauthority", &graphics->data.sdl.xauth) < 0) + goto cleanup; + if (VIR_ALLOC_N(def->graphics, 1) < 0) + goto cleanup; + def->graphics[0] = graphics; + def->ngraphics = 1; + graphics = NULL; + } + } + } + + if (!hvm && def->graphics == NULL) { /* New PV guests use this format */ + list = virConfGetValue(conf, "vfb"); + if (list && list->type == VIR_CONF_LIST && + list->list && list->list->type == VIR_CONF_STRING && + list->list->str) { + char vfb[MAX_VFB]; + char *key = vfb; + + if (virStrcpyStatic(vfb, list->list->str) == NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("VFB %s too big for destination"), + list->list->str); + goto cleanup; + } + + if (VIR_ALLOC(graphics) < 0) + goto cleanup; + if (strstr(key, "type=sdl")) + graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SDL; + else + graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC; + while (key) { + char *nextkey = strchr(key, ','); + char *end = nextkey; + if (nextkey) { + *end = '\0'; + nextkey++; + } + + if (!strchr(key, '=')) + break; + if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) { + if (STRPREFIX(key, "vncunused=")) { + if (STREQ(key + 10, "1")) + graphics->data.vnc.autoport = true; + } else if (STRPREFIX(key, "vnclisten=")) { + if (virDomainGraphicsListenSetAddress(graphics, 0, key+10, + -1, true) < 0) + goto cleanup; + } else if (STRPREFIX(key, "vncpasswd=")) { + if (VIR_STRDUP(graphics->data.vnc.auth.passwd, key + 10) < 0) + goto cleanup; + } else if (STRPREFIX(key, "keymap=")) { + if (VIR_STRDUP(graphics->data.vnc.keymap, key + 7) < 0) + goto cleanup; + } else if (STRPREFIX(key, "vncdisplay=")) { + if (virStrToLong_i(key + 11, NULL, 10, + &graphics->data.vnc.port) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("invalid vncdisplay value '%s'"), + key + 11); + goto cleanup; + } + graphics->data.vnc.port += 5900; + } + } else { + if (STRPREFIX(key, "display=")) { + if (VIR_STRDUP(graphics->data.sdl.display, key + 8) < 0) + goto cleanup; + } else if (STRPREFIX(key, "xauthority=")) { + if (VIR_STRDUP(graphics->data.sdl.xauth, key + 11) < 0) + goto cleanup; + } + } + + while (nextkey && (nextkey[0] == ',' || + nextkey[0] == ' ' || + nextkey[0] == '\t')) + nextkey++; + key = nextkey; + } + if (VIR_ALLOC_N(def->graphics, 1) < 0) + goto cleanup; + def->graphics[0] = graphics; + def->ngraphics = 1; + graphics = NULL; + } + } + + return 0; + + cleanup: + virDomainGraphicsDefFree(graphics); + return -1; +} + virDomainDefPtr xenParseXM(virConfPtr conf, int xendConfigVersion, @@ -702,7 +854,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, { const char *str; int hvm = 0; - int val; virConfValuePtr list; virDomainDefPtr def = NULL; virDomainDiskDefPtr disk = NULL; @@ -814,6 +965,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, goto cleanup; if (xenParseXMDisk(conf, def, xendConfigVersion) < 0) goto cleanup; + if (xenParseXMVfb(conf, def, xendConfigVersion) < 0) + goto cleanup; if (xenXMConfigCopyStringOpt(conf, "device_model", &def->emulator) < 0) goto cleanup; list = virConfGetValue(conf, "vif"); @@ -987,147 +1140,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, } } - /* HVM guests, or old PV guests use this config format */ - if (hvm || xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) { - if (xenXMConfigGetBool(conf, "vnc", &val, 0) < 0) - goto cleanup; - - if (val) { - if (VIR_ALLOC(graphics) < 0) - goto cleanup; - graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC; - if (xenXMConfigGetBool(conf, "vncunused", &val, 1) < 0) - goto cleanup; - graphics->data.vnc.autoport = val ? 1 : 0; - - if (!graphics->data.vnc.autoport) { - unsigned long vncdisplay; - if (xenXMConfigGetULong(conf, "vncdisplay", &vncdisplay, 0) < 0) - goto cleanup; - graphics->data.vnc.port = (int)vncdisplay + 5900; - } - - if (xenXMConfigCopyStringOpt(conf, "vnclisten", &listenAddr) < 0) - goto cleanup; - if (listenAddr && - virDomainGraphicsListenSetAddress(graphics, 0, listenAddr, - -1, true) < 0) { - goto cleanup; - } - VIR_FREE(listenAddr); - - if (xenXMConfigCopyStringOpt(conf, "vncpasswd", &graphics->data.vnc.auth.passwd) < 0) - goto cleanup; - if (xenXMConfigCopyStringOpt(conf, "keymap", &graphics->data.vnc.keymap) < 0) - goto cleanup; - - if (VIR_ALLOC_N(def->graphics, 1) < 0) - goto cleanup; - def->graphics[0] = graphics; - def->ngraphics = 1; - graphics = NULL; - } else { - if (xenXMConfigGetBool(conf, "sdl", &val, 0) < 0) - goto cleanup; - if (val) { - if (VIR_ALLOC(graphics) < 0) - goto cleanup; - graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SDL; - if (xenXMConfigCopyStringOpt(conf, "display", &graphics->data.sdl.display) < 0) - goto cleanup; - if (xenXMConfigCopyStringOpt(conf, "xauthority", &graphics->data.sdl.xauth) < 0) - goto cleanup; - if (VIR_ALLOC_N(def->graphics, 1) < 0) - goto cleanup; - def->graphics[0] = graphics; - def->ngraphics = 1; - graphics = NULL; - } - } - } - - if (!hvm && def->graphics == NULL) { /* New PV guests use this format */ - list = virConfGetValue(conf, "vfb"); - if (list && list->type == VIR_CONF_LIST && - list->list && list->list->type == VIR_CONF_STRING && - list->list->str) { - char vfb[MAX_VFB]; - char *key = vfb; - - if (virStrcpyStatic(vfb, list->list->str) == NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("VFB %s too big for destination"), - list->list->str); - goto cleanup; - } - - if (VIR_ALLOC(graphics) < 0) - goto cleanup; - - if (strstr(key, "type=sdl")) - graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SDL; - else - graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC; - - while (key) { - char *nextkey = strchr(key, ','); - char *end = nextkey; - if (nextkey) { - *end = '\0'; - nextkey++; - } - - if (!strchr(key, '=')) - break; - - if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) { - if (STRPREFIX(key, "vncunused=")) { - if (STREQ(key + 10, "1")) - graphics->data.vnc.autoport = true; - } else if (STRPREFIX(key, "vnclisten=")) { - if (virDomainGraphicsListenSetAddress(graphics, 0, key+10, - -1, true) < 0) - goto cleanup; - } else if (STRPREFIX(key, "vncpasswd=")) { - if (VIR_STRDUP(graphics->data.vnc.auth.passwd, key + 10) < 0) - goto cleanup; - } else if (STRPREFIX(key, "keymap=")) { - if (VIR_STRDUP(graphics->data.vnc.keymap, key + 7) < 0) - goto cleanup; - } else if (STRPREFIX(key, "vncdisplay=")) { - if (virStrToLong_i(key + 11, NULL, 10, - &graphics->data.vnc.port) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("invalid vncdisplay value '%s'"), - key + 11); - goto cleanup; - } - graphics->data.vnc.port += 5900; - } - } else { - if (STRPREFIX(key, "display=")) { - if (VIR_STRDUP(graphics->data.sdl.display, key + 8) < 0) - goto cleanup; - } else if (STRPREFIX(key, "xauthority=")) { - if (VIR_STRDUP(graphics->data.sdl.xauth, key + 11) < 0) - goto cleanup; - } - } - - while (nextkey && (nextkey[0] == ',' || - nextkey[0] == ' ' || - nextkey[0] == '\t')) - nextkey++; - key = nextkey; - } - if (VIR_ALLOC_N(def->graphics, 1) < 0) - goto cleanup; - def->graphics[0] = graphics; - def->ngraphics = 1; - graphics = NULL; - } - } - if (hvm) { virDomainChrDefPtr chr = NULL; -- 1.8.4.5

David Kiarie wrote:
From: Kiarie Kahurani <davidkiarie4@gmail.com>
introduce function xenParseXMVfb(virConfPtr conf,.......) which parses Vfb config
signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 296 ++++++++++++++++++++++++++++------------------------- 1 file changed, 154 insertions(+), 142 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 2c36c1b..38434be 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -695,6 +695,158 @@ int xenParseXMDisk(virConfPtr conf, virDomainDefPtr def, return 0; }
+static +int xenParseXMVfb(virConfPtr conf, virDomainDefPtr def, + int xendConfigVersion)
Ah, just noticed all the patches thus far have the function return type and name on the same line. Remember that the libvirt pattern is to have them on separate lines, e.g. static int xenParsexmVfb()
+{ + int val; + char *listenAddr = NULL; + //const char *str = NULL; + int hvm = STREQ(def->os.type, "hvm"); + virConfValuePtr list; + virDomainGraphicsDefPtr graphics = NULL; + + if (hvm || xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) { + if (xenXMConfigGetBool(conf, "vnc", &val, 0) < 0) + goto cleanup; + if (val) { + if (VIR_ALLOC(graphics) < 0) + goto cleanup; + graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC; + if (xenXMConfigGetBool(conf, "vncunused", &val, 1) < 0) + goto cleanup; + graphics->data.vnc.autoport = val ? 1 : 0; + if (!graphics->data.vnc.autoport) { + unsigned long vncdisplay; + if (xenXMConfigGetULong(conf, "vncdisplay", &vncdisplay, 0) < 0) + goto cleanup; + graphics->data.vnc.port = (int)vncdisplay + 5900; + } + + if (xenXMConfigCopyStringOpt(conf, "vnclisten", &listenAddr) < 0) + goto cleanup; + if (listenAddr && + virDomainGraphicsListenSetAddress(graphics, 0, listenAddr, + -1, true) < 0) { + goto cleanup; + } + + VIR_FREE(listenAddr); + if (xenXMConfigCopyStringOpt(conf, "vncpasswd", &graphics->data.vnc.auth.passwd) < 0) + goto cleanup; + if (xenXMConfigCopyStringOpt(conf, "keymap", &graphics->data.vnc.keymap) < 0) + goto cleanup; + if (VIR_ALLOC_N(def->graphics, 1) < 0) + goto cleanup; + def->graphics[0] = graphics; + def->ngraphics = 1; + graphics = NULL; + } else { + if (xenXMConfigGetBool(conf, "sdl", &val, 0) < 0) + goto cleanup; + if (val) { + if (VIR_ALLOC(graphics) < 0) + goto cleanup; + graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SDL; + if (xenXMConfigCopyStringOpt(conf, "display", &graphics->data.sdl.display) < 0) + goto cleanup; + if (xenXMConfigCopyStringOpt(conf, "xauthority", &graphics->data.sdl.xauth) < 0) + goto cleanup; + if (VIR_ALLOC_N(def->graphics, 1) < 0) + goto cleanup; + def->graphics[0] = graphics; + def->ngraphics = 1; + graphics = NULL; + } + } + } + + if (!hvm && def->graphics == NULL) { /* New PV guests use this format */ + list = virConfGetValue(conf, "vfb"); + if (list && list->type == VIR_CONF_LIST && + list->list && list->list->type == VIR_CONF_STRING && + list->list->str) { + char vfb[MAX_VFB]; + char *key = vfb; + + if (virStrcpyStatic(vfb, list->list->str) == NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("VFB %s too big for destination"), + list->list->str); + goto cleanup; + } + + if (VIR_ALLOC(graphics) < 0) + goto cleanup; + if (strstr(key, "type=sdl")) + graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SDL; + else + graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC; + while (key) { + char *nextkey = strchr(key, ','); + char *end = nextkey; + if (nextkey) { + *end = '\0'; + nextkey++; + } + + if (!strchr(key, '=')) + break; + if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) { + if (STRPREFIX(key, "vncunused=")) { + if (STREQ(key + 10, "1")) + graphics->data.vnc.autoport = true; + } else if (STRPREFIX(key, "vnclisten=")) { + if (virDomainGraphicsListenSetAddress(graphics, 0, key+10, + -1, true) < 0) + goto cleanup; + } else if (STRPREFIX(key, "vncpasswd=")) { + if (VIR_STRDUP(graphics->data.vnc.auth.passwd, key + 10) < 0) + goto cleanup; + } else if (STRPREFIX(key, "keymap=")) { + if (VIR_STRDUP(graphics->data.vnc.keymap, key + 7) < 0) + goto cleanup; + } else if (STRPREFIX(key, "vncdisplay=")) { + if (virStrToLong_i(key + 11, NULL, 10, + &graphics->data.vnc.port) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("invalid vncdisplay value '%s'"), + key + 11); + goto cleanup; + } + graphics->data.vnc.port += 5900; + } + } else { + if (STRPREFIX(key, "display=")) { + if (VIR_STRDUP(graphics->data.sdl.display, key + 8) < 0) + goto cleanup; + } else if (STRPREFIX(key, "xauthority=")) { + if (VIR_STRDUP(graphics->data.sdl.xauth, key + 11) < 0) + goto cleanup; + } + } + + while (nextkey && (nextkey[0] == ',' || + nextkey[0] == ' ' || + nextkey[0] == '\t')) + nextkey++; + key = nextkey; + } + if (VIR_ALLOC_N(def->graphics, 1) < 0) + goto cleanup; + def->graphics[0] = graphics; + def->ngraphics = 1; + graphics = NULL; + } + } + + return 0; + + cleanup: + virDomainGraphicsDefFree(graphics); + return -1; +} +
virDomainDefPtr xenParseXM(virConfPtr conf, int xendConfigVersion, @@ -702,7 +854,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, { const char *str; int hvm = 0; - int val; virConfValuePtr list; virDomainDefPtr def = NULL; virDomainDiskDefPtr disk = NULL; @@ -814,6 +965,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, goto cleanup; if (xenParseXMDisk(conf, def, xendConfigVersion) < 0) goto cleanup; + if (xenParseXMVfb(conf, def, xendConfigVersion) < 0) + goto cleanup; if (xenXMConfigCopyStringOpt(conf, "device_model", &def->emulator) < 0) goto cleanup; list = virConfGetValue(conf, "vif"); @@ -987,147 +1140,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, } }
- /* HVM guests, or old PV guests use this config format */ - if (hvm || xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) { - if (xenXMConfigGetBool(conf, "vnc", &val, 0) < 0) - goto cleanup; - - if (val) { - if (VIR_ALLOC(graphics) < 0) - goto cleanup; - graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC; - if (xenXMConfigGetBool(conf, "vncunused", &val, 1) < 0) - goto cleanup; - graphics->data.vnc.autoport = val ? 1 : 0; - - if (!graphics->data.vnc.autoport) { - unsigned long vncdisplay; - if (xenXMConfigGetULong(conf, "vncdisplay", &vncdisplay, 0) < 0) - goto cleanup; - graphics->data.vnc.port = (int)vncdisplay + 5900; - } - - if (xenXMConfigCopyStringOpt(conf, "vnclisten", &listenAddr) < 0) - goto cleanup; - if (listenAddr && - virDomainGraphicsListenSetAddress(graphics, 0, listenAddr, - -1, true) < 0) { - goto cleanup; - } - VIR_FREE(listenAddr); - - if (xenXMConfigCopyStringOpt(conf, "vncpasswd", &graphics->data.vnc.auth.passwd) < 0) - goto cleanup; - if (xenXMConfigCopyStringOpt(conf, "keymap", &graphics->data.vnc.keymap) < 0) - goto cleanup; - - if (VIR_ALLOC_N(def->graphics, 1) < 0) - goto cleanup; - def->graphics[0] = graphics; - def->ngraphics = 1; - graphics = NULL; - } else { - if (xenXMConfigGetBool(conf, "sdl", &val, 0) < 0) - goto cleanup; - if (val) { - if (VIR_ALLOC(graphics) < 0) - goto cleanup; - graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SDL; - if (xenXMConfigCopyStringOpt(conf, "display", &graphics->data.sdl.display) < 0) - goto cleanup; - if (xenXMConfigCopyStringOpt(conf, "xauthority", &graphics->data.sdl.xauth) < 0) - goto cleanup; - if (VIR_ALLOC_N(def->graphics, 1) < 0) - goto cleanup; - def->graphics[0] = graphics; - def->ngraphics = 1; - graphics = NULL; - } - } - } - - if (!hvm && def->graphics == NULL) { /* New PV guests use this format */ - list = virConfGetValue(conf, "vfb"); - if (list && list->type == VIR_CONF_LIST && - list->list && list->list->type == VIR_CONF_STRING && - list->list->str) { - char vfb[MAX_VFB]; - char *key = vfb; - - if (virStrcpyStatic(vfb, list->list->str) == NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("VFB %s too big for destination"), - list->list->str); - goto cleanup; - } - - if (VIR_ALLOC(graphics) < 0) - goto cleanup; - - if (strstr(key, "type=sdl")) - graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SDL; - else - graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC; - - while (key) { - char *nextkey = strchr(key, ','); - char *end = nextkey; - if (nextkey) { - *end = '\0'; - nextkey++; - } - - if (!strchr(key, '=')) - break; - - if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) { - if (STRPREFIX(key, "vncunused=")) { - if (STREQ(key + 10, "1")) - graphics->data.vnc.autoport = true; - } else if (STRPREFIX(key, "vnclisten=")) { - if (virDomainGraphicsListenSetAddress(graphics, 0, key+10, - -1, true) < 0) - goto cleanup; - } else if (STRPREFIX(key, "vncpasswd=")) { - if (VIR_STRDUP(graphics->data.vnc.auth.passwd, key + 10) < 0) - goto cleanup; - } else if (STRPREFIX(key, "keymap=")) { - if (VIR_STRDUP(graphics->data.vnc.keymap, key + 7) < 0) - goto cleanup; - } else if (STRPREFIX(key, "vncdisplay=")) { - if (virStrToLong_i(key + 11, NULL, 10, - &graphics->data.vnc.port) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("invalid vncdisplay value '%s'"), - key + 11); - goto cleanup; - } - graphics->data.vnc.port += 5900; - } - } else { - if (STRPREFIX(key, "display=")) { - if (VIR_STRDUP(graphics->data.sdl.display, key + 8) < 0) - goto cleanup; - } else if (STRPREFIX(key, "xauthority=")) { - if (VIR_STRDUP(graphics->data.sdl.xauth, key + 11) < 0) - goto cleanup; - } - } - - while (nextkey && (nextkey[0] == ',' || - nextkey[0] == ' ' || - nextkey[0] == '\t')) - nextkey++; - key = nextkey; - } - if (VIR_ALLOC_N(def->graphics, 1) < 0) - goto cleanup; - def->graphics[0] = graphics; - def->ngraphics = 1; - graphics = NULL; - } - } - if (hvm) { virDomainChrDefPtr chr = NULL;

From: Kiarie Kahurani <davidkiarie4@gmail.com> introduce function xenParseXMOS(virConfPtr conf,.......) which parses OS config instead signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 132 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 75 insertions(+), 57 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 38434be..62c7e62 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -848,6 +848,79 @@ int xenParseXMVfb(virConfPtr conf, virDomainDefPtr def, } +static +int xenParseXMOS(virConfPtr conf, virDomainDefPtr def) +{ + size_t i; + + if (STREQ(def->os.type, "hvm")) { + const char *boot; + if (xenXMConfigCopyStringOpt(conf, "device_model", &def->emulator) < 0) + return -1; + + if (xenXMConfigCopyStringOpt(conf, "device_model", &def->emulator) < 0) + return -1; + + if (xenXMConfigCopyString(conf, "kernel", &def->os.loader) < 0) + return -1; + + if (xenXMConfigGetString(conf, "boot", &boot, "c") < 0) + return -1; + + for (i = 0; i < VIR_DOMAIN_BOOT_LAST && boot[i]; i++) { + switch (*boot) { + case 'a': + def->os.bootDevs[i] = VIR_DOMAIN_BOOT_FLOPPY; + break; + case 'd': + def->os.bootDevs[i] = VIR_DOMAIN_BOOT_CDROM; + break; + case 'n': + def->os.bootDevs[i] = VIR_DOMAIN_BOOT_NET; + break; + case 'c': + default: + def->os.bootDevs[i] = VIR_DOMAIN_BOOT_DISK; + break; + } + def->os.nBootDevs++; + } + } else { + const char *extra, *root; + + if (xenXMConfigCopyStringOpt(conf, "bootloader", &def->os.bootloader) < 0) + return -1; + + if (xenXMConfigCopyStringOpt(conf, "bootargs", &def->os.bootloaderArgs) < 0) + return -1; + + if (xenXMConfigCopyStringOpt(conf, "kernel", &def->os.kernel) < 0) + return -1; + + if (xenXMConfigCopyStringOpt(conf, "ramdisk", &def->os.initrd) < 0) + return -1; + + if (xenXMConfigGetString(conf, "extra", &extra, NULL) < 0) + return -1; + + if (xenXMConfigGetString(conf, "root", &root, NULL) < 0) + return -1; + + if (root) { + if (virAsprintf(&def->os.cmdline, "root=%s %s", root, extra) < 0) + return -1; + + } else { + if (VIR_STRDUP(def->os.cmdline, extra) < 0) + return -1; + + } + } + + return 0; +} + + virDomainDefPtr xenParseXM(virConfPtr conf, int xendConfigVersion, virCapsPtr caps) @@ -858,8 +931,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, virDomainDefPtr def = NULL; virDomainDiskDefPtr disk = NULL; virDomainNetDefPtr net = NULL; - virDomainGraphicsDefPtr graphics = NULL; - size_t i; const char *defaultMachine; char *script = NULL; char *listenAddr = NULL; @@ -903,58 +974,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, goto cleanup; } - if (hvm) { - const char *boot; - if (xenXMConfigCopyString(conf, "kernel", &def->os.loader) < 0) - goto cleanup; - - if (xenXMConfigGetString(conf, "boot", &boot, "c") < 0) - goto cleanup; - - for (i = 0; i < VIR_DOMAIN_BOOT_LAST && boot[i]; i++) { - switch (*boot) { - case 'a': - def->os.bootDevs[i] = VIR_DOMAIN_BOOT_FLOPPY; - break; - case 'd': - def->os.bootDevs[i] = VIR_DOMAIN_BOOT_CDROM; - break; - case 'n': - def->os.bootDevs[i] = VIR_DOMAIN_BOOT_NET; - break; - case 'c': - default: - def->os.bootDevs[i] = VIR_DOMAIN_BOOT_DISK; - break; - } - def->os.nBootDevs++; - } - } else { - const char *extra, *root; - - if (xenXMConfigCopyStringOpt(conf, "bootloader", &def->os.bootloader) < 0) - goto cleanup; - if (xenXMConfigCopyStringOpt(conf, "bootargs", &def->os.bootloaderArgs) < 0) - goto cleanup; - - if (xenXMConfigCopyStringOpt(conf, "kernel", &def->os.kernel) < 0) - goto cleanup; - if (xenXMConfigCopyStringOpt(conf, "ramdisk", &def->os.initrd) < 0) - goto cleanup; - if (xenXMConfigGetString(conf, "extra", &extra, NULL) < 0) - goto cleanup; - if (xenXMConfigGetString(conf, "root", &root, NULL) < 0) - goto cleanup; - - if (root) { - if (virAsprintf(&def->os.cmdline, "root=%s %s", root, extra) < 0) - goto cleanup; - } else { - if (VIR_STRDUP(def->os.cmdline, extra) < 0) - goto cleanup; - } - } - + if (xenParseXMOS(conf, def) < 0) + goto cleanup; if (xenParseXMMem(conf, def) < 0) goto cleanup; if (xenParseXMEventsActions(conf, def) < 0) @@ -967,8 +988,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, goto cleanup; if (xenParseXMVfb(conf, def, xendConfigVersion) < 0) goto cleanup; - if (xenXMConfigCopyStringOpt(conf, "device_model", &def->emulator) < 0) - goto cleanup; list = virConfGetValue(conf, "vif"); if (list && list->type == VIR_CONF_LIST) { list = list->list; @@ -1235,7 +1254,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, return def; cleanup: - virDomainGraphicsDefFree(graphics); virDomainNetDefFree(net); virDomainDiskDefFree(disk); virDomainDefFree(def); -- 1.8.4.5

From: Kiarie Kahurani <davidkiarie4@gmail.com> introduce function xenParseXMCharDev(virConfPtr conf,.......) which parses char devices config instead and also got rid of some unused variables signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 176 ++++++++++++++++++++++++++++------------------------- 1 file changed, 92 insertions(+), 84 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 62c7e62..48b68fb 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -921,6 +921,96 @@ int xenParseXMOS(virConfPtr conf, virDomainDefPtr def) } +static +int xenParseXMCharDev(virConfPtr conf, virDomainDefPtr def) +{ + const char *str; + virConfValuePtr value = NULL; + virDomainChrDefPtr chr = NULL; + + if (STREQ(def->os.type, "hvm")) { + if (xenXMConfigGetString(conf, "parallel", &str, NULL) < 0) + goto cleanup; + if (str && STRNEQ(str, "none") && + !(chr = xenParseSxprChar(str, NULL))) + goto cleanup; + if (chr) { + if (VIR_ALLOC_N(def->parallels, 1) < 0) { + goto cleanup; + } + + chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL; + chr->target.port = 0; + def->parallels[0] = chr; + def->nparallels++; + chr = NULL; + } + + /* Try to get the list of values to support multiple serial ports */ + value = virConfGetValue(conf, "serial"); + if (value && value->type == VIR_CONF_LIST) { + int portnum = -1; + + value = value->list; + while (value) { + char *port = NULL; + + if ((value->type != VIR_CONF_STRING) || (value->str == NULL)) + goto cleanup; + port = value->str; + portnum++; + if (STREQ(port, "none")) { + value = value->next; + continue; + } + + if (!(chr = xenParseSxprChar(port, NULL))) + goto cleanup; + chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; + chr->target.port = portnum; + if (VIR_APPEND_ELEMENT(def->serials, def->nserials, chr) < 0) { + goto cleanup; + } + + value = value->next; + } + } else { + /* If domain is not using multiple serial ports we parse data old way */ + if (xenXMConfigGetString(conf, "serial", &str, NULL) < 0) + goto cleanup; + if (str && STRNEQ(str, "none") && + !(chr = xenParseSxprChar(str, NULL))) + goto cleanup; + if (chr) { + if (VIR_ALLOC_N(def->serials, 1) < 0) { + virDomainChrDefFree(chr); + goto cleanup; + } + chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; + chr->target.port = 0; + def->serials[0] = chr; + def->nserials++; + } + } + } else { + if (VIR_ALLOC_N(def->consoles, 1) < 0) + goto cleanup; + def->nconsoles = 1; + if (!(def->consoles[0] = xenParseSxprChar("pty", NULL))) + goto cleanup; + def->consoles[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE; + def->consoles[0]->target.port = 0; + def->consoles[0]->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; + } + + return 0; + + cleanup: + virDomainChrDefFree(chr); + return -1; +} + + virDomainDefPtr xenParseXM(virConfPtr conf, int xendConfigVersion, virCapsPtr caps) @@ -933,7 +1023,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, virDomainNetDefPtr net = NULL; const char *defaultMachine; char *script = NULL; - char *listenAddr = NULL; if (VIR_ALLOC(def) < 0) return NULL; @@ -1159,88 +1248,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, } } - if (hvm) { - virDomainChrDefPtr chr = NULL; - - if (xenXMConfigGetString(conf, "parallel", &str, NULL) < 0) - goto cleanup; - if (str && STRNEQ(str, "none") && - !(chr = xenParseSxprChar(str, NULL))) - goto cleanup; - - if (chr) { - if (VIR_ALLOC_N(def->parallels, 1) < 0) { - virDomainChrDefFree(chr); - goto cleanup; - } - chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL; - chr->target.port = 0; - def->parallels[0] = chr; - def->nparallels++; - chr = NULL; - } - - /* Try to get the list of values to support multiple serial ports */ - list = virConfGetValue(conf, "serial"); - if (list && list->type == VIR_CONF_LIST) { - int portnum = -1; - - list = list->list; - while (list) { - char *port = NULL; - - if ((list->type != VIR_CONF_STRING) || (list->str == NULL)) - goto cleanup; - - port = list->str; - portnum++; - if (STREQ(port, "none")) { - list = list->next; - continue; - } - - if (!(chr = xenParseSxprChar(port, NULL))) - goto cleanup; - - chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; - chr->target.port = portnum; - - if (VIR_APPEND_ELEMENT(def->serials, def->nserials, chr) < 0) { - virDomainChrDefFree(chr); - goto cleanup; - } - - list = list->next; - } - } else { - /* If domain is not using multiple serial ports we parse data old way */ - if (xenXMConfigGetString(conf, "serial", &str, NULL) < 0) - goto cleanup; - if (str && STRNEQ(str, "none") && - !(chr = xenParseSxprChar(str, NULL))) - goto cleanup; - if (chr) { - if (VIR_ALLOC_N(def->serials, 1) < 0) { - virDomainChrDefFree(chr); - goto cleanup; - } - chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; - chr->target.port = 0; - def->serials[0] = chr; - def->nserials++; - } - } - } else { - if (VIR_ALLOC_N(def->consoles, 1) < 0) - goto cleanup; - def->nconsoles = 1; - if (!(def->consoles[0] = xenParseSxprChar("pty", NULL))) - goto cleanup; - def->consoles[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE; - def->consoles[0]->target.port = 0; - def->consoles[0]->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; - } - + if (xenParseXMCharDev(conf, def) < 0) + goto cleanup; if (hvm) { if (xenXMConfigGetString(conf, "soundhw", &str, NULL) < 0) goto cleanup; @@ -1258,7 +1267,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, virDomainDiskDefFree(disk); virDomainDefFree(def); VIR_FREE(script); - VIR_FREE(listenAddr); return NULL; } -- 1.8.4.5

From: Kiarie Kahurani <davidkiarie4@gmail.com> introduce function xenParseXMVif(virConfPtr conf, .......) which parses char Vif config instead signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 161 ++++++++++++++++++++++++++++------------------------- 1 file changed, 86 insertions(+), 75 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 48b68fb..e6a1b7d 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1011,73 +1011,13 @@ int xenParseXMCharDev(virConfPtr conf, virDomainDefPtr def) } -virDomainDefPtr -xenParseXM(virConfPtr conf, int xendConfigVersion, - virCapsPtr caps) +static +int xenParseXMVif(virConfPtr conf, virDomainDefPtr def) { - const char *str; - int hvm = 0; - virConfValuePtr list; - virDomainDefPtr def = NULL; - virDomainDiskDefPtr disk = NULL; - virDomainNetDefPtr net = NULL; - const char *defaultMachine; char *script = NULL; + virDomainNetDefPtr net = NULL; + virConfValuePtr list = virConfGetValue(conf, "vif"); - if (VIR_ALLOC(def) < 0) - return NULL; - - def->virtType = VIR_DOMAIN_VIRT_XEN; - def->id = -1; - - if (xenXMConfigCopyString(conf, "name", &def->name) < 0) - goto cleanup; - if (xenXMConfigGetUUID(conf, "uuid", def->uuid) < 0) - goto cleanup; - - - if ((xenXMConfigGetString(conf, "builder", &str, "linux") == 0) && - STREQ(str, "hvm")) - hvm = 1; - - if (VIR_STRDUP(def->os.type, hvm ? "hvm" : "xen") < 0) - goto cleanup; - - def->os.arch = - virCapabilitiesDefaultGuestArch(caps, - def->os.type, - virDomainVirtTypeToString(def->virtType)); - if (!def->os.arch) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("no supported architecture for os type '%s'"), - def->os.type); - goto cleanup; - } - - defaultMachine = virCapabilitiesDefaultGuestMachine(caps, - def->os.type, - def->os.arch, - virDomainVirtTypeToString(def->virtType)); - if (defaultMachine != NULL) { - if (VIR_STRDUP(def->os.machine, defaultMachine) < 0) - goto cleanup; - } - - if (xenParseXMOS(conf, def) < 0) - goto cleanup; - if (xenParseXMMem(conf, def) < 0) - goto cleanup; - if (xenParseXMEventsActions(conf, def) < 0) - goto cleanup; - if (xenParseXMTimeOffset(conf, def, xendConfigVersion) < 0) - goto cleanup; - if (xenParseXMCPUFeatures(conf, def) < 0) - goto cleanup; - if (xenParseXMDisk(conf, def, xendConfigVersion) < 0) - goto cleanup; - if (xenParseXMVfb(conf, def, xendConfigVersion) < 0) - goto cleanup; - list = virConfGetValue(conf, "vif"); if (list && list->type == VIR_CONF_LIST) { list = list->list; while (list) { @@ -1098,7 +1038,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, if ((list->type != VIR_CONF_STRING) || (list->str == NULL)) goto skipnic; - key = list->str; while (key) { char *data; @@ -1107,7 +1046,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, if (!(data = strchr(key, '='))) goto skipnic; data++; - if (STRPREFIX(key, "mac=")) { int len = nextkey ? (nextkey - data) : sizeof(mac) - 1; if (virStrncpy(mac, data, len, sizeof(mac)) == NULL) { @@ -1133,14 +1071,16 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, int len = nextkey ? (nextkey - data) : sizeof(model) - 1; if (virStrncpy(model, data, len, sizeof(model)) == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Model %s too big for destination"), data); + _("Model %s too big for destination"), + data); goto skipnic; } } else if (STRPREFIX(key, "type=")) { int len = nextkey ? (nextkey - data) : sizeof(type) - 1; if (virStrncpy(type, data, len, sizeof(type)) == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Type %s too big for destination"), data); + _("Type %s too big for destination"), + data); goto skipnic; } } else if (STRPREFIX(key, "vifname=")) { @@ -1155,7 +1095,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, int len = nextkey ? (nextkey - data) : sizeof(ip) - 1; if (virStrncpy(ip, data, len, sizeof(ip)) == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("IP %s too big for destination"), data); + _("IP %s too big for destination"), + data); goto skipnic; } } @@ -1169,7 +1110,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, if (VIR_ALLOC(net) < 0) goto cleanup; - if (mac[0]) { if (virMacAddrParse(mac, &net->mac) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1198,28 +1138,99 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, if (script && script[0] && VIR_STRDUP(net->script, script) < 0) goto cleanup; - if (model[0] && VIR_STRDUP(net->model, model) < 0) goto cleanup; - if (!model[0] && type[0] && STREQ(type, "netfront") && VIR_STRDUP(net->model, "netfront") < 0) goto cleanup; - if (vifname[0] && VIR_STRDUP(net->ifname, vifname) < 0) goto cleanup; - if (VIR_APPEND_ELEMENT(def->nets, def->nnets, net) < 0) goto cleanup; - + VIR_FREE(script); skipnic: list = list->next; virDomainNetDefFree(net); } } + return 0; + + cleanup: + VIR_FREE(script); + return -1; +} + + +virDomainDefPtr +xenParseXM(virConfPtr conf, int xendConfigVersion, + virCapsPtr caps) +{ + const char *str; + int hvm = 0; + virDomainDefPtr def = NULL; + virDomainDiskDefPtr disk = NULL; + virDomainNetDefPtr net = NULL; + const char *defaultMachine; + char *script = NULL; + + if (VIR_ALLOC(def) < 0) + return NULL; + + def->virtType = VIR_DOMAIN_VIRT_XEN; + def->id = -1; + + if (xenXMConfigCopyString(conf, "name", &def->name) < 0) + goto cleanup; + if (xenXMConfigGetUUID(conf, "uuid", def->uuid) < 0) + goto cleanup; + + + if ((xenXMConfigGetString(conf, "builder", &str, "linux") == 0) && + STREQ(str, "hvm")) + hvm = 1; + + if (VIR_STRDUP(def->os.type, hvm ? "hvm" : "xen") < 0) + goto cleanup; + + def->os.arch = + virCapabilitiesDefaultGuestArch(caps, + def->os.type, + virDomainVirtTypeToString(def->virtType)); + if (!def->os.arch) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("no supported architecture for os type '%s'"), + def->os.type); + goto cleanup; + } + + defaultMachine = virCapabilitiesDefaultGuestMachine(caps, + def->os.type, + def->os.arch, + virDomainVirtTypeToString(def->virtType)); + if (defaultMachine != NULL) { + if (VIR_STRDUP(def->os.machine, defaultMachine) < 0) + goto cleanup; + } + + if (xenParseXMOS(conf, def) < 0) + goto cleanup; + if (xenParseXMMem(conf, def) < 0) + goto cleanup; + if (xenParseXMEventsActions(conf, def) < 0) + goto cleanup; + if (xenParseXMTimeOffset(conf, def, xendConfigVersion) < 0) + goto cleanup; + if (xenParseXMCPUFeatures(conf, def) < 0) + goto cleanup; + if (xenParseXMDisk(conf, def, xendConfigVersion) < 0) + goto cleanup; + if (xenParseXMVfb(conf, def, xendConfigVersion) < 0) + goto cleanup; + if (xenParseXMVif(conf, def) < 0) + goto cleanup; if (xenParseXMPCI(conf, def) < 0) goto cleanup; if (hvm) { -- 1.8.4.5

David Kiarie wrote:
From: Kiarie Kahurani <davidkiarie4@gmail.com>
introduce function xenParseXMVif(virConfPtr conf, .......) which parses char Vif config instead
signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 161 ++++++++++++++++++++++++++++------------------------- 1 file changed, 86 insertions(+), 75 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 48b68fb..e6a1b7d 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1011,73 +1011,13 @@ int xenParseXMCharDev(virConfPtr conf, virDomainDefPtr def) }
-virDomainDefPtr -xenParseXM(virConfPtr conf, int xendConfigVersion, - virCapsPtr caps) +static +int xenParseXMVif(virConfPtr conf, virDomainDefPtr def)
I'll stop mentioning return type and function name of separate lines :-).
{ - const char *str; - int hvm = 0; - virConfValuePtr list; - virDomainDefPtr def = NULL; - virDomainDiskDefPtr disk = NULL; - virDomainNetDefPtr net = NULL; - const char *defaultMachine; char *script = NULL; + virDomainNetDefPtr net = NULL; + virConfValuePtr list = virConfGetValue(conf, "vif");
- if (VIR_ALLOC(def) < 0) - return NULL; - - def->virtType = VIR_DOMAIN_VIRT_XEN; - def->id = -1; - - if (xenXMConfigCopyString(conf, "name", &def->name) < 0) - goto cleanup; - if (xenXMConfigGetUUID(conf, "uuid", def->uuid) < 0) - goto cleanup; - - - if ((xenXMConfigGetString(conf, "builder", &str, "linux") == 0) && - STREQ(str, "hvm")) - hvm = 1; - - if (VIR_STRDUP(def->os.type, hvm ? "hvm" : "xen") < 0) - goto cleanup; - - def->os.arch = - virCapabilitiesDefaultGuestArch(caps, - def->os.type, - virDomainVirtTypeToString(def->virtType)); - if (!def->os.arch) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("no supported architecture for os type '%s'"), - def->os.type); - goto cleanup; - } - - defaultMachine = virCapabilitiesDefaultGuestMachine(caps, - def->os.type, - def->os.arch, - virDomainVirtTypeToString(def->virtType)); - if (defaultMachine != NULL) { - if (VIR_STRDUP(def->os.machine, defaultMachine) < 0) - goto cleanup; - } - - if (xenParseXMOS(conf, def) < 0) - goto cleanup; - if (xenParseXMMem(conf, def) < 0) - goto cleanup; - if (xenParseXMEventsActions(conf, def) < 0) - goto cleanup; - if (xenParseXMTimeOffset(conf, def, xendConfigVersion) < 0) - goto cleanup; - if (xenParseXMCPUFeatures(conf, def) < 0) - goto cleanup; - if (xenParseXMDisk(conf, def, xendConfigVersion) < 0) - goto cleanup; - if (xenParseXMVfb(conf, def, xendConfigVersion) < 0) - goto cleanup; - list = virConfGetValue(conf, "vif"); if (list && list->type == VIR_CONF_LIST) { list = list->list; while (list) { @@ -1098,7 +1038,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
if ((list->type != VIR_CONF_STRING) || (list->str == NULL)) goto skipnic; -
More spurious whitespace changes.
key = list->str; while (key) { char *data; @@ -1107,7 +1046,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, if (!(data = strchr(key, '='))) goto skipnic; data++; -
Here too.
if (STRPREFIX(key, "mac=")) { int len = nextkey ? (nextkey - data) : sizeof(mac) - 1; if (virStrncpy(mac, data, len, sizeof(mac)) == NULL) { @@ -1133,14 +1071,16 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, int len = nextkey ? (nextkey - data) : sizeof(model) - 1; if (virStrncpy(model, data, len, sizeof(model)) == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Model %s too big for destination"), data); + _("Model %s too big for destination"), + data); goto skipnic; } } else if (STRPREFIX(key, "type=")) { int len = nextkey ? (nextkey - data) : sizeof(type) - 1; if (virStrncpy(type, data, len, sizeof(type)) == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Type %s too big for destination"), data); + _("Type %s too big for destination"), + data); goto skipnic; } } else if (STRPREFIX(key, "vifname=")) { @@ -1155,7 +1095,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, int len = nextkey ? (nextkey - data) : sizeof(ip) - 1; if (virStrncpy(ip, data, len, sizeof(ip)) == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("IP %s too big for destination"), data); + _("IP %s too big for destination"), + data);
The original actually fit within 80 columns.
goto skipnic; } } @@ -1169,7 +1110,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
if (VIR_ALLOC(net) < 0) goto cleanup; - if (mac[0]) { if (virMacAddrParse(mac, &net->mac) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1198,28 +1138,99 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, if (script && script[0] && VIR_STRDUP(net->script, script) < 0) goto cleanup; - if (model[0] && VIR_STRDUP(net->model, model) < 0) goto cleanup; - if (!model[0] && type[0] && STREQ(type, "netfront") && VIR_STRDUP(net->model, "netfront") < 0) goto cleanup; - if (vifname[0] && VIR_STRDUP(net->ifname, vifname) < 0) goto cleanup; - if (VIR_APPEND_ELEMENT(def->nets, def->nnets, net) < 0) goto cleanup; - + VIR_FREE(script);
The existing whitespace in these two hunks is fine IMO and makes the function more readable. Regards, Jim
skipnic: list = list->next; virDomainNetDefFree(net); } }
+ return 0; + + cleanup: + VIR_FREE(script); + return -1; +} + + +virDomainDefPtr +xenParseXM(virConfPtr conf, int xendConfigVersion, + virCapsPtr caps) +{ + const char *str; + int hvm = 0; + virDomainDefPtr def = NULL; + virDomainDiskDefPtr disk = NULL; + virDomainNetDefPtr net = NULL; + const char *defaultMachine; + char *script = NULL; + + if (VIR_ALLOC(def) < 0) + return NULL; + + def->virtType = VIR_DOMAIN_VIRT_XEN; + def->id = -1; + + if (xenXMConfigCopyString(conf, "name", &def->name) < 0) + goto cleanup; + if (xenXMConfigGetUUID(conf, "uuid", def->uuid) < 0) + goto cleanup; + + + if ((xenXMConfigGetString(conf, "builder", &str, "linux") == 0) && + STREQ(str, "hvm")) + hvm = 1; + + if (VIR_STRDUP(def->os.type, hvm ? "hvm" : "xen") < 0) + goto cleanup; + + def->os.arch = + virCapabilitiesDefaultGuestArch(caps, + def->os.type, + virDomainVirtTypeToString(def->virtType)); + if (!def->os.arch) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("no supported architecture for os type '%s'"), + def->os.type); + goto cleanup; + } + + defaultMachine = virCapabilitiesDefaultGuestMachine(caps, + def->os.type, + def->os.arch, + virDomainVirtTypeToString(def->virtType)); + if (defaultMachine != NULL) { + if (VIR_STRDUP(def->os.machine, defaultMachine) < 0) + goto cleanup; + } + + if (xenParseXMOS(conf, def) < 0) + goto cleanup; + if (xenParseXMMem(conf, def) < 0) + goto cleanup; + if (xenParseXMEventsActions(conf, def) < 0) + goto cleanup; + if (xenParseXMTimeOffset(conf, def, xendConfigVersion) < 0) + goto cleanup; + if (xenParseXMCPUFeatures(conf, def) < 0) + goto cleanup; + if (xenParseXMDisk(conf, def, xendConfigVersion) < 0) + goto cleanup; + if (xenParseXMVfb(conf, def, xendConfigVersion) < 0) + goto cleanup; + if (xenParseXMVif(conf, def) < 0) + goto cleanup; if (xenParseXMPCI(conf, def) < 0) goto cleanup; if (hvm) {

From: Kiarie Kahurani <davidkiarie4@gmail.com> introduce function xenParseXMEmulatedDevices(virConfPtr conf,.......) which parses the emulated hardware instead signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 93 +++++++++++++++++++++++++++--------------------------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index e6a1b7d..5959892 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1164,6 +1164,51 @@ int xenParseXMVif(virConfPtr conf, virDomainDefPtr def) } +static +int xenParseXMEmulatedDevices(virConfPtr conf, virDomainDefPtr def) +{ + const char *str; + + if (STREQ(def->os.type, "hvm")) { + if (xenXMConfigGetString(conf, "soundhw", &str, NULL) < 0) + return -1; + + if (str && + xenParseSxprSound(def, str) < 0) + return -1; + + if (xenXMConfigGetString(conf, "usbdevice", &str, NULL) < 0) + return -1; + + if (str && + (STREQ(str, "tablet") || + STREQ(str, "mouse") || + STREQ(str, "keyboard"))) { + virDomainInputDefPtr input; + if (VIR_ALLOC(input) < 0) + return -1; + + input->bus = VIR_DOMAIN_INPUT_BUS_USB; + if (STREQ(str, "mouse")) + input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE; + else if (STREQ(str, "tablet")) + input->type = VIR_DOMAIN_INPUT_TYPE_TABLET; + else if (STREQ(str, "keyboard")) + input->type = VIR_DOMAIN_INPUT_TYPE_KBD; + if (VIR_ALLOC_N(def->inputs, 1) < 0) { + virDomainInputDefFree(input); + return -1; + + } + def->inputs[0] = input; + def->ninputs = 1; + } + } + + return 0; +} + + virDomainDefPtr xenParseXM(virConfPtr conf, int xendConfigVersion, virCapsPtr caps) @@ -1171,30 +1216,23 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, const char *str; int hvm = 0; virDomainDefPtr def = NULL; - virDomainDiskDefPtr disk = NULL; - virDomainNetDefPtr net = NULL; const char *defaultMachine; - char *script = NULL; if (VIR_ALLOC(def) < 0) return NULL; def->virtType = VIR_DOMAIN_VIRT_XEN; def->id = -1; - if (xenXMConfigCopyString(conf, "name", &def->name) < 0) goto cleanup; if (xenXMConfigGetUUID(conf, "uuid", def->uuid) < 0) goto cleanup; - - if ((xenXMConfigGetString(conf, "builder", &str, "linux") == 0) && STREQ(str, "hvm")) hvm = 1; if (VIR_STRDUP(def->os.type, hvm ? "hvm" : "xen") < 0) goto cleanup; - def->os.arch = virCapabilitiesDefaultGuestArch(caps, def->os.type, @@ -1233,51 +1271,14 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, goto cleanup; if (xenParseXMPCI(conf, def) < 0) goto cleanup; - if (hvm) { - if (xenXMConfigGetString(conf, "usbdevice", &str, NULL) < 0) - goto cleanup; - if (str && - (STREQ(str, "tablet") || - STREQ(str, "mouse") || - STREQ(str, "keyboard"))) { - virDomainInputDefPtr input; - if (VIR_ALLOC(input) < 0) - goto cleanup; - input->bus = VIR_DOMAIN_INPUT_BUS_USB; - if (STREQ(str, "mouse")) - input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE; - else if (STREQ(str, "tablet")) - input->type = VIR_DOMAIN_INPUT_TYPE_TABLET; - else if (STREQ(str, "keyboard")) - input->type = VIR_DOMAIN_INPUT_TYPE_KBD; - if (VIR_ALLOC_N(def->inputs, 1) < 0) { - virDomainInputDefFree(input); - goto cleanup; - } - def->inputs[0] = input; - def->ninputs = 1; - } - } - + if (xenParseXMEmulatedDevices(conf, def) < 0) + goto cleanup; if (xenParseXMCharDev(conf, def) < 0) goto cleanup; - if (hvm) { - if (xenXMConfigGetString(conf, "soundhw", &str, NULL) < 0) - goto cleanup; - - if (str && - xenParseSxprSound(def, str) < 0) - goto cleanup; - } - - VIR_FREE(script); return def; cleanup: - virDomainNetDefFree(net); - virDomainDiskDefFree(disk); virDomainDefFree(def); - VIR_FREE(script); return NULL; } -- 1.8.4.5

From: Kiarie Kahurani <davidkiarie4@gmail.com> introduce function xenParseXMGeneralMeta(virConfPtr conf,......) which parses features like hvm= ?, builder and sets the default machine type incase its not specified signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 5959892..157d7d3 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1209,30 +1209,28 @@ int xenParseXMEmulatedDevices(virConfPtr conf, virDomainDefPtr def) } -virDomainDefPtr -xenParseXM(virConfPtr conf, int xendConfigVersion, - virCapsPtr caps) +static +int xenParseXMGeneralMeta(virConfPtr conf, virDomainDefPtr def, + virCapsPtr caps) { + + const char *defaultMachine; const char *str; int hvm = 0; - virDomainDefPtr def = NULL; - const char *defaultMachine; - - if (VIR_ALLOC(def) < 0) - return NULL; - def->virtType = VIR_DOMAIN_VIRT_XEN; - def->id = -1; if (xenXMConfigCopyString(conf, "name", &def->name) < 0) - goto cleanup; + return -1; + if (xenXMConfigGetUUID(conf, "uuid", def->uuid) < 0) - goto cleanup; + return -1; + if ((xenXMConfigGetString(conf, "builder", &str, "linux") == 0) && STREQ(str, "hvm")) hvm = 1; if (VIR_STRDUP(def->os.type, hvm ? "hvm" : "xen") < 0) - goto cleanup; + return -1; + def->os.arch = virCapabilitiesDefaultGuestArch(caps, def->os.type, @@ -1241,7 +1239,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, virReportError(VIR_ERR_INTERNAL_ERROR, _("no supported architecture for os type '%s'"), def->os.type); - goto cleanup; + return -1; } defaultMachine = virCapabilitiesDefaultGuestMachine(caps, @@ -1250,9 +1248,24 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, virDomainVirtTypeToString(def->virtType)); if (defaultMachine != NULL) { if (VIR_STRDUP(def->os.machine, defaultMachine) < 0) - goto cleanup; + return -1; } + return 0; +} +virDomainDefPtr +xenParseXM(virConfPtr conf, int xendConfigVersion, + virCapsPtr caps) +{ + virDomainDefPtr def = NULL; + + if (VIR_ALLOC(def) < 0) + return NULL; + + def->virtType = VIR_DOMAIN_VIRT_XEN; + def->id = -1; + if (xenParseXMGeneralMeta(conf, def, caps) < 0) + goto cleanup; if (xenParseXMOS(conf, def) < 0) goto cleanup; if (xenParseXMMem(conf, def) < 0) -- 1.8.4.5

From: Kiarie Kahurani <davidkiarie4@gmail.com> In the refactored code I have wrapped common code in one function that I will use latter signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 60 +++++++++++++++++++++++++++++++++++++----------------- src/xenxs/xen_xm.h | 2 ++ 2 files changed, 43 insertions(+), 19 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 157d7d3..289f0ad 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1253,6 +1253,46 @@ int xenParseXMGeneralMeta(virConfPtr conf, virDomainDefPtr def, return 0; } + + +int xenParseConfigCommon(virConfPtr conf, virDomainDefPtr def, + virCapsPtr caps, int xendConfigVersion) +{ + + if (xenParseXMGeneralMeta(conf, def, caps) < 0) + return -1; + + if (xenParseXMOS(conf, def) < 0) + return -1; + + if (xenParseXMMem(conf, def) < 0) + return -1; + + if (xenParseXMTimeOffset(conf, def, xendConfigVersion) < 0) + return -1; + + if (xenParseXMEventsActions(conf, def) < 0) + return -1; + + if (xenParseXMPCI(conf, def) < 0) + return -1; + + if (xenParseXMCPUFeatures(conf, def) < 0) + return -1; + + if (xenParseXMEmulatedDevices(conf, def) < 0) + return -1; + + if (xenParseXMCharDev(conf, def) < 0) + return -1; + + if (xenParseXMVfb(conf, def, xendConfigVersion) < 0) + return -1; + + return 0; +} + + virDomainDefPtr xenParseXM(virConfPtr conf, int xendConfigVersion, virCapsPtr caps) @@ -1264,30 +1304,12 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, def->virtType = VIR_DOMAIN_VIRT_XEN; def->id = -1; - if (xenParseXMGeneralMeta(conf, def, caps) < 0) - goto cleanup; - if (xenParseXMOS(conf, def) < 0) - goto cleanup; - if (xenParseXMMem(conf, def) < 0) - goto cleanup; - if (xenParseXMEventsActions(conf, def) < 0) - goto cleanup; - if (xenParseXMTimeOffset(conf, def, xendConfigVersion) < 0) - goto cleanup; - if (xenParseXMCPUFeatures(conf, def) < 0) + if (xenParseConfigCommon(conf, def, caps, xendConfigVersion) < 0) goto cleanup; if (xenParseXMDisk(conf, def, xendConfigVersion) < 0) goto cleanup; - if (xenParseXMVfb(conf, def, xendConfigVersion) < 0) - goto cleanup; if (xenParseXMVif(conf, def) < 0) goto cleanup; - if (xenParseXMPCI(conf, def) < 0) - goto cleanup; - if (xenParseXMEmulatedDevices(conf, def) < 0) - goto cleanup; - if (xenParseXMCharDev(conf, def) < 0) - goto cleanup; return def; cleanup: diff --git a/src/xenxs/xen_xm.h b/src/xenxs/xen_xm.h index 629a4b3..69a2d44 100644 --- a/src/xenxs/xen_xm.h +++ b/src/xenxs/xen_xm.h @@ -36,4 +36,6 @@ virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, virDomainDefPtr xenParseXM(virConfPtr conf, int xendConfigVersion, virCapsPtr caps); +int xenParseConfigCommon(virConfPtr conf, virDomainDefPtr def, + virCapsPtr caps, int xendConfigVersion); #endif /* __VIR_XEN_XM_H__ */ -- 1.8.4.5

From: Kiarie Kahurani <davidkiarie4@gmail.com> introduce function xenFormatXMGeneralMeta(virConfPtr conf, .......); which formats UUID and name instead signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 289f0ad..ae474a4 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1655,6 +1655,20 @@ xenFormatXMPCI(virConfPtr conf, /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is either 32, or 64 on a platform where long is big enough. */ verify(MAX_VIRT_CPUS <= sizeof(1UL) * CHAR_BIT); +static +int xenFormatXMGeneralMeta(virConfPtr conf, virDomainDefPtr def) +{ + char uuid[VIR_UUID_STRING_BUFLEN]; + + if (xenXMConfigSetString(conf, "name", def->name) < 0) + return -1; + + virUUIDFormat(def->uuid, uuid); + if (xenXMConfigSetString(conf, "uuid", uuid) < 0) + return -1; + + return 0; +} virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, @@ -1665,21 +1679,13 @@ virConfPtr xenFormatXM(virConnectPtr conn, size_t i; char *cpus = NULL; const char *lifecycle; - char uuid[VIR_UUID_STRING_BUFLEN]; virConfValuePtr diskVal = NULL; virConfValuePtr netVal = NULL; if (!(conf = virConfNew())) goto cleanup; - - - if (xenXMConfigSetString(conf, "name", def->name) < 0) + if (xenFormatXMGeneralMeta(conf, def) < 0) goto cleanup; - - virUUIDFormat(def->uuid, uuid); - if (xenXMConfigSetString(conf, "uuid", uuid) < 0) - goto cleanup; - if (xenXMConfigSetInt(conf, "maxmem", VIR_DIV_UP(def->mem.max_balloon, 1024)) < 0) goto cleanup; -- 1.8.4.5

David Kiarie wrote:
From: Kiarie Kahurani <davidkiarie4@gmail.com>
introduce function xenFormatXMGeneralMeta(virConfPtr conf, .......); which formats UUID and name instead
signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 289f0ad..ae474a4 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1655,6 +1655,20 @@ xenFormatXMPCI(virConfPtr conf, /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is either 32, or 64 on a platform where long is big enough. */ verify(MAX_VIRT_CPUS <= sizeof(1UL) * CHAR_BIT); +static +int xenFormatXMGeneralMeta(virConfPtr conf, virDomainDefPtr def) +{ + char uuid[VIR_UUID_STRING_BUFLEN]; + + if (xenXMConfigSetString(conf, "name", def->name) < 0) + return -1; + + virUUIDFormat(def->uuid, uuid); + if (xenXMConfigSetString(conf, "uuid", uuid) < 0) + return -1; + + return 0; +}
virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, @@ -1665,21 +1679,13 @@ virConfPtr xenFormatXM(virConnectPtr conn, size_t i; char *cpus = NULL; const char *lifecycle; - char uuid[VIR_UUID_STRING_BUFLEN]; virConfValuePtr diskVal = NULL; virConfValuePtr netVal = NULL;
if (!(conf = virConfNew())) goto cleanup; - -
For readability and consistency, I'd leave one of these blank lines.
- if (xenXMConfigSetString(conf, "name", def->name) < 0) + if (xenFormatXMGeneralMeta(conf, def) < 0) goto cleanup; -
And this one.
- virUUIDFormat(def->uuid, uuid); - if (xenXMConfigSetString(conf, "uuid", uuid) < 0) - goto cleanup; -
And this one too. Regards, Jim
if (xenXMConfigSetInt(conf, "maxmem", VIR_DIV_UP(def->mem.max_balloon, 1024)) < 0) goto cleanup;

From: Kiarie Kahurani <davidkiarie4@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@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; - if (xenXMConfigSetInt(conf, "vcpus", def->maxvcpus) < 0) goto cleanup; /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is -- 1.8.4.5

David Kiarie wrote:
From: Kiarie Kahurani <davidkiarie4@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@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

From: Kiarie Kahurani <davidkiarie4@gmail.com> introduce function xenFormatXMTimeOffset(virConfPtr conf, .......); which formats time offset config instead signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 156 ++++++++++++++++++++++++++++------------------------- 1 file changed, 84 insertions(+), 72 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 78dc949..9d868d7 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1686,12 +1686,94 @@ int xenFormatXMMem(virConfPtr conf, virDomainDefPtr def) } +static +int xenFormatXMTimeOffset(virConfPtr conf, virDomainDefPtr def, + int xendConfigVersion) +{ + int vmlocaltime; + if (xendConfigVersion < XEND_CONFIG_VERSION_3_1_0) { + /* <3.1: UTC and LOCALTIME */ + switch (def->clock.offset) { + case VIR_DOMAIN_CLOCK_OFFSET_UTC: + vmlocaltime = 0; + break; + case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME: + vmlocaltime = 1; + break; + default: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unsupported clock offset='%s'"), + virDomainClockOffsetTypeToString(def->clock.offset)); + return -1; + } + + } else { + if (STREQ(def->os.type, "hvm")) { + /* >=3.1 HV: VARIABLE */ + int rtc_timeoffset; + switch (def->clock.offset) { + case VIR_DOMAIN_CLOCK_OFFSET_VARIABLE: + vmlocaltime = (int)def->clock.data.variable.basis; + rtc_timeoffset = def->clock.data.variable.adjustment; + break; + case VIR_DOMAIN_CLOCK_OFFSET_UTC: + if (def->clock.data.utc_reset) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("unsupported clock adjustment='reset'")); + return -1; + } + vmlocaltime = 0; + rtc_timeoffset = 0; + break; + case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME: + if (def->clock.data.utc_reset) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("unsupported clock adjustment='reset'")); + return -1; + } + vmlocaltime = 1; + rtc_timeoffset = 0; + break; + default: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unsupported clock offset='%s'"), + virDomainClockOffsetTypeToString(def->clock.offset)); + return -1; + } + if (xenXMConfigSetInt(conf, "rtc_timeoffset", rtc_timeoffset) < 0) + return -1; + + } else { + /* >=3.1 PV: UTC and LOCALTIME */ + switch (def->clock.offset) { + case VIR_DOMAIN_CLOCK_OFFSET_UTC: + vmlocaltime = 0; + break; + case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME: + vmlocaltime = 1; + break; + default: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unsupported clock offset='%s'"), + virDomainClockOffsetTypeToString(def->clock.offset)); + return -1; + } + } /* !hvm */ + } + + if (xenXMConfigSetInt(conf, "localtime", vmlocaltime) < 0) + return -1; + + return 0; +} + + virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, int xendConfigVersion) { virConfPtr conf = NULL; - int hvm = 0, vmlocaltime = 0; + int hvm = 0; size_t i; char *cpus = NULL; const char *lifecycle; @@ -1827,78 +1909,8 @@ virConfPtr xenFormatXM(virConnectPtr conn, goto cleanup; } /* !hvm */ - - if (xendConfigVersion < XEND_CONFIG_VERSION_3_1_0) { - /* <3.1: UTC and LOCALTIME */ - switch (def->clock.offset) { - case VIR_DOMAIN_CLOCK_OFFSET_UTC: - vmlocaltime = 0; - break; - case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME: - vmlocaltime = 1; - break; - default: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unsupported clock offset='%s'"), - virDomainClockOffsetTypeToString(def->clock.offset)); - goto cleanup; - } - } else { - if (hvm) { - /* >=3.1 HV: VARIABLE */ - int rtc_timeoffset; - switch (def->clock.offset) { - case VIR_DOMAIN_CLOCK_OFFSET_VARIABLE: - vmlocaltime = (int)def->clock.data.variable.basis; - rtc_timeoffset = def->clock.data.variable.adjustment; - break; - case VIR_DOMAIN_CLOCK_OFFSET_UTC: - if (def->clock.data.utc_reset) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("unsupported clock adjustment='reset'")); - goto cleanup; - } - vmlocaltime = 0; - rtc_timeoffset = 0; - break; - case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME: - if (def->clock.data.utc_reset) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("unsupported clock adjustment='reset'")); - goto cleanup; - } - vmlocaltime = 1; - rtc_timeoffset = 0; - break; - default: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unsupported clock offset='%s'"), - virDomainClockOffsetTypeToString(def->clock.offset)); - goto cleanup; - } - if (xenXMConfigSetInt(conf, "rtc_timeoffset", rtc_timeoffset) < 0) - goto cleanup; - } else { - /* >=3.1 PV: UTC and LOCALTIME */ - switch (def->clock.offset) { - case VIR_DOMAIN_CLOCK_OFFSET_UTC: - vmlocaltime = 0; - break; - case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME: - vmlocaltime = 1; - break; - default: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unsupported clock offset='%s'"), - virDomainClockOffsetTypeToString(def->clock.offset)); - goto cleanup; - } - } /* !hvm */ - } - if (xenXMConfigSetInt(conf, "localtime", vmlocaltime) < 0) + if (xenFormatXMTimeOffset(conf, def, xendConfigVersion) < 0) goto cleanup; - - if (!(lifecycle = virDomainLifecycleTypeToString(def->onPoweroff))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected lifecycle action %d"), def->onPoweroff); -- 1.8.4.5

David Kiarie wrote:
From: Kiarie Kahurani <davidkiarie4@gmail.com>
introduce function xenFormatXMTimeOffset(virConfPtr conf, .......); which formats time offset config instead
signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 156 ++++++++++++++++++++++++++++------------------------- 1 file changed, 84 insertions(+), 72 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 78dc949..9d868d7 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1686,12 +1686,94 @@ int xenFormatXMMem(virConfPtr conf, virDomainDefPtr def) }
+static +int xenFormatXMTimeOffset(virConfPtr conf, virDomainDefPtr def, + int xendConfigVersion) +{ + int vmlocaltime; + if (xendConfigVersion < XEND_CONFIG_VERSION_3_1_0) { + /* <3.1: UTC and LOCALTIME */ + switch (def->clock.offset) { + case VIR_DOMAIN_CLOCK_OFFSET_UTC: + vmlocaltime = 0; + break; + case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME: + vmlocaltime = 1; + break; + default: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unsupported clock offset='%s'"), + virDomainClockOffsetTypeToString(def->clock.offset)); + return -1; + } + + } else { + if (STREQ(def->os.type, "hvm")) { + /* >=3.1 HV: VARIABLE */ + int rtc_timeoffset; + switch (def->clock.offset) { + case VIR_DOMAIN_CLOCK_OFFSET_VARIABLE: + vmlocaltime = (int)def->clock.data.variable.basis; + rtc_timeoffset = def->clock.data.variable.adjustment; + break; + case VIR_DOMAIN_CLOCK_OFFSET_UTC: + if (def->clock.data.utc_reset) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("unsupported clock adjustment='reset'")); + return -1; + } + vmlocaltime = 0; + rtc_timeoffset = 0; + break; + case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME: + if (def->clock.data.utc_reset) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("unsupported clock adjustment='reset'")); + return -1; + } + vmlocaltime = 1; + rtc_timeoffset = 0; + break; + default: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unsupported clock offset='%s'"), + virDomainClockOffsetTypeToString(def->clock.offset)); + return -1; + } + if (xenXMConfigSetInt(conf, "rtc_timeoffset", rtc_timeoffset) < 0) + return -1; + + } else { + /* >=3.1 PV: UTC and LOCALTIME */ + switch (def->clock.offset) { + case VIR_DOMAIN_CLOCK_OFFSET_UTC: + vmlocaltime = 0; + break; + case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME: + vmlocaltime = 1; + break; + default: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unsupported clock offset='%s'"), + virDomainClockOffsetTypeToString(def->clock.offset)); + return -1; + } + } /* !hvm */ + } + + if (xenXMConfigSetInt(conf, "localtime", vmlocaltime) < 0) + return -1; + + return 0; +} + + virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, int xendConfigVersion) { virConfPtr conf = NULL; - int hvm = 0, vmlocaltime = 0; + int hvm = 0; size_t i; char *cpus = NULL; const char *lifecycle; @@ -1827,78 +1909,8 @@ virConfPtr xenFormatXM(virConnectPtr conn, goto cleanup; } /* !hvm */
- - if (xendConfigVersion < XEND_CONFIG_VERSION_3_1_0) { - /* <3.1: UTC and LOCALTIME */ - switch (def->clock.offset) { - case VIR_DOMAIN_CLOCK_OFFSET_UTC: - vmlocaltime = 0; - break; - case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME: - vmlocaltime = 1; - break; - default: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unsupported clock offset='%s'"), - virDomainClockOffsetTypeToString(def->clock.offset)); - goto cleanup; - } - } else { - if (hvm) { - /* >=3.1 HV: VARIABLE */ - int rtc_timeoffset; - switch (def->clock.offset) { - case VIR_DOMAIN_CLOCK_OFFSET_VARIABLE: - vmlocaltime = (int)def->clock.data.variable.basis; - rtc_timeoffset = def->clock.data.variable.adjustment; - break; - case VIR_DOMAIN_CLOCK_OFFSET_UTC: - if (def->clock.data.utc_reset) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("unsupported clock adjustment='reset'")); - goto cleanup; - } - vmlocaltime = 0; - rtc_timeoffset = 0; - break; - case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME: - if (def->clock.data.utc_reset) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("unsupported clock adjustment='reset'")); - goto cleanup; - } - vmlocaltime = 1; - rtc_timeoffset = 0; - break; - default: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unsupported clock offset='%s'"), - virDomainClockOffsetTypeToString(def->clock.offset)); - goto cleanup; - } - if (xenXMConfigSetInt(conf, "rtc_timeoffset", rtc_timeoffset) < 0) - goto cleanup; - } else { - /* >=3.1 PV: UTC and LOCALTIME */ - switch (def->clock.offset) { - case VIR_DOMAIN_CLOCK_OFFSET_UTC: - vmlocaltime = 0; - break; - case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME: - vmlocaltime = 1; - break; - default: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unsupported clock offset='%s'"), - virDomainClockOffsetTypeToString(def->clock.offset)); - goto cleanup; - } - } /* !hvm */ - } - if (xenXMConfigSetInt(conf, "localtime", vmlocaltime) < 0) + if (xenFormatXMTimeOffset(conf, def, xendConfigVersion) < 0) goto cleanup; - -
Removed one too many blank lines :-). Regards, Jim
if (!(lifecycle = virDomainLifecycleTypeToString(def->onPoweroff))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected lifecycle action %d"), def->onPoweroff);

From: Kiarie Kahurani <davidkiarie4@gmail.com> introduce function xenFormatXMEventActions(virConfPtr conf, .......); which formats event actions config instead signed-off-by: David Kiarie<davidkiarie4@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; + + + 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) @@ -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; - - - if (hvm) { if (def->emulator && xenXMConfigSetString(conf, "device_model", def->emulator) < 0) -- 1.8.4.5

David Kiarie wrote:
From: Kiarie Kahurani <davidkiarie4@gmail.com>
introduce function xenFormatXMEventActions(virConfPtr conf, .......); which formats event actions config instead
signed-off-by: David Kiarie<davidkiarie4@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)

From: Kiarie Kahurani <davidkiarie4@gmail.com> introduce function xenFormatXMVif(virConfPtr conf, ........); which formats Vif config instead signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 60 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index bb7979d..9a6a827 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1803,16 +1803,49 @@ int xenFormatXMEventActions(virConfPtr conf, virDomainDefPtr def) } -virConfPtr xenFormatXM(virConnectPtr conn, - virDomainDefPtr def, - int xendConfigVersion) +static +int xenFormatXMVif(virConfPtr conf, virConnectPtr conn, + virDomainDefPtr def, int xendConfigVersion) +{ + virConfValuePtr netVal = NULL; + size_t i; + int hvm = STREQ(def->os.type, "hvm"); + + if (VIR_ALLOC(netVal) < 0) + goto cleanup; + netVal->type = VIR_CONF_LIST; + netVal->list = NULL; + + for (i = 0; i < def->nnets; i++) { + if (xenFormatXMNet(conn, netVal, def->nets[i], + hvm, xendConfigVersion) < 0) + goto cleanup; + } + + if (netVal->list != NULL) { + int ret = virConfSetValue(conf, "vif", netVal); + netVal = NULL; + if (ret < 0) + goto cleanup; + } + + VIR_FREE(netVal); + return 0; + + cleanup: + virConfFreeValue(netVal); + return -1; +} + + +virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, + int xendConfigVersion) { virConfPtr conf = NULL; int hvm = 0; size_t i; char *cpus = NULL; virConfValuePtr diskVal = NULL; - virConfValuePtr netVal = NULL; if (!(conf = virConfNew())) goto cleanup; @@ -2102,24 +2135,8 @@ virConfPtr xenFormatXM(virConnectPtr conn, } VIR_FREE(diskVal); - if (VIR_ALLOC(netVal) < 0) + if (xenFormatXMVif(conf, conn, def, xendConfigVersion) < 0) goto cleanup; - netVal->type = VIR_CONF_LIST; - netVal->list = NULL; - - for (i = 0; i < def->nnets; i++) { - if (xenFormatXMNet(conn, netVal, def->nets[i], - hvm, xendConfigVersion) < 0) - goto cleanup; - } - if (netVal->list != NULL) { - int ret = virConfSetValue(conf, "vif", netVal); - netVal = NULL; - if (ret < 0) - goto cleanup; - } - VIR_FREE(netVal); - if (xenFormatXMPCI(conf, def) < 0) goto cleanup; @@ -2214,7 +2231,6 @@ virConfPtr xenFormatXM(virConnectPtr conn, cleanup: virConfFreeValue(diskVal); - virConfFreeValue(netVal); VIR_FREE(cpus); if (conf) virConfFree(conf); -- 1.8.4.5

David Kiarie wrote:
From: Kiarie Kahurani <davidkiarie4@gmail.com>
introduce function xenFormatXMVif(virConfPtr conf, ........); which formats Vif config instead
signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 60 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 22 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index bb7979d..9a6a827 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1803,16 +1803,49 @@ int xenFormatXMEventActions(virConfPtr conf, virDomainDefPtr def) }
-virConfPtr xenFormatXM(virConnectPtr conn, - virDomainDefPtr def, - int xendConfigVersion) +static +int xenFormatXMVif(virConfPtr conf, virConnectPtr conn, + virDomainDefPtr def, int xendConfigVersion)
With the exception of my usual whitespace nits, the rest of this series looks good. Please address all of the whitespace comments in V3. Thanks! Regards, Jim
+{ + virConfValuePtr netVal = NULL; + size_t i; + int hvm = STREQ(def->os.type, "hvm"); + + if (VIR_ALLOC(netVal) < 0) + goto cleanup; + netVal->type = VIR_CONF_LIST; + netVal->list = NULL; + + for (i = 0; i < def->nnets; i++) { + if (xenFormatXMNet(conn, netVal, def->nets[i], + hvm, xendConfigVersion) < 0) + goto cleanup; + } + + if (netVal->list != NULL) { + int ret = virConfSetValue(conf, "vif", netVal); + netVal = NULL; + if (ret < 0) + goto cleanup; + } + + VIR_FREE(netVal); + return 0; + + cleanup: + virConfFreeValue(netVal); + return -1; +} + + +virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, + int xendConfigVersion) { virConfPtr conf = NULL; int hvm = 0; size_t i; char *cpus = NULL; virConfValuePtr diskVal = NULL; - virConfValuePtr netVal = NULL;
if (!(conf = virConfNew())) goto cleanup; @@ -2102,24 +2135,8 @@ virConfPtr xenFormatXM(virConnectPtr conn, } VIR_FREE(diskVal);
- if (VIR_ALLOC(netVal) < 0) + if (xenFormatXMVif(conf, conn, def, xendConfigVersion) < 0) goto cleanup; - netVal->type = VIR_CONF_LIST; - netVal->list = NULL; - - for (i = 0; i < def->nnets; i++) { - if (xenFormatXMNet(conn, netVal, def->nets[i], - hvm, xendConfigVersion) < 0) - goto cleanup; - } - if (netVal->list != NULL) { - int ret = virConfSetValue(conf, "vif", netVal); - netVal = NULL; - if (ret < 0) - goto cleanup; - } - VIR_FREE(netVal); - if (xenFormatXMPCI(conf, def) < 0) goto cleanup;
@@ -2214,7 +2231,6 @@ virConfPtr xenFormatXM(virConnectPtr conn,
cleanup: virConfFreeValue(diskVal); - virConfFreeValue(netVal); VIR_FREE(cpus); if (conf) virConfFree(conf);

From: Kiarie Kahurani <davidkiarie4@gmail.com> introduce function xenFormatXMVfb(virConfPtr conf, ........); which formats Vfb config instead signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 218 +++++++++++++++++++++++++++++------------------------ 1 file changed, 119 insertions(+), 99 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 9a6a827..22552bd 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1838,6 +1838,123 @@ int xenFormatXMVif(virConfPtr conf, virConnectPtr conn, } +static +int xenFormatXMVfb(virConfPtr conf, virDomainDefPtr def, + int xendConfigVersion) +{ + int hvm = STREQ(def->os.type, "hvm"); + + if (def->ngraphics == 1) { + if (hvm || (xendConfigVersion < XEND_CONFIG_MIN_VERS_PVFB_NEWCONF)) { + if (def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) { + if (xenXMConfigSetInt(conf, "sdl", 1) < 0) + return -1; + + if (xenXMConfigSetInt(conf, "vnc", 0) < 0) + return -1; + + if (def->graphics[0]->data.sdl.display && + xenXMConfigSetString(conf, "display", + def->graphics[0]->data.sdl.display) < 0) + return -1; + + if (def->graphics[0]->data.sdl.xauth && + xenXMConfigSetString(conf, "xauthority", + def->graphics[0]->data.sdl.xauth) < 0) + return -1; + + } else { + const char *listenAddr; + + if (xenXMConfigSetInt(conf, "sdl", 0) < 0) + return -1; + + if (xenXMConfigSetInt(conf, "vnc", 1) < 0) + return -1; + + if (xenXMConfigSetInt(conf, "vncunused", + def->graphics[0]->data.vnc.autoport ? 1 : 0) < 0) + return -1; + + if (!def->graphics[0]->data.vnc.autoport && + xenXMConfigSetInt(conf, "vncdisplay", + def->graphics[0]->data.vnc.port - 5900) < 0) + return -1; + + listenAddr = virDomainGraphicsListenGetAddress(def->graphics[0], 0); + if (listenAddr && + xenXMConfigSetString(conf, "vnclisten", listenAddr) < 0) + return -1; + + if (def->graphics[0]->data.vnc.auth.passwd && + xenXMConfigSetString(conf, "vncpasswd", + def->graphics[0]->data.vnc.auth.passwd) < 0) + return -1; + + if (def->graphics[0]->data.vnc.keymap && + xenXMConfigSetString(conf, "keymap", + def->graphics[0]->data.vnc.keymap) < 0) + return -1; + } + } else { + virConfValuePtr vfb, disp; + char *vfbstr = NULL; + virBuffer buf = VIR_BUFFER_INITIALIZER; + if (def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) { + virBufferAddLit(&buf, "type=sdl"); + if (def->graphics[0]->data.sdl.display) + virBufferAsprintf(&buf, ",display=%s", + def->graphics[0]->data.sdl.display); + if (def->graphics[0]->data.sdl.xauth) + virBufferAsprintf(&buf, ",xauthority=%s", + def->graphics[0]->data.sdl.xauth); + } else { + const char *listenAddr + = virDomainGraphicsListenGetAddress(def->graphics[0], 0); + + virBufferAddLit(&buf, "type=vnc"); + virBufferAsprintf(&buf, ",vncunused=%d", + def->graphics[0]->data.vnc.autoport ? 1 : 0); + if (!def->graphics[0]->data.vnc.autoport) + virBufferAsprintf(&buf, ",vncdisplay=%d", + def->graphics[0]->data.vnc.port - 5900); + if (listenAddr) + virBufferAsprintf(&buf, ",vnclisten=%s", listenAddr); + if (def->graphics[0]->data.vnc.auth.passwd) + virBufferAsprintf(&buf, ",vncpasswd=%s", + def->graphics[0]->data.vnc.auth.passwd); + if (def->graphics[0]->data.vnc.keymap) + virBufferAsprintf(&buf, ",keymap=%s", + def->graphics[0]->data.vnc.keymap); + } + + if (virBufferCheckError(&buf) < 0) + return -1; + + vfbstr = virBufferContentAndReset(&buf); + if (VIR_ALLOC(vfb) < 0) { + VIR_FREE(vfbstr); + return -1; + } + + if (VIR_ALLOC(disp) < 0) { + VIR_FREE(vfb); + VIR_FREE(vfbstr); + return -1; + } + + vfb->type = VIR_CONF_LIST; + vfb->list = disp; + disp->type = VIR_CONF_STRING; + disp->str = vfbstr; + + if (virConfSetValue(conf, "vfb", vfb) < 0) + return -1; + } + } + + return 0; +} virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, int xendConfigVersion) { @@ -2008,105 +2125,8 @@ virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, } } - if (def->ngraphics == 1) { - if (hvm || (xendConfigVersion < XEND_CONFIG_MIN_VERS_PVFB_NEWCONF)) { - if (def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) { - if (xenXMConfigSetInt(conf, "sdl", 1) < 0) - goto cleanup; - if (xenXMConfigSetInt(conf, "vnc", 0) < 0) - goto cleanup; - if (def->graphics[0]->data.sdl.display && - xenXMConfigSetString(conf, "display", - def->graphics[0]->data.sdl.display) < 0) - goto cleanup; - if (def->graphics[0]->data.sdl.xauth && - xenXMConfigSetString(conf, "xauthority", - def->graphics[0]->data.sdl.xauth) < 0) - goto cleanup; - } else { - const char *listenAddr; - - if (xenXMConfigSetInt(conf, "sdl", 0) < 0) - goto cleanup; - if (xenXMConfigSetInt(conf, "vnc", 1) < 0) - goto cleanup; - if (xenXMConfigSetInt(conf, "vncunused", - def->graphics[0]->data.vnc.autoport ? 1 : 0) < 0) - goto cleanup; - if (!def->graphics[0]->data.vnc.autoport && - xenXMConfigSetInt(conf, "vncdisplay", - def->graphics[0]->data.vnc.port - 5900) < 0) - goto cleanup; - listenAddr = virDomainGraphicsListenGetAddress(def->graphics[0], 0); - if (listenAddr && - xenXMConfigSetString(conf, "vnclisten", listenAddr) < 0) - goto cleanup; - if (def->graphics[0]->data.vnc.auth.passwd && - xenXMConfigSetString(conf, "vncpasswd", - def->graphics[0]->data.vnc.auth.passwd) < 0) - goto cleanup; - if (def->graphics[0]->data.vnc.keymap && - xenXMConfigSetString(conf, "keymap", - def->graphics[0]->data.vnc.keymap) < 0) - goto cleanup; - } - } else { - virConfValuePtr vfb, disp; - char *vfbstr = NULL; - virBuffer buf = VIR_BUFFER_INITIALIZER; - if (def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) { - virBufferAddLit(&buf, "type=sdl"); - if (def->graphics[0]->data.sdl.display) - virBufferAsprintf(&buf, ",display=%s", - def->graphics[0]->data.sdl.display); - if (def->graphics[0]->data.sdl.xauth) - virBufferAsprintf(&buf, ",xauthority=%s", - def->graphics[0]->data.sdl.xauth); - } else { - const char *listenAddr - = virDomainGraphicsListenGetAddress(def->graphics[0], 0); - - virBufferAddLit(&buf, "type=vnc"); - virBufferAsprintf(&buf, ",vncunused=%d", - def->graphics[0]->data.vnc.autoport ? 1 : 0); - if (!def->graphics[0]->data.vnc.autoport) - virBufferAsprintf(&buf, ",vncdisplay=%d", - def->graphics[0]->data.vnc.port - 5900); - if (listenAddr) - virBufferAsprintf(&buf, ",vnclisten=%s", listenAddr); - if (def->graphics[0]->data.vnc.auth.passwd) - virBufferAsprintf(&buf, ",vncpasswd=%s", - def->graphics[0]->data.vnc.auth.passwd); - if (def->graphics[0]->data.vnc.keymap) - virBufferAsprintf(&buf, ",keymap=%s", - def->graphics[0]->data.vnc.keymap); - } - if (virBufferCheckError(&buf) < 0) - goto cleanup; - - vfbstr = virBufferContentAndReset(&buf); - - if (VIR_ALLOC(vfb) < 0) { - VIR_FREE(vfbstr); - goto cleanup; - } - - if (VIR_ALLOC(disp) < 0) { - VIR_FREE(vfb); - VIR_FREE(vfbstr); - goto cleanup; - } - - vfb->type = VIR_CONF_LIST; - vfb->list = disp; - disp->type = VIR_CONF_STRING; - disp->str = vfbstr; - - if (virConfSetValue(conf, "vfb", vfb) < 0) - goto cleanup; - } - } - + if (xenFormatXMVfb(conf, def, xendConfigVersion) < 0) + goto cleanup; /* analyze of the devices */ if (VIR_ALLOC(diskVal) < 0) goto cleanup; -- 1.8.4.5

From: Kiarie Kahurani <davidkiarie4@gmail.com> introduce function xenFormatXMCPUFeatures(virConfPtr conf,.........); which formats the config instead. I have also made a few changes on the layout of the tests to enable grouping of the code into a function. --- src/xenxs/xen_xm.c | 119 ++++++++++++--------- tests/xmconfigdata/test-escape-paths.cfg | 6 +- tests/xmconfigdata/test-fullvirt-force-hpet.cfg | 6 +- tests/xmconfigdata/test-fullvirt-force-nohpet.cfg | 6 +- tests/xmconfigdata/test-fullvirt-localtime.cfg | 6 +- tests/xmconfigdata/test-fullvirt-net-ioemu.cfg | 6 +- tests/xmconfigdata/test-fullvirt-net-netfront.cfg | 6 +- tests/xmconfigdata/test-fullvirt-new-cdrom.cfg | 6 +- tests/xmconfigdata/test-fullvirt-old-cdrom.cfg | 6 +- tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg | 6 +- .../test-fullvirt-serial-dev-2-ports.cfg | 6 +- .../test-fullvirt-serial-dev-2nd-port.cfg | 6 +- tests/xmconfigdata/test-fullvirt-serial-file.cfg | 6 +- tests/xmconfigdata/test-fullvirt-serial-null.cfg | 6 +- tests/xmconfigdata/test-fullvirt-serial-pipe.cfg | 6 +- tests/xmconfigdata/test-fullvirt-serial-pty.cfg | 6 +- tests/xmconfigdata/test-fullvirt-serial-stdio.cfg | 6 +- .../test-fullvirt-serial-tcp-telnet.cfg | 6 +- tests/xmconfigdata/test-fullvirt-serial-tcp.cfg | 6 +- tests/xmconfigdata/test-fullvirt-serial-udp.cfg | 6 +- tests/xmconfigdata/test-fullvirt-serial-unix.cfg | 6 +- tests/xmconfigdata/test-fullvirt-sound.cfg | 6 +- tests/xmconfigdata/test-fullvirt-usbmouse.cfg | 6 +- tests/xmconfigdata/test-fullvirt-usbtablet.cfg | 6 +- tests/xmconfigdata/test-fullvirt-utc.cfg | 6 +- tests/xmconfigdata/test-no-source-cdrom.cfg | 6 +- tests/xmconfigdata/test-pci-devs.cfg | 6 +- 27 files changed, 145 insertions(+), 130 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 22552bd..f2b1267 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1955,41 +1955,91 @@ int xenFormatXMVfb(virConfPtr conf, virDomainDefPtr def, return 0; } -virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, - int xendConfigVersion) + + +static +int xenFormatXMCPUFeatures(virConfPtr conf, virDomainDefPtr def, + int xendConfigVersion) { - virConfPtr conf = NULL; - int hvm = 0; - size_t i; char *cpus = NULL; - virConfValuePtr diskVal = NULL; + size_t i; - if (!(conf = virConfNew())) - goto cleanup; - if (xenFormatXMGeneralMeta(conf, def) < 0) - goto cleanup; - if (xenFormatXMMem(conf, def) < 0) - goto cleanup; if (xenXMConfigSetInt(conf, "vcpus", def->maxvcpus) < 0) - goto cleanup; + return -1; /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is either 32, or 64 on a platform where long is big enough. */ if (def->vcpus < def->maxvcpus && xenXMConfigSetInt(conf, "vcpu_avail", (1UL << def->vcpus) - 1) < 0) - goto cleanup; + return -1; if ((def->cpumask != NULL) && ((cpus = virBitmapFormat(def->cpumask)) == NULL)) { - goto cleanup; + return -1; } if (cpus && xenXMConfigSetString(conf, "cpus", cpus) < 0) - goto cleanup; + return -1; + VIR_FREE(cpus); + if (STREQ(def->os.type, "hvm")) { + if (xenXMConfigSetInt(conf, "pae", + (def->features[VIR_DOMAIN_FEATURE_PAE] == + VIR_DOMAIN_FEATURE_STATE_ON) ? 1 : 0) < 0) + return -1; - hvm = STREQ(def->os.type, "hvm") ? 1 : 0; + if (xenXMConfigSetInt(conf, "acpi", + (def->features[VIR_DOMAIN_FEATURE_ACPI] == + VIR_DOMAIN_FEATURE_STATE_ON) ? 1 : 0) < 0) + return -1; + + if (xenXMConfigSetInt(conf, "apic", + (def->features[VIR_DOMAIN_FEATURE_APIC] == + VIR_DOMAIN_FEATURE_STATE_ON) ? 1 : 0) < 0) + return -1; + + if (xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4) { + if (xenXMConfigSetInt(conf, "hap", + (def->features[VIR_DOMAIN_FEATURE_HAP] == + VIR_DOMAIN_FEATURE_STATE_ON) ? 1 : 0) < 0) + return -1; + + if (xenXMConfigSetInt(conf, "viridian", + (def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] == + VIR_DOMAIN_FEATURE_STATE_ON) ? 1 : 0) < 0) + return -1; + } + + for (i = 0; i < def->clock.ntimers; i++) { + if (def->clock.timers[i]->name == VIR_DOMAIN_TIMER_NAME_HPET && + def->clock.timers[i]->present != -1 && + xenXMConfigSetInt(conf, "hpet", def->clock.timers[i]->present) < 0) + return -1; + } + } + + return 0; +} + + +virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, + int xendConfigVersion) +{ + virConfPtr conf = NULL; + int hvm = 0; + size_t i; + char *cpus = NULL; + virConfValuePtr diskVal = NULL; + if (!(conf = virConfNew())) + goto cleanup; + if (xenFormatXMGeneralMeta(conf, def) < 0) + goto cleanup; + if (xenFormatXMMem(conf, def) < 0) + goto cleanup; + if (xenFormatXMCPUFeatures(conf, def, xendConfigVersion) < 0) + goto cleanup; + hvm = STREQ(def->os.type, "hvm") ? 1 : 0; if (hvm) { char boot[VIR_DOMAIN_BOOT_LAST+1]; if (xenXMConfigSetString(conf, "builder", "hvm") < 0) @@ -2025,41 +2075,6 @@ virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, if (xenXMConfigSetString(conf, "boot", boot) < 0) goto cleanup; - - if (xenXMConfigSetInt(conf, "pae", - (def->features[VIR_DOMAIN_FEATURE_PAE] == - VIR_DOMAIN_FEATURE_STATE_ON) ? 1 : 0) < 0) - goto cleanup; - - if (xenXMConfigSetInt(conf, "acpi", - (def->features[VIR_DOMAIN_FEATURE_ACPI] == - VIR_DOMAIN_FEATURE_STATE_ON) ? 1 : 0) < 0) - goto cleanup; - - if (xenXMConfigSetInt(conf, "apic", - (def->features[VIR_DOMAIN_FEATURE_APIC] == - VIR_DOMAIN_FEATURE_STATE_ON) ? 1 : 0) < 0) - goto cleanup; - - if (xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4) { - if (xenXMConfigSetInt(conf, "hap", - (def->features[VIR_DOMAIN_FEATURE_HAP] == - VIR_DOMAIN_FEATURE_STATE_ON) ? 1 : 0) < 0) - goto cleanup; - - if (xenXMConfigSetInt(conf, "viridian", - (def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] == - VIR_DOMAIN_FEATURE_STATE_ON) ? 1 : 0) < 0) - goto cleanup; - } - - for (i = 0; i < def->clock.ntimers; i++) { - if (def->clock.timers[i]->name == VIR_DOMAIN_TIMER_NAME_HPET && - def->clock.timers[i]->present != -1 && - xenXMConfigSetInt(conf, "hpet", def->clock.timers[i]->present) < 0) - goto cleanup; - } - if (xendConfigVersion == XEND_CONFIG_VERSION_3_0_2) { for (i = 0; i < def->ndisks; i++) { if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM && diff --git a/tests/xmconfigdata/test-escape-paths.cfg b/tests/xmconfigdata/test-escape-paths.cfg index 13be2a0..4a18cc1 100644 --- a/tests/xmconfigdata/test-escape-paths.cfg +++ b/tests/xmconfigdata/test-escape-paths.cfg @@ -3,12 +3,12 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader&test" -boot = "d" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader&test" +boot = "d" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-force-hpet.cfg b/tests/xmconfigdata/test-fullvirt-force-hpet.cfg index 178aecd..c1afc08 100644 --- a/tests/xmconfigdata/test-fullvirt-force-hpet.cfg +++ b/tests/xmconfigdata/test-fullvirt-force-hpet.cfg @@ -3,13 +3,13 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "d" pae = 1 acpi = 1 apic = 1 hpet = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-force-nohpet.cfg b/tests/xmconfigdata/test-fullvirt-force-nohpet.cfg index 44f5ac7..397d8ef 100644 --- a/tests/xmconfigdata/test-fullvirt-force-nohpet.cfg +++ b/tests/xmconfigdata/test-fullvirt-force-nohpet.cfg @@ -3,13 +3,13 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "d" pae = 1 acpi = 1 apic = 1 hpet = 0 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-localtime.cfg b/tests/xmconfigdata/test-fullvirt-localtime.cfg index d4eb4a9..7292e7f 100755 --- a/tests/xmconfigdata/test-fullvirt-localtime.cfg +++ b/tests/xmconfigdata/test-fullvirt-localtime.cfg @@ -3,12 +3,12 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "d" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" localtime = 1 on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-net-ioemu.cfg b/tests/xmconfigdata/test-fullvirt-net-ioemu.cfg index 922450b..ef97329 100644 --- a/tests/xmconfigdata/test-fullvirt-net-ioemu.cfg +++ b/tests/xmconfigdata/test-fullvirt-net-ioemu.cfg @@ -3,12 +3,12 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "d" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-net-netfront.cfg b/tests/xmconfigdata/test-fullvirt-net-netfront.cfg index d15f1f5..385f917 100644 --- a/tests/xmconfigdata/test-fullvirt-net-netfront.cfg +++ b/tests/xmconfigdata/test-fullvirt-net-netfront.cfg @@ -3,12 +3,12 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "d" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg b/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg index 922450b..ef97329 100755 --- a/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg +++ b/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg @@ -3,12 +3,12 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "d" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg b/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg index 5d2ab81..27407e7 100755 --- a/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg +++ b/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg @@ -3,12 +3,12 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "d" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" cdrom = "/root/boot.iso" localtime = 0 on_poweroff = "destroy" diff --git a/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg b/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg index 4588f1f..86e0aa0 100755 --- a/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg +++ b/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg @@ -3,12 +3,12 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "d" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-serial-dev-2-ports.cfg b/tests/xmconfigdata/test-fullvirt-serial-dev-2-ports.cfg index 86e7998..8ada1fd 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-dev-2-ports.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-dev-2-ports.cfg @@ -3,12 +3,12 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "d" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-serial-dev-2nd-port.cfg b/tests/xmconfigdata/test-fullvirt-serial-dev-2nd-port.cfg index 287e08a..61e2af3 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-dev-2nd-port.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-dev-2nd-port.cfg @@ -3,12 +3,12 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "d" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-serial-file.cfg b/tests/xmconfigdata/test-fullvirt-serial-file.cfg index 08accf6..ad4a874 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-file.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-file.cfg @@ -3,12 +3,12 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "d" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-serial-null.cfg b/tests/xmconfigdata/test-fullvirt-serial-null.cfg index f16c9c2..a11c42a 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-null.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-null.cfg @@ -3,12 +3,12 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "d" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg b/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg index 1e1fa54..1ee0bc8 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg @@ -3,12 +3,12 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "d" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-serial-pty.cfg b/tests/xmconfigdata/test-fullvirt-serial-pty.cfg index ea4d4a5..10465a5 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-pty.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-pty.cfg @@ -3,12 +3,12 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "d" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg b/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg index a4e30c5..3733161 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg @@ -3,12 +3,12 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "d" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg b/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg index 2164738..442309f 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg @@ -3,12 +3,12 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "d" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg b/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg index 7f17781..f141269 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg @@ -3,12 +3,12 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "d" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-serial-udp.cfg b/tests/xmconfigdata/test-fullvirt-serial-udp.cfg index 1af3c7b..3ccc4a7 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-udp.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-udp.cfg @@ -3,12 +3,12 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "d" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-serial-unix.cfg b/tests/xmconfigdata/test-fullvirt-serial-unix.cfg index 309c89e..dd250ac 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-unix.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-unix.cfg @@ -3,12 +3,12 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "d" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-sound.cfg b/tests/xmconfigdata/test-fullvirt-sound.cfg index c4f54fe..d315f93 100644 --- a/tests/xmconfigdata/test-fullvirt-sound.cfg +++ b/tests/xmconfigdata/test-fullvirt-sound.cfg @@ -3,12 +3,12 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "d" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-usbmouse.cfg b/tests/xmconfigdata/test-fullvirt-usbmouse.cfg index 8a66035..3d30bb1 100755 --- a/tests/xmconfigdata/test-fullvirt-usbmouse.cfg +++ b/tests/xmconfigdata/test-fullvirt-usbmouse.cfg @@ -3,12 +3,12 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "d" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-usbtablet.cfg b/tests/xmconfigdata/test-fullvirt-usbtablet.cfg index 24c159e..4463e31 100755 --- a/tests/xmconfigdata/test-fullvirt-usbtablet.cfg +++ b/tests/xmconfigdata/test-fullvirt-usbtablet.cfg @@ -3,12 +3,12 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "d" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-utc.cfg b/tests/xmconfigdata/test-fullvirt-utc.cfg index 922450b..ef97329 100755 --- a/tests/xmconfigdata/test-fullvirt-utc.cfg +++ b/tests/xmconfigdata/test-fullvirt-utc.cfg @@ -3,12 +3,12 @@ uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" maxmem = 579 memory = 394 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "d" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-no-source-cdrom.cfg b/tests/xmconfigdata/test-no-source-cdrom.cfg index 7b258e5..ee22632 100644 --- a/tests/xmconfigdata/test-no-source-cdrom.cfg +++ b/tests/xmconfigdata/test-no-source-cdrom.cfg @@ -3,12 +3,12 @@ uuid = "cc2315e7-d26a-307a-438c-6d188ec4c09c" maxmem = 382 memory = 350 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "c" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "c" localtime = 0 on_poweroff = "destroy" on_reboot = "destroy" diff --git a/tests/xmconfigdata/test-pci-devs.cfg b/tests/xmconfigdata/test-pci-devs.cfg index 9f9b2f4..6d19f21 100644 --- a/tests/xmconfigdata/test-pci-devs.cfg +++ b/tests/xmconfigdata/test-pci-devs.cfg @@ -3,12 +3,12 @@ uuid = "cc2315e7-d26a-307a-438c-6d188ec4c09c" maxmem = 382 memory = 350 vcpus = 1 -builder = "hvm" -kernel = "/usr/lib/xen/boot/hvmloader" -boot = "c" pae = 1 acpi = 1 apic = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "c" localtime = 0 on_poweroff = "destroy" on_reboot = "destroy" -- 1.8.4.5

From: Kiarie Kahurani <davidkiarie4@gmail.com> introduce function xenFormatXMDiskList(virConfPtr conf, .....); which formats xm disk config instead signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 73 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 27 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index f2b1267..2d975d5 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -2022,6 +2022,51 @@ int xenFormatXMCPUFeatures(virConfPtr conf, virDomainDefPtr def, } +static +int xenFormatXMDomainDisks(virConfPtr conf, virDomainDefPtr def, + int xendConfigVersion) +{ + virConfValuePtr diskVal = NULL; + size_t i = 0; + int hvm = STREQ(def->os.type, "hvm"); + + if (VIR_ALLOC(diskVal) < 0) + goto cleanup; + + diskVal->type = VIR_CONF_LIST; + diskVal->list = NULL; + + for (i = 0; i < def->ndisks; i++) { + if (xendConfigVersion == XEND_CONFIG_VERSION_3_0_2 && + def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM && + def->disks[i]->dst && + STREQ(def->disks[i]->dst, "hdc")) { + continue; + } + + if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) + continue; + + if (xenFormatXMDisk(diskVal, def->disks[i], + hvm, xendConfigVersion) < 0) + goto cleanup; + } + + if (diskVal->list != NULL) { + int ret = virConfSetValue(conf, "disk", diskVal); + diskVal = NULL; + if (ret < 0) + goto cleanup; + } + + return 0; + + cleanup: + virConfFreeValue(diskVal); + return -1; +} + + virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, int xendConfigVersion) { @@ -2142,34 +2187,8 @@ virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, if (xenFormatXMVfb(conf, def, xendConfigVersion) < 0) goto cleanup; - /* analyze of the devices */ - if (VIR_ALLOC(diskVal) < 0) + if (xenFormatXMDomainDisks(conf, def, xendConfigVersion) < 0) goto cleanup; - diskVal->type = VIR_CONF_LIST; - diskVal->list = NULL; - - for (i = 0; i < def->ndisks; i++) { - if (xendConfigVersion == XEND_CONFIG_VERSION_3_0_2 && - def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM && - def->disks[i]->dst && - STREQ(def->disks[i]->dst, "hdc")) { - continue; - } - if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) - continue; - - if (xenFormatXMDisk(diskVal, def->disks[i], - hvm, xendConfigVersion) < 0) - goto cleanup; - } - if (diskVal->list != NULL) { - int ret = virConfSetValue(conf, "disk", diskVal); - diskVal = NULL; - if (ret < 0) - goto cleanup; - } - VIR_FREE(diskVal); - if (xenFormatXMVif(conf, conn, def, xendConfigVersion) < 0) goto cleanup; if (xenFormatXMPCI(conf, def) < 0) -- 1.8.4.5

From: Kiarie Kahurani <davidkiarie4@gmail.com> introduce function xenFormatXMEmulatedDevices(virConfPtr conf,...........) which formats emulated devices config instead signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 86 +++++++++++++++++------------- tests/xmconfigdata/test-escape-paths.cfg | 2 +- tests/xmconfigdata/test-fullvirt-sound.cfg | 2 +- 3 files changed, 52 insertions(+), 38 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 2d975d5..08d8918 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -2067,6 +2067,54 @@ int xenFormatXMDomainDisks(virConfPtr conf, virDomainDefPtr def, } +static +int xenFormatXMEmulatedHardware(virConfPtr conf, virDomainDefPtr def) +{ + size_t i; + + if (STREQ(def->os.type, "hvm")) { + if (def->sounds) { + virBuffer buf = VIR_BUFFER_INITIALIZER; + char *str = NULL; + int ret = xenFormatSxprSound(def, &buf); + str = virBufferContentAndReset(&buf); + if (ret == 0) + ret = xenXMConfigSetString(conf, "soundhw", str); + + VIR_FREE(str); + if (ret < 0) + return -1; + } + + for (i = 0; i < def->ninputs; i++) { + if (def->inputs[i]->bus == VIR_DOMAIN_INPUT_BUS_USB) { + if (xenXMConfigSetInt(conf, "usb", 1) < 0) + return -1; + + switch (def->inputs[i]->type) { + case VIR_DOMAIN_INPUT_TYPE_MOUSE: + if (xenXMConfigSetString(conf, "usbdevice", "mouse") < 0) + return -1; + + break; + case VIR_DOMAIN_INPUT_TYPE_TABLET: + if (xenXMConfigSetString(conf, "usbdevice", "tablet") < 0) + return -1; + + break; + case VIR_DOMAIN_INPUT_TYPE_KBD: + if (xenXMConfigSetString(conf, "usbdevice", "keyboard") < 0) + return -1; + + break; + } + break; + } + } + } + + return 0; +} virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, int xendConfigVersion) { @@ -2161,30 +2209,10 @@ virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, if (def->emulator && xenXMConfigSetString(conf, "device_model", def->emulator) < 0) goto cleanup; - - for (i = 0; i < def->ninputs; i++) { - if (def->inputs[i]->bus == VIR_DOMAIN_INPUT_BUS_USB) { - if (xenXMConfigSetInt(conf, "usb", 1) < 0) - goto cleanup; - switch (def->inputs[i]->type) { - case VIR_DOMAIN_INPUT_TYPE_MOUSE: - if (xenXMConfigSetString(conf, "usbdevice", "mouse") < 0) - goto cleanup; - break; - case VIR_DOMAIN_INPUT_TYPE_TABLET: - if (xenXMConfigSetString(conf, "usbdevice", "tablet") < 0) - goto cleanup; - break; - case VIR_DOMAIN_INPUT_TYPE_KBD: - if (xenXMConfigSetString(conf, "usbdevice", "keyboard") < 0) - goto cleanup; - break; - } - break; - } - } } + if (xenFormatXMEmulatedHardware(conf, def) < 0) + goto cleanup; if (xenFormatXMVfb(conf, def, xendConfigVersion) < 0) goto cleanup; if (xenFormatXMDomainDisks(conf, def, xendConfigVersion) < 0) @@ -2265,20 +2293,6 @@ virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, if (xenXMConfigSetString(conf, "serial", "none") < 0) goto cleanup; } - - - if (def->sounds) { - virBuffer buf = VIR_BUFFER_INITIALIZER; - char *str = NULL; - int ret = xenFormatSxprSound(def, &buf); - str = virBufferContentAndReset(&buf); - if (ret == 0) - ret = xenXMConfigSetString(conf, "soundhw", str); - - VIR_FREE(str); - if (ret < 0) - goto cleanup; - } } return conf; diff --git a/tests/xmconfigdata/test-escape-paths.cfg b/tests/xmconfigdata/test-escape-paths.cfg index 4a18cc1..42223b9 100644 --- a/tests/xmconfigdata/test-escape-paths.cfg +++ b/tests/xmconfigdata/test-escape-paths.cfg @@ -14,6 +14,7 @@ on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" device_model = "/usr/lib/xen/bin/qemu-dm&test" +soundhw = "sb16,es1370" sdl = 0 vnc = 1 vncunused = 1 @@ -23,4 +24,3 @@ disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", """phy:/dev/HostVG/XenGuest'",hdb,w" vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = "none" -soundhw = "sb16,es1370" diff --git a/tests/xmconfigdata/test-fullvirt-sound.cfg b/tests/xmconfigdata/test-fullvirt-sound.cfg index d315f93..a3bb409 100644 --- a/tests/xmconfigdata/test-fullvirt-sound.cfg +++ b/tests/xmconfigdata/test-fullvirt-sound.cfg @@ -14,6 +14,7 @@ on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" device_model = "/usr/lib/xen/bin/qemu-dm" +soundhw = "sb16,es1370" sdl = 0 vnc = 1 vncunused = 1 @@ -23,4 +24,3 @@ disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = "none" -soundhw = "sb16,es1370" -- 1.8.4.5

From: Kiarie Kahurani <davidkiarie4@gmail.com> introduce function xenFormatXMCharDev(virConfPtr conf,.........); which formats char devices related config signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 163 +++++++++++++++++++++++++++++------------------------ 1 file changed, 90 insertions(+), 73 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 08d8918..be5818f 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -2115,6 +2115,94 @@ int xenFormatXMEmulatedHardware(virConfPtr conf, virDomainDefPtr def) return 0; } + + +static +int xenFormatXMCharDev(virConfPtr conf, virDomainDefPtr def) +{ + size_t i; + + if (STREQ(def->os.type, "hvm")) { + if (def->nparallels) { + virBuffer buf = VIR_BUFFER_INITIALIZER; + char *str; + int ret; + + ret = xenFormatSxprChr(def->parallels[0], &buf); + str = virBufferContentAndReset(&buf); + if (ret == 0) + ret = xenXMConfigSetString(conf, "parallel", str); + VIR_FREE(str); + if (ret < 0) + return -1; + + } else { + if (xenXMConfigSetString(conf, "parallel", "none") < 0) + return -1; + } + + if (def->nserials) { + if ((def->nserials == 1) && (def->serials[0]->target.port == 0)) { + virBuffer buf = VIR_BUFFER_INITIALIZER; + char *str; + int ret; + + ret = xenFormatSxprChr(def->serials[0], &buf); + str = virBufferContentAndReset(&buf); + if (ret == 0) + ret = xenXMConfigSetString(conf, "serial", str); + VIR_FREE(str); + if (ret < 0) + return -1; + + } else { + size_t j = 0; + int maxport = -1, port; + virConfValuePtr serialVal = NULL; + + if (VIR_ALLOC(serialVal) < 0) + return -1; + + serialVal->type = VIR_CONF_LIST; + serialVal->list = NULL; + + for (i = 0; i < def->nserials; i++) + if (def->serials[i]->target.port > maxport) + maxport = def->serials[i]->target.port; + + for (port = 0; port <= maxport; port++) { + virDomainChrDefPtr chr = NULL; + for (j = 0; j < def->nserials; j++) { + if (def->serials[j]->target.port == port) { + chr = def->serials[j]; + break; + } + } + + if (xenFormatXMSerial(serialVal, chr) < 0) { + VIR_FREE(serialVal); + return -1; + } + } + + if (serialVal->list != NULL) { + int ret = virConfSetValue(conf, "serial", serialVal); + serialVal = NULL; + if (ret < 0) + return -1; + } + VIR_FREE(serialVal); + } + } else { + if (xenXMConfigSetString(conf, "serial", "none") < 0) + return -1; + } + } + + return 0; +} + + virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, int xendConfigVersion) { @@ -2221,79 +2309,8 @@ virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, goto cleanup; if (xenFormatXMPCI(conf, def) < 0) goto cleanup; - - if (hvm) { - if (def->nparallels) { - virBuffer buf = VIR_BUFFER_INITIALIZER; - char *str; - int ret; - - ret = xenFormatSxprChr(def->parallels[0], &buf); - str = virBufferContentAndReset(&buf); - if (ret == 0) - ret = xenXMConfigSetString(conf, "parallel", str); - VIR_FREE(str); - if (ret < 0) - goto cleanup; - } else { - if (xenXMConfigSetString(conf, "parallel", "none") < 0) - goto cleanup; - } - - if (def->nserials) { - if ((def->nserials == 1) && (def->serials[0]->target.port == 0)) { - virBuffer buf = VIR_BUFFER_INITIALIZER; - char *str; - int ret; - - ret = xenFormatSxprChr(def->serials[0], &buf); - str = virBufferContentAndReset(&buf); - if (ret == 0) - ret = xenXMConfigSetString(conf, "serial", str); - VIR_FREE(str); - if (ret < 0) - goto cleanup; - } else { - size_t j = 0; - int maxport = -1, port; - virConfValuePtr serialVal = NULL; - - if (VIR_ALLOC(serialVal) < 0) - goto cleanup; - serialVal->type = VIR_CONF_LIST; - serialVal->list = NULL; - - for (i = 0; i < def->nserials; i++) - if (def->serials[i]->target.port > maxport) - maxport = def->serials[i]->target.port; - - for (port = 0; port <= maxport; port++) { - virDomainChrDefPtr chr = NULL; - for (j = 0; j < def->nserials; j++) { - if (def->serials[j]->target.port == port) { - chr = def->serials[j]; - break; - } - } - if (xenFormatXMSerial(serialVal, chr) < 0) { - virConfFreeValue(serialVal); - goto cleanup; - } - } - - if (serialVal->list != NULL) { - int ret = virConfSetValue(conf, "serial", serialVal); - serialVal = NULL; - if (ret < 0) - goto cleanup; - } - VIR_FREE(serialVal); - } - } else { - if (xenXMConfigSetString(conf, "serial", "none") < 0) - goto cleanup; - } - } + if (xenFormatXMCharDev(conf, def) < 0) + goto cleanup; return conf; -- 1.8.4.5

From: Kiarie Kahurani <davidkiarie4@gmail.com> introduce function xenFormatXMOS( ); which formats config options related to OS signed-off-by:David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 72 ++++++++++++---------- tests/xmconfigdata/test-escape-paths.cfg | 2 +- tests/xmconfigdata/test-fullvirt-force-hpet.cfg | 2 +- tests/xmconfigdata/test-fullvirt-force-nohpet.cfg | 2 +- tests/xmconfigdata/test-fullvirt-localtime.cfg | 2 +- tests/xmconfigdata/test-fullvirt-net-ioemu.cfg | 2 +- tests/xmconfigdata/test-fullvirt-net-netfront.cfg | 2 +- tests/xmconfigdata/test-fullvirt-new-cdrom.cfg | 2 +- tests/xmconfigdata/test-fullvirt-old-cdrom.cfg | 2 +- tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg | 2 +- .../test-fullvirt-serial-dev-2-ports.cfg | 2 +- .../test-fullvirt-serial-dev-2nd-port.cfg | 2 +- tests/xmconfigdata/test-fullvirt-serial-file.cfg | 2 +- tests/xmconfigdata/test-fullvirt-serial-null.cfg | 2 +- tests/xmconfigdata/test-fullvirt-serial-pipe.cfg | 2 +- tests/xmconfigdata/test-fullvirt-serial-pty.cfg | 2 +- tests/xmconfigdata/test-fullvirt-serial-stdio.cfg | 2 +- .../test-fullvirt-serial-tcp-telnet.cfg | 2 +- tests/xmconfigdata/test-fullvirt-serial-tcp.cfg | 2 +- tests/xmconfigdata/test-fullvirt-serial-udp.cfg | 2 +- tests/xmconfigdata/test-fullvirt-serial-unix.cfg | 2 +- tests/xmconfigdata/test-fullvirt-sound.cfg | 2 +- tests/xmconfigdata/test-fullvirt-usbmouse.cfg | 2 +- tests/xmconfigdata/test-fullvirt-usbtablet.cfg | 2 +- tests/xmconfigdata/test-fullvirt-utc.cfg | 2 +- tests/xmconfigdata/test-no-source-cdrom.cfg | 2 +- tests/xmconfigdata/test-pci-devs.cfg | 2 +- 27 files changed, 65 insertions(+), 59 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index be5818f..8f0e12d 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -2203,32 +2203,20 @@ int xenFormatXMCharDev(virConfPtr conf, virDomainDefPtr def) } -virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, - int xendConfigVersion) +static +int xenFormatXMOS(virConfPtr conf, virDomainDefPtr def, + int xendConfigVersion) { - virConfPtr conf = NULL; - int hvm = 0; size_t i; - char *cpus = NULL; - virConfValuePtr diskVal = NULL; - if (!(conf = virConfNew())) - goto cleanup; - if (xenFormatXMGeneralMeta(conf, def) < 0) - goto cleanup; - if (xenFormatXMMem(conf, def) < 0) - goto cleanup; - if (xenFormatXMCPUFeatures(conf, def, xendConfigVersion) < 0) - goto cleanup; - hvm = STREQ(def->os.type, "hvm") ? 1 : 0; - if (hvm) { + if (STREQ(def->os.type, "hvm")) { char boot[VIR_DOMAIN_BOOT_LAST+1]; if (xenXMConfigSetString(conf, "builder", "hvm") < 0) - goto cleanup; + return -1; if (def->os.loader && xenXMConfigSetString(conf, "kernel", def->os.loader) < 0) - goto cleanup; + return -1; for (i = 0; i < def->os.nBootDevs; i++) { switch (def->os.bootDevs[i]) { @@ -2255,7 +2243,8 @@ virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, } if (xenXMConfigSetString(conf, "boot", boot) < 0) - goto cleanup; + return -1; + if (xendConfigVersion == XEND_CONFIG_VERSION_3_0_2) { for (i = 0; i < def->ndisks; i++) { if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM && @@ -2264,41 +2253,60 @@ virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, virDomainDiskGetSource(def->disks[i])) { if (xenXMConfigSetString(conf, "cdrom", virDomainDiskGetSource(def->disks[i])) < 0) - goto cleanup; + return -1; + break; } } } + if (def->emulator && + xenXMConfigSetString(conf, "device_model", def->emulator) < 0) + return -1; /* XXX floppy disks */ } else { if (def->os.bootloader && xenXMConfigSetString(conf, "bootloader", def->os.bootloader) < 0) - goto cleanup; + return -1; + if (def->os.bootloaderArgs && xenXMConfigSetString(conf, "bootargs", def->os.bootloaderArgs) < 0) - goto cleanup; + return -1; + if (def->os.kernel && xenXMConfigSetString(conf, "kernel", def->os.kernel) < 0) - goto cleanup; + return -1; + if (def->os.initrd && xenXMConfigSetString(conf, "ramdisk", def->os.initrd) < 0) - goto cleanup; + return -1; + if (def->os.cmdline && xenXMConfigSetString(conf, "extra", def->os.cmdline) < 0) - goto cleanup; + return -1; } /* !hvm */ + return 0; +} +virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, + int xendConfigVersion) +{ + virConfPtr conf = NULL; + + if (!(conf = virConfNew())) + goto cleanup; + if (xenFormatXMGeneralMeta(conf, def) < 0) + goto cleanup; + if (xenFormatXMMem(conf, def) < 0) + goto cleanup; + if (xenFormatXMCPUFeatures(conf, def, xendConfigVersion) < 0) + goto cleanup; + if (xenFormatXMOS(conf, def, xendConfigVersion) < 0) + goto cleanup; if (xenFormatXMTimeOffset(conf, def, xendConfigVersion) < 0) goto cleanup; if (xenFormatXMEventActions(conf, def) < 0) goto cleanup; - if (hvm) { - if (def->emulator && - xenXMConfigSetString(conf, "device_model", def->emulator) < 0) - goto cleanup; - } - if (xenFormatXMEmulatedHardware(conf, def) < 0) goto cleanup; if (xenFormatXMVfb(conf, def, xendConfigVersion) < 0) @@ -2315,8 +2323,6 @@ virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, return conf; cleanup: - virConfFreeValue(diskVal); - VIR_FREE(cpus); if (conf) virConfFree(conf); return NULL; diff --git a/tests/xmconfigdata/test-escape-paths.cfg b/tests/xmconfigdata/test-escape-paths.cfg index 42223b9..1336ece 100644 --- a/tests/xmconfigdata/test-escape-paths.cfg +++ b/tests/xmconfigdata/test-escape-paths.cfg @@ -9,11 +9,11 @@ apic = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader&test" boot = "d" +device_model = "/usr/lib/xen/bin/qemu-dm&test" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm&test" soundhw = "sb16,es1370" sdl = 0 vnc = 1 diff --git a/tests/xmconfigdata/test-fullvirt-force-hpet.cfg b/tests/xmconfigdata/test-fullvirt-force-hpet.cfg index c1afc08..f2377dc 100644 --- a/tests/xmconfigdata/test-fullvirt-force-hpet.cfg +++ b/tests/xmconfigdata/test-fullvirt-force-hpet.cfg @@ -10,11 +10,11 @@ hpet = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm" sdl = 0 vnc = 1 vncunused = 1 diff --git a/tests/xmconfigdata/test-fullvirt-force-nohpet.cfg b/tests/xmconfigdata/test-fullvirt-force-nohpet.cfg index 397d8ef..093c8de 100644 --- a/tests/xmconfigdata/test-fullvirt-force-nohpet.cfg +++ b/tests/xmconfigdata/test-fullvirt-force-nohpet.cfg @@ -10,11 +10,11 @@ hpet = 0 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm" sdl = 0 vnc = 1 vncunused = 1 diff --git a/tests/xmconfigdata/test-fullvirt-localtime.cfg b/tests/xmconfigdata/test-fullvirt-localtime.cfg index 7292e7f..34ea100 100755 --- a/tests/xmconfigdata/test-fullvirt-localtime.cfg +++ b/tests/xmconfigdata/test-fullvirt-localtime.cfg @@ -9,11 +9,11 @@ apic = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 1 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm" sdl = 0 vnc = 1 vncunused = 1 diff --git a/tests/xmconfigdata/test-fullvirt-net-ioemu.cfg b/tests/xmconfigdata/test-fullvirt-net-ioemu.cfg index ef97329..a4f3aec 100644 --- a/tests/xmconfigdata/test-fullvirt-net-ioemu.cfg +++ b/tests/xmconfigdata/test-fullvirt-net-ioemu.cfg @@ -9,11 +9,11 @@ apic = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm" sdl = 0 vnc = 1 vncunused = 1 diff --git a/tests/xmconfigdata/test-fullvirt-net-netfront.cfg b/tests/xmconfigdata/test-fullvirt-net-netfront.cfg index 385f917..57cff7b 100644 --- a/tests/xmconfigdata/test-fullvirt-net-netfront.cfg +++ b/tests/xmconfigdata/test-fullvirt-net-netfront.cfg @@ -9,11 +9,11 @@ apic = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm" sdl = 0 vnc = 1 vncunused = 1 diff --git a/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg b/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg index ef97329..a4f3aec 100755 --- a/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg +++ b/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg @@ -9,11 +9,11 @@ apic = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm" sdl = 0 vnc = 1 vncunused = 1 diff --git a/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg b/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg index 27407e7..9b74db4 100755 --- a/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg +++ b/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg @@ -10,11 +10,11 @@ builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" cdrom = "/root/boot.iso" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm" sdl = 0 vnc = 1 vncunused = 1 diff --git a/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg b/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg index 86e0aa0..6a0e1ac 100755 --- a/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg +++ b/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg @@ -9,11 +9,11 @@ apic = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm" sdl = 0 vnc = 1 vncunused = 1 diff --git a/tests/xmconfigdata/test-fullvirt-serial-dev-2-ports.cfg b/tests/xmconfigdata/test-fullvirt-serial-dev-2-ports.cfg index 8ada1fd..2021ac3 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-dev-2-ports.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-dev-2-ports.cfg @@ -9,11 +9,11 @@ apic = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm" sdl = 0 vnc = 1 vncunused = 1 diff --git a/tests/xmconfigdata/test-fullvirt-serial-dev-2nd-port.cfg b/tests/xmconfigdata/test-fullvirt-serial-dev-2nd-port.cfg index 61e2af3..0200194 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-dev-2nd-port.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-dev-2nd-port.cfg @@ -9,11 +9,11 @@ apic = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm" sdl = 0 vnc = 1 vncunused = 1 diff --git a/tests/xmconfigdata/test-fullvirt-serial-file.cfg b/tests/xmconfigdata/test-fullvirt-serial-file.cfg index ad4a874..4602516 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-file.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-file.cfg @@ -9,11 +9,11 @@ apic = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm" sdl = 0 vnc = 1 vncunused = 1 diff --git a/tests/xmconfigdata/test-fullvirt-serial-null.cfg b/tests/xmconfigdata/test-fullvirt-serial-null.cfg index a11c42a..c8365e8 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-null.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-null.cfg @@ -9,11 +9,11 @@ apic = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm" sdl = 0 vnc = 1 vncunused = 1 diff --git a/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg b/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg index 1ee0bc8..f30a072 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg @@ -9,11 +9,11 @@ apic = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm" sdl = 0 vnc = 1 vncunused = 1 diff --git a/tests/xmconfigdata/test-fullvirt-serial-pty.cfg b/tests/xmconfigdata/test-fullvirt-serial-pty.cfg index 10465a5..bb490b0 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-pty.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-pty.cfg @@ -9,11 +9,11 @@ apic = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm" sdl = 0 vnc = 1 vncunused = 1 diff --git a/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg b/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg index 3733161..6583076 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg @@ -9,11 +9,11 @@ apic = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm" sdl = 0 vnc = 1 vncunused = 1 diff --git a/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg b/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg index 442309f..730b2e8 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg @@ -9,11 +9,11 @@ apic = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm" sdl = 0 vnc = 1 vncunused = 1 diff --git a/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg b/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg index f141269..3a15c11 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg @@ -9,11 +9,11 @@ apic = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm" sdl = 0 vnc = 1 vncunused = 1 diff --git a/tests/xmconfigdata/test-fullvirt-serial-udp.cfg b/tests/xmconfigdata/test-fullvirt-serial-udp.cfg index 3ccc4a7..5b7804d 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-udp.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-udp.cfg @@ -9,11 +9,11 @@ apic = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm" sdl = 0 vnc = 1 vncunused = 1 diff --git a/tests/xmconfigdata/test-fullvirt-serial-unix.cfg b/tests/xmconfigdata/test-fullvirt-serial-unix.cfg index dd250ac..6cd7272 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-unix.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-unix.cfg @@ -9,11 +9,11 @@ apic = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm" sdl = 0 vnc = 1 vncunused = 1 diff --git a/tests/xmconfigdata/test-fullvirt-sound.cfg b/tests/xmconfigdata/test-fullvirt-sound.cfg index a3bb409..67dd8e0 100644 --- a/tests/xmconfigdata/test-fullvirt-sound.cfg +++ b/tests/xmconfigdata/test-fullvirt-sound.cfg @@ -9,11 +9,11 @@ apic = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm" soundhw = "sb16,es1370" sdl = 0 vnc = 1 diff --git a/tests/xmconfigdata/test-fullvirt-usbmouse.cfg b/tests/xmconfigdata/test-fullvirt-usbmouse.cfg index 3d30bb1..be27f08 100755 --- a/tests/xmconfigdata/test-fullvirt-usbmouse.cfg +++ b/tests/xmconfigdata/test-fullvirt-usbmouse.cfg @@ -9,11 +9,11 @@ apic = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm" usb = 1 usbdevice = "mouse" sdl = 0 diff --git a/tests/xmconfigdata/test-fullvirt-usbtablet.cfg b/tests/xmconfigdata/test-fullvirt-usbtablet.cfg index 4463e31..5e84e7e 100755 --- a/tests/xmconfigdata/test-fullvirt-usbtablet.cfg +++ b/tests/xmconfigdata/test-fullvirt-usbtablet.cfg @@ -9,11 +9,11 @@ apic = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm" usb = 1 usbdevice = "tablet" sdl = 0 diff --git a/tests/xmconfigdata/test-fullvirt-utc.cfg b/tests/xmconfigdata/test-fullvirt-utc.cfg index ef97329..a4f3aec 100755 --- a/tests/xmconfigdata/test-fullvirt-utc.cfg +++ b/tests/xmconfigdata/test-fullvirt-utc.cfg @@ -9,11 +9,11 @@ apic = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -device_model = "/usr/lib/xen/bin/qemu-dm" sdl = 0 vnc = 1 vncunused = 1 diff --git a/tests/xmconfigdata/test-no-source-cdrom.cfg b/tests/xmconfigdata/test-no-source-cdrom.cfg index ee22632..27bec8d 100644 --- a/tests/xmconfigdata/test-no-source-cdrom.cfg +++ b/tests/xmconfigdata/test-no-source-cdrom.cfg @@ -9,11 +9,11 @@ apic = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "c" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "destroy" on_crash = "destroy" -device_model = "/usr/lib/xen/bin/qemu-dm" sdl = 0 vnc = 1 vncunused = 1 diff --git a/tests/xmconfigdata/test-pci-devs.cfg b/tests/xmconfigdata/test-pci-devs.cfg index 6d19f21..a24a09c 100644 --- a/tests/xmconfigdata/test-pci-devs.cfg +++ b/tests/xmconfigdata/test-pci-devs.cfg @@ -9,11 +9,11 @@ apic = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "c" +device_model = "/usr/lib/xen/bin/qemu-dm" localtime = 0 on_poweroff = "destroy" on_reboot = "destroy" on_crash = "destroy" -device_model = "/usr/lib/xen/bin/qemu-dm" sdl = 0 vnc = 1 vncunused = 1 -- 1.8.4.5

From: Kiarie Kahurani <davidkiarie4@gmail.com> Introduce function xenFormatConfigCommon( ); which wraps code to be reused.Again I have being forced to make changes on the layout of the tests signed-off-by: David Kiarie<davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 56 +++++++++++++++------- src/xenxs/xen_xm.h | 4 +- tests/xmconfigdata/test-escape-paths.cfg | 4 +- tests/xmconfigdata/test-fullvirt-force-hpet.cfg | 4 +- tests/xmconfigdata/test-fullvirt-force-nohpet.cfg | 4 +- tests/xmconfigdata/test-fullvirt-localtime.cfg | 4 +- tests/xmconfigdata/test-fullvirt-net-ioemu.cfg | 4 +- tests/xmconfigdata/test-fullvirt-net-netfront.cfg | 4 +- tests/xmconfigdata/test-fullvirt-new-cdrom.cfg | 4 +- tests/xmconfigdata/test-fullvirt-old-cdrom.cfg | 4 +- tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg | 4 +- .../test-fullvirt-serial-dev-2-ports.cfg | 4 +- .../test-fullvirt-serial-dev-2nd-port.cfg | 4 +- tests/xmconfigdata/test-fullvirt-serial-file.cfg | 4 +- tests/xmconfigdata/test-fullvirt-serial-null.cfg | 4 +- tests/xmconfigdata/test-fullvirt-serial-pipe.cfg | 4 +- tests/xmconfigdata/test-fullvirt-serial-pty.cfg | 4 +- tests/xmconfigdata/test-fullvirt-serial-stdio.cfg | 4 +- .../test-fullvirt-serial-tcp-telnet.cfg | 4 +- tests/xmconfigdata/test-fullvirt-serial-tcp.cfg | 4 +- tests/xmconfigdata/test-fullvirt-serial-udp.cfg | 4 +- tests/xmconfigdata/test-fullvirt-serial-unix.cfg | 4 +- tests/xmconfigdata/test-fullvirt-sound.cfg | 4 +- tests/xmconfigdata/test-fullvirt-usbmouse.cfg | 4 +- tests/xmconfigdata/test-fullvirt-usbtablet.cfg | 4 +- tests/xmconfigdata/test-fullvirt-utc.cfg | 4 +- tests/xmconfigdata/test-no-source-cdrom.cfg | 4 +- tests/xmconfigdata/test-pci-devs.cfg | 4 +- 28 files changed, 93 insertions(+), 71 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 8f0e12d..0373945 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -2288,38 +2288,60 @@ int xenFormatXMOS(virConfPtr conf, virDomainDefPtr def, return 0; } -virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, - int xendConfigVersion) + + +int xenFormatConfigCommon(virConfPtr conf, virDomainDefPtr def, + int xendConfigVersion) { - virConfPtr conf = NULL; - if (!(conf = virConfNew())) - goto cleanup; if (xenFormatXMGeneralMeta(conf, def) < 0) - goto cleanup; + return -1; + if (xenFormatXMMem(conf, def) < 0) - goto cleanup; + return -1; + if (xenFormatXMCPUFeatures(conf, def, xendConfigVersion) < 0) - goto cleanup; + return -1; + if (xenFormatXMOS(conf, def, xendConfigVersion) < 0) - goto cleanup; + return -1; + if (xenFormatXMTimeOffset(conf, def, xendConfigVersion) < 0) - goto cleanup; + return -1; + if (xenFormatXMEventActions(conf, def) < 0) - goto cleanup; + return -1; + if (xenFormatXMEmulatedHardware(conf, def) < 0) - goto cleanup; + return -1; + if (xenFormatXMVfb(conf, def, xendConfigVersion) < 0) + return -1; + + if (xenFormatXMPCI(conf, def) < 0) + return -1; + + if (xenFormatXMCharDev(conf, def) < 0) + return -1; + + return 0; +} + + +virConfPtr +xenFormatXM(virConnectPtr conn, virDomainDefPtr def, + int xendConfigVersion) +{ + virConfPtr conf = NULL; + + if (!(conf = virConfNew())) + goto cleanup; + if (xenFormatConfigCommon(conf, def, xendConfigVersion) < 0) goto cleanup; if (xenFormatXMDomainDisks(conf, def, xendConfigVersion) < 0) goto cleanup; if (xenFormatXMVif(conf, conn, def, xendConfigVersion) < 0) goto cleanup; - if (xenFormatXMPCI(conf, def) < 0) - goto cleanup; - if (xenFormatXMCharDev(conf, def) < 0) - goto cleanup; - return conf; cleanup: diff --git a/src/xenxs/xen_xm.h b/src/xenxs/xen_xm.h index 69a2d44..f108fc5 100644 --- a/src/xenxs/xen_xm.h +++ b/src/xenxs/xen_xm.h @@ -32,10 +32,10 @@ virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, int xendConfigVersion); - virDomainDefPtr xenParseXM(virConfPtr conf, int xendConfigVersion, virCapsPtr caps); - int xenParseConfigCommon(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps, int xendConfigVersion); +int xenFormatConfigCommon(virConfPtr conf, virDomainDefPtr def, + int xendConfigVersion); #endif /* __VIR_XEN_XM_H__ */ diff --git a/tests/xmconfigdata/test-escape-paths.cfg b/tests/xmconfigdata/test-escape-paths.cfg index 1336ece..bdb9e54 100644 --- a/tests/xmconfigdata/test-escape-paths.cfg +++ b/tests/xmconfigdata/test-escape-paths.cfg @@ -20,7 +20,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", """phy:/dev/HostVG/XenGuest'",hdb,w""", "file:/root/boot.iso&test,hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = "none" +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", """phy:/dev/HostVG/XenGuest'",hdb,w""", "file:/root/boot.iso&test,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-fullvirt-force-hpet.cfg b/tests/xmconfigdata/test-fullvirt-force-hpet.cfg index f2377dc..9541cf7 100644 --- a/tests/xmconfigdata/test-fullvirt-force-hpet.cfg +++ b/tests/xmconfigdata/test-fullvirt-force-hpet.cfg @@ -20,7 +20,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = "none" +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-fullvirt-force-nohpet.cfg b/tests/xmconfigdata/test-fullvirt-force-nohpet.cfg index 093c8de..784b395 100644 --- a/tests/xmconfigdata/test-fullvirt-force-nohpet.cfg +++ b/tests/xmconfigdata/test-fullvirt-force-nohpet.cfg @@ -20,7 +20,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = "none" +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-fullvirt-localtime.cfg b/tests/xmconfigdata/test-fullvirt-localtime.cfg index 34ea100..cba70d1 100755 --- a/tests/xmconfigdata/test-fullvirt-localtime.cfg +++ b/tests/xmconfigdata/test-fullvirt-localtime.cfg @@ -19,7 +19,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = "none" +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-fullvirt-net-ioemu.cfg b/tests/xmconfigdata/test-fullvirt-net-ioemu.cfg index a4f3aec..376d722 100644 --- a/tests/xmconfigdata/test-fullvirt-net-ioemu.cfg +++ b/tests/xmconfigdata/test-fullvirt-net-ioemu.cfg @@ -19,7 +19,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = "none" +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-fullvirt-net-netfront.cfg b/tests/xmconfigdata/test-fullvirt-net-netfront.cfg index 57cff7b..cb2f13d 100644 --- a/tests/xmconfigdata/test-fullvirt-net-netfront.cfg +++ b/tests/xmconfigdata/test-fullvirt-net-netfront.cfg @@ -19,7 +19,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,type=netfront" ] parallel = "none" serial = "none" +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,type=netfront" ] diff --git a/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg b/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg index a4f3aec..376d722 100755 --- a/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg +++ b/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg @@ -19,7 +19,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = "none" +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg b/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg index 9b74db4..4bdb567 100755 --- a/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg +++ b/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg @@ -20,7 +20,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,ioemu:hda,w" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr0,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = "none" +disk = [ "phy:/dev/HostVG/XenGuest2,ioemu:hda,w" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr0,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg b/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg index 6a0e1ac..e66a88a 100755 --- a/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg +++ b/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg @@ -19,7 +19,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "tcp:127.0.0.1:7777" serial = "none" +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-fullvirt-serial-dev-2-ports.cfg b/tests/xmconfigdata/test-fullvirt-serial-dev-2-ports.cfg index 2021ac3..e9d9e8f 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-dev-2-ports.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-dev-2-ports.cfg @@ -19,7 +19,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = [ "/dev/ttyS0", "/dev/ttyS1" ] +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-fullvirt-serial-dev-2nd-port.cfg b/tests/xmconfigdata/test-fullvirt-serial-dev-2nd-port.cfg index 0200194..15f681b 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-dev-2nd-port.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-dev-2nd-port.cfg @@ -19,7 +19,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = [ "none", "/dev/ttyS1" ] +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-fullvirt-serial-file.cfg b/tests/xmconfigdata/test-fullvirt-serial-file.cfg index 4602516..b904795 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-file.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-file.cfg @@ -19,7 +19,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = "file:/tmp/serial.log" +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-fullvirt-serial-null.cfg b/tests/xmconfigdata/test-fullvirt-serial-null.cfg index c8365e8..5fee34c 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-null.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-null.cfg @@ -19,7 +19,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = "null" +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg b/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg index f30a072..d9f5bed 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg @@ -19,7 +19,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = "pipe:/tmp/serial.pipe" +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-fullvirt-serial-pty.cfg b/tests/xmconfigdata/test-fullvirt-serial-pty.cfg index bb490b0..d0e7897 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-pty.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-pty.cfg @@ -19,7 +19,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = "pty" +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg b/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg index 6583076..a5a6a2b 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg @@ -19,7 +19,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = "stdio" +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg b/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg index 730b2e8..2e2dc29 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg @@ -19,7 +19,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = "telnet:127.0.0.1:9999,server,nowait" +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg b/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg index 3a15c11..58c67fe 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg @@ -19,7 +19,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = "tcp:127.0.0.1:7777" +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-fullvirt-serial-udp.cfg b/tests/xmconfigdata/test-fullvirt-serial-udp.cfg index 5b7804d..722459a 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-udp.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-udp.cfg @@ -19,7 +19,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = "udp:127.0.0.1:9999@0.0.0.0:99998" +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-fullvirt-serial-unix.cfg b/tests/xmconfigdata/test-fullvirt-serial-unix.cfg index 6cd7272..5084b53 100755 --- a/tests/xmconfigdata/test-fullvirt-serial-unix.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-unix.cfg @@ -19,7 +19,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = "unix:/tmp/serial.sock,server,nowait" +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-fullvirt-sound.cfg b/tests/xmconfigdata/test-fullvirt-sound.cfg index 67dd8e0..1ccc561 100644 --- a/tests/xmconfigdata/test-fullvirt-sound.cfg +++ b/tests/xmconfigdata/test-fullvirt-sound.cfg @@ -20,7 +20,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = "none" +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-fullvirt-usbmouse.cfg b/tests/xmconfigdata/test-fullvirt-usbmouse.cfg index be27f08..eea676e 100755 --- a/tests/xmconfigdata/test-fullvirt-usbmouse.cfg +++ b/tests/xmconfigdata/test-fullvirt-usbmouse.cfg @@ -21,7 +21,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = "none" +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-fullvirt-usbtablet.cfg b/tests/xmconfigdata/test-fullvirt-usbtablet.cfg index 5e84e7e..ada9949 100755 --- a/tests/xmconfigdata/test-fullvirt-usbtablet.cfg +++ b/tests/xmconfigdata/test-fullvirt-usbtablet.cfg @@ -21,7 +21,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = "none" +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-fullvirt-utc.cfg b/tests/xmconfigdata/test-fullvirt-utc.cfg index a4f3aec..376d722 100755 --- a/tests/xmconfigdata/test-fullvirt-utc.cfg +++ b/tests/xmconfigdata/test-fullvirt-utc.cfg @@ -19,7 +19,7 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = "none" +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-no-source-cdrom.cfg b/tests/xmconfigdata/test-no-source-cdrom.cfg index 27bec8d..ea8712a 100644 --- a/tests/xmconfigdata/test-no-source-cdrom.cfg +++ b/tests/xmconfigdata/test-no-source-cdrom.cfg @@ -17,7 +17,7 @@ on_crash = "destroy" sdl = 0 vnc = 1 vncunused = 1 -disk = [ "phy:/dev/sda8,hda,w", ",hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:0a:7b:39,bridge=xenbr0,script=vif-bridge,model=e1000,type=ioemu" ] parallel = "none" serial = "pty" +disk = [ "phy:/dev/sda8,hda,w", ",hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:0a:7b:39,bridge=xenbr0,script=vif-bridge,model=e1000,type=ioemu" ] diff --git a/tests/xmconfigdata/test-pci-devs.cfg b/tests/xmconfigdata/test-pci-devs.cfg index a24a09c..657e421 100644 --- a/tests/xmconfigdata/test-pci-devs.cfg +++ b/tests/xmconfigdata/test-pci-devs.cfg @@ -17,8 +17,8 @@ on_crash = "destroy" sdl = 0 vnc = 1 vncunused = 1 -disk = [ "phy:/dev/sda8,hda,w", ",hdc:cdrom,r" ] -vif = [ "mac=00:16:3e:0a:7b:39,bridge=xenbr0,script=vif-bridge,model=e1000,type=ioemu" ] pci = [ "0001:0c:1b.2", "0000:01:13.0" ] parallel = "none" serial = "pty" +disk = [ "phy:/dev/sda8,hda,w", ",hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:0a:7b:39,bridge=xenbr0,script=vif-bridge,model=e1000,type=ioemu" ] -- 1.8.4.5
participants (2)
-
David Kiarie
-
Jim Fehlig