[libvirt] [test-API][PATCH] set_vcpus_*: Add check point with vcpusFlags API
Guannan Ren
gren at redhat.com
Mon Dec 17 06:28:03 UTC 2012
On 12/14/2012 04:39 PM, Wayne Sun wrote:
> * add check with vcpusFlags API, it return current or max vcpu
> base on given flags
>
> Signed-off-by: Wayne Sun <gsun at redhat.com>
> ---
> repos/setVcpus/set_vcpus_config.py | 28 ++++++++++++++++++++++++----
> repos/setVcpus/set_vcpus_live.py | 8 ++++++++
> 2 files changed, 32 insertions(+), 4 deletions(-)
>
> diff --git a/repos/setVcpus/set_vcpus_config.py b/repos/setVcpus/set_vcpus_config.py
> index 289dad1..3bb3984 100644
> --- a/repos/setVcpus/set_vcpus_config.py
> +++ b/repos/setVcpus/set_vcpus_config.py
> @@ -63,19 +63,39 @@ def set_vcpus_config(params):
> try:
> domobj = conn.lookupByName(guestname)
> if vcpu:
> + flags = libvirt.VIR_DOMAIN_AFFECT_CONFIG
> logger.info("the given vcpu number is %s" % vcpu)
> logger.info("set domain vcpu as %s with flag: %s" %
> - (vcpu, libvirt.VIR_DOMAIN_AFFECT_CONFIG))
> - domobj.setVcpusFlags(int(vcpu), libvirt.VIR_DOMAIN_AFFECT_CONFIG)
> + (vcpu, flags))
> + domobj.setVcpusFlags(int(vcpu), flags)
> logger.info("set domain vcpu succeed")
>
> + logger.info("check with vcpusFlags api")
> + ret = domobj.vcpusFlags(flags)
> + logger.info("vcpusFlags return current vcpu is: %s" % ret)
> + if ret == int(vcpu):
> + logger.info("vcpusFlags check succeed")
> + else:
> + logger.error("vcpusFlags check failed")
> + return 1
> +
> if maxvcpu:
> + flags = libvirt.VIR_DOMAIN_VCPU_MAXIMUM
> logger.info("the given max vcpu number is %s" % maxvcpu)
> logger.info("set domain maximum vcpu as %s with flag: %s" %
> - (maxvcpu, libvirt.VIR_DOMAIN_VCPU_MAXIMUM))
> - domobj.setVcpusFlags(int(maxvcpu), libvirt.VIR_DOMAIN_VCPU_MAXIMUM)
> + (maxvcpu, flags))
> + domobj.setVcpusFlags(int(maxvcpu), flags)
> logger.info("set domain vcpu succeed")
>
> + logger.info("check with vcpusFlags api")
> + ret = domobj.vcpusFlags(flags)
> + logger.info("vcpusFlags return max vcpu is: %s" % ret)
> + if ret == int(maxvcpu):
> + logger.info("vcpusFlags check succeed")
> + else:
> + logger.error("vcpusFlags check failed")
> + return 1
> +
> except libvirtError, e:
> logger.error("libvirt call failed: " + str(e))
> return 1
> diff --git a/repos/setVcpus/set_vcpus_live.py b/repos/setVcpus/set_vcpus_live.py
> index 35a2976..fdd8f8a 100644
> --- a/repos/setVcpus/set_vcpus_live.py
> +++ b/repos/setVcpus/set_vcpus_live.py
> @@ -82,6 +82,14 @@ def set_vcpus_live(params):
> logger.info("set domain vcpu as %s with flag: %s" %
> (vcpu, libvirt.VIR_DOMAIN_VCPU_LIVE))
> domobj.setVcpusFlags(vcpu, libvirt.VIR_DOMAIN_VCPU_LIVE)
> + logger.info("check with vcpusFlags api")
> + ret = domobj.vcpusFlags(libvirt.VIR_DOMAIN_VCPU_LIVE)
> + logger.info("vcpusFlags return current vcpu is: %s" % ret)
> + if ret == vcpu:
> + logger.info("vcpusFlags check succeed")
> + else:
> + logger.error("vcpusFlags check failed")
> + return 1
> except libvirtError, e:
> logger.error("libvirt call failed: " + str(e))
> return 1
ACK and pushed
Thanks.
Guannan
More information about the libvir-list
mailing list