[fedora-virt] [PATCH] Move virt-what to a python library

Daniel P. Berrange berrange at redhat.com
Thu Nov 11 15:26:18 UTC 2010


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'.

Regards,
Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


More information about the virt mailing list