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