update.log
libvirt.pc
libvirt.spec
+COPYING
\ No newline at end of file
+Tue Sep 11 20:11:05 EDT 2006 Daniel Berrange <berrange@redhat.com>
+
+ * src/xend_internal.c, src/xml.c: Added support for new 3.0.3
+ style XenD cdrom configuration for HVM guests.
+ * configure.in, tests/Makefile.am: Added new test directories
+ * tests/xml2sexprdata*, tests/sexpr2xmldata*: Removed config files
+ for test suite.
+ * tests/xml2sexprdata/*, tests/sexpr2xmldata/*: New home for test
+ suite config files
+
Tue Sep 5 13:50:05 MYT 2006 Daniel Veillard <veillard@redhat.com>
* NEWS configure.in docs//* include/libvirt/libvirt.h libvirt.specx.*:
include/libvirt/Makefile include/libvirt/libvirt.h \
python/Makefile python/tests/Makefile \
tests/Makefile proxy/Makefile \
+ tests/xml2sexprdata/Makefile \
+ tests/sexpr2xmldata/Makefile \
tests/virshdata/Makefile tests/confdata/Makefile)
return node;
}
+static int
+xend_get_config_version(virConnectPtr conn) {
+ int ret = -1;
+ struct sexpr *root;
+ const char *value;
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virXendError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ return (-1);
+ }
+
+ root = sexpr_get(conn, "/xend/node/");
+ if (root == NULL)
+ return (-1);
+
+ value = sexpr_node(root, "node/xend_config_format");
+
+ if (value) {
+ return strtol(value, NULL, 10);
+ } else {
+ /* Xen prior to 3.0.3 did not have the xend_config_format
+ field, and is implicitly version 1. */
+ return 1;
+ }
+
+ sexpr_free(root);
+ return (ret);
+}
+
+
#ifndef PROXY
/**
* xend_node_shutdown:
* the caller must free() the returned value.
*/
static char *
-xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root)
+xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root, int xendConfigVersion)
{
char *ret;
struct sexpr *cur, *node;
if (tmp == NULL)
continue;
if (!memcmp(tmp, "file:", 5)) {
- tmp += 5;
- virBufferVSprintf(&buf, " <disk type='file' device='disk'>\n");
- virBufferVSprintf(&buf, " <source file='%s'/>\n",
- tmp);
- tmp = sexpr_node(node, "device/vbd/dev");
- if (tmp == NULL) {
+ int cdrom = 0;
+ const char *src = tmp+5;
+ const char *dst = sexpr_node(node, "device/vbd/dev");
+
+ if (dst == NULL) {
virXendError(NULL, VIR_ERR_INTERNAL_ERROR,
"domain information incomplete, vbd has no dev");
goto error;
}
- if (!strncmp(tmp, "ioemu:", 6))
- tmp += 6;
- virBufferVSprintf(&buf, " <target dev='%s'/>\n", tmp);
+ if (!strncmp(dst, "ioemu:", 6))
+ dst += 6;
+ /* New style cdrom config from Xen >= 3.0.3 */
+ if (xendConfigVersion > 1) {
+ char *offset = rindex(dst, ':');
+ if (offset && !strcmp(offset, ":cdrom")) {
+ offset[0] = '\0';
+ cdrom = 1;
+ }
+ }
+
+ virBufferVSprintf(&buf, " <disk type='file' device='%s'>\n", cdrom ? "cdrom" : "disk");
+ virBufferVSprintf(&buf, " <source file='%s'/>\n", src);
+ virBufferVSprintf(&buf, " <target dev='%s'/>\n", dst);
tmp = sexpr_node(node, "device/vbd/mode");
+ /* XXX should we force mode == r, if cdrom==1, or assume
+ xend has already done this ? */
if ((tmp != NULL) && (!strcmp(tmp, "r")))
virBufferVSprintf(&buf, " <readonly/>\n");
virBufferAdd(&buf, " </disk>\n", 12);
} else if (!memcmp(tmp, "phy:", 4)) {
- tmp += 4;
- virBufferVSprintf(&buf, " <disk type='block' device='disk'>\n");
- virBufferVSprintf(&buf, " <source dev='%s'/>\n", tmp);
- tmp = sexpr_node(node, "device/vbd/dev");
- if (tmp == NULL) {
+ int cdrom = 0;
+ const char *src = tmp+4;
+ const char *dst = sexpr_node(node, "device/vbd/dev");
+
+ if (dst == NULL) {
virXendError(NULL, VIR_ERR_INTERNAL_ERROR,
"domain information incomplete, vbd has no dev");
goto error;
}
- if (!strncmp(tmp, "ioemu:", 6))
- tmp += 6;
- virBufferVSprintf(&buf, " <target dev='%s'/>\n", tmp);
+ if (!strncmp(dst, "ioemu:", 6))
+ dst += 6;
+ /* New style cdrom config from Xen >= 3.0.3 */
+ if (xendConfigVersion > 1) {
+ char *offset = rindex(dst, ':');
+ if (offset && !strcmp(offset, ":cdrom")) {
+ offset[0] = '\0';
+ cdrom = 1;
+ }
+ }
+
+ virBufferVSprintf(&buf, " <disk type='block' device='%s'>\n", cdrom ? "cdrom" : "disk");
+ virBufferVSprintf(&buf, " <source dev='%s'/>\n", src);
+ virBufferVSprintf(&buf, " <target dev='%s'/>\n", dst);
tmp = sexpr_node(node, "device/vbd/mode");
+ /* XXX should we force mode == r, if cdrom==1, or assume
+ xend has already done this ? */
if ((tmp != NULL) && (!strcmp(tmp, "r")))
virBufferVSprintf(&buf, " <readonly/>\n");
virBufferAdd(&buf, " </disk>\n", 12);
virBufferAdd(&buf, " <target dev='fdb'/>\n", 26);
virBufferAdd(&buf, " </disk>\n", 12);
}
- /* XXX new (3.0.3) Xend puts cdrom devs in usual (devices) block */
- tmp = sexpr_node(root, "domain/image/hvm/cdrom");
- if ((tmp != NULL) && (tmp[0] != 0)) {
- virBufferAdd(&buf, " <disk type='file' device='cdrom'>\n", 38);
- virBufferVSprintf(&buf, " <source file='%s'/>\n", tmp);
- virBufferAdd(&buf, " <target dev='hdc'/>\n", 26);
- virBufferAdd(&buf, " <readonly/>\n", 18);
- virBufferAdd(&buf, " </disk>\n", 12);
+
+ /* Old style cdrom config from Xen <= 3.0.2 */
+ if (xendConfigVersion == 1) {
+ tmp = sexpr_node(root, "domain/image/hvm/cdrom");
+ if ((tmp != NULL) && (tmp[0] != 0)) {
+ virBufferAdd(&buf, " <disk type='file' device='cdrom'>\n", 38);
+ virBufferVSprintf(&buf, " <source file='%s'/>\n", tmp);
+ virBufferAdd(&buf, " <target dev='hdc'/>\n", 26);
+ virBufferAdd(&buf, " <readonly/>\n", 18);
+ virBufferAdd(&buf, " </disk>\n", 12);
+ }
}
}
}
char *
-xend_parse_domain_sexp(virConnectPtr conn, char *sexpr) {
+xend_parse_domain_sexp(virConnectPtr conn, char *sexpr, int xendConfigVersion) {
struct sexpr *root = string2sexpr(sexpr);
char *data;
if (!root)
return NULL;
- data = xend_parse_sexp_desc(conn, root);
+ data = xend_parse_sexp_desc(conn, root, xendConfigVersion);
sexpr_free(root);
{
char *ret = NULL;
struct sexpr *root;
+ int xendConfigVersion;
root = sexpr_get(conn, "/xend/domain/%d?detail=1", domid);
if (root == NULL)
return (NULL);
- ret = xend_parse_sexp_desc(conn, root);
+ if ((xendConfigVersion = xend_get_config_version(conn)) < 0) {
+ virXendError(conn, VIR_ERR_INTERNAL_ERROR, "cannot determine xend config version");
+ return (NULL);
+ }
+
+ ret = xend_parse_sexp_desc(conn, root, xendConfigVersion);
sexpr_free(root);
return (ret);
char *sexpr;
char *name = NULL;
virDomainPtr dom;
+ int xendConfigVersion;
if (!VIR_IS_CONNECT(conn)) {
virXendError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
return (NULL);
}
- sexpr = virDomainParseXMLDesc(xmlDesc, &name);
+ if ((xendConfigVersion = xend_get_config_version(conn)) < 0) {
+ virXendError(conn, VIR_ERR_INTERNAL_ERROR, "cannot determine xend config version");
+ return (NULL);
+ }
+
+ sexpr = virDomainParseXMLDesc(xmlDesc, &name, xendConfigVersion);
if ((sexpr == NULL) || (name == NULL)) {
if (sexpr != NULL)
free(sexpr);
*/
int xend_log(virConnectPtr xend, char *buffer, size_t n_buffer);
- char *xend_parse_domain_sexp(virConnectPtr conn, char *root);
+ char *xend_parse_domain_sexp(virConnectPtr conn, char *root, int xendConfigVersion);
/* refactored ones */
void xenDaemonRegister(void);
* @node: node containing HVM 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 an HVM domain and add it to
* the S-Expr in buf. This is a temporary interface as the S-Expr interface
* Returns 0 in case of success, -1 in case of error.
*/
static int
-virDomainParseXMLOSDescHVM(xmlNodePtr node, virBufferPtr buf, xmlXPathContextPtr ctxt)
+virDomainParseXMLOSDescHVM(xmlNodePtr node, virBufferPtr buf, xmlXPathContextPtr ctxt, int xendConfigVersion)
{
xmlXPathObjectPtr obj = NULL;
xmlNodePtr cur, txt;
obj = xmlXPathEval(BAD_CAST "/domain/devices/disk[@device='floppy' and target/@dev='fda']/source", ctxt);
if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
(obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
- cur = obj->nodesetval->nodeTab[0];
- virBufferVSprintf(buf, "(fda '%s')",
- (const char *) xmlGetProp(cur, BAD_CAST "file"));
- cur = NULL;
+ cur = obj->nodesetval->nodeTab[0];
+ virBufferVSprintf(buf, "(fda '%s')",
+ (const char *) xmlGetProp(cur, BAD_CAST "file"));
+ cur = NULL;
}
if (obj) {
- xmlXPathFreeObject(obj);
- obj = NULL;
- }
+ xmlXPathFreeObject(obj);
+ obj = NULL;
+ }
/* get the 2nd floppy device file */
obj = xmlXPathEval(BAD_CAST "/domain/devices/disk[@device='floppy' and target/@dev='fdb']/source", ctxt);
if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
(obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
- cur = obj->nodesetval->nodeTab[0];
- virBufferVSprintf(buf, "(fdb '%s')",
- (const char *) xmlGetProp(cur, BAD_CAST "file"));
- cur = NULL;
+ cur = obj->nodesetval->nodeTab[0];
+ virBufferVSprintf(buf, "(fdb '%s')",
+ (const char *) xmlGetProp(cur, BAD_CAST "file"));
+ cur = NULL;
}
if (obj) {
- xmlXPathFreeObject(obj);
- obj = NULL;
+ xmlXPathFreeObject(obj);
+ obj = NULL;
}
/* get the cdrom device file */
- /* XXX new (3.0.3) Xend puts cdrom devs in usual (devices) block */
- obj = xmlXPathEval(BAD_CAST "/domain/devices/disk[@device='cdrom' and target/@dev='hdc']/source", ctxt);
- if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
- (obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
- cur = obj->nodesetval->nodeTab[0];
- virBufferVSprintf(buf, "(cdrom '%s')",
- (const char *) xmlGetProp(cur, BAD_CAST "file"));
- cur = NULL;
- }
- if (obj) {
- xmlXPathFreeObject(obj);
- obj = NULL;
+ /* Only XenD <= 3.0.2 wants cdrom config here */
+ if (xendConfigVersion == 1) {
+ obj = xmlXPathEval(BAD_CAST "/domain/devices/disk[@device='cdrom' and target/@dev='hdc']/source", ctxt);
+ if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
+ (obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
+ cur = obj->nodesetval->nodeTab[0];
+ virBufferVSprintf(buf, "(cdrom '%s')",
+ (const char *) xmlGetProp(cur, BAD_CAST "file"));
+ cur = NULL;
+ }
+ if (obj) {
+ xmlXPathFreeObject(obj);
+ obj = NULL;
+ }
}
obj = xmlXPathEval(BAD_CAST "/domain/features/acpi", ctxt);
* virDomainParseXMLDiskDesc:
* @node: node containing disk description
* @buf: a buffer for the result S-Expr
+ * @xendConfigVersion: xend configuration file format
*
* Parse the one disk in the XML description and add it to the S-Expr in buf
* This is a temporary interface as the S-Expr interface
* Returns 0 in case of success, -1 in case of error.
*/
static int
-virDomainParseXMLDiskDesc(xmlNodePtr node, virBufferPtr buf, int hvm)
+virDomainParseXMLDiskDesc(xmlNodePtr node, virBufferPtr buf, int hvm, int xendConfigVersion)
{
xmlNodePtr cur;
xmlChar *type = NULL;
xmlChar *target = NULL;
int ro = 0;
int typ = 0;
+ int cdrom = 0;
type = xmlGetProp(node, BAD_CAST "type");
if (type != NULL) {
return (-1);
}
- /* Skip floppy/cdrom disk used as the boot device
- * since that's incorporated into the HVM kernel
- * (image (hvm..)) part of the sexpr, rather than
- * the (devices...) bit. Odd Xend HVM config :-(
- * XXX This will have to change in Xen 3.0.3
+ /* Xend (all versions) put the floppy device config
+ * under the hvm (image (os)) block
*/
- if (hvm && device &&
- (!strcmp((const char *)device, "floppy") ||
- !strcmp((const char *)device, "cdrom"))) {
- return 0;
+ if (hvm &&
+ device &&
+ !strcmp((const char *)device, "floppy")) {
+ return 0;
+ }
+
+ /* Xend <= 3.0.2 doesn't include cdrom config here */
+ if (hvm &&
+ device &&
+ !strcmp((const char *)device, "cdrom")) {
+ if (xendConfigVersion == 1)
+ return 0;
+ else
+ cdrom = 1;
}
virBufferAdd(buf, "(device ", 8);
virBufferAdd(buf, "(vbd ", 5);
- /* XXX ioemu prefix is going away in Xen 3.0.3 */
+
if (hvm) {
char *tmp = (char *)target;
+ /* Just in case user mistakenly still puts ioemu: in their XML */
if (!strncmp((const char *) tmp, "ioemu:", 6))
tmp += 6;
- virBufferVSprintf(buf, "(dev 'ioemu:%s')", (const char *) tmp);
+
+ /* Xend <= 3.0.2 wants a ioemu: prefix on devices for HVM */
+ if (xendConfigVersion == 1)
+ virBufferVSprintf(buf, "(dev 'ioemu:%s')", (const char *) tmp);
+ else /* But newer does not */
+ virBufferVSprintf(buf, "(dev '%s%s')", (const char *) tmp, cdrom ? ":cdrom" : "");
} else
- virBufferVSprintf(buf, "(dev '%s')", (const char *) target);
+ virBufferVSprintf(buf, "(dev '%s')", (const char *) target);
+
if (typ == 0)
virBufferVSprintf(buf, "(uname 'file:%s')", source);
else if (typ == 1) {
/**
* virDomainParseXMLDesc:
* @xmldesc: string with the XML description
+ * @xendConfigVersion: xend configuration file format
*
* Parse the XML description and turn it into the xend sexp needed to
* create the comain. This is a temporary interface as the S-Expr interface
* the caller must free() the returned value.
*/
char *
-virDomainParseXMLDesc(const char *xmldesc, char **name)
+virDomainParseXMLDesc(const char *xmldesc, char **name, int xendConfigVersion)
{
xmlDocPtr xml = NULL;
xmlNodePtr node;
res = virDomainParseXMLOSDescPV(obj->nodesetval->nodeTab[0], &buf, ctxt);
} else {
hvm = 1;
- res = virDomainParseXMLOSDescHVM(obj->nodesetval->nodeTab[0], &buf, ctxt);
+ res = virDomainParseXMLOSDescHVM(obj->nodesetval->nodeTab[0], &buf, ctxt, xendConfigVersion);
}
xmlXPathFreeObject(tmpobj);
if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
(obj->nodesetval != NULL) && (obj->nodesetval->nodeNr >= 0)) {
for (i = 0; i < obj->nodesetval->nodeNr; i++) {
- res = virDomainParseXMLDiskDesc(obj->nodesetval->nodeTab[i], &buf, hvm);
+ res = virDomainParseXMLDiskDesc(obj->nodesetval->nodeTab[i], &buf, hvm, xendConfigVersion);
if (res != 0) {
goto error;
}
int virBufferAdd(virBufferPtr buf, const char *str, int len);
int virBufferVSprintf(virBufferPtr buf, const char *format, ...);
int virBufferStrcat(virBufferPtr buf, ...);
-char *virDomainParseXMLDesc(const char *xmldesc, char **name);
+char *virDomainParseXMLDesc(const char *xmldesc, char **name, int xendConfigVersion);
unsigned char *virParseUUID(char **ptr, const char *uuid);
#ifdef __cplusplus
## Process this file with automake to produce Makefile.in
-SUBDIRS = virshdata confdata
+SUBDIRS = virshdata confdata sexpr2xmldata xml2sexprdata
LIBVIRT = $(top_builddir)/src/.libs/libvirt.a
+++ /dev/null
-(domain (domid 3)(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')(boot c)(cdrom '/root/boot.iso')(acpi 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))))
+++ /dev/null
-<domain type='xen' id='3'>
- <name>fvtest</name>
- <uuid>b5d70dd275cdaca517769660b059d8bc</uuid>
- <os>
- <type>hvm</type>
- <loader>/usr/lib/xen/boot/hvmloader</loader>
- <boot dev='hd'/>
- </os>
- <memory>409600</memory>
- <vcpu>1</vcpu>
- <on_poweroff>destroy</on_poweroff>
- <on_reboot>restart</on_reboot>
- <on_crash>restart</on_crash>
- <features>
- <acpi/>
- </features>
- <devices>
- <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
- <disk type='file' device='disk'>
- <source file='/root/foo.img'/>
- <target dev='hda'/>
- </disk>
- <interface type='bridge'>
- <source bridge='xenbr0'/>
- <mac address='00:16:3e:1b:b1:47'/>
- <script path='vif-bridge'/>
- </interface>
- <disk type='file' device='cdrom'>
- <source file='/root/boot.iso'/>
- <target dev='hdc'/>
- <readonly/>
- </disk>
- <graphics type='vnc' port='5903'/>
- </devices>
-</domain>
+++ /dev/null
-(domain (domid 6)(name 'pvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d2171f48fb2e068e2386a5c413e')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(image (linux (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_64/os ')))(device (vbd (dev 'xvda')(uname 'file:/root/some.img')(mode 'w'))))
-
+++ /dev/null
-<domain type='xen' id='6'>
- <name>pvtest</name>
- <uuid>596a5d2171f48fb2e068e2386a5c413e</uuid>
- <os>
- <type>linux</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_64/os </cmdline>
- </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>
- </devices>
-</domain>
--- /dev/null
+Makefile
+Makefile.in
--- /dev/null
+
+EXTRA_DIST = $(wildcard *.xml) $(wildcard *.sexpr)
--- /dev/null
+(domain (domid 3)(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')(boot c)(acpi 1)(vnc 1)))(device (vbd (dev 'hdc:cdrom')(uname 'file:/root/boot.iso')(mode 'r')))(device (vbd (dev 'hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
--- /dev/null
+<domain type='xen' id='3'>
+ <name>fvtest</name>
+ <uuid>b5d70dd275cdaca517769660b059d8bc</uuid>
+ <os>
+ <type>hvm</type>
+ <loader>/usr/lib/xen/boot/hvmloader</loader>
+ <boot dev='hd'/>
+ </os>
+ <memory>409600</memory>
+ <vcpu>1</vcpu>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <features>
+ <acpi/>
+ </features>
+ <devices>
+ <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
+ <disk type='file' device='cdrom'>
+ <source file='/root/boot.iso'/>
+ <target dev='hdc'/>
+ <readonly/>
+ </disk>
+ <disk type='file' device='disk'>
+ <source file='/root/foo.img'/>
+ <target dev='hda'/>
+ </disk>
+ <interface type='bridge'>
+ <source bridge='xenbr0'/>
+ <mac address='00:16:3e:1b:b1:47'/>
+ <script path='vif-bridge'/>
+ </interface>
+ <graphics type='vnc' port='5903'/>
+ </devices>
+</domain>
--- /dev/null
+(domain (domid 3)(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')(boot c)(cdrom '/root/boot.iso')(acpi 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))))
--- /dev/null
+<domain type='xen' id='3'>
+ <name>fvtest</name>
+ <uuid>b5d70dd275cdaca517769660b059d8bc</uuid>
+ <os>
+ <type>hvm</type>
+ <loader>/usr/lib/xen/boot/hvmloader</loader>
+ <boot dev='hd'/>
+ </os>
+ <memory>409600</memory>
+ <vcpu>1</vcpu>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <features>
+ <acpi/>
+ </features>
+ <devices>
+ <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
+ <disk type='file' device='disk'>
+ <source file='/root/foo.img'/>
+ <target dev='hda'/>
+ </disk>
+ <interface type='bridge'>
+ <source bridge='xenbr0'/>
+ <mac address='00:16:3e:1b:b1:47'/>
+ <script path='vif-bridge'/>
+ </interface>
+ <disk type='file' device='cdrom'>
+ <source file='/root/boot.iso'/>
+ <target dev='hdc'/>
+ <readonly/>
+ </disk>
+ <graphics type='vnc' port='5903'/>
+ </devices>
+</domain>
--- /dev/null
+(domain (domid 6)(name 'pvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d2171f48fb2e068e2386a5c413e')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(image (linux (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_64/os ')))(device (vbd (dev 'xvda')(uname 'file:/root/some.img')(mode 'w'))))
+
--- /dev/null
+<domain type='xen' id='6'>
+ <name>pvtest</name>
+ <uuid>596a5d2171f48fb2e068e2386a5c413e</uuid>
+ <os>
+ <type>linux</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_64/os </cmdline>
+ </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>
+ </devices>
+</domain>
#define MAX_FILE 4096
-static int testCompareFiles(const char *xml, const char *sexpr) {
+static int testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion) {
char xmlData[MAX_FILE];
char sexprData[MAX_FILE];
char *gotxml = NULL;
if (virtTestLoadFile(sexpr, &sexprPtr, MAX_FILE) < 0)
return -1;
- if (!(gotxml = xend_parse_domain_sexp(NULL, sexprData)))
+ if (!(gotxml = xend_parse_domain_sexp(NULL, sexprData, xendConfigVersion)))
return -1;
if (getenv("DEBUG_TESTS")) {
return 0;
}
-static int testComparePV(void *data ATTRIBUTE_UNUSED) {
- return testCompareFiles("sexpr2xml-pv.xml",
- "sexpr2xml-pv.sexpr");
+static int testComparePVversion1(void *data ATTRIBUTE_UNUSED) {
+ return testCompareFiles("sexpr2xmldata/sexpr2xml-pv.xml",
+ "sexpr2xmldata/sexpr2xml-pv.sexpr",
+ 1);
}
-static int testCompareFV(void *data ATTRIBUTE_UNUSED) {
- return testCompareFiles("sexpr2xml-fv.xml",
- "sexpr2xml-fv.sexpr");
+static int testCompareFVversion1(void *data ATTRIBUTE_UNUSED) {
+ return testCompareFiles("sexpr2xmldata/sexpr2xml-fv.xml",
+ "sexpr2xmldata/sexpr2xml-fv.sexpr",
+ 1);
+}
+
+static int testComparePVversion2(void *data ATTRIBUTE_UNUSED) {
+ return testCompareFiles("sexpr2xmldata/sexpr2xml-pv.xml",
+ "sexpr2xmldata/sexpr2xml-pv.sexpr",
+ 2);
+}
+
+static int testCompareFVversion2(void *data ATTRIBUTE_UNUSED) {
+ return testCompareFiles("sexpr2xmldata/sexpr2xml-fv-v2.xml",
+ "sexpr2xmldata/sexpr2xml-fv-v2.sexpr",
+ 2);
}
int
exit(EXIT_FAILURE);
}
- if (virtTestRun("SEXPR-2-XML PV config",
- 1, testComparePV, NULL) != 0)
+ if (virtTestRun("SEXPR-2-XML PV config (version 1)",
+ 1, testComparePVversion1, NULL) != 0)
+ ret = -1;
+
+ if (virtTestRun("SEXPR-2-XML FV config (version 1)",
+ 1, testCompareFVversion1, NULL) != 0)
+ ret = -1;
+
+ if (virtTestRun("SEXPR-2-XML PV config (version 2)",
+ 1, testComparePVversion2, NULL) != 0)
ret = -1;
- if (virtTestRun("SEXPR-2-XML FV config",
- 1, testCompareFV, NULL) != 0)
+ if (virtTestRun("SEXPR-2-XML FV config (version 2)",
+ 1, testCompareFVversion2, NULL) != 0)
ret = -1;
exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
+++ /dev/null
-(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')(boot c)(cdrom '/root/boot.iso')(acpi 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
+++ /dev/null
-<domain type='xen'>
- <name>fvtest</name>
- <uuid>b5d70dd275cdaca517769660b059d8bc</uuid>
- <os>
- <type>hvm</type>
- <loader>/usr/lib/xen/boot/hvmloader</loader>
- <boot dev='hd'/>
- </os>
- <memory>409600</memory>
- <vcpu>1</vcpu>
- <on_poweroff>destroy</on_poweroff>
- <on_reboot>restart</on_reboot>
- <on_crash>restart</on_crash>
- <features>
- <acpi/>
- </features>
- <devices>
- <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
- <interface type='bridge'>
- <source bridge='xenbr0'/>
- <mac address='00:16:3e:1b:b1:47'/>
- <script path='vif-bridge'/>
- </interface>
- <disk type='file' device='cdrom'>
- <source file='/root/boot.iso'/>
- <target dev='hdc'/>
- <readonly/>
- </disk>
- <disk type='file'>
- <source file='/root/foo.img'/>
- <target dev='ioemu:hda'/>
- </disk>
- <graphics type='vnc' port='5917'/>
- </devices>
-</domain>
-
+++ /dev/null
-(vm (name 'pvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d2171f48fb2e068e2386a5c413e')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(image (linux (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_64/os ')))(device (vbd (dev 'xvda')(uname 'file:/root/some.img')(mode 'w'))))
\ No newline at end of file
+++ /dev/null
-<domain type='xen' id='15'>
- <name>pvtest</name>
- <uuid>596a5d2171f48fb2e068e2386a5c413e</uuid>
- <os>
- <type>linux</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_64/os </cmdline>
- </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>
-
--- /dev/null
+Makefile
+Makefile.in
--- /dev/null
+
+EXTRA_DIST = $(wildcard *.xml) $(wildcard *.sexpr)
--- /dev/null
+(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')(boot c)(acpi 1)(vnc 1)))(device (vbd (dev 'hdc:cdrom')(uname 'file:/root/boot.iso')(mode 'r')))(device (vbd (dev '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
--- /dev/null
+(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')(boot c)(cdrom '/root/boot.iso')(acpi 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
--- /dev/null
+<domain type='xen'>
+ <name>fvtest</name>
+ <uuid>b5d70dd275cdaca517769660b059d8bc</uuid>
+ <os>
+ <type>hvm</type>
+ <loader>/usr/lib/xen/boot/hvmloader</loader>
+ <boot dev='hd'/>
+ </os>
+ <memory>409600</memory>
+ <vcpu>1</vcpu>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <features>
+ <acpi/>
+ </features>
+ <devices>
+ <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
+ <interface type='bridge'>
+ <source bridge='xenbr0'/>
+ <mac address='00:16:3e:1b:b1:47'/>
+ <script path='vif-bridge'/>
+ </interface>
+ <disk type='file' device='cdrom'>
+ <source file='/root/boot.iso'/>
+ <target dev='hdc'/>
+ <readonly/>
+ </disk>
+ <disk type='file'>
+ <source file='/root/foo.img'/>
+ <target dev='ioemu:hda'/>
+ </disk>
+ <graphics type='vnc' port='5917'/>
+ </devices>
+</domain>
+
--- /dev/null
+(vm (name 'pvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d2171f48fb2e068e2386a5c413e')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(image (linux (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_64/os ')))(device (vbd (dev 'xvda')(uname 'file:/root/some.img')(mode 'w'))))
\ No newline at end of file
--- /dev/null
+<domain type='xen' id='15'>
+ <name>pvtest</name>
+ <uuid>596a5d2171f48fb2e068e2386a5c413e</uuid>
+ <os>
+ <type>linux</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_64/os </cmdline>
+ </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>
+
#define MAX_FILE 4096
-static int testCompareFiles(const char *xml, const char *sexpr, const char *name) {
+static int testCompareFiles(const char *xml, const char *sexpr, const char *name, int xendConfigVersion) {
char xmlData[MAX_FILE];
char sexprData[MAX_FILE];
char *gotname = NULL;
if (virtTestLoadFile(sexpr, &sexprPtr, MAX_FILE) < 0)
return -1;
- if (!(gotsexpr = virDomainParseXMLDesc(xmlData, &gotname)))
+ if (!(gotsexpr = virDomainParseXMLDesc(xmlData, &gotname, xendConfigVersion)))
return -1;
if (getenv("DEBUG_TESTS")) {
return 0;
}
-static int testComparePV(void *data ATTRIBUTE_UNUSED) {
- return testCompareFiles("xml2sexpr-pv.xml",
- "xml2sexpr-pv.sexpr",
- "pvtest");
+static int testComparePVversion1(void *data ATTRIBUTE_UNUSED) {
+ return testCompareFiles("xml2sexprdata/xml2sexpr-pv.xml",
+ "xml2sexprdata/xml2sexpr-pv.sexpr",
+ "pvtest",
+ 1);
}
-static int testCompareFV(void *data ATTRIBUTE_UNUSED) {
- return testCompareFiles("xml2sexpr-fv.xml",
- "xml2sexpr-fv.sexpr",
- "fvtest");
+static int testCompareFVversion1(void *data ATTRIBUTE_UNUSED) {
+ return testCompareFiles("xml2sexprdata/xml2sexpr-fv.xml",
+ "xml2sexprdata/xml2sexpr-fv.sexpr",
+ "fvtest",
+ 1);
+}
+
+static int testComparePVversion2(void *data ATTRIBUTE_UNUSED) {
+ return testCompareFiles("xml2sexprdata/xml2sexpr-pv.xml",
+ "xml2sexprdata/xml2sexpr-pv.sexpr",
+ "pvtest",
+ 2);
+}
+
+static int testCompareFVversion2(void *data ATTRIBUTE_UNUSED) {
+ return testCompareFiles("xml2sexprdata/xml2sexpr-fv.xml",
+ "xml2sexprdata/xml2sexpr-fv-v2.sexpr",
+ "fvtest",
+ 2);
}
int
exit(EXIT_FAILURE);
}
- if (virtTestRun("XML-2-SEXPR PV config",
- 1, testComparePV, NULL) != 0)
+ if (virtTestRun("XML-2-SEXPR PV config (format 1)",
+ 1, testComparePVversion1, NULL) != 0)
+ ret = -1;
+
+ if (virtTestRun("XML-2-SEXPR FV config (format 1)",
+ 1, testCompareFVversion1, NULL) != 0)
+ ret = -1;
+
+ if (virtTestRun("XML-2-SEXPR PV config (format 2)",
+ 1, testComparePVversion2, NULL) != 0)
ret = -1;
- if (virtTestRun("XML-2-SEXPR FV config",
- 1, testCompareFV, NULL) != 0)
+ if (virtTestRun("XML-2-SEXPR FV config (format 2)",
+ 1, testCompareFVversion2, NULL) != 0)
ret = -1;
exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);