diff --git a/src/libvirt.c b/src/libvirt.c index 30345af10d8bb65a12b63d270daafff0e9153bc6..600beaa4d5c640fcb348d245ed3ddf0aadc6bcda 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -905,7 +905,7 @@ virConnectGetDefaultURI(virConfPtr conf, static int virConnectCheckURIMissingSlash(const char *uristr, virURIPtr uri) { - if (!uri->scheme || !uri->path || !uri->server) + if (!uri->path || !uri->server) return 0; /* To avoid false positives, only check drivers that mandate @@ -1018,6 +1018,13 @@ virConnectOpenInternal(const char *name, NULLSTR(ret->uri->user), ret->uri->port, NULLSTR(ret->uri->path)); + if (ret->uri->scheme == NULL) { + virReportError(VIR_ERR_NO_CONNECT, + _("URI '%s' does not include a driver name"), + name); + goto failed; + } + if (virConnectCheckURIMissingSlash(uristr, ret->uri) < 0) { goto failed; @@ -1038,7 +1045,7 @@ virConnectOpenInternal(const char *name, * not being able to connect to libvirtd or not being able to find * certificates. */ if (STREQ(virConnectDriverTab[i]->hypervisorDriver->name, "remote") && - ret->uri != NULL && ret->uri->scheme != NULL && + ret->uri != NULL && ( #ifndef WITH_PHYP STRCASEEQ(ret->uri->scheme, "phyp") || @@ -1081,10 +1088,6 @@ virConnectOpenInternal(const char *name, VIR_DEBUG("No URI, skipping driver with URI whitelist"); continue; } - if (!ret->uri->scheme) { - VIR_DEBUG("No URI scheme, skipping driver with URI whitelist"); - continue; - } VIR_DEBUG("Checking for supported URI schemes"); for (s = 0; virConnectDriverTab[i]->uriSchemes[s] != NULL; s++) { if (STREQ(ret->uri->scheme, virConnectDriverTab[i]->uriSchemes[s])) { diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 6367848c4cb49f36c329df39c2c55ece4384dbe8..d3b588c3740d72ca9b60be9900eb6ac2ce67983c 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -738,51 +738,41 @@ doRemoteOpen(virConnectPtr conn, * URIs we don't care about */ if (conn->uri) { - if (!conn->uri->scheme) { - /* This is the ///var/lib/xen/xend-socket local path style */ - if (!conn->uri->path) - return VIR_DRV_OPEN_DECLINED; - if (conn->uri->path[0] != '/') - return VIR_DRV_OPEN_DECLINED; - - transport = trans_unix; - } else { - transport_str = get_transport_from_scheme(conn->uri->scheme); + transport_str = get_transport_from_scheme(conn->uri->scheme); - if (!transport_str) { - if (conn->uri->server) - transport = trans_tls; - else - transport = trans_unix; - } else { - if (STRCASEEQ(transport_str, "tls")) { - transport = trans_tls; - } else if (STRCASEEQ(transport_str, "unix")) { - if (conn->uri->server) { - virReportError(VIR_ERR_INVALID_ARG, - _("using unix socket and remote " - "server '%s' is not supported."), - conn->uri->server); - return VIR_DRV_OPEN_ERROR; - } else { - transport = trans_unix; - } - } else if (STRCASEEQ(transport_str, "ssh")) { - transport = trans_ssh; - } else if (STRCASEEQ(transport_str, "libssh2")) { - transport = trans_libssh2; - } else if (STRCASEEQ(transport_str, "ext")) { - transport = trans_ext; - } else if (STRCASEEQ(transport_str, "tcp")) { - transport = trans_tcp; - } else if (STRCASEEQ(transport_str, "libssh")) { - transport = trans_libssh; - } else { - virReportError(VIR_ERR_INVALID_ARG, "%s", - _("remote_open: transport in URL not recognised " - "(should be tls|unix|ssh|ext|tcp|libssh2)")); + if (!transport_str) { + if (conn->uri->server) + transport = trans_tls; + else + transport = trans_unix; + } else { + if (STRCASEEQ(transport_str, "tls")) { + transport = trans_tls; + } else if (STRCASEEQ(transport_str, "unix")) { + if (conn->uri->server) { + virReportError(VIR_ERR_INVALID_ARG, + _("using unix socket and remote " + "server '%s' is not supported."), + conn->uri->server); return VIR_DRV_OPEN_ERROR; + } else { + transport = trans_unix; } + } else if (STRCASEEQ(transport_str, "ssh")) { + transport = trans_ssh; + } else if (STRCASEEQ(transport_str, "libssh2")) { + transport = trans_libssh2; + } else if (STRCASEEQ(transport_str, "ext")) { + transport = trans_ext; + } else if (STRCASEEQ(transport_str, "tcp")) { + transport = trans_tcp; + } else if (STRCASEEQ(transport_str, "libssh")) { + transport = trans_libssh; + } else { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("remote_open: transport in URL not recognised " + "(should be tls|unix|ssh|ext|tcp|libssh2)")); + return VIR_DRV_OPEN_ERROR; } } } else {