
Hey, I've tried the following: 1.Domain d=conn.domainLookupByName("test"); System.out.print("Active test" +d.isActive() ); O/p- This gives me 1 as the answer and hence active. 2.Domain d=conn.domainLookupByName("test"); System.out.print("Active test" +d.isPersistent() ); O/p- Gives me the following error: Exception in thread "main" org.libvirt.LibvirtException: Unknown failure at org.libvirt.ErrorHandler.processError(Unknown Source) at org.libvirt.Connect.processError(Unknown Source) at org.libvirt.Domain.processError(Unknown Source) at org.libvirt.Domain.isPersistent(Unknown Source) 3. Using listDefinedDomains(): String a[]=conn.listDefinedDomains(); System.out.println(a.length); --->gives 0 System.out.println(a[0]); ----> throes null pointer exception 4.Tried looking at VMM, and all the domains are running. The output of xm --list also confirms it. Thanks! Preethi On Sat, Nov 12, 2011 at 4:51 AM, Eric Blake <eblake@redhat.com> wrote:
[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@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org