diff --git a/tests/Makefile.am b/tests/Makefile.am
index a3661f61c0a77192c9671813dd1d62a20bc310f6..71c2c74e266b53ad10e8fcd3f08b8260ec8e71d2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -43,6 +43,7 @@ EXTRA_DIST = \
oomtrace.pl \
test-lib.sh \
qemuxml2argvdata \
+ qemuxml2xmloutdata \
nodeinfodata \
schematestutils.sh \
capabilityschematest \
diff --git a/tests/domainschematest b/tests/domainschematest
index d513f5adf4d9fa9719524d0dd178d3cfb98dcf8b..7557cef5d6b0c9c2eaaec30f5b757f20f9b9cd9d 100755
--- a/tests/domainschematest
+++ b/tests/domainschematest
@@ -4,7 +4,7 @@
. $srcdir/test-lib.sh
. $abs_srcdir/schematestutils.sh
-DIRS="domainschemadata qemuxml2argvdata sexpr2xmldata xmconfigdata xml2sexprdata"
+DIRS="domainschemadata qemuxml2argvdata sexpr2xmldata xmconfigdata xml2sexprdata qemuxml2xmloutdata"
SCHEMA="domain.rng"
check_schema "$DIRS" "$SCHEMA"
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.args b/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.args
new file mode 100644
index 0000000000000000000000000000000000000000..08f0b8a7a4ca1c4071a6c3210ed88ba8a82a46b6
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.xml b/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.xml
new file mode 100644
index 0000000000000000000000000000000000000000..26c9b259431d75a0720cc8b2f1b2e3056ac72965
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.xml
@@ -0,0 +1,22 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219200
+ 219200
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.args b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.args
new file mode 100644
index 0000000000000000000000000000000000000000..fd42462f97252222cf412f93e93f5905454dd35b
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial pty -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.xml b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.xml
new file mode 100644
index 0000000000000000000000000000000000000000..f0e875e3a7772bd64a127ac5965fcbf6f176afb7
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.xml
@@ -0,0 +1,28 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219200
+ 219200
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.args
new file mode 100644
index 0000000000000000000000000000000000000000..e29a4e8137b70d7ed225670e6b4737f0970d9ab6
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -device lsi,id=scsi0,bus=pci.0,addr=0x2 -drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-ide0-0-0 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -drive file=/tmp/scsidisk.img,if=none,id=drive-scsi0-0-0 -device scsi-disk,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0 -usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.xml
new file mode 100644
index 0000000000000000000000000000000000000000..df50a27d7da5a52d1449d7237ab7d22b39858d72
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.xml
@@ -0,0 +1,28 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219200
+ 219200
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.args
new file mode 100644
index 0000000000000000000000000000000000000000..e29a4e8137b70d7ed225670e6b4737f0970d9ab6
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -device lsi,id=scsi0,bus=pci.0,addr=0x2 -drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-ide0-0-0 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -drive file=/tmp/scsidisk.img,if=none,id=drive-scsi0-0-0 -device scsi-disk,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0 -usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.xml
new file mode 100644
index 0000000000000000000000000000000000000000..a250940fa5942b90f6df8c6e90ee88f43979f73d
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.xml
@@ -0,0 +1,31 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219200
+ 219200
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 0ca98042c2a8481943bb2ad8f15008e097c352dc..a967fef2b1d2717047c9ce4bebee7c03bd2e0e02 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -275,6 +275,10 @@ mymain(int argc, char **argv)
DO_TEST("disk-usb", 0);
DO_TEST("disk-usb-device", QEMUD_CMD_FLAG_DRIVE |
QEMUD_CMD_FLAG_DEVICE | QEMUD_CMD_FLAG_NODEFCONFIG);
+ DO_TEST("disk-scsi-device", QEMUD_CMD_FLAG_DRIVE |
+ QEMUD_CMD_FLAG_DEVICE | QEMUD_CMD_FLAG_NODEFCONFIG);
+ DO_TEST("disk-scsi-device-auto", QEMUD_CMD_FLAG_DRIVE |
+ QEMUD_CMD_FLAG_DEVICE | QEMUD_CMD_FLAG_NODEFCONFIG);
DO_TEST("graphics-vnc", 0);
driver.vncSASL = 1;
@@ -320,6 +324,7 @@ mymain(int argc, char **argv)
DO_TEST("serial-many", 0);
DO_TEST("parallel-tcp", 0);
DO_TEST("console-compat", 0);
+ DO_TEST("console-compat-auto", 0);
DO_TEST("serial-vc-chardev", QEMUD_CMD_FLAG_CHARDEV|QEMUD_CMD_FLAG_DEVICE |
QEMUD_CMD_FLAG_NODEFCONFIG);
@@ -356,6 +361,8 @@ mymain(int argc, char **argv)
QEMUD_CMD_FLAG_NODEFCONFIG);
DO_TEST("balloon-device", QEMUD_CMD_FLAG_DEVICE |
QEMUD_CMD_FLAG_NODEFCONFIG);
+ DO_TEST("balloon-device-auto", QEMUD_CMD_FLAG_DEVICE |
+ QEMUD_CMD_FLAG_NODEFCONFIG);
DO_TEST("sound", 0);
DO_TEST("sound-device", QEMUD_CMD_FLAG_DEVICE |
QEMUD_CMD_FLAG_NODEFCONFIG);
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-balloon-device-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-balloon-device-auto.xml
new file mode 100644
index 0000000000000000000000000000000000000000..ed91e37a128f1094155e7c114cf81abc25110807
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-balloon-device-auto.xml
@@ -0,0 +1,25 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219200
+ 219200
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml
new file mode 100644
index 0000000000000000000000000000000000000000..79903748c6f1fc6289a913a43d44fdcf58df8c15
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml
@@ -0,0 +1,54 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219200
+ 219200
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml
new file mode 100644
index 0000000000000000000000000000000000000000..611ddb8d7b53ca67a3911a7372036d5f76b78c68
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml
@@ -0,0 +1,31 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219200
+ 219200
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-scsi-device-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-scsi-device-auto.xml
new file mode 100644
index 0000000000000000000000000000000000000000..a250940fa5942b90f6df8c6e90ee88f43979f73d
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-scsi-device-auto.xml
@@ -0,0 +1,31 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219200
+ 219200
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 00b3a1b188b379ab8c1875156627bda905bd9660..0f4c83cb840f33121f5b13a405a2e1ddb8f3018d 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -22,41 +22,63 @@ static struct qemud_driver driver;
# define MAX_FILE 4096
-static int testCompareXMLToXMLFiles(const char *xml) {
- char xmlData[MAX_FILE];
- char *xmlPtr = &(xmlData[0]);
+static int testCompareXMLToXMLFiles(const char *inxml, const char *outxml) {
+ char inXmlData[MAX_FILE];
+ char *inXmlPtr = &(inXmlData[0]);
+ char outXmlData[MAX_FILE];
+ char *outXmlPtr = &(outXmlData[0]);
char *actual = NULL;
int ret = -1;
- virDomainDefPtr vmdef = NULL;
+ virDomainDefPtr def = NULL;
- if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
+ if (virtTestLoadFile(inxml, &inXmlPtr, MAX_FILE) < 0)
+ goto fail;
+ if (virtTestLoadFile(outxml, &outXmlPtr, MAX_FILE) < 0)
goto fail;
- if (!(vmdef = virDomainDefParseString(driver.caps, xmlData,
+ if (!(def = virDomainDefParseString(driver.caps, inXmlData,
VIR_DOMAIN_XML_INACTIVE)))
goto fail;
- if (!(actual = virDomainDefFormat(vmdef, 0)))
+ if (!(actual = virDomainDefFormat(def, 0)))
goto fail;
- if (STRNEQ(xmlData, actual)) {
- virtTestDifference(stderr, xmlData, actual);
+
+ if (STRNEQ(outXmlData, actual)) {
+ virtTestDifference(stderr, outXmlData, actual);
goto fail;
}
ret = 0;
-
fail:
free(actual);
- virDomainDefFree(vmdef);
+ virDomainDefFree(def);
return ret;
}
+struct testInfo {
+ const char *name;
+ int different;
+};
+
static int testCompareXMLToXMLHelper(const void *data) {
- char xml[PATH_MAX];
- snprintf(xml, PATH_MAX, "%s/qemuxml2argvdata/qemuxml2argv-%s.xml",
- abs_srcdir, (const char*)data);
- return testCompareXMLToXMLFiles(xml);
+ const struct testInfo *info = data;
+ char xml_in[PATH_MAX];
+ char xml_out[PATH_MAX];
+ int ret;
+
+ snprintf(xml_in, PATH_MAX, "%s/qemuxml2argvdata/qemuxml2argv-%s.xml",
+ abs_srcdir, info->name);
+ snprintf(xml_out, PATH_MAX, "%s/qemuxml2xmloutdata/qemuxml2xmlout-%s.xml",
+ abs_srcdir, info->name);
+
+ if (info->different) {
+ ret = testCompareXMLToXMLFiles(xml_in, xml_out);
+ } else {
+ ret = testCompareXMLToXMLFiles(xml_in, xml_in);
+ }
+
+ return ret;
}
@@ -80,10 +102,24 @@ mymain(int argc, char **argv)
if ((driver.caps = testQemuCapsInit()) == NULL)
return (EXIT_FAILURE);
+# define DO_TEST_FULL(name, is_different) \
+ do { \
+ const struct testInfo info = {name, is_different}; \
+ if (virtTestRun("QEMU XML-2-XML " name, \
+ 1, testCompareXMLToXMLHelper, &info) < 0) \
+ ret = -1; \
+ } while (0)
+
# define DO_TEST(name) \
- if (virtTestRun("QEMU XML-2-XML " name, \
- 1, testCompareXMLToXMLHelper, (name)) < 0) \
- ret = -1
+ DO_TEST_FULL(name, 0)
+
+# define DO_TEST_DIFFERENT(name) \
+ DO_TEST_FULL(name, 1)
+
+ /* Unset or set all envvars here that are copied in qemudBuildCommandLine
+ * using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
+ * values for these envvars */
+ setenv("PATH", "/bin", 1);
DO_TEST("minimal");
DO_TEST("boot-cdrom");
@@ -107,6 +143,7 @@ mymain(int argc, char **argv)
DO_TEST("disk-drive-cache-v1-wt");
DO_TEST("disk-drive-cache-v1-wb");
DO_TEST("disk-drive-cache-v1-none");
+ DO_TEST("disk-scsi-device");
DO_TEST("graphics-vnc");
DO_TEST("graphics-vnc-sasl");
DO_TEST("graphics-vnc-tls");
@@ -142,6 +179,12 @@ mymain(int argc, char **argv)
DO_TEST("encrypted-disk");
+ /* These tests generate different XML */
+ DO_TEST_DIFFERENT("balloon-device-auto");
+ DO_TEST_DIFFERENT("channel-virtio-auto");
+ DO_TEST_DIFFERENT("console-compat-auto");
+ DO_TEST_DIFFERENT("disk-scsi-device-auto");
+
virCapabilitiesFree(driver.caps);
return (ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);