[your mailer seems to want to start a new thread rather than replying to
the existing thread, which makes following your mails difficult. Could
you please fix that?]
On 11/10/2011 09:09 PM, PREETHI RAMESH wrote:
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.
getUUID works on inactive domains. Are you sure you have active
domains? Most likely, the array length really is 0 because you haven't
started any of your domains.
Have you looked into using listDefinedDomains(), to see the remaining
persistent domains that are defined but not running?
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org