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).
This commit is contained in:
Richard W.M. Jones 2007-06-20 10:01:14 +00:00
parent 9562ed3462
commit 2958900d22
4 changed files with 44 additions and 6 deletions

View File

@ -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

View 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);
}

View 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'

View 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);