This question concerns the usage of the listDomains(). When I run this<br>
piece of code in KVM, it works perfectly fine but throws an array out of<br>bounds exception in Xen.<br>
<br> Connect conn=null;<br> conn = new Connect("xen:///", true);<br> int[] id = conn.listDomains();<br> System.out.println("lD of VM " +id[0]);<br>
<br>Answer I'd got:<br>
Well, your code assumes that id.length is >= 1, but listDomains() can<br>
return an empty array when there are no active domains known to<br>
libvirt. So you need to check id.length before accessing any element<br>
in the array.<br><br>Follow up- I tried accessing the length of the array and it's 0 all the time. And there are active domains available.<br>In fact, I'm able to getUUID from the domain name. Other functions work fine too.<br>
<br>Am I missing something?Can someone please help me? Thanks!<br>