Jon Drews
2012-Apr-09 18:19 UTC
[libvirt-users] virsh works but libvirt-java throws a 'No route to host'
I'm able to connect to my xenserver using virsh like so and I see the VMs. [jdrews at flynx ~]$ virsh -c xenapi://root at 192.168.1.23?no_verify=1 list Enter root's password for 192.168.1.23: Id Name State ---------------------------------------------------- Struct did not contain expected field memory_overhead. Struct did not contain expected field snapshot_info. Struct did not contain expected field snapshot_metadata. Struct did not contain expected field parent. Struct did not contain expected field children. Struct did not contain expected field bios_strings. Struct did not contain expected field protection_policy. Struct did not contain expected field is_snapshot_from_vmpp. Struct did not contain expected field appliance. Struct did not contain expected field start_delay. Struct did not contain expected field shutdown_delay. Struct did not contain expected field order. Struct did not contain expected field VGPUs. Struct did not contain expected field attached_PCIs. Struct did not contain expected field suspend_SR. Struct did not contain expected field version. 0 Control domain on host: xenserver-4 running Struct did not contain expected field memory_overhead. Struct did not contain expected field snapshot_info. Struct did not contain expected field snapshot_metadata. Struct did not contain expected field parent. Struct did not contain expected field children. Struct did not contain expected field bios_strings. Struct did not contain expected field protection_policy. Struct did not contain expected field is_snapshot_from_vmpp. Struct did not contain expected field appliance. Struct did not contain expected field start_delay. Struct did not contain expected field shutdown_delay. Struct did not contain expected field order. Struct did not contain expected field VGPUs. Struct did not contain expected field attached_PCIs. Struct did not contain expected field suspend_SR. Struct did not contain expected field version. 23 VM1 (RH5.2 10.4.1.69 eth0) running Struct did not contain expected field memory_overhead. Struct did not contain expected field snapshot_info. Struct did not contain expected field snapshot_metadata. Struct did not contain expected field parent. Struct did not contain expected field children. Struct did not contain expected field bios_strings. Struct did not contain expected field protection_policy. Struct did not contain expected field is_snapshot_from_vmpp. Struct did not contain expected field appliance. Struct did not contain expected field start_delay. Struct did not contain expected field shutdown_delay. Struct did not contain expected field order. Struct did not contain expected field VGPUs. Struct did not contain expected field attached_PCIs. Struct did not contain expected field suspend_SR. Struct did not contain expected field version. 25 DeviceSimulator (192.168.1.150) running Struct did not contain expected field memory_overhead. Struct did not contain expected field snapshot_info. Struct did not contain expected field snapshot_metadata. Struct did not contain expected field parent. Struct did not contain expected field children. Struct did not contain expected field bios_strings. Struct did not contain expected field protection_policy. Struct did not contain expected field is_snapshot_from_vmpp. Struct did not contain expected field appliance. Struct did not contain expected field start_delay. Struct did not contain expected field shutdown_delay. Struct did not contain expected field order. Struct did not contain expected field VGPUs. Struct did not contain expected field attached_PCIs. Struct did not contain expected field suspend_SR. Struct did not contain expected field version. 28 VM3 (RH 5.2 10.4.1.15 eth0) running Struct did not contain expected field memory_overhead. Struct did not contain expected field snapshot_info. Struct did not contain expected field snapshot_metadata. Struct did not contain expected field parent. Struct did not contain expected field children. Struct did not contain expected field bios_strings. Struct did not contain expected field protection_policy. Struct did not contain expected field is_snapshot_from_vmpp. Struct did not contain expected field appliance. Struct did not contain expected field start_delay. Struct did not contain expected field shutdown_delay. Struct did not contain expected field order. Struct did not contain expected field VGPUs. Struct did not contain expected field attached_PCIs. Struct did not contain expected field suspend_SR. Struct did not contain expected field version. 30 Router 10.4.1.x (192.168.1.254) running I'm using a compiled version of libvirt that I enabled the xenapi protocol. [jdrews at flynx ~]$ virsh -v 0.9.10 I can also start and stop VMs via virsh. So the next move for me was to get this working with the java bindings, libvirt-java. I grabbed libvirt-0.4.7.jar and built it. Eclipse is set up and I can see everything correctly. I built a small runnable test jar and ran it. [jdrews at flynx ~]$ java -jar VirtAPITesting.jar connecting on: xenapi://root at 192.168.1.23?no_verify=1 Enter root's password for 192.168.1.23 WARNING: THE ENTERED PASSWORD WILL NOT BE MASKED! mytestpass exception caught:org.libvirt.LibvirtException: unable to connect to server at '192.168.1.23:16514': No route to host level:VIR_ERR_ERROR code:VIR_ERR_SYSTEM_ERROR domain:VIR_FROM_RPC hasConn:false hasDom:false hasNet:false message:unable to connect to server at '192.168.1.23:16514': No route to host str1:%s str2:unable to connect to server at '192.168.1.23:16514': No route to host str3:null int1:-1 int2:-1 Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58) Caused by: java.lang.NullPointerException at com.codemettle.VirtAPI.testing.VirtAPITesting.main(VirtAPITesting.java:29) ... 5 more But I know there is a route to the host as virsh could get there. Sanity check: ping works fine too. [jdrews at flynx ~]$ ping 192.168.1.23 PING 192.168.1.23 (192.168.1.23) 56(84) bytes of data. 64 bytes from 192.168.1.23: icmp_req=1 ttl=64 time=1.58 ms Here is the code I'm running in the VirtAPITesting.jar. For the most part it's a direct copy of the example at the end of the libvirt java page: http://libvirt.org/java.html package com.jdrews.VirtAPI.testing; import org.libvirt.*; public class VirtAPITesting { public static void main(String[] args) throws InterruptedException { System.setProperty("jna.library.path", "/usr/local/lib/"); Connect conn=null; System.out.println( ConnectAuth defaultAuth = new ConnectAuthDefault(); try{ conn = new Connect("xenapi://root at 192.168.1.23?no_verify=1", defaultAuth, 0); } catch (LibvirtException e){ System.out.println("exception caught:"+e); System.out.println(e.getError()); } try { Domain testDomain=conn.domainLookupByName("DeviceSimulator (192.168.1.150)"); System.out.println("Domain:" + testDomain.getName() + " id " + testDomain.getID() + " running " + testDomain.getOSType()); } catch (LibvirtException e) { System.out.println("exception caught:"+e); System.out.println(e.getError()); } } } Does anyone know what's going on here? Any help or advice would be greatly appreciated. Thanks! -- Jon Drews jondrews.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20120409/d71de109/attachment.htm>