[libvirt] tests: add qemu startupPolicy testcase

Add a group of testcase of startupPolicy features for CDROM and Harddisk. It compares the output xml string after checking the presence of disk and applying startupPolicy with expected xml string. New file: tests/qemustartuppolicytest.c TestData: tests/qemustartuppolicytestdata/ Guannan Ren(4) tests: add qemustartuppolicy testcase tests: add startuppolicy testcases for cdrom tests: add startuppolicy testcases for single harddisk tests: add startuppolicy testcase for multiple mixed harddisks tests/Makefile.am | 10 ++++- tests/qemustartuppolicytest.c | 230 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/qemustartuppolicytestdata/domain-input-cdrom-absent-policy-mandatory.xml | 28 ++++++++++++++ tests/qemustartuppolicytestdata/domain-input-cdrom-absent-policy-optional.xml | 28 ++++++++++++++ tests/qemustartuppolicytestdata/domain-input-cdrom-absent-policy-requisite.xml | 28 ++++++++++++++ tests/qemustartuppolicytestdata/domain-input-cdrom-present-policy-optional.xml | 28 ++++++++++++++ tests/qemustartuppolicytestdata/domain-input-disk-absent-policy-mandatory.xml | 27 +++++++++++++ tests/qemustartuppolicytestdata/domain-input-disk-absent-policy-optional.xml | 27 +++++++++++++ tests/qemustartuppolicytestdata/domain-input-disk-present-policy-none.xml | 27 +++++++++++++ tests/qemustartuppolicytestdata/domain-input-mixed-multiple-disks-absent-policy-mandatory.xml | 36 +++++++++++++++++ tests/qemustartuppolicytestdata/domain-input-mixed-multiple-disks-absent-policy-optional.xml | 36 +++++++++++++++++ tests/qemustartuppolicytestdata/domain-input-multiple-disks-absent-policy-optional.xml | 36 +++++++++++++++++ tests/qemustartuppolicytestdata/domain-output-cdrom-absent-policy-optional.xml | 29 ++++++++++++++ tests/qemustartuppolicytestdata/domain-output-cdrom-absent-policy-requisite.xml | 29 ++++++++++++++ tests/qemustartuppolicytestdata/domain-output-cdrom-present-policy-optional.xml | 29 ++++++++++++++ tests/qemustartuppolicytestdata/domain-output-disk-absent-policy-optional.xml | 22 +++++++++++ tests/qemustartuppolicytestdata/domain-output-disk-present-policy-none.xml | 28 ++++++++++++++ tests/qemustartuppolicytestdata/domain-output-mixed-multiple-disks-absent-policy-mandatory.xml | 36 +++++++++++++++++ tests/qemustartuppolicytestdata/domain-output-mixed-multiple-disks-absent-policy-optional.xml | 27 +++++++++++++ tests/qemustartuppolicytestdata/domain-output-multiple-disks-absent-policy-optional.xml | 22 +++++++++++ 20 files changed, 761 insertions(+), 2 deletions(-)

--- tests/Makefile.am | 10 +- tests/qemustartuppolicytest.c | 218 +++++++++++++++++++++ .../domain-input-cdrom-present-policy-optional.xml | 28 +++ ...domain-output-cdrom-present-policy-optional.xml | 29 +++ 4 files changed, 283 insertions(+), 2 deletions(-) create mode 100644 tests/qemustartuppolicytest.c create mode 100644 tests/qemustartuppolicytestdata/domain-input-cdrom-present-policy-optional.xml create mode 100644 tests/qemustartuppolicytestdata/domain-output-cdrom-present-policy-optional.xml diff --git a/tests/Makefile.am b/tests/Makefile.am index a9bcf4c..e54532c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -84,6 +84,7 @@ EXTRA_DIST = \ qemuxml2argvdata \ qemuxml2xmloutdata \ qemuxmlnsdata \ + qemustartuppolicytestdata \ securityselinuxlabeldata \ schematestutils.sh \ sexpr2xmldata \ @@ -162,7 +163,7 @@ if WITH_QEMU test_programs += qemuxml2argvtest qemuxml2xmltest qemuxmlnstest \ qemuargv2xmltest qemuhelptest domainsnapshotxml2xmltest \ qemumonitortest qemumonitorjsontest qemuhotplugtest \ - qemuagenttest + qemuagenttest qemustartuppolicytest endif if WITH_LXC @@ -439,12 +440,17 @@ domainsnapshotxml2xmltest_SOURCES = \ domainsnapshotxml2xmltest.c testutilsqemu.c testutilsqemu.h \ testutils.c testutils.h domainsnapshotxml2xmltest_LDADD = $(qemu_LDADDS) + +qemustartuppolicytest_SOURCES = \ + qemustartuppolicytest.c testutilsqemu.c testutilsqemu.h \ + testutils.c testutils.h $(NULL) +qemustartuppolicytest_LDADD = $(qemu_LDADDS) else EXTRA_DIST += qemuxml2argvtest.c qemuxml2xmltest.c qemuargv2xmltest.c \ qemuxmlnstest.c qemuhelptest.c domainsnapshotxml2xmltest.c \ qemumonitortest.c testutilsqemu.c testutilsqemu.h \ qemumonitorjsontest.c qemuhotplugtest.c \ - qemuagenttest.c \ + qemuagenttest.c qemustartuppolicytest.c \ $(QEMUMONITORTESTUTILS_SOURCES) endif diff --git a/tests/qemustartuppolicytest.c b/tests/qemustartuppolicytest.c new file mode 100644 index 0000000..0f0d4b8 --- /dev/null +++ b/tests/qemustartuppolicytest.c @@ -0,0 +1,218 @@ +/* + * Copyright (C) 2013 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include <config.h> + +#include <stdlib.h> +#include <stdbool.h> + +#include "testutils.h" + +#ifdef WITH_QEMU + +# include "internal.h" +# include "conf/domain_event.h" +# include "qemu/qemu_conf.h" +# include "qemu/qemu_process.h" +# include "testutilsqemu.h" + +# define VIR_FROM_THIS VIR_FROM_NONE + +static virQEMUDriver driver; + +enum { + MANDATORY, + REQUISITE, + OPTIONAL +}; + +typedef struct _qemuStartupPolicyTestData qemuStartupPolicyTestData; +struct _qemuStartupPolicyTestData { + const char *domain_filename; + int policy; + bool disk_present; + bool fail; + bool cold_boot; +}; + +static int +qemuNewDomainObjects(virDomainXMLOptionPtr xmlopt, + virDomainObjPtr *vm, + const char *filename) +{ + int ret = -1; + + if (!(*vm = virDomainObjNew(xmlopt))) + goto cleanup; + + if (!((*vm)->def = virDomainDefParseFile(filename, + driver.caps, + driver.xmlopt, + QEMU_EXPECTED_VIRT_TYPES, + 0))) + goto cleanup; + + ret = 0; + +cleanup: + return ret; +} + +static int +testQemuStartupPolicy(const void *data) +{ + int ret = -1, check_ret = -1; + qemuStartupPolicyTestData *test = (qemuStartupPolicyTestData *)data; + const char *domain_filename = test->domain_filename; + bool cold_boot = test->cold_boot; + char *inxml = NULL; + char *outxml = NULL; + char *outXmlData = NULL; + char *actual = NULL; + virDomainObjPtr vm = NULL; + + if (virAsprintf(&inxml, "%s/qemustartuppolicytestdata/domain-input-%s.xml", + abs_srcdir, domain_filename) < 0) + goto cleanup; + + if (qemuNewDomainObjects(driver.xmlopt, &vm, inxml) < 0) + goto cleanup; + + check_ret = qemuDomainCheckDiskPresence(&driver, vm, cold_boot); + + if (check_ret < 0) { + if (test->disk_present) { + fprintf(stderr, "Disk is present, presence checking failed\n"); + } else { + if (test->policy == MANDATORY) { + if (!test->fail) + fprintf(stderr, "Disk is not present, " + "failed with mandatory policy\n"); + else + ret = 0; + } else if (test->policy == REQUISITE) { + if (cold_boot) { + if (!test->fail) + fprintf(stderr, "Disk is not present, " + "failed with requisite policy\n"); + else + ret = 0; + } else { + fprintf(stderr, "It is not cold_boot, " + "should not fail with requisite policy\n"); + } + } else if (test->policy == OPTIONAL && !test->fail) { + fprintf(stderr, "Optional policy should not break disk check\n"); + } else { + fprintf(stderr, "presence checking failed without any policy\n"); + } + } + goto cleanup; + } + + if (!(actual = virDomainDefFormat(vm->def, VIR_DOMAIN_XML_INACTIVE))) + goto cleanup; + + if (virAsprintf(&outxml, "%s/qemustartuppolicytestdata/domain-output-%s.xml", + abs_srcdir, domain_filename) < 0) + goto cleanup; + + if (virtTestLoadFile(outxml, &outXmlData) < 0) + goto cleanup; + + if (STRNEQ(outXmlData, actual)) { + virtTestDifference(stderr, outXmlData, actual); + goto cleanup; + } + + ret = 0; + +cleanup: + VIR_FREE(inxml); + VIR_FREE(outxml); + VIR_FREE(actual); + VIR_FREE(outXmlData); + virObjectUnref(vm); + return ret; +} + +static int +mymain(void) +{ + int ret = 0; + qemuStartupPolicyTestData data = {NULL}; + + driver.config = virQEMUDriverConfigNew(false); + if ((driver.caps = testQemuCapsInit()) == NULL) + return EXIT_FAILURE; + + if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver))) + return EXIT_FAILURE; + + if (!(driver.domainEventState = virDomainEventStateNew())) + return EXIT_FAILURE; + +# define DO_TEST(file, pol, present, fial) \ + data.domain_filename = file; \ + data.policy = pol; \ + data.disk_present = present; \ + data.fail = fial; \ + \ + if (virtTestRun(#file, 1, testQemuStartupPolicy, &data) < 0) \ + ret = -1; \ + +# define DO_TEST_MANDATORY(file, disk_present, fail) \ + do { \ + data.cold_boot = true; \ + DO_TEST(file, MANDATORY, disk_present, fail) \ + } while (0) + +# define DO_TEST_REQUISITE(file, disk_present, boot, fail) \ + do { \ + data.cold_boot = boot; \ + DO_TEST(file, REQUISITE, disk_present, fail) \ + } while (0) + +# define DO_TEST_OPTIONAL(file, disk_present) \ + do { \ + data.cold_boot = true; \ + DO_TEST(file, OPTIONAL, disk_present, false) \ + } while (0) + + DO_TEST_OPTIONAL("cdrom-present-policy-optional", false); + + virObjectUnref(driver.caps); + virObjectUnref(driver.xmlopt); + virObjectUnref(driver.config); + virDomainEventStateFree(driver.domainEventState); + + return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} + +VIRT_TEST_MAIN(mymain) + +#else + +int +main(void) +{ + return EXIT_AM_SKIP; +} + +#endif /* WITH_QEMU */ diff --git a/tests/qemustartuppolicytestdata/domain-input-cdrom-present-policy-optional.xml b/tests/qemustartuppolicytestdata/domain-input-cdrom-present-policy-optional.xml new file mode 100644 index 0000000..7087a21 --- /dev/null +++ b/tests/qemustartuppolicytestdata/domain-input-cdrom-present-policy-optional.xml @@ -0,0 +1,28 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>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='file' device='cdrom'> + <target dev='hdc' bus='ide'/> + <driver name='qemu' type='raw'/> + <source file='/dev/null' startupPolicy='optional'/> + <readonly/> + <address type='drive' controller='0' bus='1' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemustartuppolicytestdata/domain-output-cdrom-present-policy-optional.xml b/tests/qemustartuppolicytestdata/domain-output-cdrom-present-policy-optional.xml new file mode 100644 index 0000000..f5316f9 --- /dev/null +++ b/tests/qemustartuppolicytestdata/domain-output-cdrom-present-policy-optional.xml @@ -0,0 +1,29 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>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='file' device='cdrom'> + <driver name='qemu' type='raw'/> + <source file='/dev/null' startupPolicy='optional'/> + <target dev='hdc' bus='ide'/> + <readonly/> + <address type='drive' controller='0' bus='1' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <memballoon model='virtio'/> + </devices> +</domain> -- 1.8.3.1

--- tests/qemustartuppolicytest.c | 4 +++ .../domain-input-cdrom-absent-policy-mandatory.xml | 28 +++++++++++++++++++++ .../domain-input-cdrom-absent-policy-optional.xml | 28 +++++++++++++++++++++ .../domain-input-cdrom-absent-policy-requisite.xml | 28 +++++++++++++++++++++ .../domain-output-cdrom-absent-policy-optional.xml | 29 ++++++++++++++++++++++ ...domain-output-cdrom-absent-policy-requisite.xml | 29 ++++++++++++++++++++++ 6 files changed, 146 insertions(+) create mode 100644 tests/qemustartuppolicytestdata/domain-input-cdrom-absent-policy-mandatory.xml create mode 100644 tests/qemustartuppolicytestdata/domain-input-cdrom-absent-policy-optional.xml create mode 100644 tests/qemustartuppolicytestdata/domain-input-cdrom-absent-policy-requisite.xml create mode 100644 tests/qemustartuppolicytestdata/domain-output-cdrom-absent-policy-optional.xml create mode 100644 tests/qemustartuppolicytestdata/domain-output-cdrom-absent-policy-requisite.xml diff --git a/tests/qemustartuppolicytest.c b/tests/qemustartuppolicytest.c index 0f0d4b8..df09507 100644 --- a/tests/qemustartuppolicytest.c +++ b/tests/qemustartuppolicytest.c @@ -196,6 +196,10 @@ mymain(void) } while (0) DO_TEST_OPTIONAL("cdrom-present-policy-optional", false); + DO_TEST_OPTIONAL("cdrom-absent-policy-optional", false); + DO_TEST_MANDATORY("cdrom-absent-policy-mandatory", false, true); + DO_TEST_REQUISITE("cdrom-absent-policy-requisite", false, true, true); + DO_TEST_REQUISITE("cdrom-absent-policy-requisite", false, false, false); virObjectUnref(driver.caps); virObjectUnref(driver.xmlopt); diff --git a/tests/qemustartuppolicytestdata/domain-input-cdrom-absent-policy-mandatory.xml b/tests/qemustartuppolicytestdata/domain-input-cdrom-absent-policy-mandatory.xml new file mode 100644 index 0000000..0999aef --- /dev/null +++ b/tests/qemustartuppolicytestdata/domain-input-cdrom-absent-policy-mandatory.xml @@ -0,0 +1,28 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>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='file' device='cdrom'> + <target dev='hdc' bus='ide'/> + <driver name='qemu' type='raw'/> + <source file='/dev/cdrom-nonexist' startupPolicy='mandatory'/> + <readonly/> + <address type='drive' controller='0' bus='1' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemustartuppolicytestdata/domain-input-cdrom-absent-policy-optional.xml b/tests/qemustartuppolicytestdata/domain-input-cdrom-absent-policy-optional.xml new file mode 100644 index 0000000..cdcc96b --- /dev/null +++ b/tests/qemustartuppolicytestdata/domain-input-cdrom-absent-policy-optional.xml @@ -0,0 +1,28 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>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='file' device='cdrom'> + <target dev='hdc' bus='ide'/> + <driver name='qemu' type='raw'/> + <source file='/dev/cdrom-nonexist' startupPolicy='optional'/> + <readonly/> + <address type='drive' controller='0' bus='1' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemustartuppolicytestdata/domain-input-cdrom-absent-policy-requisite.xml b/tests/qemustartuppolicytestdata/domain-input-cdrom-absent-policy-requisite.xml new file mode 100644 index 0000000..8035dfb --- /dev/null +++ b/tests/qemustartuppolicytestdata/domain-input-cdrom-absent-policy-requisite.xml @@ -0,0 +1,28 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>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='file' device='cdrom'> + <target dev='hdc' bus='ide'/> + <driver name='qemu' type='raw'/> + <source file='/dev/cdrom-nonexist' startupPolicy='requisite'/> + <readonly/> + <address type='drive' controller='0' bus='1' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemustartuppolicytestdata/domain-output-cdrom-absent-policy-optional.xml b/tests/qemustartuppolicytestdata/domain-output-cdrom-absent-policy-optional.xml new file mode 100644 index 0000000..fab116e --- /dev/null +++ b/tests/qemustartuppolicytestdata/domain-output-cdrom-absent-policy-optional.xml @@ -0,0 +1,29 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>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='file' device='cdrom'> + <driver name='qemu' type='raw'/> + <source startupPolicy='optional'/> + <target dev='hdc' bus='ide'/> + <readonly/> + <address type='drive' controller='0' bus='1' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemustartuppolicytestdata/domain-output-cdrom-absent-policy-requisite.xml b/tests/qemustartuppolicytestdata/domain-output-cdrom-absent-policy-requisite.xml new file mode 100644 index 0000000..7d40817 --- /dev/null +++ b/tests/qemustartuppolicytestdata/domain-output-cdrom-absent-policy-requisite.xml @@ -0,0 +1,29 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>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='file' device='cdrom'> + <driver name='qemu' type='raw'/> + <source startupPolicy='requisite'/> + <target dev='hdc' bus='ide'/> + <readonly/> + <address type='drive' controller='0' bus='1' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <memballoon model='virtio'/> + </devices> +</domain> -- 1.8.3.1

--- tests/qemustartuppolicytest.c | 4 ++++ .../domain-input-disk-absent-policy-mandatory.xml | 27 +++++++++++++++++++++ .../domain-input-disk-absent-policy-optional.xml | 27 +++++++++++++++++++++ .../domain-input-disk-present-policy-none.xml | 27 +++++++++++++++++++++ .../domain-output-disk-absent-policy-optional.xml | 22 +++++++++++++++++ .../domain-output-disk-present-policy-none.xml | 28 ++++++++++++++++++++++ 6 files changed, 135 insertions(+) create mode 100644 tests/qemustartuppolicytestdata/domain-input-disk-absent-policy-mandatory.xml create mode 100644 tests/qemustartuppolicytestdata/domain-input-disk-absent-policy-optional.xml create mode 100644 tests/qemustartuppolicytestdata/domain-input-disk-present-policy-none.xml create mode 100644 tests/qemustartuppolicytestdata/domain-output-disk-absent-policy-optional.xml create mode 100644 tests/qemustartuppolicytestdata/domain-output-disk-present-policy-none.xml diff --git a/tests/qemustartuppolicytest.c b/tests/qemustartuppolicytest.c index df09507..7081400 100644 --- a/tests/qemustartuppolicytest.c +++ b/tests/qemustartuppolicytest.c @@ -201,6 +201,10 @@ mymain(void) DO_TEST_REQUISITE("cdrom-absent-policy-requisite", false, true, true); DO_TEST_REQUISITE("cdrom-absent-policy-requisite", false, false, false); + DO_TEST_OPTIONAL("disk-absent-policy-optional", false); + DO_TEST_OPTIONAL("disk-present-policy-none", true); + DO_TEST_MANDATORY("disk-absent-policy-mandatory", false, true); + virObjectUnref(driver.caps); virObjectUnref(driver.xmlopt); virObjectUnref(driver.config); diff --git a/tests/qemustartuppolicytestdata/domain-input-disk-absent-policy-mandatory.xml b/tests/qemustartuppolicytestdata/domain-input-disk-absent-policy-mandatory.xml new file mode 100644 index 0000000..5164a4e --- /dev/null +++ b/tests/qemustartuppolicytestdata/domain-input-disk-absent-policy-mandatory.xml @@ -0,0 +1,27 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>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='file' device='disk'> + <target dev='hdc' bus='ide'/> + <driver name='qemu' type='raw'/> + <source file='/dev/disk-nonexist' startupPolicy='mandatory'/> + <address type='drive' controller='0' bus='1' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemustartuppolicytestdata/domain-input-disk-absent-policy-optional.xml b/tests/qemustartuppolicytestdata/domain-input-disk-absent-policy-optional.xml new file mode 100644 index 0000000..8d25ea9 --- /dev/null +++ b/tests/qemustartuppolicytestdata/domain-input-disk-absent-policy-optional.xml @@ -0,0 +1,27 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>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='file' device='disk'> + <target dev='hdc' bus='ide'/> + <driver name='qemu' type='raw'/> + <source file='/dev/disk-nonexist' startupPolicy='optional'/> + <address type='drive' controller='0' bus='1' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemustartuppolicytestdata/domain-input-disk-present-policy-none.xml b/tests/qemustartuppolicytestdata/domain-input-disk-present-policy-none.xml new file mode 100644 index 0000000..1ec6a90 --- /dev/null +++ b/tests/qemustartuppolicytestdata/domain-input-disk-present-policy-none.xml @@ -0,0 +1,27 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>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='file' device='disk'> + <target dev='hdc' bus='ide'/> + <driver name='qemu' type='raw'/> + <source file='/dev/null'/> + <address type='drive' controller='0' bus='1' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemustartuppolicytestdata/domain-output-disk-absent-policy-optional.xml b/tests/qemustartuppolicytestdata/domain-output-disk-absent-policy-optional.xml new file mode 100644 index 0000000..d68cd79 --- /dev/null +++ b/tests/qemustartuppolicytestdata/domain-output-disk-absent-policy-optional.xml @@ -0,0 +1,22 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>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> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemustartuppolicytestdata/domain-output-disk-present-policy-none.xml b/tests/qemustartuppolicytestdata/domain-output-disk-present-policy-none.xml new file mode 100644 index 0000000..8b0aeef --- /dev/null +++ b/tests/qemustartuppolicytestdata/domain-output-disk-present-policy-none.xml @@ -0,0 +1,28 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>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='file' device='disk'> + <driver name='qemu' type='raw'/> + <source file='/dev/null'/> + <target dev='hdc' bus='ide'/> + <address type='drive' controller='0' bus='1' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <memballoon model='virtio'/> + </devices> +</domain> -- 1.8.3.1

--- tests/qemustartuppolicytest.c | 4 +++ ...ixed-multiple-disks-absent-policy-mandatory.xml | 36 ++++++++++++++++++++++ ...mixed-multiple-disks-absent-policy-optional.xml | 36 ++++++++++++++++++++++ ...input-multiple-disks-absent-policy-optional.xml | 36 ++++++++++++++++++++++ ...ixed-multiple-disks-absent-policy-mandatory.xml | 36 ++++++++++++++++++++++ ...mixed-multiple-disks-absent-policy-optional.xml | 27 ++++++++++++++++ ...utput-multiple-disks-absent-policy-optional.xml | 22 +++++++++++++ 7 files changed, 197 insertions(+) create mode 100644 tests/qemustartuppolicytestdata/domain-input-mixed-multiple-disks-absent-policy-mandatory.xml create mode 100644 tests/qemustartuppolicytestdata/domain-input-mixed-multiple-disks-absent-policy-optional.xml create mode 100644 tests/qemustartuppolicytestdata/domain-input-multiple-disks-absent-policy-optional.xml create mode 100644 tests/qemustartuppolicytestdata/domain-output-mixed-multiple-disks-absent-policy-mandatory.xml create mode 100644 tests/qemustartuppolicytestdata/domain-output-mixed-multiple-disks-absent-policy-optional.xml create mode 100644 tests/qemustartuppolicytestdata/domain-output-multiple-disks-absent-policy-optional.xml diff --git a/tests/qemustartuppolicytest.c b/tests/qemustartuppolicytest.c index 7081400..4757ed3 100644 --- a/tests/qemustartuppolicytest.c +++ b/tests/qemustartuppolicytest.c @@ -205,6 +205,10 @@ mymain(void) DO_TEST_OPTIONAL("disk-present-policy-none", true); DO_TEST_MANDATORY("disk-absent-policy-mandatory", false, true); + DO_TEST_OPTIONAL("multiple-disks-absent-policy-optional", false); + DO_TEST_OPTIONAL("mixed-multiple-disks-absent-policy-optional", false); + DO_TEST_MANDATORY("mixed-multiple-disks-absent-policy-mandatory", false, true); + virObjectUnref(driver.caps); virObjectUnref(driver.xmlopt); virObjectUnref(driver.config); diff --git a/tests/qemustartuppolicytestdata/domain-input-mixed-multiple-disks-absent-policy-mandatory.xml b/tests/qemustartuppolicytestdata/domain-input-mixed-multiple-disks-absent-policy-mandatory.xml new file mode 100644 index 0000000..b98fa80 --- /dev/null +++ b/tests/qemustartuppolicytestdata/domain-input-mixed-multiple-disks-absent-policy-mandatory.xml @@ -0,0 +1,36 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>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='file' device='disk'> + <target dev='vda' bus='virtio'/> + <driver name='qemu' type='raw'/> + <source file='/dev/disk-nonexist1' startupPolicy='mandatory'/> + </disk> + <disk type='file' device='disk'> + <target dev='vdb' bus='virtio'/> + <driver name='qemu' type='raw'/> + <source file='/dev/null' startupPolicy='mandatory'/> + </disk> + <disk type='file' device='disk'> + <target dev='vdc' bus='virtio'/> + <driver name='qemu' type='raw'/> + <source file='/dev/disk-nonexist3' startupPolicy='optional'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemustartuppolicytestdata/domain-input-mixed-multiple-disks-absent-policy-optional.xml b/tests/qemustartuppolicytestdata/domain-input-mixed-multiple-disks-absent-policy-optional.xml new file mode 100644 index 0000000..2f68912 --- /dev/null +++ b/tests/qemustartuppolicytestdata/domain-input-mixed-multiple-disks-absent-policy-optional.xml @@ -0,0 +1,36 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>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='file' device='disk'> + <target dev='vda' bus='virtio'/> + <driver name='qemu' type='raw'/> + <source file='/dev/disk-nonexist1' startupPolicy='optional'/> + </disk> + <disk type='file' device='disk'> + <target dev='vdb' bus='virtio'/> + <driver name='qemu' type='raw'/> + <source file='/dev/null' startupPolicy='mandatory'/> + </disk> + <disk type='file' device='disk'> + <target dev='vdc' bus='virtio'/> + <driver name='qemu' type='raw'/> + <source file='/dev/disk-nonexist3' startupPolicy='optional'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemustartuppolicytestdata/domain-input-multiple-disks-absent-policy-optional.xml b/tests/qemustartuppolicytestdata/domain-input-multiple-disks-absent-policy-optional.xml new file mode 100644 index 0000000..da7572f --- /dev/null +++ b/tests/qemustartuppolicytestdata/domain-input-multiple-disks-absent-policy-optional.xml @@ -0,0 +1,36 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>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='file' device='disk'> + <target dev='vda' bus='virtio'/> + <driver name='qemu' type='raw'/> + <source file='/dev/disk-nonexist1' startupPolicy='optional'/> + </disk> + <disk type='file' device='disk'> + <target dev='vdb' bus='virtio'/> + <driver name='qemu' type='raw'/> + <source file='/dev/disk-nonexist2' startupPolicy='optional'/> + </disk> + <disk type='file' device='disk'> + <target dev='vdc' bus='virtio'/> + <driver name='qemu' type='raw'/> + <source file='/dev/disk-nonexist3' startupPolicy='optional'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemustartuppolicytestdata/domain-output-mixed-multiple-disks-absent-policy-mandatory.xml b/tests/qemustartuppolicytestdata/domain-output-mixed-multiple-disks-absent-policy-mandatory.xml new file mode 100644 index 0000000..b98fa80 --- /dev/null +++ b/tests/qemustartuppolicytestdata/domain-output-mixed-multiple-disks-absent-policy-mandatory.xml @@ -0,0 +1,36 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>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='file' device='disk'> + <target dev='vda' bus='virtio'/> + <driver name='qemu' type='raw'/> + <source file='/dev/disk-nonexist1' startupPolicy='mandatory'/> + </disk> + <disk type='file' device='disk'> + <target dev='vdb' bus='virtio'/> + <driver name='qemu' type='raw'/> + <source file='/dev/null' startupPolicy='mandatory'/> + </disk> + <disk type='file' device='disk'> + <target dev='vdc' bus='virtio'/> + <driver name='qemu' type='raw'/> + <source file='/dev/disk-nonexist3' startupPolicy='optional'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemustartuppolicytestdata/domain-output-mixed-multiple-disks-absent-policy-optional.xml b/tests/qemustartuppolicytestdata/domain-output-mixed-multiple-disks-absent-policy-optional.xml new file mode 100644 index 0000000..e23a712 --- /dev/null +++ b/tests/qemustartuppolicytestdata/domain-output-mixed-multiple-disks-absent-policy-optional.xml @@ -0,0 +1,27 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>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='file' device='disk'> + <driver name='qemu' type='raw'/> + <source file='/dev/null' startupPolicy='mandatory'/> + <target dev='vdb' bus='virtio'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemustartuppolicytestdata/domain-output-multiple-disks-absent-policy-optional.xml b/tests/qemustartuppolicytestdata/domain-output-multiple-disks-absent-policy-optional.xml new file mode 100644 index 0000000..d68cd79 --- /dev/null +++ b/tests/qemustartuppolicytestdata/domain-output-multiple-disks-absent-policy-optional.xml @@ -0,0 +1,22 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>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> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <memballoon model='virtio'/> + </devices> +</domain> -- 1.8.3.1
participants (1)
-
Guannan Ren