mirror of https://gitee.com/openkylin/libvirt.git
tests: Test qemuxml2xml when expected xml changes
Add tests for auto memballon, implicit IDE, SCSI, virtio channel controllers, and console/serial back compat. Additionally, an explicit qemuxml2argvtest for scsi disks is added. Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
e4fb6a3c7d
commit
b2a4a383d3
|
@ -43,6 +43,7 @@ EXTRA_DIST = \
|
|||
oomtrace.pl \
|
||||
test-lib.sh \
|
||||
qemuxml2argvdata \
|
||||
qemuxml2xmloutdata \
|
||||
nodeinfodata \
|
||||
schematestutils.sh \
|
||||
capabilityschematest \
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
|
@ -0,0 +1,22 @@
|
|||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory>219200</memory>
|
||||
<currentMemory>219200</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch='i686' machine='pc'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<disk type='block' device='disk'>
|
||||
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||
<target dev='hda' bus='ide'/>
|
||||
</disk>
|
||||
</devices>
|
||||
</domain>
|
|
@ -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
|
|
@ -0,0 +1,28 @@
|
|||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory>219200</memory>
|
||||
<currentMemory>219200</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch='i686' machine='pc'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<disk type='block' device='disk'>
|
||||
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||
<target dev='hda' bus='ide'/>
|
||||
<address type='drive' controller='0' bus='0' unit='0'/>
|
||||
</disk>
|
||||
<controller type='ide' index='0'/>
|
||||
<console type='pty'>
|
||||
<target port='0'/>
|
||||
</console>
|
||||
<memballoon model='virtio'/>
|
||||
</devices>
|
||||
</domain>
|
|
@ -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
|
|
@ -0,0 +1,28 @@
|
|||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory>219200</memory>
|
||||
<currentMemory>219200</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch='i686' machine='pc'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<disk type='block' device='disk'>
|
||||
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||
<target dev='hda' bus='ide'/>
|
||||
</disk>
|
||||
<controller type='ide' index='0'/>
|
||||
<disk type='file' device='disk'>
|
||||
<source file='/tmp/scsidisk.img'/>
|
||||
<target dev='sda' bus='scsi'/>
|
||||
</disk>
|
||||
<memballoon model='virtio'/>
|
||||
</devices>
|
||||
</domain>
|
|
@ -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
|
|
@ -0,0 +1,31 @@
|
|||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory>219200</memory>
|
||||
<currentMemory>219200</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch='i686' machine='pc'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<disk type='block' device='disk'>
|
||||
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||
<target dev='hda' bus='ide'/>
|
||||
<address type='drive' controller='0' bus='0' unit='0'/>
|
||||
</disk>
|
||||
<disk type='file' device='disk'>
|
||||
<source file='/tmp/scsidisk.img'/>
|
||||
<target dev='sda' bus='scsi'/>
|
||||
<address type='drive' controller='0' bus='0' unit='0'/>
|
||||
</disk>
|
||||
<controller type='ide' index='0'/>
|
||||
<controller type='scsi' index='0'/>
|
||||
<memballoon model='virtio'/>
|
||||
</devices>
|
||||
</domain>
|
|
@ -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);
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory>219200</memory>
|
||||
<currentMemory>219200</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch='i686' machine='pc'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<disk type='block' device='disk'>
|
||||
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||
<target dev='hda' bus='ide'/>
|
||||
<address type='drive' controller='0' bus='0' unit='0'/>
|
||||
</disk>
|
||||
<controller type='ide' index='0'/>
|
||||
<memballoon model='virtio'/>
|
||||
</devices>
|
||||
</domain>
|
|
@ -0,0 +1,54 @@
|
|||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory>219200</memory>
|
||||
<currentMemory>219200</currentMemory>
|
||||
<vcpu cpuset='1-4,8-20,525'>1</vcpu>
|
||||
<os>
|
||||
<type arch='i686' machine='pc'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<disk type='block' device='disk'>
|
||||
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||
<target dev='hda' bus='ide'/>
|
||||
<address type='drive' controller='0' bus='0' unit='0'/>
|
||||
</disk>
|
||||
<controller type='ide' index='0'/>
|
||||
<controller type='virtio-serial' index='0' ports='16' vectors='4'/>
|
||||
<controller type='virtio-serial' index='1'>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
|
||||
</controller>
|
||||
<controller type='virtio-serial' index='2'/>
|
||||
<channel type='pty'>
|
||||
<target type='virtio' name='org.linux-kvm.port.0'/>
|
||||
<address type='virtio-serial' controller='0' bus='0' port='0'/>
|
||||
</channel>
|
||||
<channel type='pty'>
|
||||
<target type='virtio' name='org.linux-kvm.port.foo'/>
|
||||
<address type='virtio-serial' controller='1' bus='0' port='0'/>
|
||||
</channel>
|
||||
<channel type='pty'>
|
||||
<target type='virtio' name='org.linux-kvm.port.bar'/>
|
||||
<address type='virtio-serial' controller='1' bus='0' port='3'/>
|
||||
</channel>
|
||||
<channel type='pty'>
|
||||
<target type='virtio' name='org.linux-kvm.port.wizz'/>
|
||||
<address type='virtio-serial' controller='0' bus='0' port='1'/>
|
||||
</channel>
|
||||
<channel type='pty'>
|
||||
<target type='virtio' name='org.linux-kvm.port.ooh'/>
|
||||
<address type='virtio-serial' controller='1' bus='0' port='4'/>
|
||||
</channel>
|
||||
<channel type='pty'>
|
||||
<target type='virtio' name='org.linux-kvm.port.lla'/>
|
||||
<address type='virtio-serial' controller='2' bus='0' port='0'/>
|
||||
</channel>
|
||||
<memballoon model='virtio'/>
|
||||
</devices>
|
||||
</domain>
|
|
@ -0,0 +1,31 @@
|
|||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory>219200</memory>
|
||||
<currentMemory>219200</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch='i686' machine='pc'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<disk type='block' device='disk'>
|
||||
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||
<target dev='hda' bus='ide'/>
|
||||
<address type='drive' controller='0' bus='0' unit='0'/>
|
||||
</disk>
|
||||
<controller type='ide' index='0'/>
|
||||
<serial type='pty'>
|
||||
<target port='0'/>
|
||||
</serial>
|
||||
<console type='pty'>
|
||||
<target port='0'/>
|
||||
</console>
|
||||
<memballoon model='virtio'/>
|
||||
</devices>
|
||||
</domain>
|
|
@ -0,0 +1,31 @@
|
|||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory>219200</memory>
|
||||
<currentMemory>219200</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch='i686' machine='pc'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<disk type='block' device='disk'>
|
||||
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||
<target dev='hda' bus='ide'/>
|
||||
<address type='drive' controller='0' bus='0' unit='0'/>
|
||||
</disk>
|
||||
<disk type='file' device='disk'>
|
||||
<source file='/tmp/scsidisk.img'/>
|
||||
<target dev='sda' bus='scsi'/>
|
||||
<address type='drive' controller='0' bus='0' unit='0'/>
|
||||
</disk>
|
||||
<controller type='ide' index='0'/>
|
||||
<controller type='scsi' index='0'/>
|
||||
<memballoon model='virtio'/>
|
||||
</devices>
|
||||
</domain>
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue