[libvirt-users] Finding out if Xen or KVM is used

PREETHI RAMESH iampreethiramesh at gmail.com
Sat Nov 5 07:17:09 UTC 2011


I've got 2 doubts:
1.I've been trying to write an application using Libvirt's Java API which
should run on both Xen and KVM running machines and execute the Xen or KVM
code based on the hypervisor used. I want the physical machine to know if
it's running Xen or KVM and execute only that code.

While using getURI(), I need to use it as
conn.getURI()
but then I can't use conn without declaring it previously as Connect
conn=new Connect("URI");

Is there any way to get the URI used and hence the hypervisor used?

2. This question concerns the usage of the listDomains(). When I run this
piece of code in KVM, it works perfectly fine but throws an array out of
bounds exception in Xen.

Connect conn=null;
             conn = new Connect("xen:///", true);
             int[] id = conn.listDomains();
             System.out.println("lD of VM " +id[0]);

Thanks for your time.
P Ramesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20111105/d687552c/attachment.htm>


More information about the libvirt-users mailing list