Signed-off-by: Luyao Huang <lhuang@xxxxxxxxxx> --- cases/linux_domain.conf | 6 +++ repos/domain/add_del_iothread.py | 82 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 repos/domain/add_del_iothread.py diff --git a/cases/linux_domain.conf b/cases/linux_domain.conf index fd32aad..8a7efe9 100644 --- a/cases/linux_domain.conf +++ b/cases/linux_domain.conf @@ -281,6 +281,12 @@ domain:set_memory_period conn qemu:///system +domain:add_del_iothread + guestname + $defaultname + conn + qemu:///system + domain:destroy guestname $defaultname diff --git a/repos/domain/add_del_iothread.py b/repos/domain/add_del_iothread.py new file mode 100644 index 0000000..2d874f9 --- /dev/null +++ b/repos/domain/add_del_iothread.py @@ -0,0 +1,82 @@ +#!/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 add_del_iothread(params): + """ + test API for addIOThread and delIOThread 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") + + for i in range(300, 1000): + if not find_iothreadid_fromxml(vm, 1, i): + logger.info("add iothread %d to running guest" % i) + vm.addIOThread(i, libvirt.VIR_DOMAIN_AFFECT_LIVE) + if find_iothreadid_fromxml(vm, 1, i): + vm.delIOThread(i, libvirt.VIR_DOMAIN_AFFECT_LIVE) + if find_iothreadid_fromxml(vm, 1, i): + logger.info("FAIL: still can find iothread id in XML") + fail=1 + + break + else: + logger.info("FAIL: cannot find iothread id in XML") + fail=1 + break + + """ test effect guest config""" + logger.info("test with guest inactive XML") + for i in range(300, 1000): + if not find_iothreadid_fromxml(vm, 0, i): + logger.info("add iothread %d to guest config" % i) + vm.addIOThread(i, libvirt.VIR_DOMAIN_AFFECT_CONFIG) + if find_iothreadid_fromxml(vm, 0, i): + vm.delIOThread(i, libvirt.VIR_DOMAIN_AFFECT_CONFIG) + if find_iothreadid_fromxml(vm, 0, i): + logger.info("FAIL: still can find iothread id in XML") + fail=1 + + break + else: + logger.info("FAIL: cannot find iothread id in XML") + fail=1 + break + + 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