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!
Show replies by date