Kaitlin Rupert wrote:
Deepti B Kalakeri wrote:
>
>
> Kaitlin Rupert wrote:
>> Deepti B. Kalakeri wrote:
>>> # HG changeset patch
>>> # User Deepti B. Kalakeri<deeptik(a)linux.vnet.ibm.com
>>> # Date 1260446374 28800
>>> # Node ID e95a3d156fc2284484f98f07c39fbfd65929a395
>>> # Parent 683a8a57d54506032a659bdb9178b7558827ffde
>>> [TEST] Fixing vsms/08_modifyresource.py
>>>
>>> Tested with KVM and current sources on Fedora
>>> Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
>>>
>>> diff -r 683a8a57d545 -r e95a3d156fc2
>>> suites/libvirt-cim/lib/XenKvmLib/vsms_util.py
>>> --- a/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py Sat Dec 05
>>> 02:22:09 2009 -0200
>>> +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py Thu Dec 10
>>> 03:59:34 2009 -0800
>>> @@ -120,9 +120,10 @@
>>> cxml.dumpxml(server)
>>> dom = cxml.xml_get_dom_name()
>>> cpu = virsh_vcpuinfo(server, dom, virt)
>>> - if cpu is None:
>>> + if int(cpu) < int(ncpu) or cpu is None:
>>
>> This works, but it's more of a work around. In this case, vcpuinfo
>> returns an error. When we check the output for the VCPU string, we
>> get zero occurrences, which is what virsh_vcpuinfo() returns.
>>
>> A better check would be to see if the virsh call returns an error.
>> If it does, virsh_vcpuinfo() should return None. Otherwise, it
>> should return an integer.
> virsh_vcpuinfo() uses the following command cmd = "virsh -c %s
> vcpuinfo %s 2>/dev/null | grep VCPU | wc -l" % (virt2uri(virt), dom)
> which would return success even when no records are found. So I think a
Agreed. I think that's a flaw of the virsh_vcpuinfo() call though.
Because you never know whether "virsh -c %s vcpuinfo %s" fails. I
would remove the "| grep VCPU | wc -l" portion of the command. Check
to see if the call fails - if it does, return None from
virsh_vcpuinfo(). If the call doesn't fall, parse the output to get
the VCPU count.
Yes! This is what I was thinking of, but was as you said this will take
little more code than the one line which did the work for us.
Thoughts? This is a lot more work, but then you would know when the
virsh call is failing (as opposed to just returning 0 VCPus).
I will work on this
and send the patch.
> better way would be to verify the value returned and return the out
> when command returns something >0,
> otherwise None.
>
> Any suggestions ?
>
--
Thanks and Regards,
Deepti B. Kalakeri
IBM Linux Technology Center
deeptik(a)linux.vnet.ibm.com