]> xenbits.xensource.com Git - libvirt.git/commitdiff
driver: ensure NULL URI isn't passed to drivers with whitelisted URIs
authorDaniel P. Berrangé <berrange@redhat.com>
Wed, 28 Mar 2018 11:49:29 +0000 (12:49 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Thu, 12 Apr 2018 15:52:02 +0000 (16:52 +0100)
Ensuring that we don't call the virDrvConnectOpen method with a NULL URI
means that the drivers can drop various checks for NULL URIs. These were
not needed anymore since the probe functionality was split

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
23 files changed:
src/bhyve/bhyve_driver.c
src/esx/esx_driver.c
src/hyperv/hyperv_driver.c
src/interface/interface_backend_netcf.c
src/interface/interface_backend_udev.c
src/libvirt.c
src/libxl/libxl_driver.c
src/lxc/lxc_driver.c
src/network/bridge_driver.c
src/node_device/node_device_driver.c
src/nwfilter/nwfilter_driver.c
src/openvz/openvz_driver.c
src/phyp/phyp_driver.c
src/qemu/qemu_driver.c
src/secret/secret_driver.c
src/storage/storage_driver.c
src/test/test_driver.c
src/uml/uml_driver.c
src/vbox/vbox_common.c
src/vbox/vbox_driver.c
src/vmware/vmware_driver.c
src/vz/vz_driver.c
src/xenapi/xenapi_driver.c

index 49c7db6567a3480dbd43488e54324a8eb54c1b6e..980d145496d7e9d0f906c870c14ca45de086c175 100644 (file)
@@ -199,21 +199,17 @@ bhyveConnectOpen(virConnectPtr conn,
 {
      virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-     if (conn->uri == NULL) {
-         return VIR_DRV_OPEN_DECLINED;
-     } else {
-         if (STRNEQ_NULLABLE(conn->uri->path, "/system")) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("Unexpected bhyve URI path '%s', try bhyve:///system"),
-                           conn->uri->path);
-            return VIR_DRV_OPEN_ERROR;
-         }
-
-         if (bhyve_driver == NULL) {
-             virReportError(VIR_ERR_INTERNAL_ERROR,
-                            "%s", _("bhyve state driver is not active"));
-             return VIR_DRV_OPEN_ERROR;
-         }
+     if (STRNEQ_NULLABLE(conn->uri->path, "/system")) {
+         virReportError(VIR_ERR_INTERNAL_ERROR,
+                        _("Unexpected bhyve URI path '%s', try bhyve:///system"),
+                        conn->uri->path);
+         return VIR_DRV_OPEN_ERROR;
+     }
+
+     if (bhyve_driver == NULL) {
+         virReportError(VIR_ERR_INTERNAL_ERROR,
+                        "%s", _("bhyve state driver is not active"));
+         return VIR_DRV_OPEN_ERROR;
      }
 
      if (virConnectOpenEnsureACL(conn) < 0)
index 9b6944ba5991c166b4eb952fe971fea7dc610be6..335d9a970d2a3acb96c1f8274a328935053f6ea4 100644 (file)
@@ -851,10 +851,6 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
 
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    /* Decline if the URI is NULL or the scheme is NULL */
-    if (!conn->uri)
-        return VIR_DRV_OPEN_DECLINED;
-
     if (STRCASENEQ(conn->uri->scheme, "vpx") &&
         conn->uri->path && STRNEQ(conn->uri->path, "/")) {
         VIR_WARN("Ignoring unexpected path '%s' for non-vpx scheme '%s'",
index 4ad8855dcc21ce5d13953d22b3862e68e05d60a2..d02c0ac3734e7c6ef905cad493bdb4c6bc14fdf3 100644 (file)
@@ -128,10 +128,6 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
 
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    /* Decline if the URI is NULL or the scheme is NULL */
-    if (conn->uri == NULL)
-        return VIR_DRV_OPEN_DECLINED;
-
     /* Require server part */
     if (conn->uri->server == NULL) {
         virReportError(VIR_ERR_INVALID_ARG, "%s",
index ff3443c8e63b40bbd41b6c427e5ffafb4b14dc48..cc2402febb321b0c19c846ff14c60b57d29ae3c1 100644 (file)
@@ -159,31 +159,25 @@ netcfConnectOpen(virConnectPtr conn,
 {
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    /* Verify uri was specified */
-    if (conn->uri == NULL) {
-        /* Only hypervisor drivers are permitted to auto-open on NULL uri */
-        return VIR_DRV_OPEN_DECLINED;
-    } else {
-        if (driver == NULL) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("interface state driver is not active"));
+    if (driver == NULL) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("interface state driver is not active"));
+        return VIR_DRV_OPEN_ERROR;
+    }
+
+    if (driver->privileged) {
+        if (STRNEQ(conn->uri->path, "/system")) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("unexpected interface URI path '%s', try interface:///system"),
+                           conn->uri->path);
             return VIR_DRV_OPEN_ERROR;
         }
-
-        if (driver->privileged) {
-            if (STRNEQ(conn->uri->path, "/system")) {
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               _("unexpected interface URI path '%s', try interface:///system"),
-                               conn->uri->path);
-                return VIR_DRV_OPEN_ERROR;
-            }
-        } else {
-            if (STRNEQ(conn->uri->path, "/session")) {
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               _("unexpected interface URI path '%s', try interface:///session"),
-                               conn->uri->path);
-                return VIR_DRV_OPEN_ERROR;
-            }
+    } else {
+        if (STRNEQ(conn->uri->path, "/session")) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("unexpected interface URI path '%s', try interface:///session"),
+                           conn->uri->path);
+            return VIR_DRV_OPEN_ERROR;
         }
     }
 
index 743aafd8baf03e5573d502f622b9efc82495faca..4b975ae4b47011d269ad8b04ddb538dfdc5ca1b7 100644 (file)
@@ -1203,31 +1203,25 @@ udevConnectOpen(virConnectPtr conn,
 {
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    /* Verify uri was specified */
-    if (conn->uri == NULL) {
-        /* Only hypervisor drivers are permitted to auto-open on NULL uri */
-        return VIR_DRV_OPEN_DECLINED;
-    } else {
-        if (driver == NULL) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("interface state driver is not active"));
+    if (driver == NULL) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("interface state driver is not active"));
+        return VIR_DRV_OPEN_ERROR;
+    }
+
+    if (driver->privileged) {
+        if (STRNEQ(conn->uri->path, "/system")) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("unexpected interface URI path '%s', try interface:///system"),
+                           conn->uri->path);
             return VIR_DRV_OPEN_ERROR;
         }
-
-        if (driver->privileged) {
-            if (STRNEQ(conn->uri->path, "/system")) {
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               _("unexpected interface URI path '%s', try interface:///system"),
-                               conn->uri->path);
-                return VIR_DRV_OPEN_ERROR;
-            }
-        } else {
-            if (STRNEQ(conn->uri->path, "/session")) {
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               _("unexpected interface URI path '%s', try interface:///session"),
-                               conn->uri->path);
-                return VIR_DRV_OPEN_ERROR;
-            }
+    } else {
+        if (STRNEQ(conn->uri->path, "/session")) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("unexpected interface URI path '%s', try interface:///session"),
+                           conn->uri->path);
+            return VIR_DRV_OPEN_ERROR;
         }
     }
 
index cc1387341adb904c307744b41adc335db9991633..30345af10d8bb65a12b63d270daafff0e9153bc6 100644 (file)
@@ -1074,9 +1074,13 @@ virConnectOpenInternal(const char *name,
         }
 
         /* Filter drivers based on declared URI schemes */
-        if (virConnectDriverTab[i]->uriSchemes && ret->uri) {
+        if (virConnectDriverTab[i]->uriSchemes) {
             bool matchScheme = false;
             size_t s;
+            if (!ret->uri) {
+                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;
index 872790e7432c893c7a8105d5560762c39159a92b..45d0c99902739ba1c05ac16906d1e3e4af2b19c0 100644 (file)
@@ -845,26 +845,22 @@ libxlConnectOpen(virConnectPtr conn,
 {
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    if (conn->uri == NULL) {
-        return VIR_DRV_OPEN_DECLINED;
-    } else {
-        /* Error if xen or libxl scheme specified but driver not started. */
-        if (libxl_driver == NULL) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("libxenlight state driver is not active"));
-            return VIR_DRV_OPEN_ERROR;
-        }
+    /* Error if xen or libxl scheme specified but driver not started. */
+    if (libxl_driver == NULL) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("libxenlight state driver is not active"));
+        return VIR_DRV_OPEN_ERROR;
+    }
 
-        /* /session isn't supported in libxenlight */
-        if (conn->uri->path &&
-            STRNEQ(conn->uri->path, "") &&
-            STRNEQ(conn->uri->path, "/") &&
-            STRNEQ(conn->uri->path, "/system")) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("unexpected Xen URI path '%s', try xen:///system"),
-                           NULLSTR(conn->uri->path));
-            return VIR_DRV_OPEN_ERROR;
-        }
+    /* /session isn't supported in libxenlight */
+    if (conn->uri->path &&
+        STRNEQ(conn->uri->path, "") &&
+        STRNEQ(conn->uri->path, "/") &&
+        STRNEQ(conn->uri->path, "/system")) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("unexpected Xen URI path '%s', try xen:///system"),
+                       NULLSTR(conn->uri->path));
+        return VIR_DRV_OPEN_ERROR;
     }
 
     if (virConnectOpenEnsureACL(conn) < 0)
index 43815b2f20d0c27b94771642120088a2c10afb55..ce541152caf86d73eadb42ce12f789f874e70e74 100644 (file)
@@ -169,26 +169,21 @@ static virDrvOpenStatus lxcConnectOpen(virConnectPtr conn,
 {
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    /* Verify uri was specified */
-    if (conn->uri == NULL) {
-        return VIR_DRV_OPEN_DECLINED;
-    } else {
-        /* If path isn't '/' then they typoed, tell them correct path */
-        if (conn->uri->path != NULL &&
-            STRNEQ(conn->uri->path, "/") &&
-            STRNEQ(conn->uri->path, "/system")) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("Unexpected LXC URI path '%s', try lxc:///system"),
-                           conn->uri->path);
-            return VIR_DRV_OPEN_ERROR;
-        }
+    /* If path isn't '/' then they typoed, tell them correct path */
+    if (conn->uri->path != NULL &&
+        STRNEQ(conn->uri->path, "/") &&
+        STRNEQ(conn->uri->path, "/system")) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Unexpected LXC URI path '%s', try lxc:///system"),
+                       conn->uri->path);
+        return VIR_DRV_OPEN_ERROR;
+    }
 
-        /* URI was good, but driver isn't active */
-        if (lxc_driver == NULL) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           "%s", _("lxc state driver is not active"));
-            return VIR_DRV_OPEN_ERROR;
-        }
+    /* URI was good, but driver isn't active */
+    if (lxc_driver == NULL) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       "%s", _("lxc state driver is not active"));
+        return VIR_DRV_OPEN_ERROR;
     }
 
     if (virConnectOpenEnsureACL(conn) < 0)
index 98754d44719ad6e568079f1b3e911910d647312e..2e9191f75d53d4f633edb556346d8b44047ba9ca 100644 (file)
@@ -878,31 +878,25 @@ networkConnectOpen(virConnectPtr conn,
 {
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    /* Verify uri was specified */
-    if (conn->uri == NULL) {
-        /* Only hypervisor drivers are permitted to auto-open on NULL uri */
-        return VIR_DRV_OPEN_DECLINED;
-    } else {
-        if (network_driver == NULL) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("network state driver is not active"));
+    if (network_driver == NULL) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("network state driver is not active"));
+        return VIR_DRV_OPEN_ERROR;
+    }
+
+    if (network_driver->privileged) {
+        if (STRNEQ(conn->uri->path, "/system")) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("unexpected network URI path '%s', try network:///system"),
+                           conn->uri->path);
             return VIR_DRV_OPEN_ERROR;
         }
-
-        if (network_driver->privileged) {
-            if (STRNEQ(conn->uri->path, "/system")) {
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               _("unexpected network URI path '%s', try network:///system"),
-                               conn->uri->path);
-                return VIR_DRV_OPEN_ERROR;
-            }
-        } else {
-            if (STRNEQ(conn->uri->path, "/session")) {
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               _("unexpected network URI path '%s', try network:///session"),
-                               conn->uri->path);
-                return VIR_DRV_OPEN_ERROR;
-            }
+    } else {
+        if (STRNEQ(conn->uri->path, "/session")) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("unexpected network URI path '%s', try network:///session"),
+                           conn->uri->path);
+            return VIR_DRV_OPEN_ERROR;
         }
     }
 
index a3e3d76dfc80928d00179e167c0fbd879ab1b272..61afa1f8eb490af27ec5d6c98fced8c89112cf8e 100644 (file)
@@ -54,31 +54,25 @@ nodeConnectOpen(virConnectPtr conn,
 {
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    /* Verify uri was specified */
-    if (conn->uri == NULL) {
-        /* Only hypervisor drivers are permitted to auto-open on NULL uri */
-        return VIR_DRV_OPEN_DECLINED;
-    } else {
-        if (driver == NULL) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("nodedev state driver is not active"));
+    if (driver == NULL) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("nodedev state driver is not active"));
+        return VIR_DRV_OPEN_ERROR;
+    }
+
+    if (driver->privileged) {
+        if (STRNEQ(conn->uri->path, "/system")) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("unexpected nodedev URI path '%s', try nodedev:///system"),
+                           conn->uri->path);
             return VIR_DRV_OPEN_ERROR;
         }
-
-        if (driver->privileged) {
-            if (STRNEQ(conn->uri->path, "/system")) {
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               _("unexpected nodedev URI path '%s', try nodedev:///system"),
-                               conn->uri->path);
-                return VIR_DRV_OPEN_ERROR;
-            }
-        } else {
-            if (STRNEQ(conn->uri->path, "/session")) {
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               _("unexpected nodedev URI path '%s', try nodedev:///session"),
-                               conn->uri->path);
-                return VIR_DRV_OPEN_ERROR;
-            }
+    } else {
+        if (STRNEQ(conn->uri->path, "/session")) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("unexpected nodedev URI path '%s', try nodedev:///session"),
+                           conn->uri->path);
+            return VIR_DRV_OPEN_ERROR;
         }
     }
 
index 76289265a21a7e1b66d98eeca3d489450cd3f2ee..542de03596de6203e3d3b9c501e4765ae9a4a688 100644 (file)
@@ -371,23 +371,17 @@ nwfilterConnectOpen(virConnectPtr conn,
 {
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    /* Verify uri was specified */
-    if (conn->uri == NULL) {
-        /* Only hypervisor drivers are permitted to auto-open on NULL uri */
-        return VIR_DRV_OPEN_DECLINED;
-    } else {
-        if (driver == NULL) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("nwfilter state driver is not active"));
-            return VIR_DRV_OPEN_ERROR;
-        }
+    if (driver == NULL) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("nwfilter state driver is not active"));
+        return VIR_DRV_OPEN_ERROR;
+    }
 
-        if (STRNEQ(conn->uri->path, "/system")) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("unexpected nwfilter URI path '%s', try nwfilter:///system"),
-                           conn->uri->path);
-            return VIR_DRV_OPEN_ERROR;
-        }
+    if (STRNEQ(conn->uri->path, "/system")) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("unexpected nwfilter URI path '%s', try nwfilter:///system"),
+                       conn->uri->path);
+        return VIR_DRV_OPEN_ERROR;
     }
 
     if (virConnectOpenEnsureACL(conn) < 0)
index e2346eabc99adc5d0c441c927e818ca7c17aca9c..7cdf65c7f5dc6eaeca2f7b1f30194c8c6f087762 100644 (file)
@@ -1354,29 +1354,25 @@ static virDrvOpenStatus openvzConnectOpen(virConnectPtr conn,
 
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    if (conn->uri == NULL) {
-        return VIR_DRV_OPEN_DECLINED;
-    } else {
-        /* If path isn't /system, then they typoed, so tell them correct path */
-        if (conn->uri->path == NULL ||
-            STRNEQ(conn->uri->path, "/system")) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("unexpected OpenVZ URI path '%s', try openvz:///system"),
-                           conn->uri->path);
-            return VIR_DRV_OPEN_ERROR;
-        }
+    /* If path isn't /system, then they typoed, so tell them correct path */
+    if (conn->uri->path == NULL ||
+        STRNEQ(conn->uri->path, "/system")) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("unexpected OpenVZ URI path '%s', try openvz:///system"),
+                       conn->uri->path);
+        return VIR_DRV_OPEN_ERROR;
+    }
 
-        if (!virFileExists("/proc/vz")) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("OpenVZ control file /proc/vz does not exist"));
-            return VIR_DRV_OPEN_ERROR;
-        }
+    if (!virFileExists("/proc/vz")) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("OpenVZ control file /proc/vz does not exist"));
+        return VIR_DRV_OPEN_ERROR;
+    }
 
-        if (access("/proc/vz", W_OK) < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("OpenVZ control file /proc/vz is not accessible"));
-            return VIR_DRV_OPEN_ERROR;
-        }
+    if (access("/proc/vz", W_OK) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("OpenVZ control file /proc/vz is not accessible"));
+        return VIR_DRV_OPEN_ERROR;
     }
 
     /* We now know the URI is definitely for this driver, so beyond
index ddbd9144bc4c53723fea31bbd782518fd6c714f4..55d459df5c77d03373e4456cb526c7ce600b6b5b 100644 (file)
@@ -1141,9 +1141,6 @@ phypConnectOpen(virConnectPtr conn,
 
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    if (!conn || !conn->uri)
-        return VIR_DRV_OPEN_DECLINED;
-
     if (conn->uri->server == NULL) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        "%s", _("Missing server name in phyp:// URI"));
index bd9c592a7a86cacbd47c773d4358b289b194fa9e..d814e0a2edda0ce6633537ba57c1537e4a28842b 100644 (file)
@@ -1143,38 +1143,34 @@ static virDrvOpenStatus qemuConnectOpen(virConnectPtr conn,
     virDrvOpenStatus ret = VIR_DRV_OPEN_ERROR;
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    if (conn->uri == NULL) {
-        return VIR_DRV_OPEN_DECLINED;
-    } else {
-        if (qemu_driver == NULL) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("qemu state driver is not active"));
-            goto cleanup;
-        }
+    if (qemu_driver == NULL) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("qemu state driver is not active"));
+        goto cleanup;
+    }
+
+    cfg = virQEMUDriverGetConfig(qemu_driver);
+    if (conn->uri->path == NULL) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("no QEMU URI path given, try %s"),
+                       cfg->uri);
+        goto cleanup;
+    }
 
-        cfg = virQEMUDriverGetConfig(qemu_driver);
-        if (conn->uri->path == NULL) {
+    if (virQEMUDriverIsPrivileged(qemu_driver)) {
+        if (STRNEQ(conn->uri->path, "/system") &&
+            STRNEQ(conn->uri->path, "/session")) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("no QEMU URI path given, try %s"),
-                           cfg->uri);
+                           _("unexpected QEMU URI path '%s', try qemu:///system"),
+                           conn->uri->path);
             goto cleanup;
         }
-
-        if (virQEMUDriverIsPrivileged(qemu_driver)) {
-            if (STRNEQ(conn->uri->path, "/system") &&
-                STRNEQ(conn->uri->path, "/session")) {
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               _("unexpected QEMU URI path '%s', try qemu:///system"),
-                               conn->uri->path);
-                goto cleanup;
-            }
-        } else {
-            if (STRNEQ(conn->uri->path, "/session")) {
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               _("unexpected QEMU URI path '%s', try qemu:///session"),
-                               conn->uri->path);
-                goto cleanup;
-            }
+    } else {
+        if (STRNEQ(conn->uri->path, "/session")) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("unexpected QEMU URI path '%s', try qemu:///session"),
+                           conn->uri->path);
+            goto cleanup;
         }
     }
 
index aedfa10dccf7890aa9b2b252794c4849181ead05..02fcaece35b5ff15810bf1dfebb31a74629d7f69 100644 (file)
@@ -524,31 +524,25 @@ secretConnectOpen(virConnectPtr conn,
 {
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    /* Verify uri was specified */
-    if (conn->uri == NULL) {
-        /* Only hypervisor drivers are permitted to auto-open on NULL uri */
-        return VIR_DRV_OPEN_DECLINED;
-    } else {
-        if (driver == NULL) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("secret state driver is not active"));
+    if (driver == NULL) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("secret state driver is not active"));
+        return VIR_DRV_OPEN_ERROR;
+    }
+
+    if (driver->privileged) {
+        if (STRNEQ(conn->uri->path, "/system")) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("unexpected secret URI path '%s', try secret:///system"),
+                           conn->uri->path);
             return VIR_DRV_OPEN_ERROR;
         }
-
-        if (driver->privileged) {
-            if (STRNEQ(conn->uri->path, "/system")) {
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               _("unexpected secret URI path '%s', try secret:///system"),
-                               conn->uri->path);
-                return VIR_DRV_OPEN_ERROR;
-            }
-        } else {
-            if (STRNEQ(conn->uri->path, "/session")) {
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               _("unexpected secret URI path '%s', try secret:///session"),
-                               conn->uri->path);
-                return VIR_DRV_OPEN_ERROR;
-            }
+    } else {
+        if (STRNEQ(conn->uri->path, "/session")) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("unexpected secret URI path '%s', try secret:///session"),
+                           conn->uri->path);
+            return VIR_DRV_OPEN_ERROR;
         }
     }
 
index 1a8173384230755256accf775761502d1339311b..6104276730766b74d469b10a218372518531fad9 100644 (file)
@@ -384,31 +384,25 @@ storageConnectOpen(virConnectPtr conn,
 {
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    /* Verify uri was specified */
-    if (conn->uri == NULL) {
-        /* Only hypervisor drivers are permitted to auto-open on NULL uri */
-        return VIR_DRV_OPEN_DECLINED;
-    } else {
-        if (driver == NULL) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("storage state driver is not active"));
+    if (driver == NULL) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("storage state driver is not active"));
+        return VIR_DRV_OPEN_ERROR;
+    }
+
+    if (driver->privileged) {
+        if (STRNEQ(conn->uri->path, "/system")) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("unexpected storage URI path '%s', try storage:///system"),
+                           conn->uri->path);
             return VIR_DRV_OPEN_ERROR;
         }
-
-        if (driver->privileged) {
-            if (STRNEQ(conn->uri->path, "/system")) {
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               _("unexpected storage URI path '%s', try storage:///system"),
-                               conn->uri->path);
-                return VIR_DRV_OPEN_ERROR;
-            }
-        } else {
-            if (STRNEQ(conn->uri->path, "/session")) {
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               _("unexpected storage URI path '%s', try storage:///session"),
-                               conn->uri->path);
-                return VIR_DRV_OPEN_ERROR;
-            }
+    } else {
+        if (STRNEQ(conn->uri->path, "/session")) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("unexpected storage URI path '%s', try storage:///session"),
+                           conn->uri->path);
+            return VIR_DRV_OPEN_ERROR;
         }
     }
 
index 7f9c7f751ebe9b4794acb44a91095e24f11201fe..56d496a84980df6f28d5153685ba0852196ce46e 100644 (file)
@@ -1454,10 +1454,6 @@ testConnectOpen(virConnectPtr conn,
 
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    if (!conn->uri)
-        return VIR_DRV_OPEN_DECLINED;
-
-    /* From this point on, the connection is for us. */
     if (!conn->uri->path
         || conn->uri->path[0] == '\0'
         || (conn->uri->path[0] == '/' && conn->uri->path[1] == '\0')) {
index 2315cd4d1589795f0fe83c3f025c4751bd40d7e7..ac168ce77b2fb7251ffae97610f7d970639bc5e1 100644 (file)
@@ -1203,35 +1203,31 @@ static virDrvOpenStatus umlConnectOpen(virConnectPtr conn,
 {
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    if (conn->uri == NULL) {
-        return VIR_DRV_OPEN_DECLINED;
-    } else {
-        /* Check path and tell them correct path if they made a mistake */
-        if (uml_driver->privileged) {
-            if (STRNEQ(conn->uri->path, "/system") &&
-                STRNEQ(conn->uri->path, "/session")) {
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               _("unexpected UML URI path '%s', try uml:///system"),
-                               conn->uri->path);
-                return VIR_DRV_OPEN_ERROR;
-            }
-        } else {
-            if (STRNEQ(conn->uri->path, "/session")) {
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               _("unexpected UML URI path '%s', try uml:///session"),
-                               conn->uri->path);
-                return VIR_DRV_OPEN_ERROR;
-            }
+    /* Check path and tell them correct path if they made a mistake */
+    if (uml_driver->privileged) {
+        if (STRNEQ(conn->uri->path, "/system") &&
+            STRNEQ(conn->uri->path, "/session")) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("unexpected UML URI path '%s', try uml:///system"),
+                           conn->uri->path);
+            return VIR_DRV_OPEN_ERROR;
         }
-
-        /* URI was good, but driver isn't active */
-        if (uml_driver == NULL) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("uml state driver is not active"));
+    } else {
+        if (STRNEQ(conn->uri->path, "/session")) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("unexpected UML URI path '%s', try uml:///session"),
+                           conn->uri->path);
             return VIR_DRV_OPEN_ERROR;
         }
     }
 
+    /* URI was good, but driver isn't active */
+    if (uml_driver == NULL) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("uml state driver is not active"));
+        return VIR_DRV_OPEN_ERROR;
+    }
+
     if (virConnectOpenEnsureACL(conn) < 0)
         return VIR_DRV_OPEN_ERROR;
 
index cead821934f7d1dde1940bfaeba1defd0dae8397..cd6807d28a3f9657ce6775bf591a7c261e60a7c3 100644 (file)
@@ -517,9 +517,6 @@ vboxConnectOpen(virConnectPtr conn,
 
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    if (conn->uri == NULL)
-        return VIR_DRV_OPEN_DECLINED;
-
     if (conn->uri->path == NULL || STREQ(conn->uri->path, "")) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("no VirtualBox driver path specified (try vbox:///session)"));
index 395fa8e3d6d4a2ce7e48f8f54b33d8ac25c3c3c5..9e95ab01c5b996437e88d4b7e773104586ae70ac 100644 (file)
@@ -58,9 +58,6 @@ static virDrvOpenStatus dummyConnectOpen(virConnectPtr conn,
 
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    if (conn->uri == NULL)
-        return VIR_DRV_OPEN_DECLINED;
-
     if (conn->uri->path == NULL || STREQ(conn->uri->path, "")) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("no VirtualBox driver path specified (try vbox:///session)"));
index 6118e6fa1376e7ef711d2b31eb889d461a6e2551..de3708aab340263afadef9d6af211b8ae409d76a 100644 (file)
@@ -130,17 +130,12 @@ vmwareConnectOpen(virConnectPtr conn,
 
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    if (conn->uri == NULL) {
-        /* @TODO accept */
-        return VIR_DRV_OPEN_DECLINED;
-    } else {
-        /* If path isn't /session, then they typoed, so tell them correct path */
-        if (conn->uri->path == NULL || STRNEQ(conn->uri->path, "/session")) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("unexpected VMware URI path '%s', try vmwareplayer:///session, vmwarews:///session or vmwarefusion:///session"),
-                           NULLSTR(conn->uri->path));
-            return VIR_DRV_OPEN_ERROR;
-        }
+    /* If path isn't /session, then they typoed, so tell them correct path */
+    if (conn->uri->path == NULL || STRNEQ(conn->uri->path, "/session")) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("unexpected VMware URI path '%s', try vmwareplayer:///session, vmwarews:///session or vmwarefusion:///session"),
+                       NULLSTR(conn->uri->path));
+        return VIR_DRV_OPEN_ERROR;
     }
 
     /* We now know the URI is definitely for this driver, so beyond
index f3047cad6cbd26982333d593445fda491638fa40..5867f1c9118819fb789586eaa5b4618da05c50a6 100644 (file)
@@ -358,9 +358,6 @@ vzConnectOpen(virConnectPtr conn,
 
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    if (!conn->uri)
-        return VIR_DRV_OPEN_DECLINED;
-
     /* From this point on, the connection is for us. */
     if (STRNEQ_NULLABLE(conn->uri->path, "/system")) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
index 86f9e7706dc025bb3ac407dcf5f4f4a8c142aee6..42b305d3169c0c5edbbd4d1c72181e0c213e646b 100644 (file)
@@ -146,9 +146,6 @@ xenapiConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
 
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    if (conn->uri == NULL)
-        return VIR_DRV_OPEN_DECLINED;
-
     if (conn->uri->server == NULL) {
         xenapiSessionErrorHandler(conn, VIR_ERR_INVALID_ARG,
                                   _("Server name not in URI"));