[fedora-virt] [PATCH] Move virt-what to a python library
Bryan Kearney
bkearney at redhat.com
Thu Nov 11 15:44:26 UTC 2010
On 11/11/2010 10:26 AM, Daniel P. Berrange wrote:
> On Thu, Nov 11, 2010 at 09:55:45AM -0500, Bryan Kearney wrote:
>> We discussed this a bit yesterday. I have some python client code which
>> needs to know "is guest" and optionally the hypervisor type. The
>> supplied patch uses the same detection logic as the bash script, but
>> puts it into a python library. The detection logic may be a bit dubious,
>> but at least this would allow a single place for such logic.
>>
>
>> + def hypervisor_type(self):
>> + if self.on_vmware(): return vmware
>> + if self.on_virtualpc(): return virtualpc
>> + if self.on_virtualbox(): return virtualbox
>> + if self.on_openvz(): return openvz
>> + if self.on_uml(): return uml
>> + if self.on_xen_hvm(): return xenhvm
>> + if self.is_xen_dom0(): return xendom0
>> + if self.is_xen_domU(): return xendomU
>> + if self.on_kvm(): return kvm
>> + if self.on_qemu(): return qemu
>> + return None
>
> IMHO this is broken by design. I run a RHEL-5 dom0 inside a Fedora
> 14 KVM guest. So multiple of those tests will evaluate to true,
> but this API design hardcodes arbitrary precedence rules that
> mean it always returns 'Xen Dom0' and never 'KVM'.
Ok.. I miss read the original code. The amended patch brings it in line
where it can return a collection of hypervisor strings.
-- bk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Move-the-logic-for-detecting-the-hypervisor-type-int.patch
Type: text/x-patch
Size: 13577 bytes
Desc: not available
Url : http://lists.fedoraproject.org/pipermail/virt/attachments/20101111/004d0c27/attachment-0001.bin
More information about the virt
mailing list