[libvirt] [test-API][PATCH] Add test case set_cpu_shares.py for setting cpu scheduler info

Osier Yang jyang at redhat.com
Mon Dec 12 07:46:56 UTC 2011


On 2011年12月12日 15:22, Nan Zhang wrote:
> * repos/domain/set_cpu_shares.py: set the value of cpu_shares
>    property of the guest.
> ---
>   repos/domain/set_cpu_shares.py |  111 ++++++++++++++++++++++++++++++++++++++++
>   1 files changed, 111 insertions(+), 0 deletions(-)
>   create mode 100644 repos/domain/set_cpu_shares.py
>
> diff --git a/repos/domain/set_cpu_shares.py b/repos/domain/set_cpu_shares.py
> new file mode 100644
> index 0000000..4560809
> --- /dev/null
> +++ b/repos/domain/set_cpu_shares.py
> @@ -0,0 +1,111 @@
> +#!/usr/bin/env python
> +"""Set the value of cpu_shares property of the guest
> +   domain:set_cpu_shares
> +       guestname
> +           xxx
> +       flags
> +           0|1|2
> +"""

Per you are testing the cpu_shares, there should be one parameter
for it, so that one can pass whatever value for cpu_shares as he
wants. I see you hardcode it as 2048. Which is not the right way
to go.

And 0|1|2 is not that visible for one get what the actual meaning
is. You might want to use more sensiable strings to do that e.g.
"live", "config", "current".

Also it's quite bad to use the integers (such as 0|1|2) directly in
the codes, which is not good for reading and future maintaining.

So you might want to do like following:

"live" --convert--> "libvirt.VIR_DOMAIN_AFFECT_LIVE"

dom.setSchedulerParametersFlags(params,flags)

Regards,
Osier




More information about the libvir-list mailing list