[Libvir] Patch to 'ping' XenD when opening connection

Daniel P. Berrange berrange at redhat.com
Mon Jun 12 15:01:33 UTC 2006


Currently the XenD driver's implementation of the 'open' method will return
success, regardless of whether XenD is even present. The attached patch
makes the open method do a 'ping' to see if XenD is actually there, returning
failure if it is not. This ensures that the XenD driver backend doesn't get
activated when connecting to alternate non-Xen backends, such as the test
backend I committed last week.  

The current 'ping' is simply to call the xenDaemonGetVersion() method since
that's a pretty simle & low-overhead way to testing livliness of XenD. Any
suggestions for a better ping - if not I'll go ahead & commit this change 

Regards,
Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 
-------------- next part --------------
Index: src/xend_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xend_internal.c,v
retrieving revision 1.26
diff -u -r1.26 xend_internal.c
--- src/xend_internal.c	27 Apr 2006 14:14:23 -0000	1.26
+++ src/xend_internal.c	12 Jun 2006 15:58:37 -0000
@@ -1651,6 +1651,7 @@
 {
     xmlURIPtr uri;
     int ret;
+    unsigned long version;
 
     if (name == NULL) {
         name = "http://localhost:8000/";
@@ -1663,8 +1664,17 @@
     }
 
     xmlFreeURI(uri);
-    
-    return (xenDaemonOpen_tcp(conn, "localhost", 8000));
+
+    ret = xenDaemonOpen_tcp(conn, "localhost", 8000);
+    if (ret < 0) {
+      return ret;
+    }
+
+    /* A sort of "ping" to make sure the daemon is actually
+       alive & well, rather than just assuming it is */
+    if ((ret = xenDaemonGetVersion(conn, &version)) < 0) {
+      return ret;
+    }
 
 /*    return(xenDaemonOpen_unix(conn, "/var/lib/xend/xend-socket")); */
 


More information about the libvir-list mailing list