diff --git a/ChangeLog b/ChangeLog index 5e0ca2a229..7a8c8dfca8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Jun 20 10:54:00 BST 2007 Richard W.M. Jones + + * 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 * src/xend_internal.c: Recognise xen:/// as the standard diff --git a/src/libvirt.c b/src/libvirt.c index c81fe5c033..ac722652e4 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -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); } diff --git a/src/test.c b/src/test.c index 765dc55503..5c5865dabb 100644 --- a/src/test.c +++ b/src/test.c @@ -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' diff --git a/src/xen_unified.c b/src/xen_unified.c index bfc546e22a..87bbd60c6e 100644 --- a/src/xen_unified.c +++ b/src/xen_unified.c @@ -30,6 +30,7 @@ #include #include #include +#include #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);