]> xenbits.xensource.com Git - libvirt.git/commitdiff
Wed Jun 20 10:54:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
authorRichard W.M. Jones <rjones@redhat.com>
Wed, 20 Jun 2007 10:01:14 +0000 (10:01 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Wed, 20 Jun 2007 10:01:14 +0000 (10:01 +0000)
* src/libvirt.c src/test.c src/xen_unified.c: Fix URI processing
  so that local file URIs work again.  Move remote driver to
  last in the list, and fix all drivers so they decline remote
  URIs (Daniel Berrange).

ChangeLog
src/libvirt.c
src/test.c
src/xen_unified.c

index 5e0ca2a2293b5b55ca14b887c30e8cd1fbd99410..7a8c8dfca8b1875986dfe4865eb76bcf10441aa1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Jun 20 10:54:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
+
+       * src/libvirt.c src/test.c src/xen_unified.c: Fix URI processing
+         so that local file URIs work again.  Move remote driver to
+         last in the list, and fix all drivers so they decline remote
+         URIs (Daniel Berrange).
+
 Tue Jun 19 20:07:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
 
        * src/xend_internal.c: Recognise xen:/// as the standard
index c81fe5c0330190cb190dd3d0f5f708b32009b1c6..ac722652e425d34099fca94f6c1172cc3d4826ca 100644 (file)
@@ -65,9 +65,6 @@ virInitialize(void)
      * Note that the order is important: the first ones have a higher
      * priority when calling virConnectOpen.
      */
-#ifdef WITH_REMOTE
-    if (remoteRegister () == -1) return -1;
-#endif
 #ifdef WITH_TEST
     if (testRegister() == -1) return -1;
 #endif
@@ -77,6 +74,9 @@ virInitialize(void)
 #ifdef WITH_XEN
     if (xenUnifiedRegister () == -1) return -1;
 #endif
+#ifdef WITH_REMOTE
+    if (remoteRegister () == -1) return -1;
+#endif
 
     return(0);
 }
index 765dc55503491acff9c9714504e9528fadb9bebf..5c5865dabb3db309a867e854998c33b7a486e736 100644 (file)
@@ -729,6 +729,12 @@ int testOpen(virConnectPtr conn,
         return VIR_DRV_OPEN_DECLINED;
     }
 
+    /* Remote driver should handle these. */
+    if (uri->server) {
+        xmlFreeURI(uri);
+        return VIR_DRV_OPEN_DECLINED;
+    }
+
     /* From this point on, the connection is for us. */
     if (!uri->path
         || uri->path[0] == '\0'
index bfc546e22a4f29f94b072b57d81847e6eaebf998..87bbd60c6ee2c5dcb290b057d91d34c7b8d7abcd 100644 (file)
@@ -30,6 +30,7 @@
 #include <string.h>
 #include <sys/types.h>
 #include <xen/dom0_ops.h>
+#include <libxml/uri.h>
 
 #include "internal.h"
 
@@ -86,12 +87,36 @@ xenUnifiedOpen (virConnectPtr conn, const char *name, int flags)
 {
     int i, j;
     xenUnifiedPrivatePtr priv;
+    xmlURIPtr uri;
 
-    /* If name == NULL, name == "", or begins with "xen", then it's for us. */
+    /* Convert NULL or "" to xen:/// for back compat */
     if (!name || name[0] == '\0')
-        name = "Xen";
-    if (strncasecmp (name, "Xen", 3) != 0)
+        name = "xen:///";
+
+    /* Convert xen -> xen:/// for back compat */
+    if (!strcasecmp(name, "xen"))
+        name = "xen:///";
+
+    uri = xmlParseURI(name);
+    if (uri == NULL) {
+        xenUnifiedError(NULL, VIR_ERR_NO_SUPPORT, name);
+        return VIR_DRV_OPEN_DECLINED;
+    }
+
+    /* Refuse any URI which doesn't start xen:///, / or http:// */
+    if (uri->scheme &&
+        strcasecmp(uri->scheme, "xen") != 0 &&
+        strcasecmp(uri->scheme, "http")) {
+        xmlFreeURI(uri);
         return VIR_DRV_OPEN_DECLINED;
+    }
+
+    /* Refuse any xen:// URI with a server specified - allow remote to do it */
+    if (uri->scheme && !strcasecmp(uri->scheme, "xen") && uri->server) {
+        xmlFreeURI(uri);
+        return VIR_DRV_OPEN_DECLINED;
+    }
+    xmlFreeURI(uri);
 
     /* Allocate per-connection private data. */
     priv = malloc (sizeof *priv);