[libvirt] Problem with listDomains() in Xen

PREETHI RAMESH iampreethiramesh at gmail.com
Fri Nov 11 03:44:02 UTC 2011


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]);

Answer I'd got:
Well, your code assumes that id.length is >= 1, but listDomains() can
return an empty array when there are no active domains known to
libvirt. So you need to check id.length before accessing any element
in the array.

Follow up- I tried accessing the length of the array and it's 0 all the
time. And there are active domains available.
In fact, I'm able to getUUID from the domain name. Other functions work
fine too.

Am I missing something?Can someone please help me? Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20111111/d97289ef/attachment-0001.htm>


More information about the libvir-list mailing list