[virt-tools-list] [PATCH virt-manager 14/14] tests: virt-xml: Add test cases for --start option

Marc Hartmayer mhartmay at linux.ibm.com
Tue Feb 26 09:56:44 UTC 2019


The test cases verify that:

 + --start works
 + --define --start works
 + --no-define --start works
 + --start works in combination with --add and --remove
 + combination of --start --update isn't valid
 + combination of --define --no-define --start isn't valid

Signed-off-by: Marc Hartmayer <mhartmay at linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy at linux.ibm.com>
---
 .../compare/virt-xml-add-disk-basic-start.xml | 11 ++++
 ...virt-xml-add-disk-create-storage-start.xml | 11 ++++
 .../virt-xml-add-host-device-start.xml        | 14 +++++
 .../virt-xml-remove-disk-path-start.xml       | 20 +++++++
 .../virt-xml-start-select-disk-bootorder.xml  | 33 +++++++++++
 .../virt-xml-start-select-disk-bootorder2.xml | 32 ++++++++++
 tests/clitest.py                              | 17 ++++++
 tests/testsuite.xml                           | 58 +++++++++++++++++++
 8 files changed, 196 insertions(+)
 create mode 100644 tests/cli-test-xml/compare/virt-xml-add-disk-basic-start.xml
 create mode 100644 tests/cli-test-xml/compare/virt-xml-add-disk-create-storage-start.xml
 create mode 100644 tests/cli-test-xml/compare/virt-xml-add-host-device-start.xml
 create mode 100644 tests/cli-test-xml/compare/virt-xml-remove-disk-path-start.xml
 create mode 100644 tests/cli-test-xml/compare/virt-xml-start-select-disk-bootorder.xml
 create mode 100644 tests/cli-test-xml/compare/virt-xml-start-select-disk-bootorder2.xml

diff --git a/tests/cli-test-xml/compare/virt-xml-add-disk-basic-start.xml b/tests/cli-test-xml/compare/virt-xml-add-disk-basic-start.xml
new file mode 100644
index 000000000000..0071d9e76aa7
--- /dev/null
+++ b/tests/cli-test-xml/compare/virt-xml-add-disk-basic-start.xml
@@ -0,0 +1,11 @@
+       <model type="cirrus" vram="16384" heads="1" primary="yes"/>
+     </video>
+     <memballoon model="virtio"/>
++    <disk type="file" device="disk">
++      <source file="/dev/default-pool/testvol1.img"/>
++      <target dev="vdf" bus="virtio"/>
++    </disk>
+   </devices>
+ </domain>
+
+Domain 'test-state-shutoff' started successfully.
\ No newline at end of file
diff --git a/tests/cli-test-xml/compare/virt-xml-add-disk-create-storage-start.xml b/tests/cli-test-xml/compare/virt-xml-add-disk-create-storage-start.xml
new file mode 100644
index 000000000000..6a02dcc36485
--- /dev/null
+++ b/tests/cli-test-xml/compare/virt-xml-add-disk-create-storage-start.xml
@@ -0,0 +1,11 @@
+       <model type="cirrus" vram="16384" heads="1" primary="yes"/>
+     </video>
+     <memballoon model="virtio"/>
++    <disk type="file" device="disk">
++      <source file="/dev/default-pool/new1.img"/>
++      <target dev="hdd" bus="ide"/>
++    </disk>
+   </devices>
+ </domain>
+
+Domain 'test-state-shutoff' started successfully.
\ No newline at end of file
diff --git a/tests/cli-test-xml/compare/virt-xml-add-host-device-start.xml b/tests/cli-test-xml/compare/virt-xml-add-host-device-start.xml
new file mode 100644
index 000000000000..b3db52793710
--- /dev/null
+++ b/tests/cli-test-xml/compare/virt-xml-add-host-device-start.xml
@@ -0,0 +1,14 @@
+       <model type="cirrus" vram="16384" heads="1" primary="yes"/>
+     </video>
+     <memballoon model="virtio"/>
++    <hostdev mode="subsystem" type="usb" managed="yes">
++      <source>
++        <vendor id="0x04b3"/>
++        <product id="0x4485"/>
++      </source>
++    </hostdev>
+   </devices>
+ </domain>
+
+Domain 'test-state-shutoff' defined successfully.
+Domain 'test-state-shutoff' started successfully.
\ No newline at end of file
diff --git a/tests/cli-test-xml/compare/virt-xml-remove-disk-path-start.xml b/tests/cli-test-xml/compare/virt-xml-remove-disk-path-start.xml
new file mode 100644
index 000000000000..e04db8fba761
--- /dev/null
+++ b/tests/cli-test-xml/compare/virt-xml-remove-disk-path-start.xml
@@ -0,0 +1,20 @@
+   <on_lockfailure>poweroff</on_lockfailure>
+   <devices>
+     <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
+-    <disk type="block" device="disk">
+-      <driver name="qemu"/>
+-      <source dev="/dev/null"/>
+-      <target dev="vda" bus="virtio"/>
+-      <boot order="10"/>
+-    </disk>
+-    <disk type="block" device="disk">
+-      <driver name="qemu"/>
+-      <source dev="/dev/null"/>
+-      <target dev="vdb" bus="virtio"/>
+-      <boot order="3"/>
+-    </disk>
+     <disk type="block" device="cdrom">
+       <target dev="hdc" bus="ide"/>
+       <readonly/>
+
+Domain 'test-state-shutoff' started successfully.
\ No newline at end of file
diff --git a/tests/cli-test-xml/compare/virt-xml-start-select-disk-bootorder.xml b/tests/cli-test-xml/compare/virt-xml-start-select-disk-bootorder.xml
new file mode 100644
index 000000000000..280d9fc5f078
--- /dev/null
+++ b/tests/cli-test-xml/compare/virt-xml-start-select-disk-bootorder.xml
@@ -0,0 +1,33 @@
+       <driver name="qemu"/>
+       <source dev="/dev/null"/>
+       <target dev="vda" bus="virtio"/>
+-      <boot order="10"/>
++      <boot order="1"/>
+     </disk>
+     <disk type="block" device="disk">
+       <driver name="qemu"/>
+       <source dev="/dev/null"/>
+       <target dev="vdb" bus="virtio"/>
+-      <boot order="3"/>
++      <boot order="4"/>
+     </disk>
+     <disk type="block" device="cdrom">
+       <target dev="hdc" bus="ide"/>
+       <readonly/>
+-      <boot order="1"/>
++      <boot order="2"/>
+       <address type="drive" controller="0" bus="1" target="0" unit="0"/>
+     </disk>
+     <controller type="ide" index="0"/>
+@@
+       <source network="default"/>
+       <target dev="testnet0"/>
+       <model type="virtio"/>
+-      <boot order="2"/>
++      <boot order="3"/>
+     </interface>
+     <interface type="network">
+       <mac address="52:54:00:11:fa:28"/>
+
+Domain 'test-state-shutoff' defined successfully.
+Domain 'test-state-shutoff' started successfully.
\ No newline at end of file
diff --git a/tests/cli-test-xml/compare/virt-xml-start-select-disk-bootorder2.xml b/tests/cli-test-xml/compare/virt-xml-start-select-disk-bootorder2.xml
new file mode 100644
index 000000000000..1144f4c5221b
--- /dev/null
+++ b/tests/cli-test-xml/compare/virt-xml-start-select-disk-bootorder2.xml
@@ -0,0 +1,32 @@
+       <driver name="qemu"/>
+       <source dev="/dev/null"/>
+       <target dev="vda" bus="virtio"/>
+-      <boot order="10"/>
++      <boot order="1"/>
+     </disk>
+     <disk type="block" device="disk">
+       <driver name="qemu"/>
+       <source dev="/dev/null"/>
+       <target dev="vdb" bus="virtio"/>
+-      <boot order="3"/>
++      <boot order="4"/>
+     </disk>
+     <disk type="block" device="cdrom">
+       <target dev="hdc" bus="ide"/>
+       <readonly/>
+-      <boot order="1"/>
++      <boot order="2"/>
+       <address type="drive" controller="0" bus="1" target="0" unit="0"/>
+     </disk>
+     <controller type="ide" index="0"/>
+@@
+       <source network="default"/>
+       <target dev="testnet0"/>
+       <model type="virtio"/>
+-      <boot order="2"/>
++      <boot order="3"/>
+     </interface>
+     <interface type="network">
+       <mac address="52:54:00:11:fa:28"/>
+
+Domain 'test-state-shutoff' started successfully.
\ No newline at end of file
diff --git a/tests/clitest.py b/tests/clitest.py
index 9670f2228bd5..dde64d535687 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -894,6 +894,7 @@ c = vixml.add_category("misc", "")
 c.add_valid("--help")  # basic --help test
 c.add_valid("--sound=? --tpm=?")  # basic introspection test
 c.add_valid("test-state-shutoff --edit --update --boot menu=on")  # --update with inactive VM, should work but warn
+c.add_invalid("test-state-shutoff --edit --update --boot menu=on --start")
 c.add_invalid("test --edit --hostdev driver_name=vfio")  # Guest has no hostdev to edit
 c.add_invalid("test --edit --cpu host-passthrough --boot hd,network")  # Specified more than 1 option
 c.add_invalid("test --edit")  # specified no edit option
@@ -969,6 +970,12 @@ c.add_compare("--edit /tmp/foobar2 --disk shareable=off,readonly=on", "edit-sele
 c.add_compare("--edit mac=00:11:7f:33:44:55 --network target=nic55", "edit-select-network-mac")
 c.add_compare("--edit target=hda --disk boot_order=1", "edit-select-disk-bootorder")
 
+c = vixml.add_category("edit and start selection", "test-state-shutoff --print-diff --start")
+c.add_compare("--define --edit target=vda --disk boot_order=1", "start-select-disk-bootorder")
+c.add_invalid("--define --no-define --edit target=vda --disk boot_order=1")
+c.add_compare("--edit target=vda --disk boot_order=1", "start-select-disk-bootorder2")
+c.add_compare("--no-define --edit target=vda --disk boot_order=1", "start-select-disk-bootorder2")
+
 c = vixml.add_category("edit selection 2", "test-collide --print-diff --define")
 c.add_compare("--edit target=hda --disk boot_order=1", "edit-select-disk-bootorder2")
 
@@ -996,6 +1003,16 @@ c.add_compare("--remove-device --disk /dev/null", "remove-disk-path")
 c.add_compare("--remove-device --video all", "remove-video-all", check_version="1.3.3")  # check_version=video primary= attribute
 c.add_compare("--remove-device --host-device 0x04b3:0x4485", "remove-hostdev-name", check_version="1.2.11")  # check_version=video ram output change
 
+c = vixml.add_category("add/rm devices and start", "test-state-shutoff --print-diff --start")
+c.add_invalid("--add-device --pm suspend_to_disk=yes")  # --add-device without a device
+c.add_invalid("--remove-device --clock utc")  # --remove-device without a dev
+# one test in combination with --define
+c.add_compare("--define --add-device --host-device usb_device_4b3_4485_noserial", "add-host-device-start")
+# all other test cases without
+c.add_compare("--add-device --disk %(EXISTIMG1)s,bus=virtio,target=vdf", "add-disk-basic-start")
+c.add_compare("--add-device --disk %(NEWIMG1)s,size=.01", "add-disk-create-storage-start")
+c.add_compare("--remove-device --disk /dev/null", "remove-disk-path-start")
+
 c = vixml.add_category("add/rm devices OS KVM", "--connect %(URI-KVM)s test --print-diff --define")
 c.add_compare("--add-device --disk %(EXISTIMG1)s", "kvm-add-disk-os-from-xml")  # Guest OS (none) from XML
 c.add_compare("--add-device --disk %(EXISTIMG1)s --os-variant fedora28", "kvm-add-disk-os-from-cmdline")  # Guest OS (fedora) provided on command line
diff --git a/tests/testsuite.xml b/tests/testsuite.xml
index fa0a077f6706..2e6f0fd627a7 100644
--- a/tests/testsuite.xml
+++ b/tests/testsuite.xml
@@ -289,6 +289,64 @@
   <memory>1048576</memory>
   <bootloader>/tmp/bootfoo</bootloader>
   <test:runstate>5</test:runstate>
+    <metadata>
+    <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
+      <libosinfo:os id="http://fedoraproject.org/fedora/17"/>
+    </libosinfo:libosinfo>
+  </metadata>
+  <currentMemory>204800</currentMemory>
+  <memory>409600</memory>
+  <uuid>12345678-1234-1234-1234-123456789012</uuid>
+  <os>
+    <type arch="i686" machine="foobar">hvm</type>
+  </os>
+  <features>
+    <acpi/>
+    <apic/>
+    <hyperv>
+      <vapic state="off"/>
+      <spinlocks state="on" retries="12287"/>
+    </hyperv>
+    <vmport state="off"/>
+  </features>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <on_lockfailure>poweroff</on_lockfailure>
+  <devices>
+    <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
+     <disk type="block" device="disk">
+      <driver name="qemu"/>
+      <source dev="/dev/null"/>
+      <target dev="vda" bus="virtio"/>
+      <boot order="10"/>
+     </disk>
+     <disk type="block" device="disk">
+      <driver name="qemu"/>
+      <source dev="/dev/null"/>
+      <target dev="vdb" bus="virtio"/>
+      <boot order="3"/>
+    </disk>
+    <disk type="block" device="cdrom">
+      <target dev="hdc" bus="ide"/>
+      <readonly/>
+      <boot order="1"/>
+    </disk>
+    <interface type="network">
+      <source network="default"/>
+      <mac address="22:22:33:44:55:66"/>
+      <model type="virtio"/>
+      <boot order="2"/>
+    </interface>
+    <interface type="network">
+      <source network="default"/>
+      <mac address="52:54:00:11:fa:28"/>
+      <model type="virtio"/>
+    </interface>
+    <graphics type="vnc" display=":3.4" xauth="/tmp/.Xauthority"/>
+    <console type="pty"/>
+    <memballoon model="virtio"/>
+  </devices>
 </domain>
 
 
-- 
2.17.0




More information about the virt-tools-list mailing list