Now that the legacy Xen driver has been dropped, we no longer need to
support URIs such as "/path/to/xend/socket", and so can mandate that a
URI scheme must always be present.

Signed-off-by: Daniel P. Berrangé <berra...@redhat.com>
---
 src/libvirt.c              | 15 ++++++----
 src/remote/remote_driver.c | 74 ++++++++++++++++++++--------------------------
 2 files changed, 41 insertions(+), 48 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index 30345af10d..600beaa4d5 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 901a2ebfbd..ce2ea27cd8 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -771,51 +771,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 {
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to