[Libvir] PATCH: Allow Xen HVM kernel+initrd booting

The latest xen-unstable tree has support for booting HVM guests using an explicit kernel+initrd+cmdline, as an alternative to the traditional BIOS boot from harddisk/cdrom/network. This gives Xen HVM parity with KVM in terms of boot methods. The current libvirt Xen driver though assumes that Xen paravirt is always kernel+initrd or bootloader based, while Xen HVM is always BIOS based. This patch re-factors the Xen driver so that it allows kernel+initrd for both Xen paravirt and HVM guests. NB, Xen HVM previously abused the 'kernel' parameter in the SEXPR to refer to the HVM guest firmware (ie /usr/lib/xen/boot/hvmloader). With the new support for booting kernel+initrd in HVM guests, the firmware can now be specified using an explicit 'loader' parameter - for backwards compatability you can still use the old 'kernel' parameter too if doing a BIOS boot. Second, it is also now possible for a paravirt guest to provide an explicit patch to a QEMU device model, aka the <emulator> tag in libvirt, so this pach also enables that functionality for paravirt guests. Finally, since the paravirt framebuffer is tied up in all this code too, I also include John's patch to make us deal with <graphics> properly in legacy guests and old XenD. Thankfully we have a large test suite of SEXPR/XML files, so while this is a pretty major refactoring of code, I'm fairly confident we won't cause bad regressions. A couple of the existing test cases needed their sample SEXPR tweaked since we now generate a couple of (...) bits in a different order, the result is functionally the same though. Finally as an example, we can create a HVM guest on xen-unstable using this XML snippet - note how we can now pass parameters to the installer for HVM too ! <domain type='xen'> <name>kernel</name> <uuid>06ed00fe-1162-4fc4-b5d8-11993ee4a8b9</uuid> <os> <type>hvm</type> <loader>/usr/lib/xen/boot/hvmloader</loader> <kernel>/root/vmlinuz.f864</kernel> <initrd>/root/initrd.img.f864</initrd> <cmdline>console=ttyS0 console=tty0</cmdline> </os> <memory>540672</memory> <currentMemory>531456</currentMemory> <vcpu>1</vcpu> <on_poweroff>preserve</on_poweroff> <on_reboot>preserve</on_reboot> <on_crash>preserve</on_crash> <features> <acpi/> <apic/> <pae/> </features> <devices> <emulator>/usr/lib64/xen/bin/qemu-dm</emulator> <interface type='bridge'> <source bridge='xenbr0'/> <mac address='00:16:3e:0e:e8:b7'/> <script path='vif-bridge'/> </interface> <disk type='file' device='disk'> <driver name='file'/> <source file='/root/kernel.img'/> <target dev='hda'/> </disk> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' listen='0.0.0.0'/> <console tty='pty'/> </devices> </domain> src/xend_internal.c | 122 +++++++------ src/xml.c | 183 ++++++++------------ tests/sexpr2xmldata/sexpr2xml-fv-kernel.sexpr | 1 tests/sexpr2xmldata/sexpr2xml-fv-kernel.xml | 26 ++ tests/sexpr2xmldata/sexpr2xml-fv-legacy-vfb.sexpr | 70 +++++++ tests/sexpr2xmldata/sexpr2xml-fv-legacy-vfb.xml | 33 +++ tests/sexpr2xmltest.c | 20 ++ tests/xml2sexprdata/xml2sexpr-fv-kernel.sexpr | 1 tests/xml2sexprdata/xml2sexpr-fv-kernel.xml | 24 ++ tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr | 2 tests/xml2sexprdata/xml2sexpr-fv-usbmouse.sexpr | 2 tests/xml2sexprdata/xml2sexpr-fv-usbtablet.sexpr | 2 tests/xml2sexprdata/xml2sexpr-fv-utc.sexpr | 2 tests/xml2sexprdata/xml2sexpr-fv-v2.sexpr | 2 tests/xml2sexprdata/xml2sexpr-fv-vncunused.sexpr | 2 tests/xml2sexprdata/xml2sexpr-fv.sexpr | 2 tests/xml2sexprdata/xml2sexpr-no-source-cdrom.sexpr | 2 tests/xml2sexprtest.c | 11 + 18 files changed, 346 insertions(+), 161 deletions(-) Dan. Index: src/xend_internal.c =================================================================== RCS file: /data/cvs/libvirt/src/xend_internal.c,v retrieving revision 1.165 diff -u -p -r1.165 xend_internal.c --- src/xend_internal.c 30 Jan 2008 16:38:18 -0000 1.165 +++ src/xend_internal.c 3 Feb 2008 18:37:17 -0000 @@ -1280,65 +1280,84 @@ xend_log(virConnectPtr xend, char *buffe static int xend_parse_sexp_desc_os(virConnectPtr xend, struct sexpr *node, virBufferPtr buf, int hvm, int bootloader) { - const char *tmp; + const char *loader = NULL; + const char *kernel = NULL; + const char *initrd = NULL; + const char *cmdline = NULL; + const char *root = NULL; if (node == NULL || buf == NULL) { return(-1); } virBufferAdd(buf, " <os>\n", 7); + if (hvm) + virBufferAdd(buf, " <type>hvm</type>\n", -1); + else + virBufferAdd(buf, " <type>linux</type>\n", -1); + if (hvm) { - virBufferVSprintf(buf, " <type>hvm</type>\n"); - tmp = sexpr_node(node, "domain/image/hvm/kernel"); - if (tmp == NULL) - tmp = sexpr_node(node, "domain/image/hvm/loader"); - if (tmp == NULL && !bootloader) { - virXendError(xend, VIR_ERR_INTERNAL_ERROR, - _("domain information incomplete, missing kernel & bootloader")); - return(-1); - } - if (tmp) - virBufferVSprintf(buf, " <loader>%s</loader>\n", tmp); - tmp = sexpr_node(node, "domain/image/hvm/boot"); - if ((tmp != NULL) && (tmp[0] != 0)) { - while (*tmp) { - if (*tmp == 'a') - /* XXX no way to deal with boot from 2nd floppy */ - virBufferAdd(buf, " <boot dev='fd'/>\n", 21 ); - else if (*tmp == 'c') - /* - * Don't know what to put here. Say the vm has been given 3 - * disks - hda, hdb, hdc. How does one identify the boot disk? - * We're going to assume that first disk is the boot disk since - * this is most common practice - */ - virBufferAdd(buf, " <boot dev='hd'/>\n", 21 ); - else if (*tmp == 'd') - virBufferAdd(buf, " <boot dev='cdrom'/>\n", 24 ); - else if (*tmp == 'n') - virBufferAdd(buf, " <boot dev='network'/>\n", 26 ); - tmp++; + loader = sexpr_node(node, "domain/image/hvm/loader"); + if (loader == NULL) { + loader = sexpr_node(node, "domain/image/hvm/kernel"); + + if (loader == NULL) { + virXendError(xend, VIR_ERR_INTERNAL_ERROR, + _("domain information incomplete, missing HVM loader")); + return(-1); } + } else { + kernel = sexpr_node(node, "domain/image/hvm/kernel"); + initrd = sexpr_node(node, "domain/image/hvm/ramdisk"); + cmdline = sexpr_node(node, "domain/image/hvm/args"); + root = sexpr_node(node, "domain/image/hvm/root"); } } else { - virBufferVSprintf(buf, " <type>linux</type>\n"); - tmp = sexpr_node(node, "domain/image/linux/kernel"); - if (tmp == NULL && !bootloader) { + kernel = sexpr_node(node, "domain/image/linux/kernel"); + initrd = sexpr_node(node, "domain/image/linux/ramdisk"); + cmdline = sexpr_node(node, "domain/image/linux/args"); + root = sexpr_node(node, "domain/image/linux/root"); + } + + if (hvm) + virBufferVSprintf(buf, " <loader>%s</loader>\n", loader); + + if (kernel) { + virBufferVSprintf(buf, " <kernel>%s</kernel>\n", kernel); + if (initrd && initrd[0]) + virBufferVSprintf(buf, " <initrd>%s</initrd>\n", initrd); + if (root && root[0]) + virBufferVSprintf(buf, " <root>%s</root>\n", root); + if (cmdline && cmdline[0]) + virBufferEscapeString(buf, " <cmdline>%s</cmdline>\n", cmdline); + } else { + if (hvm) { + const char *boot = sexpr_node(node, "domain/image/hvm/boot"); + if ((boot != NULL) && (boot[0] != 0)) { + while (*boot) { + if (*boot == 'a') + /* XXX no way to deal with boot from 2nd floppy */ + virBufferAdd(buf, " <boot dev='fd'/>\n", 21 ); + else if (*boot == 'c') + /* + * Don't know what to put here. Say the vm has been given 3 + * disks - hda, hdb, hdc. How does one identify the boot disk? + * We're going to assume that first disk is the boot disk since + * this is most common practice + */ + virBufferAdd(buf, " <boot dev='hd'/>\n", 21 ); + else if (*boot == 'd') + virBufferAdd(buf, " <boot dev='cdrom'/>\n", 24 ); + else if (*boot == 'n') + virBufferAdd(buf, " <boot dev='network'/>\n", 26 ); + boot++; + } + } + } else if (!bootloader) { virXendError(xend, VIR_ERR_INTERNAL_ERROR, _("domain information incomplete, missing kernel & bootloader")); return(-1); } - if (tmp) - virBufferVSprintf(buf, " <kernel>%s</kernel>\n", tmp); - tmp = sexpr_node(node, "domain/image/linux/ramdisk"); - if ((tmp != NULL) && (tmp[0] != 0)) - virBufferVSprintf(buf, " <initrd>%s</initrd>\n", tmp); - tmp = sexpr_node(node, "domain/image/linux/root"); - if ((tmp != NULL) && (tmp[0] != 0)) - virBufferVSprintf(buf, " <root>%s</root>\n", tmp); - tmp = sexpr_node(node, "domain/image/linux/args"); - if ((tmp != NULL) && (tmp[0] != 0)) - virBufferEscapeString(buf, " <cmdline>%s</cmdline>\n", tmp); } virBufferAdd(buf, " </os>\n", 8); @@ -1367,7 +1386,7 @@ xend_parse_sexp_desc(virConnectPtr conn, const char *tmp; char *tty; virBuffer buf; - int hvm = 0, bootloader = 0; + int hvm = 0, bootloader = 0, vfb = 0; int domid = -1; int max_mem, cur_mem; unsigned char uuid[VIR_UUID_BUFLEN]; @@ -1487,8 +1506,10 @@ xend_parse_sexp_desc(virConnectPtr conn, virBufferAdd(&buf, " <devices>\n", 12); - /* in case of HVM we have devices emulation */ - tmp = sexpr_node(root, "domain/image/hvm/device_model"); + if (hvm) + tmp = sexpr_node(root, "domain/image/hvm/device_model"); + else + tmp = sexpr_node(root, "domain/image/linux/device_model"); if ((tmp != NULL) && (tmp[0] != 0)) virBufferVSprintf(&buf, " <emulator>%s</emulator>\n", tmp); @@ -1681,6 +1702,7 @@ xend_parse_sexp_desc(virConnectPtr conn, tmp = sexpr_node(node, "device/vfb/type"); if (tmp && !strcmp(tmp, "sdl")) { + vfb = 1; virBufferVSprintf(&buf, " <input type='mouse' bus='%s'/>\n", hvm ? "ps2": "xen"); virBufferAdd(&buf, " <graphics type='sdl'/>\n", 27); } else if (tmp && !strcmp(tmp, "vnc")) { @@ -1688,6 +1710,7 @@ xend_parse_sexp_desc(virConnectPtr conn, const char *listenAddr = sexpr_node(node, "device/vfb/vnclisten"); const char *vncPasswd = NULL; const char *keymap = sexpr_node(node, "device/vfb/keymap"); + vfb = 1; virBufferVSprintf(&buf, " <input type='mouse' bus='%s'/>\n", hvm ? "ps2": "xen"); virBufferVSprintf(&buf, " <graphics type='vnc' port='%d'", port); if (listenAddr) @@ -1751,8 +1774,7 @@ xend_parse_sexp_desc(virConnectPtr conn, } /* Graphics device (HVM <= 3.0.4, or PV <= 3.0.3) vnc config */ - if ((hvm && xendConfigVersion < 4) || - (!hvm && xendConfigVersion < 3)) { + if (!vfb) { tmp = sexpr_fmt_node(root, "domain/image/%s/vnc", hvm ? "hvm" : "linux"); if (tmp != NULL) { if (tmp[0] == '1') { Index: src/xml.c =================================================================== RCS file: /data/cvs/libvirt/src/xml.c,v retrieving revision 1.105 diff -u -p -r1.105 xml.c --- src/xml.c 29 Jan 2008 18:23:43 -0000 1.105 +++ src/xml.c 3 Feb 2008 18:37:17 -0000 @@ -839,22 +839,21 @@ virDomainParseXMLGraphicsDescVFB(virConn * @ctxt: a path context representing the XML description * @vcpus: number of virtual CPUs to configure * @xendConfigVersion: xend configuration file format + * @hasKernel: whether the domain is booting from a kernel * - * Parse the OS part of the XML description for an HVM domain and add it to - * the S-Expr in buf. This is a temporary interface as the S-Expr interface - * will be replaced by XML-RPC in the future. However the XML format should - * stay valid over time. + * Parse the OS part of the XML description for a HVM domain + * and add it to the S-Expr in buf. * * Returns 0 in case of success, -1 in case of error. */ static int virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node, virBufferPtr buf, xmlXPathContextPtr ctxt, - int vcpus, int xendConfigVersion) + int vcpus, int xendConfigVersion, + int hasKernel) { xmlNodePtr cur, txt; xmlNodePtr *nodes = NULL; - xmlChar *type = NULL; xmlChar *loader = NULL; char bootorder[5]; int nbootorder = 0; @@ -864,14 +863,8 @@ virDomainParseXMLOSDescHVM(virConnectPtr cur = node->children; while (cur != NULL) { if (cur->type == XML_ELEMENT_NODE) { - if ((type == NULL) && - (xmlStrEqual(cur->name, BAD_CAST "type"))) { - txt = cur->children; - if ((txt != NULL) && (txt->type == XML_TEXT_NODE) && - (txt->next == NULL)) - type = txt->content; - } else if ((loader == NULL) && - (xmlStrEqual(cur->name, BAD_CAST "loader"))) { + if ((loader == NULL) && + (xmlStrEqual(cur->name, BAD_CAST "loader"))) { txt = cur->children; if ((txt != NULL) && (txt->type == XML_TEXT_NODE) && (txt->next == NULL)) @@ -904,29 +897,31 @@ virDomainParseXMLOSDescHVM(virConnectPtr } cur = cur->next; } + /* + * XenD always needs boot order defined for HVM, even if + * booting off a kernel + initrd, so force to 'c' if nothing + * else is specified + */ + if (nbootorder == 0) + bootorder[nbootorder++] = 'c'; bootorder[nbootorder] = '\0'; - if ((type == NULL) || (!xmlStrEqual(type, BAD_CAST "hvm"))) { - /* VIR_ERR_OS_TYPE */ - virXMLError(conn, VIR_ERR_OS_TYPE, (const char *) type, 0); - return (-1); - } - virBufferAdd(buf, "(image (hvm ", 12); + if (loader == NULL) { - virXMLError(conn, VIR_ERR_NO_KERNEL, NULL, 0); - goto error; + virXMLError(conn, VIR_ERR_INTERNAL_ERROR, "no HVM domain loader", 0); + return -1; + } + /* + * Originally XenD abused the 'kernel' parameter for the HVM + * firmware. New XenD allows HVM guests to boot from a kernel + * and if this is enabled, the HVM firmware must use the new + * 'loader' parameter + */ + if (hasKernel) { + virBufferVSprintf(buf, "(loader '%s')", (const char *) loader); } else { virBufferVSprintf(buf, "(kernel '%s')", (const char *) loader); } - /* get the device emulation model */ - str = virXPathString("string(/domain/devices/emulator[1])", ctxt); - if (str == NULL) { - virXMLError(conn, VIR_ERR_NO_KERNEL, NULL, 0); /* TODO: error */ - goto error; - } - virBufferVSprintf(buf, "(device_model '%s')", str); - xmlFree(str); - virBufferVSprintf(buf, "(vcpus %d)", vcpus); if (nbootorder) @@ -1047,27 +1042,12 @@ virDomainParseXMLOSDescHVM(virConnectPtr virBufferAdd(buf, "(serial pty)", 12); } - /* HVM graphics for xen <= 3.0.5 */ - if (xendConfigVersion < 4) { - /* Is a graphics device specified? */ - cur = virXPathNode("/domain/devices/graphics[1]", ctxt); - if (cur != NULL) { - res = virDomainParseXMLGraphicsDescImage(conn, cur, buf, - xendConfigVersion); - if (res != 0) { - goto error; - } - } - } - str = virXPathString("string(/domain/clock/@offset)", ctxt); if (str != NULL && !strcmp(str, "localtime")) { virBufferAdd(buf, "(localtime 1)", 13); } free(str); - virBufferAdd(buf, "))", 2); - return (0); error: @@ -1075,45 +1055,34 @@ virDomainParseXMLOSDescHVM(virConnectPtr return (-1); } + /** - * virDomainParseXMLOSDescPV: + * virDomainParseXMLOSDescKernel: * @conn: pointer to the hypervisor connection * @node: node containing PV OS description * @buf: a buffer for the result S-Expr - * @ctxt: a path context representing the XML description - * @xendConfigVersion: xend configuration file format * - * Parse the OS part of the XML description for a paravirtualized domain - * and add it to the S-Expr in buf. This is a temporary interface as the - * S-Expr interface will be replaced by XML-RPC in the future. However - * the XML format should stay valid over time. + * Parse the OS part of the XML description for a domain using a direct + * kernel and initrd to boot. * * Returns 0 in case of success, -1 in case of error. */ static int -virDomainParseXMLOSDescPV(virConnectPtr conn, xmlNodePtr node, - virBufferPtr buf, xmlXPathContextPtr ctxt, - int xendConfigVersion) +virDomainParseXMLOSDescKernel(virConnectPtr conn ATTRIBUTE_UNUSED, + xmlNodePtr node, + virBufferPtr buf) { xmlNodePtr cur, txt; - const xmlChar *type = NULL; const xmlChar *root = NULL; const xmlChar *kernel = NULL; const xmlChar *initrd = NULL; const xmlChar *cmdline = NULL; - int res; cur = node->children; while (cur != NULL) { if (cur->type == XML_ELEMENT_NODE) { - if ((type == NULL) - && (xmlStrEqual(cur->name, BAD_CAST "type"))) { - txt = cur->children; - if ((txt != NULL) && (txt->type == XML_TEXT_NODE) && - (txt->next == NULL)) - type = txt->content; - } else if ((kernel == NULL) && - (xmlStrEqual(cur->name, BAD_CAST "kernel"))) { + if ((kernel == NULL) && + (xmlStrEqual(cur->name, BAD_CAST "kernel"))) { txt = cur->children; if ((txt != NULL) && (txt->type == XML_TEXT_NODE) && (txt->next == NULL)) @@ -1140,18 +1109,9 @@ virDomainParseXMLOSDescPV(virConnectPtr } cur = cur->next; } - if ((type != NULL) && (!xmlStrEqual(type, BAD_CAST "linux"))) { - /* VIR_ERR_OS_TYPE */ - virXMLError(conn, VIR_ERR_OS_TYPE, (const char *) type, 0); - return (-1); - } - virBufferAdd(buf, "(image (linux ", 14); - if (kernel == NULL) { - virXMLError(conn, VIR_ERR_NO_KERNEL, NULL, 0); - return (-1); - } else { - virBufferVSprintf(buf, "(kernel '%s')", (const char *) kernel); - } + + virBufferVSprintf(buf, "(kernel '%s')", (const char *) kernel); + if (initrd != NULL) virBufferVSprintf(buf, "(ramdisk '%s')", (const char *) initrd); if (root != NULL) @@ -1159,20 +1119,6 @@ virDomainParseXMLOSDescPV(virConnectPtr if (cmdline != NULL) virBufferVSprintf(buf, "(args '%s')", (const char *) cmdline); - /* PV graphics for xen <= 3.0.4 */ - if (xendConfigVersion < 3) { - cur = virXPathNode("/domain/devices/graphics[1]", ctxt); - if (cur != NULL) { - res = virDomainParseXMLGraphicsDescImage(conn, cur, buf, - xendConfigVersion); - if (res != 0) { - goto error; - } - } - } - - error: - virBufferAdd(buf, "))", 2); return (0); } @@ -1706,23 +1652,54 @@ virDomainParseXMLDesc(virConnectPtr conn if (!bootloader) { if ((node = virXPathNode("/domain/os[1]", ctxt)) != NULL) { + int has_kernel = 0; + /* Analyze of the os description, based on HVM or PV. */ str = virXPathString("string(/domain/os/type[1])", ctxt); - - if ((str == NULL) || (strcmp(str, "hvm"))) { - res = virDomainParseXMLOSDescPV(conn, node, - &buf, ctxt, - xendConfigVersion); - } else { + if ((str != NULL) && STREQ(str, "hvm")) hvm = 1; - res = virDomainParseXMLOSDescHVM(conn, node, &buf, ctxt, - vcpus, xendConfigVersion); - } + xmlFree(str); + str = NULL; - free(str); + if (hvm) + virBufferAdd(&buf, "(image (hvm ", 12); + else + virBufferAdd(&buf, "(image (linux ", 14); + + if (virXPathBoolean("count(/domain/os/kernel) > 0", ctxt)) { + if (virDomainParseXMLOSDescKernel(conn, node, + &buf) != 0) + goto error; + has_kernel = 1; + } - if (res != 0) + if (hvm && + virDomainParseXMLOSDescHVM(conn, node, + &buf, ctxt, vcpus, + xendConfigVersion, + has_kernel) != 0) goto error; + + /* get the device emulation model */ + str = virXPathString("string(/domain/devices/emulator[1])", ctxt); + if (str != NULL) { + virBufferVSprintf(&buf, "(device_model '%s')", str); + xmlFree(str); + str = NULL; + } + + /* PV graphics for xen <= 3.0.4, or HVM graphics for xen <= 3.1.0 */ + if ((!hvm && xendConfigVersion < 3) || + (hvm && xendConfigVersion < 4)) { + xmlNodePtr cur; + cur = virXPathNode("/domain/devices/graphics[1]", ctxt); + if (cur != NULL && + virDomainParseXMLGraphicsDescImage(conn, cur, &buf, + xendConfigVersion) != 0) + goto error; + } + + virBufferAdd(&buf, "))", 2); } else { virXMLError(conn, VIR_ERR_NO_OS, nam, 0); goto error; Index: tests/sexpr2xmltest.c =================================================================== RCS file: /data/cvs/libvirt/tests/sexpr2xmltest.c,v retrieving revision 1.22 diff -u -p -r1.22 sexpr2xmltest.c --- tests/sexpr2xmltest.c 29 Jan 2008 18:15:54 -0000 1.22 +++ tests/sexpr2xmltest.c 3 Feb 2008 18:37:17 -0000 @@ -178,6 +178,18 @@ static int testCompareFVclockLocaltime(c 1); } +static int testCompareFVKernel(const void *data ATTRIBUTE_UNUSED) { + return testCompareFiles("sexpr2xmldata/sexpr2xml-fv-kernel.xml", + "sexpr2xmldata/sexpr2xml-fv-kernel.sexpr", + 1); +} + +static int testCompareFVLegacyVFB(const void *data ATTRIBUTE_UNUSED) { + return testCompareFiles("sexpr2xmldata/sexpr2xml-fv-legacy-vfb.xml", + "sexpr2xmldata/sexpr2xml-fv-legacy-vfb.sexpr", + 4); +} + int main(int argc, char **argv) @@ -276,6 +288,14 @@ main(int argc, char **argv) 1, testCompareFVclockLocaltime, NULL) != 0) ret = -1; + if (virtTestRun("SEXPR-2-XML FV kernel", + 1, testCompareFVKernel, NULL) != 0) + ret = -1; + + if (virtTestRun("SEXPR-2-XML FV legacy VFB", + 1, testCompareFVLegacyVFB, NULL) != 0) + ret = -1; + exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE); } #else /* WITHOUT_XEN */ Index: tests/xml2sexprtest.c =================================================================== RCS file: /data/cvs/libvirt/tests/xml2sexprtest.c,v retrieving revision 1.21 diff -u -p -r1.21 xml2sexprtest.c --- tests/xml2sexprtest.c 29 Jan 2008 18:15:54 -0000 1.21 +++ tests/xml2sexprtest.c 3 Feb 2008 18:37:17 -0000 @@ -235,6 +235,13 @@ static int testCompareFVInputUSBTablet(c 1); } +static int testCompareFVKernel(const void *data ATTRIBUTE_UNUSED) { + return testCompareFiles("xml2sexprdata/xml2sexpr-fv-kernel.xml", + "xml2sexprdata/xml2sexpr-fv-kernel.sexpr", + "fvtest", + 1); +} + int @@ -351,6 +358,10 @@ main(int argc, char **argv) 1, testCompareFVclockLocaltime, NULL) != 0) ret = -1; + if (virtTestRun("XML-2-SEXPR FV kernel", + 1, testCompareFVKernel, NULL) != 0) + ret = -1; + exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE); } Index: tests/sexpr2xmldata/sexpr2xml-fv-kernel.sexpr =================================================================== RCS file: tests/sexpr2xmldata/sexpr2xml-fv-kernel.sexpr diff -N tests/sexpr2xmldata/sexpr2xml-fv-kernel.sexpr --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tests/sexpr2xmldata/sexpr2xml-fv-kernel.sexpr 3 Feb 2008 18:37:17 -0000 @@ -0,0 +1 @@ +(domain (domid 15)(name 'fvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d2171f48fb2e068e2386a5c413e')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(image (hvm (kernel '/var/lib/xen/vmlinuz.2Dn2YT')(ramdisk '/var/lib/xen/initrd.img.0u-Vhq')(args ' method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test/5.91/x86_... ')(loader '/usr/lib/xen/boot/hvmloader')(vcpus 2)(usb 1)(serial pty)))(device (vbd (dev 'ioemu:xvda')(uname 'file:/root/some.img')(mode 'w')))) \ No newline at end of file Index: tests/sexpr2xmldata/sexpr2xml-fv-kernel.xml =================================================================== RCS file: tests/sexpr2xmldata/sexpr2xml-fv-kernel.xml diff -N tests/sexpr2xmldata/sexpr2xml-fv-kernel.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tests/sexpr2xmldata/sexpr2xml-fv-kernel.xml 3 Feb 2008 18:37:17 -0000 @@ -0,0 +1,26 @@ +<domain type='xen' id='15'> + <name>fvtest</name> + <uuid>596a5d21-71f4-8fb2-e068-e2386a5c413e</uuid> + <os> + <type>hvm</type> + <loader>/usr/lib/xen/boot/hvmloader</loader> + <kernel>/var/lib/xen/vmlinuz.2Dn2YT</kernel> + <initrd>/var/lib/xen/initrd.img.0u-Vhq</initrd> + <cmdline> method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test/5.91/x86_... </cmdline> + </os> + <memory>430080</memory> + <vcpu>2</vcpu> + <on_poweroff>destroy</on_poweroff> + <on_reboot>destroy</on_reboot> + <on_crash>destroy</on_crash> + <features> + </features> + <clock offset='utc'/> + <devices> + <disk type='file' device='disk'> + <driver name='file'/> + <source file='/root/some.img'/> + <target dev='xvda'/> + </disk> + </devices> +</domain> Index: tests/sexpr2xmldata/sexpr2xml-fv-legacy-vfb.sexpr =================================================================== RCS file: tests/sexpr2xmldata/sexpr2xml-fv-legacy-vfb.sexpr diff -N tests/sexpr2xmldata/sexpr2xml-fv-legacy-vfb.sexpr --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tests/sexpr2xmldata/sexpr2xml-fv-legacy-vfb.sexpr 3 Feb 2008 18:37:17 -0000 @@ -0,0 +1,70 @@ +(domain + (domid 1) + (on_crash restart) + (uuid fde0533d-d043-88c6-dfba-4822fa32f309) + (bootloader_args ) + (vcpus 1) + (name s10u4) + (on_poweroff destroy) + (on_reboot restart) + (bootloader ) + (maxmem 1024) + (memory 1024) + (shadow_memory 9) + (cpu_weight 256) + (cpu_cap 0) + (features ) + (on_xend_start ignore) + (on_xend_stop shutdown) + (start_time 1201894394.0) + (cpu_time 17.253230349) + (online_vcpus 1) + (image + (hvm + (kernel /usr/lib/xen/boot/hvmloader) + (boot c) + (device_model /usr/lib/xen/bin/qemu-dm) + (keymap en-us) + (localtime 0) + (pae 1) + (vnc 1) + (vncunused 1) + (notes (SUSPEND_CANCEL 1)) + ) + ) + (status 2) + (state -b----) + (store_mfn 262142) + (device + (vif + (mac 00:16:3e:3b:b9:d7) + (script vif-vnic) + (uuid 33b87cce-c187-4bdd-8301-6411a48be129) + (backend 0) + ) + ) + (device + (vbd + (uname phy:/dev/zvol/dsk/export/s10u4-root) + (uuid b1d5196f-aae7-74bb-43dc-b4aae943b9bd) + (mode w) + (dev hda:disk) + (backend 0) + (bootable 1) + ) + ) + (device + (vfb + (vncunused 1) + (uuid d45dfd90-c0e0-8851-8f14-f16ba9512d2d) + (location localhost:5900) + ) + ) + (device + (console + (protocol vt100) + (location 3) + (uuid 0248d3f7-f3ae-78e8-4829-ad51a6f94efd) + ) + ) +) Index: tests/sexpr2xmldata/sexpr2xml-fv-legacy-vfb.xml =================================================================== RCS file: tests/sexpr2xmldata/sexpr2xml-fv-legacy-vfb.xml diff -N tests/sexpr2xmldata/sexpr2xml-fv-legacy-vfb.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tests/sexpr2xmldata/sexpr2xml-fv-legacy-vfb.xml 3 Feb 2008 18:37:17 -0000 @@ -0,0 +1,33 @@ +<domain type='xen' id='1'> + <name>s10u4</name> + <uuid>fde0533d-d043-88c6-dfba-4822fa32f309</uuid> + <os> + <type>hvm</type> + <loader>/usr/lib/xen/boot/hvmloader</loader> + <boot dev='hd'/> + </os> + <memory>1048576</memory> + <vcpu>1</vcpu> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <features> + <pae/> + </features> + <clock offset='utc'/> + <devices> + <emulator>/usr/lib/xen/bin/qemu-dm</emulator> + <interface type='ethernet'> + <target dev='vif1.0'/> + <mac address='00:16:3e:3b:b9:d7'/> + <script path='vif-vnic'/> + </interface> + <disk type='block' device='disk'> + <driver name='phy'/> + <source dev='/dev/zvol/dsk/export/s10u4-root'/> + <target dev='hda'/> + </disk> + <input type='mouse' bus='ps2'/> + <graphics type='vnc' port='-1' keymap='en-us'/> + </devices> +</domain> Index: tests/xml2sexprdata/xml2sexpr-fv-kernel.sexpr =================================================================== RCS file: tests/xml2sexprdata/xml2sexpr-fv-kernel.sexpr diff -N tests/xml2sexprdata/xml2sexpr-fv-kernel.sexpr --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tests/xml2sexprdata/xml2sexpr-fv-kernel.sexpr 3 Feb 2008 18:37:17 -0000 @@ -0,0 +1 @@ +(vm (name 'fvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d2171f48fb2e068e2386a5c413e')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(image (hvm (kernel '/var/lib/xen/vmlinuz.2Dn2YT')(ramdisk '/var/lib/xen/initrd.img.0u-Vhq')(args ' method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test/5.91/x86_... ')(loader '/usr/lib/xen/boot/hvmloader')(vcpus 2)(boot c)(usb 1)(serial pty)))(device (vbd (dev 'ioemu:xvda')(uname 'file:/root/some.img')(mode 'w')))) \ No newline at end of file Index: tests/xml2sexprdata/xml2sexpr-fv-kernel.xml =================================================================== RCS file: tests/xml2sexprdata/xml2sexpr-fv-kernel.xml diff -N tests/xml2sexprdata/xml2sexpr-fv-kernel.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tests/xml2sexprdata/xml2sexpr-fv-kernel.xml 3 Feb 2008 18:37:17 -0000 @@ -0,0 +1,24 @@ +<domain type='xen' id='15'> + <name>fvtest</name> + <uuid>596a5d2171f48fb2e068e2386a5c413e</uuid> + <os> + <type>hvm</type> + <kernel>/var/lib/xen/vmlinuz.2Dn2YT</kernel> + <initrd>/var/lib/xen/initrd.img.0u-Vhq</initrd> + <cmdline> method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test/5.91/x86_... </cmdline> + <loader>/usr/lib/xen/boot/hvmloader</loader> + </os> + <memory>430080</memory> + <vcpu>2</vcpu> + <on_poweroff>destroy</on_poweroff> + <on_reboot>destroy</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <disk type='file' device='disk'> + <source file='/root/some.img'/> + <target dev='xvda'/> + </disk> + <console tty='/dev/pts/4'/> + </devices> +</domain> + Index: tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr =================================================================== RCS file: /data/cvs/libvirt/tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr,v retrieving revision 1.2 diff -u -p -r1.2 xml2sexpr-fv-localtime.sexpr --- tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr 18 Jul 2007 21:08:22 -0000 1.2 +++ tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr 3 Feb 2008 18:37:17 -0000 @@ -1 +1 @@ -(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(vnc 1)(localtime 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu)))) \ No newline at end of file +(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(localtime 1)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu)))) \ No newline at end of file Index: tests/xml2sexprdata/xml2sexpr-fv-usbmouse.sexpr =================================================================== RCS file: /data/cvs/libvirt/tests/xml2sexprdata/xml2sexpr-fv-usbmouse.sexpr,v retrieving revision 1.1 diff -u -p -r1.1 xml2sexpr-fv-usbmouse.sexpr --- tests/xml2sexprdata/xml2sexpr-fv-usbmouse.sexpr 18 Jul 2007 21:08:22 -0000 1.1 +++ tests/xml2sexprdata/xml2sexpr-fv-usbmouse.sexpr 3 Feb 2008 18:37:17 -0000 @@ -1 +1 @@ -(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(usbdevice mouse)(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu)))) \ No newline at end of file +(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(usbdevice mouse)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu)))) \ No newline at end of file Index: tests/xml2sexprdata/xml2sexpr-fv-usbtablet.sexpr =================================================================== RCS file: /data/cvs/libvirt/tests/xml2sexprdata/xml2sexpr-fv-usbtablet.sexpr,v retrieving revision 1.1 diff -u -p -r1.1 xml2sexpr-fv-usbtablet.sexpr --- tests/xml2sexprdata/xml2sexpr-fv-usbtablet.sexpr 18 Jul 2007 21:08:22 -0000 1.1 +++ tests/xml2sexprdata/xml2sexpr-fv-usbtablet.sexpr 3 Feb 2008 18:37:17 -0000 @@ -1 +1 @@ -(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(usbdevice tablet)(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu)))) \ No newline at end of file +(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(usbdevice tablet)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu)))) \ No newline at end of file Index: tests/xml2sexprdata/xml2sexpr-fv-utc.sexpr =================================================================== RCS file: /data/cvs/libvirt/tests/xml2sexprdata/xml2sexpr-fv-utc.sexpr,v retrieving revision 1.2 diff -u -p -r1.2 xml2sexpr-fv-utc.sexpr --- tests/xml2sexprdata/xml2sexpr-fv-utc.sexpr 18 Jul 2007 21:08:22 -0000 1.2 +++ tests/xml2sexprdata/xml2sexpr-fv-utc.sexpr 3 Feb 2008 18:37:17 -0000 @@ -1 +1 @@ -(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu)))) \ No newline at end of file +(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu)))) \ No newline at end of file Index: tests/xml2sexprdata/xml2sexpr-fv-v2.sexpr =================================================================== RCS file: /data/cvs/libvirt/tests/xml2sexprdata/xml2sexpr-fv-v2.sexpr,v retrieving revision 1.6 diff -u -p -r1.6 xml2sexpr-fv-v2.sexpr --- tests/xml2sexprdata/xml2sexpr-fv-v2.sexpr 18 Jul 2007 21:08:22 -0000 1.6 +++ tests/xml2sexprdata/xml2sexpr-fv-v2.sexpr 3 Feb 2008 18:37:17 -0000 @@ -1 +1 @@ -(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(vcpus 1)(boot c)(acpi 1)(usb 1)(vnc 1)(vncdisplay 17)(keymap ja)))(device (vbd (dev 'hdc:cdrom')(uname 'file:/root/boot.iso')(mode 'r')))(device (vbd (dev 'hda:disk')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu)))) \ No newline at end of file +(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(acpi 1)(usb 1)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)(vncdisplay 17)(keymap ja)))(device (vbd (dev 'hdc:cdrom')(uname 'file:/root/boot.iso')(mode 'r')))(device (vbd (dev 'hda:disk')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu)))) \ No newline at end of file Index: tests/xml2sexprdata/xml2sexpr-fv-vncunused.sexpr =================================================================== RCS file: /data/cvs/libvirt/tests/xml2sexprdata/xml2sexpr-fv-vncunused.sexpr,v retrieving revision 1.5 diff -u -p -r1.5 xml2sexpr-fv-vncunused.sexpr --- tests/xml2sexprdata/xml2sexpr-fv-vncunused.sexpr 18 Jul 2007 21:08:22 -0000 1.5 +++ tests/xml2sexprdata/xml2sexpr-fv-vncunused.sexpr 3 Feb 2008 18:37:17 -0000 @@ -1 +1 @@ -(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(vcpus 1)(boot c)(acpi 1)(usb 1)(vnc 1)(vncunused 1)(keymap ja)))(device (vbd (dev 'hdc:cdrom')(uname 'file:/root/boot.iso')(mode 'r')))(device (vbd (dev 'hda:disk')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu)))) \ No newline at end of file +(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(acpi 1)(usb 1)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)(vncunused 1)(keymap ja)))(device (vbd (dev 'hdc:cdrom')(uname 'file:/root/boot.iso')(mode 'r')))(device (vbd (dev 'hda:disk')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu)))) \ No newline at end of file Index: tests/xml2sexprdata/xml2sexpr-fv.sexpr =================================================================== RCS file: /data/cvs/libvirt/tests/xml2sexprdata/xml2sexpr-fv.sexpr,v retrieving revision 1.3 diff -u -p -r1.3 xml2sexpr-fv.sexpr --- tests/xml2sexprdata/xml2sexpr-fv.sexpr 18 Jul 2007 21:08:22 -0000 1.3 +++ tests/xml2sexprdata/xml2sexpr-fv.sexpr 3 Feb 2008 18:37:17 -0000 @@ -1 +1 @@ -(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu)))) \ No newline at end of file +(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu)))) \ No newline at end of file Index: tests/xml2sexprdata/xml2sexpr-no-source-cdrom.sexpr =================================================================== RCS file: /data/cvs/libvirt/tests/xml2sexprdata/xml2sexpr-no-source-cdrom.sexpr,v retrieving revision 1.2 diff -u -p -r1.2 xml2sexpr-no-source-cdrom.sexpr --- tests/xml2sexprdata/xml2sexpr-no-source-cdrom.sexpr 18 Jul 2007 21:08:22 -0000 1.2 +++ tests/xml2sexprdata/xml2sexpr-no-source-cdrom.sexpr 3 Feb 2008 18:37:17 -0000 @@ -1 +1 @@ -(vm (name 'test')(memory 350)(maxmem 382)(vcpus 1)(uuid 'cc2315e7d26a307a438c6d188ec4c09c')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib/xen/bin/qemu-dm')(vcpus 1)(boot c)(acpi 1)(apic 1)(pae 1)(usb 1)(vnc 1)(vncdisplay 6)))(device (vbd (dev 'hda:disk:disk')(uname 'phy:/dev/sda8')(mode 'w')))(device (vbd (dev 'hdc:cdrom')(mode 'r')))(device (vif (mac '00:16:3e:0a:7b:39')(type ioemu)))) \ No newline at end of file +(vm (name 'test')(memory 350)(maxmem 382)(vcpus 1)(uuid 'cc2315e7d26a307a438c6d188ec4c09c')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(acpi 1)(apic 1)(pae 1)(usb 1)(device_model '/usr/lib/xen/bin/qemu-dm')(vnc 1)(vncdisplay 6)))(device (vbd (dev 'hda:disk:disk')(uname 'phy:/dev/sda8')(mode 'w')))(device (vbd (dev 'hdc:cdrom')(mode 'r')))(device (vif (mac '00:16:3e:0a:7b:39')(type ioemu)))) \ No newline at end of file -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

On Sun, Feb 03, 2008 at 06:47:18PM +0000, Daniel P. Berrange wrote:
The latest xen-unstable tree has support for booting HVM guests using an explicit kernel+initrd+cmdline, as an alternative to the traditional BIOS boot from harddisk/cdrom/network. This gives Xen HVM parity with KVM in terms of boot methods. The current libvirt Xen driver though assumes that Xen paravirt is always kernel+initrd or bootloader based, while Xen HVM is always BIOS based.
This patch re-factors the Xen driver so that it allows kernel+initrd for both Xen paravirt and HVM guests.
NB, Xen HVM previously abused the 'kernel' parameter in the SEXPR to refer to the HVM guest firmware (ie /usr/lib/xen/boot/hvmloader). With the new support for booting kernel+initrd in HVM guests, the firmware can now be specified using an explicit 'loader' parameter - for backwards compatability you can still use the old 'kernel' parameter too if doing a BIOS boot.
Second, it is also now possible for a paravirt guest to provide an explicit patch to a QEMU device model, aka the <emulator> tag in libvirt, so this pach also enables that functionality for paravirt guests.
So basically Xen PV, Xen FV and KVM <os> blocks should now share the same set of functionalities, sharight the same syntax, right ? And the refactoring comes from the 3 being able to share more code, if yes that sounds excellent :-)
Finally, since the paravirt framebuffer is tied up in all this code too, I also include John's patch to make us deal with <graphics> properly in legacy guests and old XenD.
okay
Thankfully we have a large test suite of SEXPR/XML files, so while this is a pretty major refactoring of code, I'm fairly confident we won't cause bad regressions.
A couple of the existing test cases needed their sample SEXPR tweaked since we now generate a couple of (...) bits in a different order, the result is functionally the same though.
okay, that should not be a problem.
Finally as an example, we can create a HVM guest on xen-unstable using this XML snippet - note how we can now pass parameters to the installer for HVM too !
Looks like unification of the description, great !
<domain type='xen'> <name>kernel</name> <uuid>06ed00fe-1162-4fc4-b5d8-11993ee4a8b9</uuid> <os> <type>hvm</type> <loader>/usr/lib/xen/boot/hvmloader</loader> <kernel>/root/vmlinuz.f864</kernel> <initrd>/root/initrd.img.f864</initrd> <cmdline>console=ttyS0 console=tty0</cmdline> </os> <memory>540672</memory> <currentMemory>531456</currentMemory> <vcpu>1</vcpu> <on_poweroff>preserve</on_poweroff> <on_reboot>preserve</on_reboot> <on_crash>preserve</on_crash> <features> <acpi/> <apic/> <pae/> </features> <devices> <emulator>/usr/lib64/xen/bin/qemu-dm</emulator> <interface type='bridge'> <source bridge='xenbr0'/> <mac address='00:16:3e:0e:e8:b7'/> <script path='vif-bridge'/> </interface> <disk type='file' device='disk'> <driver name='file'/> <source file='/root/kernel.img'/> <target dev='hda'/> </disk> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' listen='0.0.0.0'/> <console tty='pty'/> </devices> </domain>
If we were to switch that domain to PV, the change would basically to remove os/loader and devices/emulator, change os/type to be linux, and then get kernel and initrd to point to the PV versions, right ?
Dan.
Index: src/xend_internal.c =================================================================== RCS file: /data/cvs/libvirt/src/xend_internal.c,v retrieving revision 1.165 diff -u -p -r1.165 xend_internal.c --- src/xend_internal.c 30 Jan 2008 16:38:18 -0000 1.165 +++ src/xend_internal.c 3 Feb 2008 18:37:17 -0000 @@ -1280,65 +1280,84 @@ xend_log(virConnectPtr xend, char *buffe static int xend_parse_sexp_desc_os(virConnectPtr xend, struct sexpr *node, virBufferPtr buf, int hvm, int bootloader) { - const char *tmp; + const char *loader = NULL; + const char *kernel = NULL; + const char *initrd = NULL; + const char *cmdline = NULL; + const char *root = NULL;
if (node == NULL || buf == NULL) { return(-1); }
virBufferAdd(buf, " <os>\n", 7); + if (hvm) + virBufferAdd(buf, " <type>hvm</type>\n", -1); + else + virBufferAdd(buf, " <type>linux</type>\n", -1); +
okay, unification, great !
- * Parse the OS part of the XML description for an HVM domain and add it to - * the S-Expr in buf. This is a temporary interface as the S-Expr interface - * will be replaced by XML-RPC in the future. However the XML format should - * stay valid over time. + * Parse the OS part of the XML description for a HVM domain + * and add it to the S-Expr in buf.
Hum :-)
+ /* + * Originally XenD abused the 'kernel' parameter for the HVM + * firmware. New XenD allows HVM guests to boot from a kernel + * and if this is enabled, the HVM firmware must use the new + * 'loader' parameter + */ + if (hasKernel) { + virBufferVSprintf(buf, "(loader '%s')", (const char *) loader); } else { virBufferVSprintf(buf, "(kernel '%s')", (const char *) loader); }
What happen if someone uses libvirt-0.4.1 with an old xend and an HVM with kernel XML description is given ? I suppose (kernel) gets ignored but it fails because the loader is not proper.
RCS file: /data/cvs/libvirt/tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr,v retrieving revision 1.2 diff -u -p -r1.2 xml2sexpr-fv-localtime.sexpr --- tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr 18 Jul 2007 21:08:22 -0000 1.2 +++ tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr 3 Feb 2008 18:37:17 -0000 @@ -1 +1 @@ -(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(vnc 1)(localtime 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu)))) \ No newline at end of file +(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(localtime 1)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
Humpf maybe we should add a indenting flag for sexpr2string and use it for regression tests, that's hard to read and near impossible to debug,
\ No newline at end of file and would avoid that EOL mess...
Looks good to me, +1 Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

On Mon, Feb 04, 2008 at 09:44:12AM -0500, Daniel Veillard wrote:
So basically Xen PV, Xen FV and KVM <os> blocks should now share the same set of functionalities, sharight the same syntax, right ? And the refactoring comes from the 3 being able to share more code, if yes that sounds excellent :-)
Almost the same. pv guests won't have use for a <boot dev="c"/> tag since they have no BIOS, nor do they have a <loader> tag, but other than that they're the same.
<domain type='xen'> <name>kernel</name> <uuid>06ed00fe-1162-4fc4-b5d8-11993ee4a8b9</uuid> <os> <type>hvm</type> <loader>/usr/lib/xen/boot/hvmloader</loader> <kernel>/root/vmlinuz.f864</kernel> <initrd>/root/initrd.img.f864</initrd> <cmdline>console=ttyS0 console=tty0</cmdline> </os> <memory>540672</memory> <currentMemory>531456</currentMemory> <vcpu>1</vcpu> <on_poweroff>preserve</on_poweroff> <on_reboot>preserve</on_reboot> <on_crash>preserve</on_crash> <features> <acpi/> <apic/> <pae/> </features> <devices> <emulator>/usr/lib64/xen/bin/qemu-dm</emulator> <interface type='bridge'> <source bridge='xenbr0'/> <mac address='00:16:3e:0e:e8:b7'/> <script path='vif-bridge'/> </interface> <disk type='file' device='disk'> <driver name='file'/> <source file='/root/kernel.img'/> <target dev='hda'/> </disk> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' listen='0.0.0.0'/> <console tty='pty'/> </devices> </domain>
If we were to switch that domain to PV, the change would basically to remove os/loader and devices/emulator, change os/type to be linux, and then get kernel and initrd to point to the PV versions, right ?
No need to get rid of devices/emulator - that's valid for paravirt guests too now - qemu-dm is used to provide the VNC / SDL framebuffer and text console in paravirt guests too now. So merely remove loader and the os/type to linux.
+ /* + * Originally XenD abused the 'kernel' parameter for the HVM + * firmware. New XenD allows HVM guests to boot from a kernel + * and if this is enabled, the HVM firmware must use the new + * 'loader' parameter + */ + if (hasKernel) { + virBufferVSprintf(buf, "(loader '%s')", (const char *) loader); } else { virBufferVSprintf(buf, "(kernel '%s')", (const char *) loader); }
What happen if someone uses libvirt-0.4.1 with an old xend and an HVM with kernel XML description is given ? I suppose (kernel) gets ignored but it fails because the loader is not proper.
Yep, user error. If they try to use a kernel+initrd on an old XenD there's nothing we can do to make it work. I don't want to do a Xen version check in libvirt though, because this kernel+initrd stuff is something I backport to the Xen currently in Fedora so any version check would be bogus. Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

Daniel P. Berrange wrote: [...] Looks good, but needs to update the documentation too. Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903

"Daniel P. Berrange" <berrange@redhat.com> wrote:
The latest xen-unstable tree has support for booting HVM guests using an explicit kernel+initrd+cmdline, as an alternative to the traditional BIOS boot from harddisk/cdrom/network. This gives Xen HVM parity with KVM in terms of boot methods. The current libvirt Xen driver though assumes that Xen paravirt is always kernel+initrd or bootloader based, while Xen HVM is always BIOS based. ...
This patch looks fine to me, too.

On Sun, 2008-02-03 at 18:47 +0000, Daniel P. Berrange wrote:
- - if ((str == NULL) || (strcmp(str, "hvm"))) { - res = virDomainParseXMLOSDescPV(conn, node, - &buf, ctxt, - xendConfigVersion); - } else { + if ((str != NULL) && STREQ(str, "hvm")) hvm = 1; - res = virDomainParseXMLOSDescHVM(conn, node, &buf, ctxt, - vcpus, xendConfigVersion); - } + xmlFree(str); + str = NULL;
- free(str); + if (hvm) + virBufferAdd(&buf, "(image (hvm ", 12); + else + virBufferAdd(&buf, "(image (linux ", 14);
Okay, I was seeing something weird that is at least somewhat related to this patch. This is with libvirt-0.4.0-5.fc9.i386 and python-virtinst cset 374:507a70e9ed10 Trying to do a paravirt install with virt-install I was seeing it blow up with "virDomainCreateLinux() failed XML description for domain is not well formed or invalid" The problem was <os><type>xen</type> Changing that to <os><type>linux</type> made it work fine Updating to libvirt CVS made it work fine too, since you now don't check that the os type is "linux" Dunno, haven't looked into this much and I'm not sure if it's of any real concern ... just thought I'd mention it. Cheers, Mark.

On Fri, Mar 07, 2008 at 02:50:03PM +0000, Mark McLoughlin wrote:
On Sun, 2008-02-03 at 18:47 +0000, Daniel P. Berrange wrote:
- - if ((str == NULL) || (strcmp(str, "hvm"))) { - res = virDomainParseXMLOSDescPV(conn, node, - &buf, ctxt, - xendConfigVersion); - } else { + if ((str != NULL) && STREQ(str, "hvm")) hvm = 1; - res = virDomainParseXMLOSDescHVM(conn, node, &buf, ctxt, - vcpus, xendConfigVersion); - } + xmlFree(str); + str = NULL;
- free(str); + if (hvm) + virBufferAdd(&buf, "(image (hvm ", 12); + else + virBufferAdd(&buf, "(image (linux ", 14);
Okay, I was seeing something weird that is at least somewhat related to this patch.
This is with libvirt-0.4.0-5.fc9.i386 and python-virtinst cset 374:507a70e9ed10
Trying to do a paravirt install with virt-install I was seeing it blow up with "virDomainCreateLinux() failed XML description for domain is not well formed or invalid"
The problem was <os><type>xen</type>
Changing that to <os><type>linux</type> made it work fine
Updating to libvirt CVS made it work fine too, since you now don't check that the os type is "linux"
Dunno, haven't looked into this much and I'm not sure if it's of any real concern ... just thought I'd mention it.
The problem is that the Xen driver expects the OS type to be 'linux' but the capabilities XML is advertising the OS type as 'xen'. Technically 'xen' is the correct value, since its refering to a guest ABI & the ABI is xen, not linux. Since we can't break XML semantics we have to stick with 'linux'. Thus I've added a workaround to make virt-install still use 'linux' if talking to the Xen driver. Dan. -- |: Red Hat, Engineering, Boston -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Sun, Mar 09, 2008 at 09:11:49PM +0000, Daniel P. Berrange wrote:
The problem is that the Xen driver expects the OS type to be 'linux' but the capabilities XML is advertising the OS type as 'xen'. Technically 'xen' is the correct value, since its refering to a guest ABI & the ABI is xen, not linux. Since we can't break XML semantics we have to stick with 'linux'. Thus I've added a workaround to make virt-install still use 'linux' if talking to the Xen driver.
Can we not make the Xen driver accept either? Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top

On Mon, Mar 10, 2008 at 11:33:49AM +0000, Richard W.M. Jones wrote:
On Sun, Mar 09, 2008 at 09:11:49PM +0000, Daniel P. Berrange wrote:
The problem is that the Xen driver expects the OS type to be 'linux' but the capabilities XML is advertising the OS type as 'xen'. Technically 'xen' is the correct value, since its refering to a guest ABI & the ABI is xen, not linux. Since we can't break XML semantics we have to stick with 'linux'. Thus I've added a workaround to make virt-install still use 'linux' if talking to the Xen driver.
Can we not make the Xen driver accept either?
It does accept either now - in fact it accepts anything which isn't 'hvm' for the paravirt case. I changed virt-install though so that it is compat with libvirt < 0.4.1, and when generating XML it'll still use 'linux' Dan. -- |: Red Hat, Engineering, Boston -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (5)
-
Daniel P. Berrange
-
Daniel Veillard
-
Jim Meyering
-
Mark McLoughlin
-
Richard W.M. Jones