Change in vdsm[master]: virt: add test to allow custom XML parsing test

mpolednik at redhat.com mpolednik at redhat.com
Thu Apr 16 09:21:16 UTC 2015


Martin Polednik has uploaded a new change for review.

Change subject: virt: add test to allow custom XML parsing test
......................................................................

virt: add test to allow custom XML parsing test

Tests should run against explicit device specification, but it may be
useful to have a means of simply testing that parse of given XML
succeeds. This patch implements such functionality, allowing user to
supply XML in tests/devices/data and modify
tests/parsing/custom_vm_tests.py to see if the parsing conforms general
device specification.

Change-Id: I3bb24e2854e6f7b93c5108eca8b6f79f17353e85
Signed-off-by: Martin Polednik <mpolednik at redhat.com>
---
M tests/Makefile.am
M tests/devices/data/Makefile.am
A tests/devices/data/testSriovVm.xml
M tests/devices/parsing/Makefile.am
A tests/devices/parsing/custom_vm_tests.py
5 files changed, 181 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/09/39909/1

diff --git a/tests/Makefile.am b/tests/Makefile.am
index b8a8964..2bc9018 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -27,6 +27,7 @@
 
 device_modules = \
 	devices/parsing/complex_vm_tests.py \
+	devices/parsing/custom_vm_tests.py \
 	$(NULL)
 
 test_modules = \
diff --git a/tests/devices/data/Makefile.am b/tests/devices/data/Makefile.am
index 0ead0e2..6a6288c 100644
--- a/tests/devices/data/Makefile.am
+++ b/tests/devices/data/Makefile.am
@@ -22,4 +22,5 @@
 
 dist_vdsmdevdatatests_DATA = \
 	testComplexVm.xml \
+	testSriovVm.xml \
 	$(NULL)
diff --git a/tests/devices/data/testSriovVm.xml b/tests/devices/data/testSriovVm.xml
new file mode 100644
index 0000000..2980c7f
--- /dev/null
+++ b/tests/devices/data/testSriovVm.xml
@@ -0,0 +1,144 @@
+<domain type='kvm' id='2'>
+  <name>vm1_Copy</name>
+  <uuid>78144ebf-7894-456e-997f-9fc96083341e</uuid>
+  <memory unit='KiB'>1048576</memory>
+  <currentMemory unit='KiB'>1048576</currentMemory>
+  <vcpu placement='static' current='1'>16</vcpu>
+  <cputune>
+    <shares>1020</shares>
+    <period>12500</period>
+    <quota>100000</quota>
+  </cputune>
+  <resource>
+    <partition>/machine</partition>
+  </resource>
+    <sysinfo type='smbios'>
+      <system>
+        <entry name='manufacturer'>oVirt</entry>
+        <entry name='product'>oVirt Node</entry>
+        <entry name='version'>7.1-0.1.el7</entry>
+        <entry name='serial'>38373035-3536-4247-3830-333334344139</entry>
+        <entry name='uuid'>78144ebf-7894-456e-997f-9fc96083341e</entry>
+      </system>
+    </sysinfo>
+  <os>
+    <type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>
+    <smbios mode='sysinfo'/>
+  </os>
+  <features>
+    <acpi/>
+  </features>
+  <cpu mode='custom' match='exact'>
+    <model fallback='allow'>Conroe</model>
+    <topology sockets='16' cores='1' threads='1'/>
+  </cpu>
+  <clock offset='variable' adjustment='0' basis='utc'>
+    <timer name='rtc' tickpolicy='catchup'/>
+    <timer name='pit' tickpolicy='delay'/>
+    <timer name='hpet' present='no'/>
+  </clock>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/libexec/qemu-kvm</emulator>
+    <disk type='file' device='cdrom'>
+      <driver name='qemu' type='raw'/>
+      <source startupPolicy='optional'/>
+      <backingStore/>
+      <target dev='hdc' bus='ide'/>
+      <readonly/>
+      <serial></serial>
+      <alias name='ide0-1-0'/>
+      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
+    </disk>
+    <disk type='file' device='disk' snapshot='no'>
+      <driver name='qemu' type='raw' cache='none' error_policy='stop' io='threads'/>
+      <source file='/rhev/data-center/bd4ba8d0-024e-412b-aa6e-b22a1654f53e/9a8980dc-b533-4085-884e-daa9f3753ce7/images/369a5d94-05bc-41c0-84c5-ed3b1b8d2d89/79d06c74-8a95-4e4b-afba-8d09975c5f8d'>
+        <seclabel model='selinux' labelskip='yes'/>
+      </source>
+      <backingStore/>
+      <target dev='vda' bus='virtio'/>
+      <serial>369a5d94-05bc-41c0-84c5-ed3b1b8d2d89</serial>
+      <boot order='1'/>
+      <alias name='virtio-disk0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
+    </disk>
+    <controller type='scsi' index='0' model='virtio-scsi'>
+      <alias name='scsi0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+    </controller>
+    <controller type='virtio-serial' index='0' ports='16'>
+      <alias name='virtio-serial0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+    </controller>
+    <controller type='usb' index='0'>
+      <alias name='usb0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'>
+      <alias name='pci.0'/>
+    </controller>
+    <controller type='ide' index='0'>
+      <alias name='ide0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+    </controller>
+    <interface type='hostdev'>
+      <mac address='00:1a:4a:16:01:53'/>
+      <driver name='vfio'/>
+      <source>
+        <address type='pci' domain='0x0000' bus='0x02' slot='0x10' function='0x0'/>
+      </source>
+      <alias name='hostdev0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
+    </interface>
+    <interface type='bridge'>
+      <mac address='00:1a:4a:16:01:54'/>
+      <source bridge='ovirtmgmt'/>
+      <bandwidth>
+      </bandwidth>
+      <target dev='vnet0'/>
+      <model type='virtio'/>
+      <filterref filter='vdsm-no-mac-spoofing'/>
+      <link state='down'/>
+      <alias name='net1'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </interface>
+    <channel type='unix'>
+      <source mode='bind' path='/var/lib/libvirt/qemu/channels/78144ebf-7894-456e-997f-9fc96083341e.com.redhat.rhevm.vdsm'/>
+      <target type='virtio' name='com.redhat.rhevm.vdsm'/>
+      <alias name='channel0'/>
+      <address type='virtio-serial' controller='0' bus='0' port='1'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='bind' path='/var/lib/libvirt/qemu/channels/78144ebf-7894-456e-997f-9fc96083341e.org.qemu.guest_agent.0'/>
+      <target type='virtio' name='org.qemu.guest_agent.0'/>
+      <alias name='channel1'/>
+      <address type='virtio-serial' controller='0' bus='0' port='2'/>
+    </channel>
+    <channel type='spicevmc'>
+      <target type='virtio' name='com.redhat.spice.0'/>
+      <alias name='channel2'/>
+      <address type='virtio-serial' controller='0' bus='0' port='3'/>
+    </channel>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <graphics type='spice' port='5900' tlsPort='5901' autoport='yes' listen='0' passwdValidTo='1970-01-01T00:00:01'>
+      <listen type='address' address='0'/>
+    </graphics>
+    <video>
+      <model type='qxl' ram='65536' vram='32768' vgamem='16384' heads='1'/>
+      <alias name='video0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    </video>
+    <memballoon model='virtio'>
+      <alias name='balloon0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
+    </memballoon>
+  </devices>
+  <seclabel type='dynamic' model='selinux' relabel='yes'>
+    <label>system_u:system_r:svirt_t:s0:c799,c978</label>
+    <imagelabel>system_u:object_r:svirt_image_t:s0:c799,c978</imagelabel>
+  </seclabel>
+</domain>
+
diff --git a/tests/devices/parsing/Makefile.am b/tests/devices/parsing/Makefile.am
index 978e9bd..26edbd4 100644
--- a/tests/devices/parsing/Makefile.am
+++ b/tests/devices/parsing/Makefile.am
@@ -23,4 +23,5 @@
 dist_vdsmdevparsingtests_PYTHON = \
 	__init__.py \
 	complex_vm_tests.py \
+	custom_vm_tests.py \
 	$(NULL)
diff --git a/tests/devices/parsing/custom_vm_tests.py b/tests/devices/parsing/custom_vm_tests.py
new file mode 100644
index 0000000..eca8db9
--- /dev/null
+++ b/tests/devices/parsing/custom_vm_tests.py
@@ -0,0 +1,34 @@
+import os
+
+from testlib import permutations, expandPermutations
+from testlib import XMLTestCase
+
+from virt import domain_descriptor
+import vmfakelib as fake
+
+import verify
+
+
+ at expandPermutations
+class TestVmDevicesXmlParsing(XMLTestCase, verify.DeviceMixin):
+
+    @permutations([['testComplexVm.xml'], ['testSriovVm.xml']])
+    def test_custom_vm(self, domain_xml):
+        params = {'name': 'complexVm', 'displaySecurePort': '-1',
+                  'memSize': '256', 'displayPort': '-1', 'display': 'qxl'}
+
+        devices = [{'device': 'spice', 'type': 'graphics'}]
+
+        test_path = os.path.realpath(__file__)
+        dir_name = os.path.split(test_path)[0]
+        api_path = os.path.join(
+            dir_name, '..', 'data', domain_xml)
+
+        domain = None
+        with open(api_path, 'r') as domxml:
+            domain = domxml.read()
+
+        with fake.VM(params=params, devices=devices) as vm:
+            vm._domain = domain_descriptor.DomainDescriptor(domain)
+            vm._getUnderlyingVmDevicesInfo()
+            self.verifyDevicesConf(vm.conf['devices'])


-- 
To view, visit https://gerrit.ovirt.org/39909
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3bb24e2854e6f7b93c5108eca8b6f79f17353e85
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpolednik at redhat.com>


More information about the vdsm-patches mailing list