[libvirt] [PATCH V5 00/12] xen_xm.c code refactor

Kiarie Kahurani (12): src/xenxs: Export code for reuse src/xenxs: Refactor code formating general VM config src/xenxs: Refactor code formating memory config src/xenxs: Refactor code formating virtual time config src/xenxs: Refactor code formating event actions config src/xenxs: Refactor code formating Char devices config src/xenxs: Refactor code formating xm disk config src/xenxs: Refactor code formating CPU features config src/xenxs: Refactor code formating OS config src/xenxs: Refactor code formating Vfb config src/xenxs: Refactor code formating emulated devices config src/xenxs: Export code src/xenxs/xen_xm.c | 858 +++++++++++++-------- src/xenxs/xen_xm.h | 4 + tests/xmconfigdata/test-escape-paths.cfg | 12 +- tests/xmconfigdata/test-fullvirt-force-hpet.cfg | 10 +- tests/xmconfigdata/test-fullvirt-force-nohpet.cfg | 10 +- tests/xmconfigdata/test-fullvirt-localtime.cfg | 10 +- tests/xmconfigdata/test-fullvirt-net-ioemu.cfg | 10 +- tests/xmconfigdata/test-fullvirt-net-netfront.cfg | 10 +- tests/xmconfigdata/test-fullvirt-new-cdrom.cfg | 10 +- tests/xmconfigdata/test-fullvirt-old-cdrom.cfg | 10 +- tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg | 10 +- .../test-fullvirt-serial-dev-2-ports.cfg | 10 +- .../test-fullvirt-serial-dev-2nd-port.cfg | 10 +- tests/xmconfigdata/test-fullvirt-serial-file.cfg | 10 +- tests/xmconfigdata/test-fullvirt-serial-null.cfg | 10 +- tests/xmconfigdata/test-fullvirt-serial-pipe.cfg | 10 +- tests/xmconfigdata/test-fullvirt-serial-pty.cfg | 10 +- tests/xmconfigdata/test-fullvirt-serial-stdio.cfg | 10 +- .../test-fullvirt-serial-tcp-telnet.cfg | 10 +- tests/xmconfigdata/test-fullvirt-serial-tcp.cfg | 10 +- tests/xmconfigdata/test-fullvirt-serial-udp.cfg | 10 +- tests/xmconfigdata/test-fullvirt-serial-unix.cfg | 10 +- tests/xmconfigdata/test-fullvirt-sound.cfg | 12 +- tests/xmconfigdata/test-fullvirt-usbmouse.cfg | 10 +- tests/xmconfigdata/test-fullvirt-usbtablet.cfg | 10 +- tests/xmconfigdata/test-fullvirt-utc.cfg | 10 +- tests/xmconfigdata/test-no-source-cdrom.cfg | 10 +- tests/xmconfigdata/test-paravirt-net-e1000.cfg | 2 +- tests/xmconfigdata/test-paravirt-net-vifname.cfg | 2 +- .../test-paravirt-new-pvfb-vncdisplay.cfg | 2 +- tests/xmconfigdata/test-paravirt-new-pvfb.cfg | 2 +- .../test-paravirt-old-pvfb-vncdisplay.cfg | 2 +- tests/xmconfigdata/test-paravirt-old-pvfb.cfg | 2 +- tests/xmconfigdata/test-paravirt-vcpu.cfg | 2 +- tests/xmconfigdata/test-pci-devs.cfg | 10 +- 35 files changed, 663 insertions(+), 477 deletions(-) This series refactor xen_xm.c code into functions for reuse when writing a xen-xl parser. Changes since V4 fixed SOB issue. -- 1.8.4.5

wrap code tagged for resuse into one function and export it Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 73 +++++++++++++++++++++++++++++++----------------------- src/xenxs/xen_xm.h | 2 ++ 2 files changed, 44 insertions(+), 31 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index f70b395..8238026 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1263,59 +1263,70 @@ xenParseXMOS(virConfPtr conf, virDomainDefPtr def) } -/* - * Turn a config record into a lump of XML describing the - * domain, suitable for later feeding for virDomainCreateXML - */ -virDomainDefPtr -xenParseXM(virConfPtr conf, int xendConfigVersion, - virCapsPtr caps) +int +xenParseConfigCommon(virConfPtr conf, virDomainDefPtr def, + virCapsPtr caps, int xendConfigVersion) { - 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; + return -1; if (xenParseXMOS(conf, def) < 0) - goto cleanup; + return -1; if (xenParseXMMem(conf, def) < 0) - goto cleanup; + return -1; + + if (xenParseXMTimeOffset(conf, def, xendConfigVersion) < 0) + return -1; if (xenParseXMEventsActions(conf, def) < 0) - goto cleanup; + return -1; + + if (xenParseXMPCI(conf, def) < 0) + return -1; if (xenParseXMCPUFeatures(conf, def) < 0) - goto cleanup; + return -1; - if (xenParseXMTimeOffset(conf, def, xendConfigVersion) < 0) - goto cleanup; + if (xenParseXMEmulatedDevices(conf, def) < 0) + return -1; - if (xenParseXMDisk(conf, def, xendConfigVersion) < 0) - goto cleanup; + if (xenParseXMCharDev(conf, def) < 0) + return -1; + + if (xenParseXMVfb(conf, def, xendConfigVersion) < 0) + return -1; if (xenXMConfigCopyStringOpt(conf, "device_model", &def->emulator) < 0) - goto cleanup; + return -1; if (xenParseXMVif(conf, def) < 0) - goto cleanup; + return -1; - if (xenParseXMPCI(conf, def) < 0) - goto cleanup; + return 0; +} - if (xenParseXMEmulatedDevices(conf, def) < 0) - goto cleanup; +/* + * Turn a config record into a lump of XML describing the + * domain, suitable for later feeding for virDomainCreateXML + */ +virDomainDefPtr +xenParseXM(virConfPtr conf, int xendConfigVersion, + virCapsPtr caps) +{ + virDomainDefPtr def = NULL; - if (xenParseXMVfb(conf, def, xendConfigVersion) < 0) + if (VIR_ALLOC(def) < 0) + return NULL; + + def->virtType = VIR_DOMAIN_VIRT_XEN; + def->id = -1; + + if (xenParseConfigCommon(conf, def, caps, xendConfigVersion) < 0) goto cleanup; - if (xenParseXMCharDev(conf, def) < 0) + if (xenParseXMDisk(conf, def, xendConfigVersion) < 0) goto cleanup; return def; diff --git a/src/xenxs/xen_xm.h b/src/xenxs/xen_xm.h index 629a4b3..261ba1f 100644 --- a/src/xenxs/xen_xm.h +++ b/src/xenxs/xen_xm.h @@ -35,5 +35,7 @@ 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

Kiarie Kahurani wrote:
wrap code tagged for resuse into one function and export it
Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 73 +++++++++++++++++++++++++++++++----------------------- src/xenxs/xen_xm.h | 2 ++
This patch got me thinking about the 'xenxs' directory and its contents. IMO, the directory should be named 'xenconfig' since it contains parsing/formating functions for the various xen config formats. Its contents should be xen_sxpr.[ch] for sxpr format, xen_xm.[ch] for xm format, and xen_xl.[ch] for xl format. xen_common.[ch] would contain parsing/formating functions common to xm and xl. Any opinions on this layout? I can work on a patch if others think this is reasonable. Your patch looks good, but I'll defer pushing it until hearing opinions on the above suggestion. Regards, Jim

On 08/11/2014 11:20 PM, Jim Fehlig wrote:
Kiarie Kahurani wrote:
wrap code tagged for resuse into one function and export it
Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 73 +++++++++++++++++++++++++++++++----------------------- src/xenxs/xen_xm.h | 2 ++
This patch got me thinking about the 'xenxs' directory and its contents. IMO, the directory should be named 'xenconfig' since it contains parsing/formating functions for the various xen config formats. Its contents should be xen_sxpr.[ch] for sxpr format, xen_xm.[ch] for xm format, and xen_xl.[ch] for xl format. xen_common.[ch] would contain parsing/formating functions common to xm and xl. Any opinions on this layout? I can work on a patch if others think this is reasonable.
Sounds fine to me. And 'git mv' makes it rather easy to do; just make sure you have 'git config diff.renames true' before sending the patch, so that the patch is compressed to just the tweaks accounting for the new names rather than wholesale delete/add actions. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Tue, Aug 12, 2014 at 12:21 AM, Kiarie Kahurani <davidkiarie4@gmail.com> wrote:
wrap code tagged for resuse into one function and export it
Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 73 +++++++++++++++++++++++++++++++----------------------- src/xenxs/xen_xm.h | 2 ++ 2 files changed, 44 insertions(+), 31 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index f70b395..8238026 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1263,59 +1263,70 @@ xenParseXMOS(virConfPtr conf, virDomainDefPtr def) }
-/* - * Turn a config record into a lump of XML describing the - * domain, suitable for later feeding for virDomainCreateXML - */ -virDomainDefPtr -xenParseXM(virConfPtr conf, int xendConfigVersion, - virCapsPtr caps) +int +xenParseConfigCommon(virConfPtr conf, virDomainDefPtr def, + virCapsPtr caps, int xendConfigVersion) { - 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; + return -1;
if (xenParseXMOS(conf, def) < 0) - goto cleanup; + return -1;
if (xenParseXMMem(conf, def) < 0) - goto cleanup; + return -1; + + if (xenParseXMTimeOffset(conf, def, xendConfigVersion) < 0) + return -1;
if (xenParseXMEventsActions(conf, def) < 0) - goto cleanup; + return -1; + + if (xenParseXMPCI(conf, def) < 0) + return -1;
if (xenParseXMCPUFeatures(conf, def) < 0) - goto cleanup; + return -1;
- if (xenParseXMTimeOffset(conf, def, xendConfigVersion) < 0) - goto cleanup; + if (xenParseXMEmulatedDevices(conf, def) < 0) + return -1;
- if (xenParseXMDisk(conf, def, xendConfigVersion) < 0) - goto cleanup; + if (xenParseXMCharDev(conf, def) < 0) + return -1; + + if (xenParseXMVfb(conf, def, xendConfigVersion) < 0) + return -1;
if (xenXMConfigCopyStringOpt(conf, "device_model", &def->emulator) < 0) - goto cleanup; + return -1;
I guess this should come of too; its already taken care of by xenParseXMOS.
if (xenParseXMVif(conf, def) < 0) - goto cleanup; + return -1;
- if (xenParseXMPCI(conf, def) < 0) - goto cleanup; + return 0; +}
- if (xenParseXMEmulatedDevices(conf, def) < 0) - goto cleanup; +/* + * Turn a config record into a lump of XML describing the + * domain, suitable for later feeding for virDomainCreateXML + */ +virDomainDefPtr +xenParseXM(virConfPtr conf, int xendConfigVersion, + virCapsPtr caps) +{ + virDomainDefPtr def = NULL;
- if (xenParseXMVfb(conf, def, xendConfigVersion) < 0) + if (VIR_ALLOC(def) < 0) + return NULL; + + def->virtType = VIR_DOMAIN_VIRT_XEN; + def->id = -1; + + if (xenParseConfigCommon(conf, def, caps, xendConfigVersion) < 0) goto cleanup;
- if (xenParseXMCharDev(conf, def) < 0) + if (xenParseXMDisk(conf, def, xendConfigVersion) < 0) goto cleanup;
return def; diff --git a/src/xenxs/xen_xm.h b/src/xenxs/xen_xm.h index 629a4b3..261ba1f 100644 --- a/src/xenxs/xen_xm.h +++ b/src/xenxs/xen_xm.h @@ -35,5 +35,7 @@ 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

introduce function xenFormatXMGeneralMeta(virConfPtr conf,......); which parses uuid and name instead Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 53 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 8238026..62d7f8f 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1337,8 +1337,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, } -static -int xenXMConfigSetInt(virConfPtr conf, const char *setting, long long l) +static int +xenXMConfigSetInt(virConfPtr conf, const char *setting, long long l) { virConfValuePtr value = NULL; @@ -1460,8 +1460,10 @@ xenFormatXMDisk(virConfValuePtr list, return -1; } -static int xenFormatXMSerial(virConfValuePtr list, - virDomainChrDefPtr serial) + +static int +xenFormatXMSerial(virConfValuePtr list, + virDomainChrDefPtr serial) { virBuffer buf = VIR_BUFFER_INITIALIZER; virConfValuePtr val, tmp; @@ -1497,10 +1499,12 @@ static int xenFormatXMSerial(virConfValuePtr list, return -1; } -static int xenFormatXMNet(virConnectPtr conn, - virConfValuePtr list, - virDomainNetDefPtr net, - int hvm, int xendConfigVersion) + +static int +xenFormatXMNet(virConnectPtr conn, + virConfValuePtr list, + virDomainNetDefPtr net, + int hvm, int xendConfigVersion) { virBuffer buf = VIR_BUFFER_INITIALIZER; virConfValuePtr val, tmp; @@ -1602,10 +1606,8 @@ static int xenFormatXMNet(virConnectPtr conn, } - static int -xenFormatXMPCI(virConfPtr conf, - virDomainDefPtr def) +xenFormatXMPCI(virConfPtr conf, virDomainDefPtr def) { virConfValuePtr pciVal = NULL; @@ -1671,32 +1673,41 @@ xenFormatXMPCI(virConfPtr conf, } +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; +} /* 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); -virConfPtr xenFormatXM(virConnectPtr conn, - virDomainDefPtr def, - int xendConfigVersion) +virConfPtr +xenFormatXM(virConnectPtr conn, + virDomainDefPtr def, + int xendConfigVersion) { virConfPtr conf = NULL; int hvm = 0, vmlocaltime = 0; 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) - goto cleanup; - - virUUIDFormat(def->uuid, uuid); - if (xenXMConfigSetString(conf, "uuid", uuid) < 0) + if (xenFormatXMGeneralMeta(conf, def) < 0) goto cleanup; if (xenXMConfigSetInt(conf, "maxmem", -- 1.8.4.5

Kiarie Kahurani wrote:
introduce function xenFormatXMGeneralMeta(virConfPtr conf,......); which parses uuid and name instead
Sorry for the delay, but it took me longer than expected to rebase the series after some initial changes. No fault of yours, just too much indecision on my part.
Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 53 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 21 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 8238026..62d7f8f 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1337,8 +1337,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, }
-static -int xenXMConfigSetInt(virConfPtr conf, const char *setting, long long l) +static int +xenXMConfigSetInt(virConfPtr conf, const char *setting, long long l)
All of these whitespace changes should be done in a separate cleanup patch.
{ virConfValuePtr value = NULL;
@@ -1460,8 +1460,10 @@ xenFormatXMDisk(virConfValuePtr list, return -1; }
-static int xenFormatXMSerial(virConfValuePtr list, - virDomainChrDefPtr serial) + +static int +xenFormatXMSerial(virConfValuePtr list, + virDomainChrDefPtr serial) { virBuffer buf = VIR_BUFFER_INITIALIZER; virConfValuePtr val, tmp; @@ -1497,10 +1499,12 @@ static int xenFormatXMSerial(virConfValuePtr list, return -1; }
-static int xenFormatXMNet(virConnectPtr conn, - virConfValuePtr list, - virDomainNetDefPtr net, - int hvm, int xendConfigVersion) + +static int +xenFormatXMNet(virConnectPtr conn, + virConfValuePtr list, + virDomainNetDefPtr net, + int hvm, int xendConfigVersion) { virBuffer buf = VIR_BUFFER_INITIALIZER; virConfValuePtr val, tmp; @@ -1602,10 +1606,8 @@ static int xenFormatXMNet(virConnectPtr conn, }
- static int -xenFormatXMPCI(virConfPtr conf, - virDomainDefPtr def) +xenFormatXMPCI(virConfPtr conf, virDomainDefPtr def) {
virConfValuePtr pciVal = NULL; @@ -1671,32 +1673,41 @@ xenFormatXMPCI(virConfPtr conf, }
+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; +} /* 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);
-virConfPtr xenFormatXM(virConnectPtr conn, - virDomainDefPtr def, - int xendConfigVersion) +virConfPtr +xenFormatXM(virConnectPtr conn, + virDomainDefPtr def, + int xendConfigVersion) { virConfPtr conf = NULL; int hvm = 0, vmlocaltime = 0; 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) - goto cleanup; - - virUUIDFormat(def->uuid, uuid); - if (xenXMConfigSetString(conf, "uuid", uuid) < 0) + if (xenFormatXMGeneralMeta(conf, def) < 0) goto cleanup;
if (xenXMConfigSetInt(conf, "maxmem",
But this last hunk, which is the meat of the patch, looks good. The parse refactoring has been committed, so I'd like to commit the format refactoring too, before reworking the layout of the xenxs directory. I'll remove the unrelated whitespace changes before pushing. Regards, Jim

introduce function xenFormatXMMem(virConfPtr conf,...........); which parses memory config instead Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 62d7f8f..ad70b5a 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1687,6 +1687,23 @@ 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; +} + + /* 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); @@ -1710,12 +1727,7 @@ xenFormatXM(virConnectPtr conn, if (xenFormatXMGeneralMeta(conf, def) < 0) goto cleanup; - if (xenXMConfigSetInt(conf, "maxmem", - VIR_DIV_UP(def->mem.max_balloon, 1024)) < 0) - goto cleanup; - - if (xenXMConfigSetInt(conf, "memory", - VIR_DIV_UP(def->mem.cur_balloon, 1024)) < 0) + if (xenFormatXMMem(conf, def) < 0) goto cleanup; if (xenXMConfigSetInt(conf, "vcpus", def->maxvcpus) < 0) -- 1.8.4.5

Kiarie Kahurani wrote:
introduce function xenFormatXMMem(virConfPtr conf,...........); which parses memory config instead
Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
Trivial, ACK. Will push shortly. Regards, Jim

introduce function xenFormatXMTimeOffset(virConfPtr conf,........); which formats time config instead Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 153 ++++++++++++++++++++++++++++------------------------- 1 file changed, 82 insertions(+), 71 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index ad70b5a..b17574d 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1704,6 +1704,86 @@ 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; +} /* 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); @@ -1714,7 +1794,7 @@ xenFormatXM(virConnectPtr conn, int xendConfigVersion) { virConfPtr conf = NULL; - int hvm = 0, vmlocaltime = 0; + int hvm = 0; size_t i; char *cpus = NULL; const char *lifecycle; @@ -1853,78 +1933,9 @@ 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

Kiarie Kahurani wrote:
introduce function xenFormatXMTimeOffset(virConfPtr conf,........); which formats time config instead
Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 153 ++++++++++++++++++++++++++++------------------------- 1 file changed, 82 insertions(+), 71 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index ad70b5a..b17574d 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1704,6 +1704,86 @@ xenFormatXMMem(virConfPtr conf, virDomainDefPtr def) }
+static int +xenFormatXMTimeOffset(virConfPtr conf, virDomainDefPtr def, + int xendConfigVersion)
If function name + params exceeds 80 columns, common practice is each param after the first on a separate line. E.g. xenFormatTimeOffset(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion) { ...
+{ + int vmlocaltime; + if (xendConfigVersion < XEND_CONFIG_VERSION_3_1_0) {
Preferred style is a blank line after local variable declaration. ACK otherwise. I'll fixup these nits before pushing. Regards, Jim

On Wed, Aug 13, 2014 at 05:15:58PM -0600, Jim Fehlig wrote:
Kiarie Kahurani wrote:
introduce function xenFormatXMTimeOffset(virConfPtr conf,........); which formats time config instead
Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 153 ++++++++++++++++++++++++++++------------------------- 1 file changed, 82 insertions(+), 71 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index ad70b5a..b17574d 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1704,6 +1704,86 @@ xenFormatXMMem(virConfPtr conf, virDomainDefPtr def) }
+static int +xenFormatXMTimeOffset(virConfPtr conf, virDomainDefPtr def, + int xendConfigVersion)
If function name + params exceeds 80 columns, common practice is each param after the first on a separate line. E.g.
xenFormatTimeOffset(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion) { ...
+{ + int vmlocaltime; + if (xendConfigVersion < XEND_CONFIG_VERSION_3_1_0) {
Preferred style is a blank line after local variable declaration.
ACK otherwise. I'll fixup these nits before pushing.
Regards, Jim
BTW in the tests data I see configs like <clock offset = 'utc' adjustment = 'reset'> while if am not wrong the code in xen_xm.c explicity rejects such config unsupported clock adjustment = 'reset'

introduce function xenFormatXMEventActions(virConfPtr conf,.........); which formats event actions instead Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 63 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index b17574d..677735d 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1784,6 +1784,41 @@ xenFormatXMTimeOffset(virConfPtr conf, virDomainDefPtr def, return 0; } + + +static int +xenFormatXMEventActions(virConfPtr conf, virDomainDefPtr def) +{ + const char *lifecycle = NULL; + + if (!(lifecycle = virDomainLifecycleTypeToString(def->onPoweroff))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected lifecycle action %d"), def->onPoweroff); + return -1; + } + if (xenXMConfigSetString(conf, "on_poweroff", lifecycle) < 0) + return -1; + + + if (!(lifecycle = virDomainLifecycleTypeToString(def->onReboot))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected lifecycle action %d"), def->onReboot); + return -1; + } + if (xenXMConfigSetString(conf, "on_reboot", lifecycle) < 0) + return -1; + + + if (!(lifecycle = virDomainLifecycleCrashTypeToString(def->onCrash))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected lifecycle action %d"), def->onCrash); + return -1; + } + if (xenXMConfigSetString(conf, "on_crash", lifecycle) < 0) + return -1; + + return 0; +} /* 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); @@ -1797,7 +1832,6 @@ xenFormatXM(virConnectPtr conn, int hvm = 0; size_t i; char *cpus = NULL; - const char *lifecycle; virConfValuePtr diskVal = NULL; virConfValuePtr netVal = NULL; @@ -1936,33 +1970,8 @@ 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); + if (xenFormatXMEventActions(conf, def) < 0) goto cleanup; - } - if (xenXMConfigSetString(conf, "on_reboot", lifecycle) < 0) - goto cleanup; - - - if (!(lifecycle = virDomainLifecycleCrashTypeToString(def->onCrash))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected lifecycle action %d"), def->onCrash); - goto cleanup; - } - if (xenXMConfigSetString(conf, "on_crash", lifecycle) < 0) - goto cleanup; - - if (hvm) { if (def->emulator && -- 1.8.4.5

Kiarie Kahurani wrote:
introduce function xenFormatXMEventActions(virConfPtr conf,.........); which formats event actions instead
Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 63 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 27 deletions(-)
Trivial, ACK. Will push shortly. Regards, Jim

introduce function xenFormatXMCharDev(virConfPtr conf,........); which formats Char devices config instead Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 163 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 91 insertions(+), 72 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 677735d..b4a7468 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1819,6 +1819,94 @@ xenFormatXMEventActions(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; +} + + /* 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); @@ -2149,79 +2237,10 @@ xenFormatXM(virConnectPtr conn, 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; + if (hvm) { if (def->sounds) { virBuffer buf = VIR_BUFFER_INITIALIZER; char *str = NULL; -- 1.8.4.5

Kiarie Kahurani wrote:
introduce function xenFormatXMCharDev(virConfPtr conf,........); which formats Char devices config instead
Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 163 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 91 insertions(+), 72 deletions(-)
Mechanical. ACK. Will push shortly. Regards, Jim

introduce function xenFormatXMDomainDisks(virConfPtr conf,.........); which formats domain disks config instead Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 72 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 28 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index b4a7468..2c381f8 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1907,6 +1907,49 @@ xenFormatXMCharDev(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; +} /* 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); @@ -1920,7 +1963,6 @@ xenFormatXM(virConnectPtr conn, int hvm = 0; size_t i; char *cpus = NULL; - virConfValuePtr diskVal = NULL; virConfValuePtr netVal = NULL; if (!(conf = virConfNew())) @@ -2188,33 +2230,8 @@ xenFormatXM(virConnectPtr conn, } } - /* 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 (VIR_ALLOC(netVal) < 0) goto cleanup; @@ -2258,7 +2275,6 @@ xenFormatXM(virConnectPtr conn, return conf; cleanup: - virConfFreeValue(diskVal); virConfFreeValue(netVal); VIR_FREE(cpus); if (conf) -- 1.8.4.5

Kiarie Kahurani wrote:
introduce function xenFormatXMDomainDisks(virConfPtr conf,.........); which formats domain disks config instead
Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 72 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 28 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index b4a7468..2c381f8 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1907,6 +1907,49 @@ xenFormatXMCharDev(virConfPtr conf, virDomainDefPtr def) }
+static int +xenFormatXMDomainDisks(virConfPtr conf, virDomainDefPtr def, + int xendConfigVersion)
Style nit I mentioned in the other patch. Otherwise ACK. Regards, Jim

introduce functions xenFormatXMCPUFeatures(virConfPtr conf, ......); which formats CPU features config instead Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 118 ++++++++++++--------- 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, 146 insertions(+), 128 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 2c381f8..a856698 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1950,6 +1950,73 @@ xenFormatXMDomainDisks(virConfPtr conf, virDomainDefPtr def, virConfFreeValue(diskVal); return -1; } + + +static int +xenFormatXMCPUFeatures(virConfPtr conf, virDomainDefPtr def, + int xendConfigVersion) +{ + char *cpus = NULL; + size_t i; + + if (xenXMConfigSetInt(conf, "vcpus", def->maxvcpus) < 0) + 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) + return -1; + + if ((def->cpumask != NULL) && + ((cpus = virBitmapFormat(def->cpumask)) == NULL)) { + return -1; + } + + if (cpus && + xenXMConfigSetString(conf, "cpus", cpus) < 0) + return -1; + + VIR_FREE(cpus); + if (STREQ(def->os.type, "hvm")) { + if (xenXMConfigSetInt(conf, "pae", + (def->features[VIR_DOMAIN_FEATURE_PAE] == + VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) + return -1; + + if (xenXMConfigSetInt(conf, "acpi", + (def->features[VIR_DOMAIN_FEATURE_ACPI] == + VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) + return -1; + + if (xenXMConfigSetInt(conf, "apic", + (def->features[VIR_DOMAIN_FEATURE_APIC] == + VIR_TRISTATE_SWITCH_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_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) + return -1; + + if (xenXMConfigSetInt(conf, "viridian", + (def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] == + VIR_TRISTATE_SWITCH_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; +} + + /* 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); @@ -1974,24 +2041,9 @@ xenFormatXM(virConnectPtr conn, if (xenFormatXMMem(conf, def) < 0) goto cleanup; - if (xenXMConfigSetInt(conf, "vcpus", def->maxvcpus) < 0) - goto cleanup; - /* 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) + if (xenFormatXMCPUFeatures(conf, def, xendConfigVersion) < 0) goto cleanup; - if ((def->cpumask != NULL) && - ((cpus = virBitmapFormat(def->cpumask)) == NULL)) { - goto cleanup; - } - - if (cpus && - xenXMConfigSetString(conf, "cpus", cpus) < 0) - goto cleanup; - VIR_FREE(cpus); - hvm = STREQ(def->os.type, "hvm") ? 1 : 0; if (hvm) { @@ -2030,40 +2082,6 @@ xenFormatXM(virConnectPtr conn, if (xenXMConfigSetString(conf, "boot", boot) < 0) goto cleanup; - if (xenXMConfigSetInt(conf, "pae", - (def->features[VIR_DOMAIN_FEATURE_PAE] == - VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) - goto cleanup; - - if (xenXMConfigSetInt(conf, "acpi", - (def->features[VIR_DOMAIN_FEATURE_ACPI] == - VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) - goto cleanup; - - if (xenXMConfigSetInt(conf, "apic", - (def->features[VIR_DOMAIN_FEATURE_APIC] == - VIR_TRISTATE_SWITCH_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_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) - goto cleanup; - - if (xenXMConfigSetInt(conf, "viridian", - (def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] == - VIR_TRISTATE_SWITCH_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

Kiarie Kahurani wrote:
introduce functions xenFormatXMCPUFeatures(virConfPtr conf, ......); which formats CPU features config instead
Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 118 ++++++++++++--------- 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, 146 insertions(+), 128 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 2c381f8..a856698 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1950,6 +1950,73 @@ xenFormatXMDomainDisks(virConfPtr conf, virDomainDefPtr def, virConfFreeValue(diskVal); return -1; } + + +static int +xenFormatXMCPUFeatures(virConfPtr conf, virDomainDefPtr def, + int xendConfigVersion) +{ + char *cpus = NULL; + size_t i; + + if (xenXMConfigSetInt(conf, "vcpus", def->maxvcpus) < 0) + 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) + return -1; + + if ((def->cpumask != NULL) && + ((cpus = virBitmapFormat(def->cpumask)) == NULL)) { + return -1; + } + + if (cpus && + xenXMConfigSetString(conf, "cpus", cpus) < 0) + return -1; + + VIR_FREE(cpus);
I'd consider these to be allocation-related, as opposed to features. I've changed the patch a bit to introduce xenFormatXMCPUAllocation and xenFormatXMCPUFeatures.
+ if (STREQ(def->os.type, "hvm")) { + if (xenXMConfigSetInt(conf, "pae", + (def->features[VIR_DOMAIN_FEATURE_PAE] == + VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) + return -1; + + if (xenXMConfigSetInt(conf, "acpi", + (def->features[VIR_DOMAIN_FEATURE_ACPI] == + VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) + return -1; + + if (xenXMConfigSetInt(conf, "apic", + (def->features[VIR_DOMAIN_FEATURE_APIC] == + VIR_TRISTATE_SWITCH_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_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) + return -1; + + if (xenXMConfigSetInt(conf, "viridian", + (def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] == + VIR_TRISTATE_SWITCH_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; +} + + /* 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); @@ -1974,24 +2041,9 @@ xenFormatXM(virConnectPtr conn, if (xenFormatXMMem(conf, def) < 0) goto cleanup;
- if (xenXMConfigSetInt(conf, "vcpus", def->maxvcpus) < 0) - goto cleanup; - /* 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) + if (xenFormatXMCPUFeatures(conf, def, xendConfigVersion) < 0)
With my changes, allocations can be formatted here
goto cleanup;
- if ((def->cpumask != NULL) && - ((cpus = virBitmapFormat(def->cpumask)) == NULL)) { - goto cleanup; - } - - if (cpus && - xenXMConfigSetString(conf, "cpus", cpus) < 0) - goto cleanup; - VIR_FREE(cpus); - hvm = STREQ(def->os.type, "hvm") ? 1 : 0;
if (hvm) { @@ -2030,40 +2082,6 @@ xenFormatXM(virConnectPtr conn, if (xenXMConfigSetString(conf, "boot", boot) < 0) goto cleanup;
- if (xenXMConfigSetInt(conf, "pae", - (def->features[VIR_DOMAIN_FEATURE_PAE] == - VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) - goto cleanup; - - if (xenXMConfigSetInt(conf, "acpi", - (def->features[VIR_DOMAIN_FEATURE_ACPI] == - VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) - goto cleanup; - - if (xenXMConfigSetInt(conf, "apic", - (def->features[VIR_DOMAIN_FEATURE_APIC] == - VIR_TRISTATE_SWITCH_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_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) - goto cleanup; - - if (xenXMConfigSetInt(conf, "viridian", - (def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] == - VIR_TRISTATE_SWITCH_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; - } -
and features formatted here.
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
With this approach, all the test data file changes are avoided. Simplified patch below. Regards, Jim

On Wed, Aug 13, 2014 at 05:35:52PM -0600, Jim Fehlig wrote:
Kiarie Kahurani wrote:
introduce functions xenFormatXMCPUFeatures(virConfPtr conf, ......); which formats CPU features config instead
Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 118 ++++++++++++--------- 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, 146 insertions(+), 128 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 2c381f8..a856698 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1950,6 +1950,73 @@ xenFormatXMDomainDisks(virConfPtr conf, virDomainDefPtr def, virConfFreeValue(diskVal); return -1; } + + +static int +xenFormatXMCPUFeatures(virConfPtr conf, virDomainDefPtr def, + int xendConfigVersion) +{ + char *cpus = NULL; + size_t i; + + if (xenXMConfigSetInt(conf, "vcpus", def->maxvcpus) < 0) + 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) + return -1; + + if ((def->cpumask != NULL) && + ((cpus = virBitmapFormat(def->cpumask)) == NULL)) { + return -1; + } + + if (cpus && + xenXMConfigSetString(conf, "cpus", cpus) < 0) + return -1; + + VIR_FREE(cpus);
I'd consider these to be allocation-related, as opposed to features. I've changed the patch a bit to introduce xenFormatXMCPUAllocation and xenFormatXMCPUFeatures.
+ if (STREQ(def->os.type, "hvm")) { + if (xenXMConfigSetInt(conf, "pae", + (def->features[VIR_DOMAIN_FEATURE_PAE] == + VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) + return -1; + + if (xenXMConfigSetInt(conf, "acpi", + (def->features[VIR_DOMAIN_FEATURE_ACPI] == + VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) + return -1; + + if (xenXMConfigSetInt(conf, "apic", + (def->features[VIR_DOMAIN_FEATURE_APIC] == + VIR_TRISTATE_SWITCH_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_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) + return -1; + + if (xenXMConfigSetInt(conf, "viridian", + (def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] == + VIR_TRISTATE_SWITCH_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; +} + + /* 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); @@ -1974,24 +2041,9 @@ xenFormatXM(virConnectPtr conn, if (xenFormatXMMem(conf, def) < 0) goto cleanup;
- if (xenXMConfigSetInt(conf, "vcpus", def->maxvcpus) < 0) - goto cleanup; - /* 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) + if (xenFormatXMCPUFeatures(conf, def, xendConfigVersion) < 0)
With my changes, allocations can be formatted here
goto cleanup;
- if ((def->cpumask != NULL) && - ((cpus = virBitmapFormat(def->cpumask)) == NULL)) { - goto cleanup; - } - - if (cpus && - xenXMConfigSetString(conf, "cpus", cpus) < 0) - goto cleanup; - VIR_FREE(cpus); - hvm = STREQ(def->os.type, "hvm") ? 1 : 0;
if (hvm) { @@ -2030,40 +2082,6 @@ xenFormatXM(virConnectPtr conn, if (xenXMConfigSetString(conf, "boot", boot) < 0) goto cleanup;
- if (xenXMConfigSetInt(conf, "pae", - (def->features[VIR_DOMAIN_FEATURE_PAE] == - VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) - goto cleanup; - - if (xenXMConfigSetInt(conf, "acpi", - (def->features[VIR_DOMAIN_FEATURE_ACPI] == - VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) - goto cleanup; - - if (xenXMConfigSetInt(conf, "apic", - (def->features[VIR_DOMAIN_FEATURE_APIC] == - VIR_TRISTATE_SWITCH_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_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) - goto cleanup; - - if (xenXMConfigSetInt(conf, "viridian", - (def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] == - VIR_TRISTATE_SWITCH_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; - } -
and features formatted here.
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
With this approach, all the test data file changes are avoided. Simplified patch below.
Regards, Jim
From 88e7f74c646b555cea64501254e53a19ff6ba780 Mon Sep 17 00:00:00 2001 From: Kiarie Kahurani <davidkiarie4@gmail.com> Date: Tue, 12 Aug 2014 00:21:31 +0300 Subject: [PATCH 07/11] src/xenxs: Refactor code formating CPU config
introduce functions xenFormatXMCPUAllocation(virConfPtr conf, ......); xenFormatXMCPUFeatures(virConfPtr conf, ......); which formats CPU allocation and features config
Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> Signed-off-by: Jim Fehlig <jfehlig@suse.com> --- src/xenxs/xen_xm.c | 131 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 81 insertions(+), 50 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 36a5ea1..432fee2 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1942,6 +1942,85 @@ xenFormatXMDisks(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion) }
+static int +xenFormatXMCPUAllocation(virConfPtr conf, virDomainDefPtr def) +{ + int ret = -1; + char *cpus = NULL; + + if (xenXMConfigSetInt(conf, "vcpus", def->maxvcpus) < 0) + goto cleanup; + + /* 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; + + if ((def->cpumask != NULL) && + ((cpus = virBitmapFormat(def->cpumask)) == NULL)) { + goto cleanup; + } + + if (cpus && + xenXMConfigSetString(conf, "cpus", cpus) < 0) + goto cleanup; + + ret = 0; + + cleanup: + VIR_FREE(cpus); + return ret; +} + + +static int +xenFormatXMCPUFeatures(virConfPtr conf, + virDomainDefPtr def, + int xendConfigVersion) +{ + size_t i; + + if (STREQ(def->os.type, "hvm")) { + if (xenXMConfigSetInt(conf, "pae", + (def->features[VIR_DOMAIN_FEATURE_PAE] == + VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) + return -1; + + if (xenXMConfigSetInt(conf, "acpi", + (def->features[VIR_DOMAIN_FEATURE_ACPI] == + VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) + return -1; + + if (xenXMConfigSetInt(conf, "apic", + (def->features[VIR_DOMAIN_FEATURE_APIC] == + VIR_TRISTATE_SWITCH_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_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) + return -1; + + if (xenXMConfigSetInt(conf, "viridian", + (def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] == + VIR_TRISTATE_SWITCH_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; +} + + /* 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); @@ -1954,7 +2033,6 @@ xenFormatXM(virConnectPtr conn, virConfPtr conf = NULL; int hvm = 0; size_t i; - char *cpus = NULL; virConfValuePtr netVal = NULL;
if (!(conf = virConfNew())) @@ -1966,23 +2044,8 @@ xenFormatXM(virConnectPtr conn, if (xenFormatXMMem(conf, def) < 0) goto cleanup;
- if (xenXMConfigSetInt(conf, "vcpus", def->maxvcpus) < 0) + if (xenFormatXMCPUAllocation(conf, def) < 0) goto cleanup; - /* 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; - - if ((def->cpumask != NULL) && - ((cpus = virBitmapFormat(def->cpumask)) == NULL)) { - goto cleanup; - } - - if (cpus && - xenXMConfigSetString(conf, "cpus", cpus) < 0) - goto cleanup; - VIR_FREE(cpus);
hvm = STREQ(def->os.type, "hvm") ? 1 : 0;
@@ -2022,40 +2085,9 @@ xenFormatXM(virConnectPtr conn, if (xenXMConfigSetString(conf, "boot", boot) < 0) goto cleanup;
- if (xenXMConfigSetInt(conf, "pae", - (def->features[VIR_DOMAIN_FEATURE_PAE] == - VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) + if (xenFormatXMCPUFeatures(conf, def, xendConfigVersion) < 0) goto cleanup;
- if (xenXMConfigSetInt(conf, "acpi", - (def->features[VIR_DOMAIN_FEATURE_ACPI] == - VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) - goto cleanup; - - if (xenXMConfigSetInt(conf, "apic", - (def->features[VIR_DOMAIN_FEATURE_APIC] == - VIR_TRISTATE_SWITCH_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_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) - goto cleanup; - - if (xenXMConfigSetInt(conf, "viridian", - (def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] == - VIR_TRISTATE_SWITCH_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 && @@ -2268,7 +2300,6 @@ xenFormatXM(virConnectPtr conn,
cleanup: virConfFreeValue(netVal); - VIR_FREE(cpus); if (conf) virConfFree(conf); return NULL; -- 1.8.4.5
Good one, it also paves way for the inclusion of the many cpu allocation and features config options that xl has to offer

introduce function xenFormatXMOS(virConfPtr conf,........); which formats OS config instead Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 95 ++++++++++++---------- 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, 80 insertions(+), 67 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index a856698..9edfbbb 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -2017,43 +2017,20 @@ xenFormatXMCPUFeatures(virConfPtr conf, virDomainDefPtr def, } -/* 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); - -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 netVal = 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]) { @@ -2080,7 +2057,7 @@ xenFormatXM(virConnectPtr conn, } 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++) { @@ -2090,31 +2067,72 @@ xenFormatXM(virConnectPtr conn, 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; +} +/* 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); + +virConfPtr +xenFormatXM(virConnectPtr conn, + virDomainDefPtr def, + int xendConfigVersion) +{ + virConfPtr conf = NULL; + int hvm = 0; + size_t i; + virConfValuePtr netVal = 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"); + + if (xenFormatXMOS(conf, def, xendConfigVersion) < 0) + goto cleanup; + if (xenFormatXMTimeOffset(conf, def, xendConfigVersion) < 0) goto cleanup; @@ -2122,10 +2140,6 @@ xenFormatXM(virConnectPtr conn, goto cleanup; if (hvm) { - 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) @@ -2294,7 +2308,6 @@ xenFormatXM(virConnectPtr conn, cleanup: virConfFreeValue(netVal); - 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 4a18cc1..68984da 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" sdl = 0 vnc = 1 vncunused = 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 d315f93..a12a30c 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" sdl = 0 vnc = 1 vncunused = 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

Kiarie Kahurani wrote:
introduce function xenFormatXMOS(virConfPtr conf,........);
I split this into three functions: - xenFormatXMEmulator - xenFormatXMCDROM - xenFormatXMOS Formating of emulator and cdrom can be different between xm and xl, and we may want to account for that in the near future.
which formats OS config instead
Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 95 ++++++++++++---------- 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 +-
Avoids changing all the test data files too. Simplified patch below. BTW, I got interrupted during my earlier review, so "will push shortly" had changed to "will push tomorrow" :-). Regards, Jim

On Thu, Aug 14, 2014 at 12:15:32AM -0600, Jim Fehlig wrote:
Kiarie Kahurani wrote:
introduce function xenFormatXMOS(virConfPtr conf,........);
I split this into three functions:
- xenFormatXMEmulator - xenFormatXMCDROM - xenFormatXMOS
Formating of emulator and cdrom can be different between xm and xl, and we may want to account for that in the near future.
which formats OS config instead
Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 95 ++++++++++++---------- 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 +-
Avoids changing all the test data files too. Simplified patch below.
BTW, I got interrupted during my earlier review, so "will push shortly" had changed to "will push tomorrow" :-).
Regards, Jim
From 76824b192ecac2d9f19406c11446b616ca96e9d4 Mon Sep 17 00:00:00 2001 From: Kiarie Kahurani <davidkiarie4@gmail.com> Date: Tue, 12 Aug 2014 00:21:32 +0300 Subject: [PATCH 08/11] src/xenxs: Refactor code formating OS config
introduce functions xenFormatXMEmulator(virConfPtr conf,........); xenFormatXMCDROM(virConfPtr conf, .......); xenFormatXMOS(virConfPtr conf,........); which formats OS and associated config instead
Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> Signed-off-by: Jim Fehlig <jfehlig@suse.com> --- src/xenxs/xen_xm.c | 161 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 101 insertions(+), 60 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 432fee2..72ae913 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -2021,42 +2021,57 @@ xenFormatXMCPUFeatures(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 +xenFormatXMEmulator(virConfPtr conf, virDomainDefPtr def) +{ + if (def->emulator && + xenXMConfigSetString(conf, "device_model", def->emulator) < 0) + return -1;
-virConfPtr -xenFormatXM(virConnectPtr conn, - virDomainDefPtr def, - int xendConfigVersion) + return 0; +} + + +static int +xenFormatXMCDROM(virConfPtr conf, + virDomainDefPtr def, + int xendConfigVersion) { - virConfPtr conf = NULL; - int hvm = 0; size_t i; - virConfValuePtr netVal = NULL; - - if (!(conf = virConfNew())) - goto cleanup;
- if (xenFormatXMGeneralMeta(conf, def) < 0) - goto cleanup; + if (STREQ(def->os.type, "hvm")) { + 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 && + def->disks[i]->dst && + STREQ(def->disks[i]->dst, "hdc") && + virDomainDiskGetSource(def->disks[i])) { + if (xenXMConfigSetString(conf, "cdrom", + virDomainDiskGetSource(def->disks[i])) < 0) + return -1; + break; + } + } + } + }
- if (xenFormatXMMem(conf, def) < 0) - goto cleanup; + return 0; +}
- if (xenFormatXMCPUAllocation(conf, def) < 0) - goto cleanup;
- hvm = STREQ(def->os.type, "hvm") ? 1 : 0; +static int +xenFormatXMOS(virConfPtr conf, virDomainDefPtr def) +{ + size_t i;
- 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]) { @@ -2075,6 +2090,7 @@ xenFormatXM(virConnectPtr conn, break; } } + if (!def->os.nBootDevs) { boot[0] = 'c'; boot[1] = '\0'; @@ -2083,43 +2099,69 @@ xenFormatXM(virConnectPtr conn, }
if (xenXMConfigSetString(conf, "boot", boot) < 0) - goto cleanup; - - if (xenFormatXMCPUFeatures(conf, def, xendConfigVersion) < 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 && - def->disks[i]->dst && - STREQ(def->disks[i]->dst, "hdc") && - virDomainDiskGetSource(def->disks[i])) { - if (xenXMConfigSetString(conf, "cdrom", - virDomainDiskGetSource(def->disks[i])) < 0) - goto cleanup; - break; - } - } - } + return -1;
/* XXX floppy disks */ } else { if (def->os.bootloader && - xenXMConfigSetString(conf, "bootloader", def->os.bootloader) < 0) - goto cleanup; - if (def->os.bootloaderArgs && - xenXMConfigSetString(conf, "bootargs", def->os.bootloaderArgs) < 0) - goto cleanup; - if (def->os.kernel && - xenXMConfigSetString(conf, "kernel", def->os.kernel) < 0) - goto cleanup; - if (def->os.initrd && - xenXMConfigSetString(conf, "ramdisk", def->os.initrd) < 0) - goto cleanup; - if (def->os.cmdline && - xenXMConfigSetString(conf, "extra", def->os.cmdline) < 0) - goto cleanup; - } /* !hvm */ + xenXMConfigSetString(conf, "bootloader", def->os.bootloader) < 0) + return -1; + + if (def->os.bootloaderArgs && + xenXMConfigSetString(conf, "bootargs", def->os.bootloaderArgs) < 0) + return -1; + + if (def->os.kernel && + xenXMConfigSetString(conf, "kernel", def->os.kernel) < 0) + return -1; + + if (def->os.initrd && + xenXMConfigSetString(conf, "ramdisk", def->os.initrd) < 0) + return -1; + + if (def->os.cmdline && + xenXMConfigSetString(conf, "extra", def->os.cmdline) < 0) + return -1; + } /* !hvm */ + + return 0; +} + + +/* 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); + +virConfPtr +xenFormatXM(virConnectPtr conn, + virDomainDefPtr def, + int xendConfigVersion) +{ + virConfPtr conf = NULL; + int hvm = STREQ(def->os.type, "hvm") ? 1 : 0; + size_t i; + virConfValuePtr netVal = NULL; + + if (!(conf = virConfNew())) + goto cleanup; + + if (xenFormatXMGeneralMeta(conf, def) < 0) + goto cleanup; + + if (xenFormatXMMem(conf, def) < 0) + goto cleanup; + + if (xenFormatXMCPUAllocation(conf, def) < 0) + goto cleanup; + + if (xenFormatXMOS(conf, def) < 0) + goto cleanup; + + if (xenFormatXMCPUFeatures(conf, def, xendConfigVersion) < 0) + goto cleanup; + + if (xenFormatXMCDROM(conf, def, xendConfigVersion) < 0) + goto cleanup;
if (xenFormatXMTimeOffset(conf, def, xendConfigVersion) < 0) goto cleanup; @@ -2127,11 +2169,10 @@ xenFormatXM(virConnectPtr conn, if (xenFormatXMEventActions(conf, def) < 0) goto cleanup;
- if (hvm) { - if (def->emulator && - xenXMConfigSetString(conf, "device_model", def->emulator) < 0) - goto cleanup; + if (xenFormatXMEmulator(conf, def) < 0) + goto cleanup;
+ if (hvm) { for (i = 0; i < def->ninputs; i++) { if (def->inputs[i]->bus == VIR_DOMAIN_INPUT_BUS_USB) { if (xenXMConfigSetInt(conf, "usb", 1) < 0) -- 1.8.4.5
Looks better too.

introduce function xenFormatXMVfb(virConfPtr conf,.........); which formats Vfb config instead Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 171 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 97 insertions(+), 74 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 9edfbbb..4795644 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -2102,108 +2102,65 @@ xenFormatXMOS(virConfPtr conf, virDomainDefPtr def, return 0; } -/* 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); - -virConfPtr -xenFormatXM(virConnectPtr conn, - virDomainDefPtr def, - int xendConfigVersion) -{ - virConfPtr conf = NULL; - int hvm = 0; - size_t i; - virConfValuePtr netVal = 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"); - 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) { - 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; - } - } - } +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) - goto cleanup; + return -1; + if (xenXMConfigSetInt(conf, "vnc", 0) < 0) - goto cleanup; + return -1; + if (def->graphics[0]->data.sdl.display && xenXMConfigSetString(conf, "display", def->graphics[0]->data.sdl.display) < 0) - goto cleanup; + return -1; + if (def->graphics[0]->data.sdl.xauth && xenXMConfigSetString(conf, "xauthority", def->graphics[0]->data.sdl.xauth) < 0) - goto cleanup; + return -1; + } else { const char *listenAddr; if (xenXMConfigSetInt(conf, "sdl", 0) < 0) - goto cleanup; + return -1; + if (xenXMConfigSetInt(conf, "vnc", 1) < 0) - goto cleanup; + return -1; + if (xenXMConfigSetInt(conf, "vncunused", def->graphics[0]->data.vnc.autoport ? 1 : 0) < 0) - goto cleanup; + return -1; + if (!def->graphics[0]->data.vnc.autoport && xenXMConfigSetInt(conf, "vncdisplay", def->graphics[0]->data.vnc.port - 5900) < 0) - goto cleanup; + return -1; + listenAddr = virDomainGraphicsListenGetAddress(def->graphics[0], 0); if (listenAddr && xenXMConfigSetString(conf, "vnclisten", listenAddr) < 0) - goto cleanup; + return -1; + if (def->graphics[0]->data.vnc.auth.passwd && xenXMConfigSetString(conf, "vncpasswd", def->graphics[0]->data.vnc.auth.passwd) < 0) - goto cleanup; + return -1; + if (def->graphics[0]->data.vnc.keymap && xenXMConfigSetString(conf, "keymap", def->graphics[0]->data.vnc.keymap) < 0) - goto cleanup; + return -1; } } else { virConfValuePtr vfb, disp; @@ -2236,20 +2193,20 @@ xenFormatXM(virConnectPtr conn, virBufferAsprintf(&buf, ",keymap=%s", def->graphics[0]->data.vnc.keymap); } + if (virBufferCheckError(&buf) < 0) - goto cleanup; + return -1; vfbstr = virBufferContentAndReset(&buf); - if (VIR_ALLOC(vfb) < 0) { VIR_FREE(vfbstr); - goto cleanup; + return -1; } if (VIR_ALLOC(disp) < 0) { VIR_FREE(vfb); VIR_FREE(vfbstr); - goto cleanup; + return -1; } vfb->type = VIR_CONF_LIST; @@ -2258,10 +2215,76 @@ xenFormatXM(virConnectPtr conn, disp->str = vfbstr; if (virConfSetValue(conf, "vfb", vfb) < 0) - goto cleanup; + return -1; + } + } + + return 0; +} +/* 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); + +virConfPtr +xenFormatXM(virConnectPtr conn, + virDomainDefPtr def, + int xendConfigVersion) +{ + virConfPtr conf = NULL; + int hvm = 0; + size_t i; + virConfValuePtr netVal = 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"); + + 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) { + 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 (xenFormatXMVfb(conf, def, xendConfigVersion) < 0) + goto cleanup; + if (xenFormatXMDomainDisks(conf, def, xendConfigVersion) < 0) goto cleanup; -- 1.8.4.5

Kiarie Kahurani wrote:
introduce function xenFormatXMVfb(virConfPtr conf,.........); which formats Vfb config instead
Continuing my review from yesterday...
Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 171 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 97 insertions(+), 74 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 9edfbbb..4795644 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -2102,108 +2102,65 @@ xenFormatXMOS(virConfPtr conf, virDomainDefPtr def,
return 0; } -/* 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); - -virConfPtr -xenFormatXM(virConnectPtr conn, - virDomainDefPtr def, - int xendConfigVersion) -{ - virConfPtr conf = NULL; - int hvm = 0; - size_t i; - virConfValuePtr netVal = 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");
- 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) { - 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; - } - } - } +static int +xenFormatXMVfb(virConfPtr conf, virDomainDefPtr def, + int xendConfigVersion)
Previously mentioned style nit. Will fix before pushing. Otherwise ACK. Regards, Jim

introduce function xenFormatXMEmulatedHardware(virConfPtr conf,....); which formats emulated hardware config instead Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 150 +++++++++++++++++------------ tests/xmconfigdata/test-escape-paths.cfg | 2 +- tests/xmconfigdata/test-fullvirt-sound.cfg | 2 +- 3 files changed, 92 insertions(+), 62 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 4795644..9718c92 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -2221,6 +2221,93 @@ xenFormatXMVfb(virConfPtr conf, virDomainDefPtr def, return 0; } + + +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; +} + + +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; +} + + /* 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); @@ -2231,9 +2318,6 @@ xenFormatXM(virConnectPtr conn, int xendConfigVersion) { virConfPtr conf = NULL; - int hvm = 0; - size_t i; - virConfValuePtr netVal = NULL; if (!(conf = virConfNew())) goto cleanup; @@ -2247,8 +2331,6 @@ xenFormatXM(virConnectPtr conn, if (xenFormatXMCPUFeatures(conf, def, xendConfigVersion) < 0) goto cleanup; - hvm = STREQ(def->os.type, "hvm"); - if (xenFormatXMOS(conf, def, xendConfigVersion) < 0) goto cleanup; @@ -2258,29 +2340,8 @@ xenFormatXM(virConnectPtr conn, if (xenFormatXMEventActions(conf, def) < 0) goto cleanup; - if (hvm) { - 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; @@ -2288,23 +2349,8 @@ xenFormatXM(virConnectPtr conn, if (xenFormatXMDomainDisks(conf, def, xendConfigVersion) < 0) goto cleanup; - 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; @@ -2312,25 +2358,9 @@ xenFormatXM(virConnectPtr conn, if (xenFormatXMCharDev(conf, def) < 0) goto cleanup; - if (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) - goto cleanup; - } - } - return conf; cleanup: - virConfFreeValue(netVal); if (conf) virConfFree(conf); return NULL; diff --git a/tests/xmconfigdata/test-escape-paths.cfg b/tests/xmconfigdata/test-escape-paths.cfg index 68984da..1336ece 100644 --- a/tests/xmconfigdata/test-escape-paths.cfg +++ b/tests/xmconfigdata/test-escape-paths.cfg @@ -14,6 +14,7 @@ localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" +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 a12a30c..67dd8e0 100644 --- a/tests/xmconfigdata/test-fullvirt-sound.cfg +++ b/tests/xmconfigdata/test-fullvirt-sound.cfg @@ -14,6 +14,7 @@ localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" +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

Kiarie Kahurani wrote:
introduce function xenFormatXMEmulatedHardware(virConfPtr conf,....);
You've also added xenFormatXMVif in this patch. It should be in a separate patch IMO. Once removed, a better description of this patch is "src/xenxs: Refactor code formating peripheral device config" since it parses input devices, sound, etc.
which formats emulated hardware config instead
Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 150 +++++++++++++++++------------ tests/xmconfigdata/test-escape-paths.cfg | 2 +- tests/xmconfigdata/test-fullvirt-sound.cfg | 2 +- 3 files changed, 92 insertions(+), 62 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 4795644..9718c92 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -2221,6 +2221,93 @@ xenFormatXMVfb(virConfPtr conf, virDomainDefPtr def,
return 0; } + + +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; +} + + +static int +xenFormatXMEmulatedHardware(virConfPtr conf, virDomainDefPtr def)
I've split this into xenFormatXMInputDevs and xenFormatXMSound.
+{ + 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; +} + + /* 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); @@ -2231,9 +2318,6 @@ xenFormatXM(virConnectPtr conn, int xendConfigVersion) { virConfPtr conf = NULL; - int hvm = 0; - size_t i; - virConfValuePtr netVal = NULL;
if (!(conf = virConfNew())) goto cleanup; @@ -2247,8 +2331,6 @@ xenFormatXM(virConnectPtr conn, if (xenFormatXMCPUFeatures(conf, def, xendConfigVersion) < 0) goto cleanup;
- hvm = STREQ(def->os.type, "hvm"); - if (xenFormatXMOS(conf, def, xendConfigVersion) < 0) goto cleanup;
@@ -2258,29 +2340,8 @@ xenFormatXM(virConnectPtr conn, if (xenFormatXMEventActions(conf, def) < 0) goto cleanup;
- if (hvm) { - 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; @@ -2288,23 +2349,8 @@ xenFormatXM(virConnectPtr conn, if (xenFormatXMDomainDisks(conf, def, xendConfigVersion) < 0) goto cleanup;
- 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; @@ -2312,25 +2358,9 @@ xenFormatXM(virConnectPtr conn, if (xenFormatXMCharDev(conf, def) < 0) goto cleanup;
- if (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) - goto cleanup; - } - } - return conf;
cleanup: - virConfFreeValue(netVal); if (conf) virConfFree(conf); return NULL; diff --git a/tests/xmconfigdata/test-escape-paths.cfg b/tests/xmconfigdata/test-escape-paths.cfg
index 68984da..1336ece 100644 --- a/tests/xmconfigdata/test-escape-paths.cfg +++ b/tests/xmconfigdata/test-escape-paths.cfg
Separate functions for sound and input devices also avoids changes to the test data files. Simplified patch below. I've also included the trivial "11.2/12" patch for refactoring the vif formatting. Regards, Jim

export code for reuse Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> --- src/xenxs/xen_xm.c | 59 +++++++++++++--------- src/xenxs/xen_xm.h | 2 + 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-paravirt-net-e1000.cfg | 2 +- tests/xmconfigdata/test-paravirt-net-vifname.cfg | 2 +- .../test-paravirt-new-pvfb-vncdisplay.cfg | 2 +- tests/xmconfigdata/test-paravirt-new-pvfb.cfg | 2 +- .../test-paravirt-old-pvfb-vncdisplay.cfg | 2 +- tests/xmconfigdata/test-paravirt-old-pvfb.cfg | 2 +- tests/xmconfigdata/test-paravirt-vcpu.cfg | 2 +- tests/xmconfigdata/test-pci-devs.cfg | 2 +- 35 files changed, 69 insertions(+), 58 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 9718c92..7eb7ffb 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -2308,54 +2308,63 @@ xenFormatXMEmulatedHardware(virConfPtr conf, virDomainDefPtr def) } -/* 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); - -virConfPtr -xenFormatXM(virConnectPtr conn, - virDomainDefPtr def, - int xendConfigVersion) +int xenFormatConfigCommon(virConfPtr conf, virDomainDefPtr def, + virConnectPtr conn, 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) - goto cleanup; - - if (xenFormatXMDomainDisks(conf, def, xendConfigVersion) < 0) - goto cleanup; + return -1; if (xenFormatXMVif(conf, conn, def, xendConfigVersion) < 0) - goto cleanup; + return -1; if (xenFormatXMPCI(conf, def) < 0) - goto cleanup; + return -1; if (xenFormatXMCharDev(conf, def) < 0) + return -1; + + return 0; +} +/* 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); + +virConfPtr +xenFormatXM(virConnectPtr conn, + virDomainDefPtr def, + int xendConfigVersion) +{ + virConfPtr conf = NULL; + + if (!(conf = virConfNew())) + goto cleanup; + + if (xenFormatConfigCommon(conf, def, conn, xendConfigVersion) < 0) + goto cleanup; + + if (xenFormatXMDomainDisks(conf, def, xendConfigVersion) < 0) goto cleanup; return conf; diff --git a/src/xenxs/xen_xm.h b/src/xenxs/xen_xm.h index 261ba1f..c48fa41 100644 --- a/src/xenxs/xen_xm.h +++ b/src/xenxs/xen_xm.h @@ -37,5 +37,7 @@ virDomainDefPtr xenParseXM(virConfPtr conf, int xendConfigVersion, virCapsPtr caps); int xenParseConfigCommon(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps, int xendConfigVersion); +int xenFormatConfigCommon(virConfPtr conf, virDomainDefPtr def, + virConnectPtr conn, 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..2055858 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" ] diff --git a/tests/xmconfigdata/test-fullvirt-force-hpet.cfg b/tests/xmconfigdata/test-fullvirt-force-hpet.cfg index f2377dc..89d8024 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" ] diff --git a/tests/xmconfigdata/test-fullvirt-force-nohpet.cfg b/tests/xmconfigdata/test-fullvirt-force-nohpet.cfg index 093c8de..7219001 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" ] diff --git a/tests/xmconfigdata/test-fullvirt-localtime.cfg b/tests/xmconfigdata/test-fullvirt-localtime.cfg index 34ea100..3a75a0f 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" ] diff --git a/tests/xmconfigdata/test-fullvirt-net-ioemu.cfg b/tests/xmconfigdata/test-fullvirt-net-ioemu.cfg index a4f3aec..10fcd80 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" ] diff --git a/tests/xmconfigdata/test-fullvirt-net-netfront.cfg b/tests/xmconfigdata/test-fullvirt-net-netfront.cfg index 57cff7b..8f63d2e 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" ] diff --git a/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg b/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg index a4f3aec..10fcd80 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" ] diff --git a/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg b/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg index 9b74db4..f5db0f0 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" ] diff --git a/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg b/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg index 6a0e1ac..de01a4a 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" ] diff --git a/tests/xmconfigdata/test-fullvirt-serial-dev-2-ports.cfg b/tests/xmconfigdata/test-fullvirt-serial-dev-2-ports.cfg index 2021ac3..d8028f3 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" ] diff --git a/tests/xmconfigdata/test-fullvirt-serial-dev-2nd-port.cfg b/tests/xmconfigdata/test-fullvirt-serial-dev-2nd-port.cfg index 0200194..226aecb 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" ] diff --git a/tests/xmconfigdata/test-fullvirt-serial-file.cfg b/tests/xmconfigdata/test-fullvirt-serial-file.cfg index 4602516..fb1c9ab 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" ] diff --git a/tests/xmconfigdata/test-fullvirt-serial-null.cfg b/tests/xmconfigdata/test-fullvirt-serial-null.cfg index c8365e8..d91b07f 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" ] diff --git a/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg b/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg index f30a072..ce27cf2 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" ] diff --git a/tests/xmconfigdata/test-fullvirt-serial-pty.cfg b/tests/xmconfigdata/test-fullvirt-serial-pty.cfg index bb490b0..5c8c962 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" ] diff --git a/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg b/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg index 6583076..e89b875 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" ] diff --git a/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg b/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg index 730b2e8..a556b8a 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" ] diff --git a/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg b/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg index 3a15c11..1690c3b 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" ] diff --git a/tests/xmconfigdata/test-fullvirt-serial-udp.cfg b/tests/xmconfigdata/test-fullvirt-serial-udp.cfg index 5b7804d..481bedb 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" ] diff --git a/tests/xmconfigdata/test-fullvirt-serial-unix.cfg b/tests/xmconfigdata/test-fullvirt-serial-unix.cfg index 6cd7272..a5cb063 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" ] diff --git a/tests/xmconfigdata/test-fullvirt-sound.cfg b/tests/xmconfigdata/test-fullvirt-sound.cfg index 67dd8e0..5f33f0f 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" ] diff --git a/tests/xmconfigdata/test-fullvirt-usbmouse.cfg b/tests/xmconfigdata/test-fullvirt-usbmouse.cfg index be27f08..438e55d 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" ] diff --git a/tests/xmconfigdata/test-fullvirt-usbtablet.cfg b/tests/xmconfigdata/test-fullvirt-usbtablet.cfg index 5e84e7e..5637385 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" ] diff --git a/tests/xmconfigdata/test-fullvirt-utc.cfg b/tests/xmconfigdata/test-fullvirt-utc.cfg index a4f3aec..10fcd80 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" ] diff --git a/tests/xmconfigdata/test-no-source-cdrom.cfg b/tests/xmconfigdata/test-no-source-cdrom.cfg index 27bec8d..63537e7 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" ] diff --git a/tests/xmconfigdata/test-paravirt-net-e1000.cfg b/tests/xmconfigdata/test-paravirt-net-e1000.cfg index bcc16fb..ac43507 100755 --- a/tests/xmconfigdata/test-paravirt-net-e1000.cfg +++ b/tests/xmconfigdata/test-paravirt-net-e1000.cfg @@ -9,5 +9,5 @@ on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" vfb = [ "type=vnc,vncunused=1,vnclisten=127.0.0.1,vncpasswd=123poi" ] -disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ] vif = [ "mac=00:16:3e:66:94:9c,bridge=br0,script=vif-bridge,model=e1000" ] +disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ] diff --git a/tests/xmconfigdata/test-paravirt-net-vifname.cfg b/tests/xmconfigdata/test-paravirt-net-vifname.cfg index 98ce75b..c66721c 100644 --- a/tests/xmconfigdata/test-paravirt-net-vifname.cfg +++ b/tests/xmconfigdata/test-paravirt-net-vifname.cfg @@ -9,5 +9,5 @@ on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" vfb = [ "type=vnc,vncunused=1,vnclisten=127.0.0.1,vncpasswd=123poi" ] -disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ] vif = [ "mac=00:16:3e:66:94:9c,bridge=br0,script=vif-bridge,model=e1000,vifname=net0" ] +disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ] diff --git a/tests/xmconfigdata/test-paravirt-new-pvfb-vncdisplay.cfg b/tests/xmconfigdata/test-paravirt-new-pvfb-vncdisplay.cfg index 633552c..de1c912 100644 --- a/tests/xmconfigdata/test-paravirt-new-pvfb-vncdisplay.cfg +++ b/tests/xmconfigdata/test-paravirt-new-pvfb-vncdisplay.cfg @@ -9,5 +9,5 @@ on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" vfb = [ "type=vnc,vncunused=0,vncdisplay=25,vnclisten=127.0.0.1,vncpasswd=123poi" ] -disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ] vif = [ "mac=00:16:3e:66:94:9c,bridge=br0,script=vif-bridge" ] +disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ] diff --git a/tests/xmconfigdata/test-paravirt-new-pvfb.cfg b/tests/xmconfigdata/test-paravirt-new-pvfb.cfg index 8b56e19..df91e89 100755 --- a/tests/xmconfigdata/test-paravirt-new-pvfb.cfg +++ b/tests/xmconfigdata/test-paravirt-new-pvfb.cfg @@ -9,5 +9,5 @@ on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" vfb = [ "type=vnc,vncunused=1,vnclisten=127.0.0.1,vncpasswd=123poi" ] -disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ] vif = [ "mac=00:16:3e:66:94:9c,bridge=br0,script=vif-bridge" ] +disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ] diff --git a/tests/xmconfigdata/test-paravirt-old-pvfb-vncdisplay.cfg b/tests/xmconfigdata/test-paravirt-old-pvfb-vncdisplay.cfg index eea3365..6f9a1aa 100644 --- a/tests/xmconfigdata/test-paravirt-old-pvfb-vncdisplay.cfg +++ b/tests/xmconfigdata/test-paravirt-old-pvfb-vncdisplay.cfg @@ -14,5 +14,5 @@ vncunused = 0 vncdisplay = 25 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ] vif = [ "mac=00:16:3e:66:94:9c,bridge=br0,script=vif-bridge" ] +disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ] diff --git a/tests/xmconfigdata/test-paravirt-old-pvfb.cfg b/tests/xmconfigdata/test-paravirt-old-pvfb.cfg index ed9c771..7daad8c 100755 --- a/tests/xmconfigdata/test-paravirt-old-pvfb.cfg +++ b/tests/xmconfigdata/test-paravirt-old-pvfb.cfg @@ -13,5 +13,5 @@ vnc = 1 vncunused = 1 vnclisten = "127.0.0.1" vncpasswd = "123poi" -disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ] vif = [ "mac=00:16:3e:66:94:9c,bridge=br0,script=vif-bridge" ] +disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ] diff --git a/tests/xmconfigdata/test-paravirt-vcpu.cfg b/tests/xmconfigdata/test-paravirt-vcpu.cfg index 2ac0f79..fb89bf9 100644 --- a/tests/xmconfigdata/test-paravirt-vcpu.cfg +++ b/tests/xmconfigdata/test-paravirt-vcpu.cfg @@ -9,5 +9,5 @@ localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" -disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ] vif = [ "mac=00:16:3e:66:94:9c,bridge=br0,script=vif-bridge" ] +disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ] diff --git a/tests/xmconfigdata/test-pci-devs.cfg b/tests/xmconfigdata/test-pci-devs.cfg index a24a09c..4e3096d 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" ] -- 1.8.4.5

Kiarie Kahurani wrote:
Kiarie Kahurani (12): src/xenxs: Export code for reuse
[...]
src/xenxs: Refactor code formating general VM config src/xenxs: Refactor code formating memory config src/xenxs: Refactor code formating virtual time config src/xenxs: Refactor code formating event actions config src/xenxs: Refactor code formating Char devices config src/xenxs: Refactor code formating xm disk config src/xenxs: Refactor code formating CPU features config src/xenxs: Refactor code formating OS config src/xenxs: Refactor code formating Vfb config src/xenxs: Refactor code formating emulated devices config
I've pushed 2-11 plus the additional patch for vif formating. I planned to defer 1/12 and 12/12 until reworking the xenxs directory https://www.redhat.com/archives/libvir-list/2014-August/msg00519.html But I think it would be better to have them before creating xen_common.[ch], to avoid temporarily exporting all the xen{Parse,Format}XM* functions in xen_common.h. In the end, we'll only need to export xen{Parse,Format}Common. Regards, Jim
participants (5)
-
David Kiarie
-
David kiarie
-
Eric Blake
-
Jim Fehlig
-
Kiarie Kahurani