[libvirt-test-api][PATCH 3/3] Add a new test case for ioThreadInfo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Luyao Huang <lhuang@xxxxxxxxxx>
---
 cases/linux_domain.conf       |  6 ++++
 repos/domain/info_iothread.py | 80 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 86 insertions(+)
 create mode 100644 repos/domain/info_iothread.py

diff --git a/cases/linux_domain.conf b/cases/linux_domain.conf
index b0bfb24..f8b5663 100644
--- a/cases/linux_domain.conf
+++ b/cases/linux_domain.conf
@@ -293,6 +293,12 @@ domain:pin_iothread
     conn
         qemu:///system
 
+domain:info_iothread
+    guestname
+        $defaultname
+    conn
+        qemu:///system
+
 domain:destroy
     guestname
         $defaultname
diff --git a/repos/domain/info_iothread.py b/repos/domain/info_iothread.py
new file mode 100644
index 0000000..74aedac
--- /dev/null
+++ b/repos/domain/info_iothread.py
@@ -0,0 +1,80 @@
+#!/usr/bin/env python
+
+import libvirt
+from libvirt import libvirtError
+import lxml
+import lxml.etree
+
+required_params = ('guestname',)
+optional_params = {'conn': 'qemu:///system'}
+
+def find_iothreadid_fromxml(vm, running, iothreadid):
+    if (running == 1):
+        tree = lxml.etree.fromstring(vm.XMLDesc(0))
+    else:
+        tree = lxml.etree.fromstring(vm.XMLDesc(libvirt.VIR_DOMAIN_XML_INACTIVE))
+
+    set = tree.xpath("//iothreadids/iothread")
+    for n in set:
+        ids = n.attrib['id']
+        if int(ids) == iothreadid:
+            return True
+
+    return False
+
+def info_iothread(params):
+    """
+       test API for ioThreadInfo in class virDomain
+    """
+
+    logger = params['logger']
+    fail=0
+
+    try:
+        conn = libvirt.open(params['conn'])
+
+        logger.info("get connection to libvirtd")
+        guest = params['guestname']
+        vm = conn.lookupByName(guest)
+        logger.info("test guest name: %s" % guest)
+
+        """ test effect guest running XML """
+        if vm.isActive() == 1:
+            logger.info("guest is running test with running guest")
+
+            ret = vm.ioThreadInfo(libvirt.VIR_DOMAIN_AFFECT_LIVE)
+
+            if len(ret) == 0:
+                vm.addIOThread(1, libvirt.VIR_DOMAIN_AFFECT_LIVE)
+                if not find_iothreadid_fromxml(vm, 1, 1):
+                    logger.info("FAIL: cannot find iothread id in XML")
+                    return 1
+                else:
+                    ret = vm.ioThreadInfo(libvirt.VIR_DOMAIN_AFFECT_LIVE)
+
+            for n in ret:
+                if not find_iothreadid_fromxml(vm, 1, n[0]):
+                    logger.info("FAIL: cannot find iothread id in XML")
+                    fail=1
+
+        """ test effect guest config"""
+        logger.info("test with guest inactive XML")
+        ret = vm.ioThreadInfo(libvirt.VIR_DOMAIN_AFFECT_CONFIG)
+
+        if len(ret) == 0:
+            vm.addIOThread(1, libvirt.VIR_DOMAIN_AFFECT_CONFIG)
+            if not find_iothreadid_fromxml(vm, 0, 1):
+                logger.info("FAIL: cannot find iothread id in XML")
+                return 1
+            else:
+                ret = vm.ioThreadInfo(libvirt.VIR_DOMAIN_AFFECT_CONFIG)
+
+        for n in ret:
+            if not find_iothreadid_fromxml(vm, 0, n[0]):
+                logger.info("FAIL: cannot find iothread id in XML")
+                fail=1
+
+    except libvirtError, e:
+        logger.error("API error message: %s" % e.message)
+        fail=1
+    return fail
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]