[libvirt] [libvirt-test-api][PATCH 3/3] Add a new test case for ioThreadInfo
hongming
honzhang at redhat.com
Mon Aug 31 05:49:27 UTC 2015
On 08/13/2015 11:09 AM, Luyao Huang wrote:
> Signed-off-by: Luyao Huang <lhuang at redhat.com>
> ---
> 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
ACK and Pushed
Thanks
Hongming
More information about the libvir-list
mailing list