[virt-tools-list] [virt-manager PATCH 4/5] tests: Add some tests for virt-xml with KVM

Andrea Bolognani abologna at redhat.com
Fri Nov 9 15:36:39 UTC 2018


We're mostly interested in how the default bus/model for
devices are influenced by knowledge about the guest OS, but
since the whole thing requires to be connected to the QEMU
driver we might as well create a new category and leave room
for more QEMU-specific tests being added down the line.

Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 .../compare/virt-xml-kvm-add-disk-default.xml      | 13 +++++++++++++
 .../virt-xml-kvm-add-disk-os-from-cmdline.xml      | 14 ++++++++++++++
 .../compare/virt-xml-kvm-add-disk-os-from-xml.xml  | 14 ++++++++++++++
 .../compare/virt-xml-kvm-add-network-default.xml   | 13 +++++++++++++
 .../virt-xml-kvm-add-network-os-from-cmdline.xml   | 14 ++++++++++++++
 .../virt-xml-kvm-add-network-os-from-xml.xml       | 14 ++++++++++++++
 tests/clitest.py                                   |  7 +++++++
 7 files changed, 89 insertions(+)
 create mode 100644 tests/cli-test-xml/compare/virt-xml-kvm-add-disk-default.xml
 create mode 100644 tests/cli-test-xml/compare/virt-xml-kvm-add-disk-os-from-cmdline.xml
 create mode 100644 tests/cli-test-xml/compare/virt-xml-kvm-add-disk-os-from-xml.xml
 create mode 100644 tests/cli-test-xml/compare/virt-xml-kvm-add-network-default.xml
 create mode 100644 tests/cli-test-xml/compare/virt-xml-kvm-add-network-os-from-cmdline.xml
 create mode 100644 tests/cli-test-xml/compare/virt-xml-kvm-add-network-os-from-xml.xml

diff --git a/tests/cli-test-xml/compare/virt-xml-kvm-add-disk-default.xml b/tests/cli-test-xml/compare/virt-xml-kvm-add-disk-default.xml
new file mode 100644
index 00000000..4ee0f1cb
--- /dev/null
+++ b/tests/cli-test-xml/compare/virt-xml-kvm-add-disk-default.xml
@@ -0,0 +1,13 @@
+   <on_reboot>restart</on_reboot>
+   <on_crash>destroy</on_crash>
+   <devices>
++    <disk type="file" device="disk">
++      <driver name="qemu" type="qcow2"/>
++      <source file="/dev/default-pool/testvol1.img"/>
++      <target dev="hda" bus="ide"/>
++    </disk>
+   </devices>
+ </domain>
+
+Domain 'test' defined successfully.
+Changes will take effect after the domain is fully powered off.
\ No newline at end of file
diff --git a/tests/cli-test-xml/compare/virt-xml-kvm-add-disk-os-from-cmdline.xml b/tests/cli-test-xml/compare/virt-xml-kvm-add-disk-os-from-cmdline.xml
new file mode 100644
index 00000000..e5e4bd62
--- /dev/null
+++ b/tests/cli-test-xml/compare/virt-xml-kvm-add-disk-os-from-cmdline.xml
@@ -0,0 +1,14 @@
+     <panic model="s390"/>
+     <panic model="pseries"/>
+     <panic model="hyperv"/>
++    <disk type="file" device="disk">
++      <driver name="qemu" type="qcow2"/>
++      <source file="/dev/default-pool/testvol1.img"/>
++      <target dev="vdaf" bus="virtio"/>
++    </disk>
+   </devices>
+   <seclabel type="dynamic" model="selinux" relabel="yes"/>
+   <seclabel type="static" model="dac" relabel="yes">
+
+Domain 'test-many-devices' defined successfully.
+Changes will take effect after the domain is fully powered off.
\ No newline at end of file
diff --git a/tests/cli-test-xml/compare/virt-xml-kvm-add-disk-os-from-xml.xml b/tests/cli-test-xml/compare/virt-xml-kvm-add-disk-os-from-xml.xml
new file mode 100644
index 00000000..e5e4bd62
--- /dev/null
+++ b/tests/cli-test-xml/compare/virt-xml-kvm-add-disk-os-from-xml.xml
@@ -0,0 +1,14 @@
+     <panic model="s390"/>
+     <panic model="pseries"/>
+     <panic model="hyperv"/>
++    <disk type="file" device="disk">
++      <driver name="qemu" type="qcow2"/>
++      <source file="/dev/default-pool/testvol1.img"/>
++      <target dev="vdaf" bus="virtio"/>
++    </disk>
+   </devices>
+   <seclabel type="dynamic" model="selinux" relabel="yes"/>
+   <seclabel type="static" model="dac" relabel="yes">
+
+Domain 'test-many-devices' defined successfully.
+Changes will take effect after the domain is fully powered off.
\ No newline at end of file
diff --git a/tests/cli-test-xml/compare/virt-xml-kvm-add-network-default.xml b/tests/cli-test-xml/compare/virt-xml-kvm-add-network-default.xml
new file mode 100644
index 00000000..92bf1816
--- /dev/null
+++ b/tests/cli-test-xml/compare/virt-xml-kvm-add-network-default.xml
@@ -0,0 +1,13 @@
+   <on_reboot>restart</on_reboot>
+   <on_crash>destroy</on_crash>
+   <devices>
++    <interface type="bridge">
++      <source bridge="eth0"/>
++      <mac address="00:11:22:33:44:55"/>
++      <model type="e1000"/>
++    </interface>
+   </devices>
+ </domain>
+
+Domain 'test' defined successfully.
+Changes will take effect after the domain is fully powered off.
\ No newline at end of file
diff --git a/tests/cli-test-xml/compare/virt-xml-kvm-add-network-os-from-cmdline.xml b/tests/cli-test-xml/compare/virt-xml-kvm-add-network-os-from-cmdline.xml
new file mode 100644
index 00000000..c834c936
--- /dev/null
+++ b/tests/cli-test-xml/compare/virt-xml-kvm-add-network-os-from-cmdline.xml
@@ -0,0 +1,14 @@
+     <panic model="s390"/>
+     <panic model="pseries"/>
+     <panic model="hyperv"/>
++    <interface type="bridge">
++      <source bridge="eth0"/>
++      <mac address="00:11:22:33:44:55"/>
++      <model type="virtio"/>
++    </interface>
+   </devices>
+   <seclabel type="dynamic" model="selinux" relabel="yes"/>
+   <seclabel type="static" model="dac" relabel="yes">
+
+Domain 'test-many-devices' defined successfully.
+Changes will take effect after the domain is fully powered off.
\ No newline at end of file
diff --git a/tests/cli-test-xml/compare/virt-xml-kvm-add-network-os-from-xml.xml b/tests/cli-test-xml/compare/virt-xml-kvm-add-network-os-from-xml.xml
new file mode 100644
index 00000000..c834c936
--- /dev/null
+++ b/tests/cli-test-xml/compare/virt-xml-kvm-add-network-os-from-xml.xml
@@ -0,0 +1,14 @@
+     <panic model="s390"/>
+     <panic model="pseries"/>
+     <panic model="hyperv"/>
++    <interface type="bridge">
++      <source bridge="eth0"/>
++      <mac address="00:11:22:33:44:55"/>
++      <model type="virtio"/>
++    </interface>
+   </devices>
+   <seclabel type="dynamic" model="selinux" relabel="yes"/>
+   <seclabel type="static" model="dac" relabel="yes">
+
+Domain 'test-many-devices' defined successfully.
+Changes will take effect after the domain is fully powered off.
\ No newline at end of file
diff --git a/tests/clitest.py b/tests/clitest.py
index 144eac7a..80f38e65 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -954,6 +954,13 @@ 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 (KVM)", "--connect %(URI-KVM)s --print-diff --define")
+c.add_compare("test --add-device --disk %(EXISTIMG1)s", "kvm-add-disk-default") # Guest OS is not known
+c.add_compare("test-many-devices --add-device --disk %(EXISTIMG1)s", "kvm-add-disk-os-from-xml") # Guest OS information taken from the guest XML
+c.add_compare("test-many-devices --add-device --disk %(EXISTIMG1)s --os-variant winme", "kvm-add-disk-os-from-cmdline") # Guest OS information provided on the command line
+c.add_compare("test --add-device --network default", "kvm-add-network-default") # Guest OS is not known
+c.add_compare("test-many-devices --add-device --network default", "kvm-add-network-os-from-xml") # Guest OS information taken from the guest XML
+c.add_compare("test-many-devices --add-device --network default --os-variant winme", "kvm-add-network-os-from-cmdline") # Guest OS information provided on the command line
 
 
 
-- 
2.19.1




More information about the virt-tools-list mailing list