]> xenbits.xensource.com Git - libvirt.git/commitdiff
driver: declare supported URI schemes in virConnectDriver struct
authorDaniel P. Berrangé <berrange@redhat.com>
Tue, 27 Mar 2018 14:51:45 +0000 (15:51 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Thu, 12 Apr 2018 15:52:02 +0000 (16:52 +0100)
Declare what URI schemes a driver supports in its virConnectDriver
struct. This allows us to skip trying to open the driver entirely
if the URI scheme doesn't match.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
26 files changed:
src/bhyve/bhyve_driver.c
src/driver.h
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/node_device/node_device_hal.c
src/node_device/node_device_udev.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 2e815ca70e8f475fea3d78f787926a33d932f4ae..49c7db6567a3480dbd43488e54324a8eb54c1b6e 100644 (file)
@@ -202,9 +202,6 @@ bhyveConnectOpen(virConnectPtr conn,
      if (conn->uri == NULL) {
          return VIR_DRV_OPEN_DECLINED;
      } else {
-         if (!conn->uri->scheme || STRNEQ(conn->uri->scheme, "bhyve"))
-             return VIR_DRV_OPEN_DECLINED;
-
          if (STRNEQ_NULLABLE(conn->uri->path, "/system")) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("Unexpected bhyve URI path '%s', try bhyve:///system"),
@@ -1736,6 +1733,7 @@ static virHypervisorDriver bhyveHypervisorDriver = {
 
 static virConnectDriver bhyveConnectDriver = {
     .localOnly = true,
+    .uriSchemes = (const char *[]){ "bhyve", NULL },
     .hypervisorDriver = &bhyveHypervisorDriver,
 };
 
index 5fb0b523c89e8bf317f86c8f7fd0b824ed895f7f..b071a3a782567e0f3bf9e94b9f4a16791cc683dc 100644 (file)
@@ -81,6 +81,12 @@ typedef virConnectDriver *virConnectDriverPtr;
 struct _virConnectDriver {
     /* Wether driver permits a server in the URI */
     bool localOnly;
+    /*
+     * NULL terminated list of supported URI schemes.
+     *  - Single element { NULL } list indicates no supported schemes
+     *  - NULL list indicates wildcard supportnig all schemes
+     */
+    const char **uriSchemes;
     virHypervisorDriverPtr hypervisorDriver;
     virInterfaceDriverPtr interfaceDriver;
     virNetworkDriverPtr networkDriver;
index 927267f1cc9861f20a8018c5b98b4a2e69eb414c..9b6944ba5991c166b4eb952fe971fea7dc610be6 100644 (file)
@@ -845,7 +845,6 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
                unsigned int flags)
 {
     virDrvOpenStatus result = VIR_DRV_OPEN_ERROR;
-    char *plus;
     esxPrivate *priv = NULL;
     char *potentialVCenterIPAddress = NULL;
     char vCenterIPAddress[NI_MAXHOST] = "";
@@ -853,32 +852,9 @@ 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 || !conn->uri->scheme)
+    if (!conn->uri)
         return VIR_DRV_OPEN_DECLINED;
 
-    /* Decline if the scheme is not one of {vpx|esx|gsx} */
-    plus = strchr(conn->uri->scheme, '+');
-
-    if (!plus) {
-        if (STRCASENEQ(conn->uri->scheme, "vpx") &&
-            STRCASENEQ(conn->uri->scheme, "esx") &&
-            STRCASENEQ(conn->uri->scheme, "gsx")) {
-            return VIR_DRV_OPEN_DECLINED;
-        }
-    } else {
-        if (plus - conn->uri->scheme != 3 ||
-            (STRCASENEQLEN(conn->uri->scheme, "vpx", 3) &&
-             STRCASENEQLEN(conn->uri->scheme, "esx", 3) &&
-             STRCASENEQLEN(conn->uri->scheme, "gsx", 3))) {
-            return VIR_DRV_OPEN_DECLINED;
-        }
-
-        virReportError(VIR_ERR_INVALID_ARG,
-                       _("Transport '%s' in URI scheme is not supported, try again "
-                         "without the transport part"), plus + 1);
-        return VIR_DRV_OPEN_ERROR;
-    }
-
     if (STRCASENEQ(conn->uri->scheme, "vpx") &&
         conn->uri->path && STRNEQ(conn->uri->path, "/")) {
         VIR_WARN("Ignoring unexpected path '%s' for non-vpx scheme '%s'",
@@ -5262,6 +5238,7 @@ static virHypervisorDriver esxHypervisorDriver = {
 
 
 static virConnectDriver esxConnectDriver = {
+    .uriSchemes = (const char *[]){ "vpx", "esx", "gsx", NULL },
     .hypervisorDriver = &esxHypervisorDriver,
     .interfaceDriver = &esxInterfaceDriver,
     .networkDriver = &esxNetworkDriver,
index e512b626eae8ba8bde23bdc29d038a5bc43f3ea6..4ad8855dcc21ce5d13953d22b3862e68e05d60a2 100644 (file)
@@ -122,7 +122,6 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
                   unsigned int flags)
 {
     virDrvOpenStatus result = VIR_DRV_OPEN_ERROR;
-    char *plus;
     hypervPrivate *priv = NULL;
     char *username = NULL;
     char *password = NULL;
@@ -130,27 +129,9 @@ 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 || conn->uri->scheme == NULL)
+    if (conn->uri == NULL)
         return VIR_DRV_OPEN_DECLINED;
 
-    /* Decline if the scheme is not hyperv */
-    plus = strchr(conn->uri->scheme, '+');
-
-    if (plus == NULL) {
-        if (STRCASENEQ(conn->uri->scheme, "hyperv"))
-            return VIR_DRV_OPEN_DECLINED;
-    } else {
-        if (plus - conn->uri->scheme != 6 ||
-            STRCASENEQLEN(conn->uri->scheme, "hyperv", 6)) {
-            return VIR_DRV_OPEN_DECLINED;
-        }
-
-        virReportError(VIR_ERR_INVALID_ARG,
-                       _("Transport '%s' in URI scheme is not supported, try again "
-                         "without the transport part"), plus + 1);
-        return VIR_DRV_OPEN_ERROR;
-    }
-
     /* Require server part */
     if (conn->uri->server == NULL) {
         virReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -1685,6 +1666,7 @@ hypervDebugHandler(const char *message, debug_level_e level,
 
 
 static virConnectDriver hypervConnectDriver = {
+    .uriSchemes = (const char *[]){ "hyperv", NULL },
     .hypervisorDriver = &hypervHypervisorDriver,
 };
 
index 3da958980fa5bb0a9e7996586f9a92ddcc8c445f..ff3443c8e63b40bbd41b6c427e5ffafb4b14dc48 100644 (file)
@@ -164,9 +164,6 @@ netcfConnectOpen(virConnectPtr conn,
         /* Only hypervisor drivers are permitted to auto-open on NULL uri */
         return VIR_DRV_OPEN_DECLINED;
     } else {
-        if (STRNEQ_NULLABLE(conn->uri->scheme, "interface"))
-            return VIR_DRV_OPEN_DECLINED;
-
         if (driver == NULL) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("interface state driver is not active"));
@@ -1221,6 +1218,7 @@ static virHypervisorDriver interfaceHypervisorDriver = {
 
 static virConnectDriver interfaceConnectDriver = {
     .localOnly = true,
+    .uriSchemes = (const char *[]){ "interface", NULL },
     .hypervisorDriver = &interfaceHypervisorDriver,
     .interfaceDriver = &interfaceDriver,
 };
index 2b8a9da6822f994babd3449866de1468f5eb8817..743aafd8baf03e5573d502f622b9efc82495faca 100644 (file)
@@ -1208,9 +1208,6 @@ udevConnectOpen(virConnectPtr conn,
         /* Only hypervisor drivers are permitted to auto-open on NULL uri */
         return VIR_DRV_OPEN_DECLINED;
     } else {
-        if (STRNEQ_NULLABLE(conn->uri->scheme, "interface"))
-            return VIR_DRV_OPEN_DECLINED;
-
         if (driver == NULL) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("interface state driver is not active"));
@@ -1292,6 +1289,7 @@ static virHypervisorDriver udevHypervisorDriver = {
 
 static virConnectDriver udevConnectDriver = {
     .localOnly = true,
+    .uriSchemes = (const char *[]){ "interface", NULL },
     .hypervisorDriver = &udevHypervisorDriver,
     .interfaceDriver = &udevIfaceDriver,
 };
index 2b2b3ed4254c60d276d327e1086ca91bc0c919da..cc1387341adb904c307744b41adc335db9991633 100644 (file)
@@ -1073,6 +1073,30 @@ virConnectOpenInternal(const char *name,
             continue;
         }
 
+        /* Filter drivers based on declared URI schemes */
+        if (virConnectDriverTab[i]->uriSchemes && ret->uri) {
+            bool matchScheme = false;
+            size_t s;
+            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])) {
+                    VIR_DEBUG("Matched URI scheme '%s'", ret->uri->scheme);
+                    matchScheme = true;
+                    break;
+                }
+            }
+            if (!matchScheme) {
+                VIR_DEBUG("No matching URI scheme");
+                continue;
+            }
+        } else {
+            VIR_DEBUG("Matching any URI scheme for '%s'", ret->uri ? ret->uri->scheme : "");
+        }
+
         ret->driver = virConnectDriverTab[i]->hypervisorDriver;
         ret->interfaceDriver = virConnectDriverTab[i]->interfaceDriver;
         ret->networkDriver = virConnectDriverTab[i]->networkDriver;
index ce4741cf4c12e82744c35f02357c0f3b5d7eee48..872790e7432c893c7a8105d5560762c39159a92b 100644 (file)
@@ -848,10 +848,6 @@ libxlConnectOpen(virConnectPtr conn,
     if (conn->uri == NULL) {
         return VIR_DRV_OPEN_DECLINED;
     } else {
-        /* Only xen scheme */
-        if (conn->uri->scheme == NULL || STRNEQ(conn->uri->scheme, "xen"))
-            return VIR_DRV_OPEN_DECLINED;
-
         /* Error if xen or libxl scheme specified but driver not started. */
         if (libxl_driver == NULL) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -6579,6 +6575,7 @@ static virHypervisorDriver libxlHypervisorDriver = {
 
 static virConnectDriver libxlConnectDriver = {
     .localOnly = true,
+    .uriSchemes = (const char *[]){ "xen", NULL },
     .hypervisorDriver = &libxlHypervisorDriver,
 };
 
index 97742bfba797f095c502d20b17675d7afe0f1b2e..43815b2f20d0c27b94771642120088a2c10afb55 100644 (file)
@@ -173,10 +173,6 @@ static virDrvOpenStatus lxcConnectOpen(virConnectPtr conn,
     if (conn->uri == NULL) {
         return VIR_DRV_OPEN_DECLINED;
     } else {
-        if (conn->uri->scheme == NULL ||
-            STRNEQ(conn->uri->scheme, "lxc"))
-            return VIR_DRV_OPEN_DECLINED;
-
         /* If path isn't '/' then they typoed, tell them correct path */
         if (conn->uri->path != NULL &&
             STRNEQ(conn->uri->path, "/") &&
@@ -5634,6 +5630,7 @@ static virHypervisorDriver lxcHypervisorDriver = {
 
 static virConnectDriver lxcConnectDriver = {
     .localOnly = true,
+    .uriSchemes = (const char *[]){ "lxc", NULL },
     .hypervisorDriver = &lxcHypervisorDriver,
 };
 
index ca48a0358c45585146695f636fe2fac7501dd199..98754d44719ad6e568079f1b3e911910d647312e 100644 (file)
@@ -883,9 +883,6 @@ networkConnectOpen(virConnectPtr conn,
         /* Only hypervisor drivers are permitted to auto-open on NULL uri */
         return VIR_DRV_OPEN_DECLINED;
     } else {
-        if (STRNEQ_NULLABLE(conn->uri->scheme, "network"))
-            return VIR_DRV_OPEN_DECLINED;
-
         if (network_driver == NULL) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("network state driver is not active"));
@@ -5613,6 +5610,7 @@ static virHypervisorDriver networkHypervisorDriver = {
 
 static virConnectDriver networkConnectDriver = {
     .localOnly = true,
+    .uriSchemes = (const char *[]){ "network", NULL },
     .hypervisorDriver = &networkHypervisorDriver,
     .networkDriver = &networkDriver,
 };
index ad4938fcd6bd39d8adfe43453f38a241ff858cc6..a3e3d76dfc80928d00179e167c0fbd879ab1b272 100644 (file)
@@ -59,9 +59,6 @@ nodeConnectOpen(virConnectPtr conn,
         /* Only hypervisor drivers are permitted to auto-open on NULL uri */
         return VIR_DRV_OPEN_DECLINED;
     } else {
-        if (STRNEQ_NULLABLE(conn->uri->scheme, "nodedev"))
-            return VIR_DRV_OPEN_DECLINED;
-
         if (driver == NULL) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("nodedev state driver is not active"));
index 4c251da88ab26d14d6d6f68345fd4f5e6517127f..2101101bc691cce7489015fd95db4365e50cd360 100644 (file)
@@ -784,6 +784,7 @@ static virHypervisorDriver halHypervisorDriver = {
 
 static virConnectDriver halConnectDriver = {
     .localOnly = true,
+    .uriSchemes = (const char *[]){ "nodedev", NULL },
     .hypervisorDriver = &halHypervisorDriver,
     .nodeDeviceDriver = &halNodeDeviceDriver,
 };
index d89b5ff7cc854cb3598c8f062bb8d4f88fe48c91..de018164023d2617e1ce7608174fb0ac312d503e 100644 (file)
@@ -1958,6 +1958,7 @@ static virHypervisorDriver udevHypervisorDriver = {
 
 static virConnectDriver udevConnectDriver = {
     .localOnly = true,
+    .uriSchemes = (const char *[]){ "nodedev", NULL },
     .hypervisorDriver = &udevHypervisorDriver,
     .nodeDeviceDriver = &udevNodeDeviceDriver,
 };
index 71aca5a9686ed54f505b7071fd04aaf3ee108fda..76289265a21a7e1b66d98eeca3d489450cd3f2ee 100644 (file)
@@ -376,9 +376,6 @@ nwfilterConnectOpen(virConnectPtr conn,
         /* Only hypervisor drivers are permitted to auto-open on NULL uri */
         return VIR_DRV_OPEN_DECLINED;
     } else {
-        if (STRNEQ_NULLABLE(conn->uri->scheme, "nwfilter"))
-            return VIR_DRV_OPEN_DECLINED;
-
         if (driver == NULL) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("nwfilter state driver is not active"));
@@ -709,6 +706,7 @@ static virHypervisorDriver nwfilterHypervisorDriver = {
 
 static virConnectDriver nwfilterConnectDriver = {
     .localOnly = true,
+    .uriSchemes = (const char *[]){ "nwfilter", NULL },
     .hypervisorDriver = &nwfilterHypervisorDriver,
     .nwfilterDriver = &nwfilterDriver,
 };
index 339f88994c36e6a21ba13dd01b7abe6254132a97..e2346eabc99adc5d0c441c927e818ca7c17aca9c 100644 (file)
@@ -1357,11 +1357,6 @@ static virDrvOpenStatus openvzConnectOpen(virConnectPtr conn,
     if (conn->uri == NULL) {
         return VIR_DRV_OPEN_DECLINED;
     } else {
-        /* If scheme isn't 'openvz', then its for another driver */
-        if (conn->uri->scheme == NULL ||
-            STRNEQ(conn->uri->scheme, "openvz"))
-            return VIR_DRV_OPEN_DECLINED;
-
         /* If path isn't /system, then they typoed, so tell them correct path */
         if (conn->uri->path == NULL ||
             STRNEQ(conn->uri->path, "/system")) {
@@ -2521,6 +2516,7 @@ static virHypervisorDriver openvzHypervisorDriver = {
 
 static virConnectDriver openvzConnectDriver = {
     .localOnly = true,
+    .uriSchemes = (const char *[]){ "openvz", NULL },
     .hypervisorDriver = &openvzHypervisorDriver,
 };
 
index cce7448abc44653f617e7844cab8ba7b875d433c..ddbd9144bc4c53723fea31bbd782518fd6c714f4 100644 (file)
@@ -1144,9 +1144,6 @@ phypConnectOpen(virConnectPtr conn,
     if (!conn || !conn->uri)
         return VIR_DRV_OPEN_DECLINED;
 
-    if (conn->uri->scheme == NULL || STRNEQ(conn->uri->scheme, "phyp"))
-        return VIR_DRV_OPEN_DECLINED;
-
     if (conn->uri->server == NULL) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        "%s", _("Missing server name in phyp:// URI"));
@@ -3766,6 +3763,7 @@ static virInterfaceDriver phypInterfaceDriver = {
 };
 
 static virConnectDriver phypConnectDriver = {
+    .uriSchemes = (const char *[]){ "phyp", NULL },
     .hypervisorDriver = &phypHypervisorDriver,
     .interfaceDriver = &phypInterfaceDriver,
     .storageDriver = &phypStorageDriver,
index ca08ba463d173afda86574bc7ecfb390079e2c21..bd9c592a7a86cacbd47c773d4358b289b194fa9e 100644 (file)
@@ -1146,13 +1146,6 @@ static virDrvOpenStatus qemuConnectOpen(virConnectPtr conn,
     if (conn->uri == NULL) {
         return VIR_DRV_OPEN_DECLINED;
     } else {
-        /* If URI isn't 'qemu' its definitely not for us */
-        if (conn->uri->scheme == NULL ||
-            STRNEQ(conn->uri->scheme, "qemu")) {
-            ret = VIR_DRV_OPEN_DECLINED;
-            goto cleanup;
-        }
-
         if (qemu_driver == NULL) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("qemu state driver is not active"));
@@ -21564,6 +21557,7 @@ static virHypervisorDriver qemuHypervisorDriver = {
 
 static virConnectDriver qemuConnectDriver = {
     .localOnly = true,
+    .uriSchemes = (const char *[]){ "qemu", NULL },
     .hypervisorDriver = &qemuHypervisorDriver,
 };
 
index 06d116f07f5acc895686db6ae8c6b8b8863c4707..aedfa10dccf7890aa9b2b252794c4849181ead05 100644 (file)
@@ -529,9 +529,6 @@ secretConnectOpen(virConnectPtr conn,
         /* Only hypervisor drivers are permitted to auto-open on NULL uri */
         return VIR_DRV_OPEN_DECLINED;
     } else {
-        if (STRNEQ_NULLABLE(conn->uri->scheme, "secret"))
-            return VIR_DRV_OPEN_DECLINED;
-
         if (driver == NULL) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("secret state driver is not active"));
@@ -659,6 +656,7 @@ static virHypervisorDriver secretHypervisorDriver = {
 
 static virConnectDriver secretConnectDriver = {
     .localOnly = true,
+    .uriSchemes = (const char *[]){ "secret", NULL },
     .hypervisorDriver = &secretHypervisorDriver,
     .secretDriver = &secretDriver,
 };
index 7eb5fad929ff8b93643ce3186544877e652f33de..1a8173384230755256accf775761502d1339311b 100644 (file)
@@ -389,9 +389,6 @@ storageConnectOpen(virConnectPtr conn,
         /* Only hypervisor drivers are permitted to auto-open on NULL uri */
         return VIR_DRV_OPEN_DECLINED;
     } else {
-        if (STRNEQ_NULLABLE(conn->uri->scheme, "storage"))
-            return VIR_DRV_OPEN_DECLINED;
-
         if (driver == NULL) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("storage state driver is not active"));
@@ -2852,6 +2849,7 @@ static virHypervisorDriver storageHypervisorDriver = {
 
 static virConnectDriver storageConnectDriver = {
     .localOnly = true,
+    .uriSchemes = (const char *[]){ "storage", NULL },
     .hypervisorDriver = &storageHypervisorDriver,
     .storageDriver = &storageDriver,
 };
index de3943406e0e0c6d5337d636c15442c71a2817df..7f9c7f751ebe9b4794acb44a91095e24f11201fe 100644 (file)
@@ -1457,9 +1457,6 @@ testConnectOpen(virConnectPtr conn,
     if (!conn->uri)
         return VIR_DRV_OPEN_DECLINED;
 
-    if (!conn->uri->scheme || STRNEQ(conn->uri->scheme, "test"))
-        return VIR_DRV_OPEN_DECLINED;
-
     /* From this point on, the connection is for us. */
     if (!conn->uri->path
         || conn->uri->path[0] == '\0'
@@ -7062,6 +7059,7 @@ static virNodeDeviceDriver testNodeDeviceDriver = {
 
 static virConnectDriver testConnectDriver = {
     .localOnly = true,
+    .uriSchemes = (const char *[]){ "test", NULL },
     .hypervisorDriver = &testHypervisorDriver,
     .interfaceDriver = &testInterfaceDriver,
     .networkDriver = &testNetworkDriver,
index 7fae561affb882c0348da1a4b9c2a8d8805e1781..2315cd4d1589795f0fe83c3f025c4751bd40d7e7 100644 (file)
@@ -1206,10 +1206,6 @@ static virDrvOpenStatus umlConnectOpen(virConnectPtr conn,
     if (conn->uri == NULL) {
         return VIR_DRV_OPEN_DECLINED;
     } else {
-        if (conn->uri->scheme == NULL ||
-            STRNEQ(conn->uri->scheme, "uml"))
-            return VIR_DRV_OPEN_DECLINED;
-
         /* Check path and tell them correct path if they made a mistake */
         if (uml_driver->privileged) {
             if (STRNEQ(conn->uri->path, "/system") &&
@@ -3014,6 +3010,7 @@ static virHypervisorDriver umlHypervisorDriver = {
 
 static virConnectDriver umlConnectDriver = {
     .localOnly = true,
+    .uriSchemes = (const char *[]){ "uml", NULL },
     .hypervisorDriver = &umlHypervisorDriver,
 };
 
index 204f08ea8a3e10a524d510546e12678f8ea1b2a4..cead821934f7d1dde1940bfaeba1defd0dae8397 100644 (file)
@@ -520,10 +520,6 @@ vboxConnectOpen(virConnectPtr conn,
     if (conn->uri == NULL)
         return VIR_DRV_OPEN_DECLINED;
 
-    if (conn->uri->scheme == NULL ||
-        STRNEQ(conn->uri->scheme, "vbox"))
-        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 e3880b4826b758137c86c5e8c671a3f393a8a315..395fa8e3d6d4a2ce7e48f8f54b33d8ac25c3c3c5 100644 (file)
@@ -58,9 +58,7 @@ static virDrvOpenStatus dummyConnectOpen(virConnectPtr conn,
 
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    if (conn->uri == NULL ||
-        conn->uri->scheme == NULL ||
-        STRNEQ(conn->uri->scheme, "vbox"))
+    if (conn->uri == NULL)
         return VIR_DRV_OPEN_DECLINED;
 
     if (conn->uri->path == NULL || STREQ(conn->uri->path, "")) {
@@ -96,6 +94,7 @@ static virHypervisorDriver vboxDriverDummy = {
 
 static virConnectDriver vboxConnectDriver = {
     .localOnly = true,
+    .uriSchemes = (const char *[]){ "vbox", NULL },
     .hypervisorDriver = NULL,
 };
 
index 435b9ee6ff9cc16928925728744b0d9b42a2672d..6118e6fa1376e7ef711d2b31eb889d461a6e2551 100644 (file)
@@ -134,12 +134,6 @@ vmwareConnectOpen(virConnectPtr conn,
         /* @TODO accept */
         return VIR_DRV_OPEN_DECLINED;
     } else {
-        if (conn->uri->scheme == NULL ||
-            (STRNEQ(conn->uri->scheme, "vmwareplayer") &&
-             STRNEQ(conn->uri->scheme, "vmwarews") &&
-             STRNEQ(conn->uri->scheme, "vmwarefusion")))
-            return VIR_DRV_OPEN_DECLINED;
-
         /* 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,
@@ -1268,6 +1262,7 @@ static virHypervisorDriver vmwareHypervisorDriver = {
 
 static virConnectDriver vmwareConnectDriver = {
     .localOnly = true,
+    .uriSchemes = (const char *[]){ "vmwareplayer", "vmwarews", "vmwarefusion", NULL },
     .hypervisorDriver = &vmwareHypervisorDriver,
 };
 
index 8842056ea4feda818d1b441bf5081009fda792cd..f3047cad6cbd26982333d593445fda491638fa40 100644 (file)
@@ -361,19 +361,6 @@ vzConnectOpen(virConnectPtr conn,
     if (!conn->uri)
         return VIR_DRV_OPEN_DECLINED;
 
-    if (!conn->uri->scheme)
-        return VIR_DRV_OPEN_DECLINED;
-
-    if (STRNEQ(conn->uri->scheme, "vz") &&
-        STRNEQ(conn->uri->scheme, "parallels"))
-        return VIR_DRV_OPEN_DECLINED;
-
-    if (STREQ(conn->uri->scheme, "vz") && STRNEQ(conn->driver->name, "vz"))
-        return VIR_DRV_OPEN_DECLINED;
-
-    if (STREQ(conn->uri->scheme, "parallels") && STRNEQ(conn->driver->name, "Parallels"))
-        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,
@@ -4140,6 +4127,7 @@ static virHypervisorDriver vzHypervisorDriver = {
 
 static virConnectDriver vzConnectDriver = {
     .localOnly = true,
+    .uriSchemes = (const char *[]){ "vz", NULL },
     .hypervisorDriver = &vzHypervisorDriver,
 };
 
@@ -4209,6 +4197,7 @@ vzRegister(void)
     parallelsHypervisorDriver.name = "Parallels";
     parallelsConnectDriver = vzConnectDriver;
     parallelsConnectDriver.hypervisorDriver = &parallelsHypervisorDriver;
+    parallelsConnectDriver.uriSchemes = (const char *[]){ "parallels", NULL },
     if (virRegisterConnectDriver(&parallelsConnectDriver, true) < 0)
         return -1;
 
index fb462cd3a13085ee53bab9f26aa733078c4bffe4..86f9e7706dc025bb3ac407dcf5f4f4a8c142aee6 100644 (file)
@@ -146,10 +146,8 @@ xenapiConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
 
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    if (conn->uri == NULL || conn->uri->scheme == NULL ||
-        STRCASENEQ(conn->uri->scheme, "XenAPI")) {
+    if (conn->uri == NULL)
         return VIR_DRV_OPEN_DECLINED;
-    }
 
     if (conn->uri->server == NULL) {
         xenapiSessionErrorHandler(conn, VIR_ERR_INVALID_ARG,
@@ -2075,6 +2073,7 @@ static virHypervisorDriver xenapiHypervisorDriver = {
 
 
 static virConnectDriver xenapiConnectDriver = {
+    .uriSchemes = (const char *[]){ "xenapi", NULL },
     .hypervisorDriver = &xenapiHypervisorDriver,
 };