From nobody Wed May 14 11:33:25 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1523288764948100.38828082311989; Mon, 9 Apr 2018 08:46:04 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B0F775A72; Mon, 9 Apr 2018 15:46:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7945E183A0; Mon, 9 Apr 2018 15:46:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 3A9214CAA2; Mon, 9 Apr 2018 15:46:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w39FjwBI032414 for ; Mon, 9 Apr 2018 11:45:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2B77F2024CA8; Mon, 9 Apr 2018 15:45:58 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91D9B2024CA7; Mon, 9 Apr 2018 15:45:57 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 9 Apr 2018 16:45:48 +0100 Message-Id: <20180409154551.22604-6-berrange@redhat.com> In-Reply-To: <20180409154551.22604-1-berrange@redhat.com> References: <20180409154551.22604-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/8] driver: declare supported URI schemes in virConnectDriver struct X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 09 Apr 2018 15:46:03 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 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=C3=A9 --- src/bhyve/bhyve_driver.c | 4 +--- src/driver.h | 6 ++++++ src/esx/esx_driver.c | 27 ++------------------------- src/hyperv/hyperv_driver.c | 22 ++-------------------- src/interface/interface_backend_netcf.c | 4 +--- src/interface/interface_backend_udev.c | 4 +--- src/libvirt.c | 24 ++++++++++++++++++++++++ src/libxl/libxl_driver.c | 5 +---- src/lxc/lxc_driver.c | 5 +---- src/network/bridge_driver.c | 4 +--- src/node_device/node_device_driver.c | 3 --- src/node_device/node_device_hal.c | 1 + src/node_device/node_device_udev.c | 1 + src/nwfilter/nwfilter_driver.c | 4 +--- src/openvz/openvz_driver.c | 6 +----- src/phyp/phyp_driver.c | 4 +--- src/qemu/qemu_driver.c | 8 +------- src/secret/secret_driver.c | 4 +--- src/storage/storage_driver.c | 4 +--- src/test/test_driver.c | 4 +--- src/uml/uml_driver.c | 5 +---- src/vbox/vbox_common.c | 4 ---- src/vbox/vbox_driver.c | 5 ++--- src/vmware/vmware_driver.c | 7 +------ src/vz/vz_driver.c | 15 ++------------- src/xenapi/xenapi_driver.c | 5 ++--- 26 files changed, 57 insertions(+), 128 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index cc1d4ba6fb..21754dfc10 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -202,9 +202,6 @@ bhyveConnectOpen(virConnectPtr conn, if (conn->uri =3D=3D 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"), @@ -1752,6 +1749,7 @@ static virHypervisorDriver bhyveHypervisorDriver =3D { =20 static virConnectDriver bhyveConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "bhyve", NULL }, .hypervisorDriver =3D &bhyveHypervisorDriver, }; =20 diff --git a/src/driver.h b/src/driver.h index 5fb0b523c8..b071a3a782 100644 --- a/src/driver.h +++ b/src/driver.h @@ -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; diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 927267f1cc..9b6944ba59 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -845,7 +845,6 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr au= th, unsigned int flags) { virDrvOpenStatus result =3D VIR_DRV_OPEN_ERROR; - char *plus; esxPrivate *priv =3D NULL; char *potentialVCenterIPAddress =3D NULL; char vCenterIPAddress[NI_MAXHOST] =3D ""; @@ -853,32 +852,9 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr a= uth, virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 /* 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; =20 - /* Decline if the scheme is not one of {vpx|esx|gsx} */ - plus =3D 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 !=3D 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, t= ry 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 =3D { =20 =20 static virConnectDriver esxConnectDriver =3D { + .uriSchemes =3D (const char *[]){ "vpx", "esx", "gsx", NULL }, .hypervisorDriver =3D &esxHypervisorDriver, .interfaceDriver =3D &esxInterfaceDriver, .networkDriver =3D &esxNetworkDriver, diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index e512b626ea..4ad8855dcc 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -122,7 +122,6 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr= auth, unsigned int flags) { virDrvOpenStatus result =3D VIR_DRV_OPEN_ERROR; - char *plus; hypervPrivate *priv =3D NULL; char *username =3D NULL; char *password =3D NULL; @@ -130,27 +129,9 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPt= r auth, virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 /* Decline if the URI is NULL or the scheme is NULL */ - if (conn->uri =3D=3D NULL || conn->uri->scheme =3D=3D NULL) + if (conn->uri =3D=3D NULL) return VIR_DRV_OPEN_DECLINED; =20 - /* Decline if the scheme is not hyperv */ - plus =3D strchr(conn->uri->scheme, '+'); - - if (plus =3D=3D NULL) { - if (STRCASENEQ(conn->uri->scheme, "hyperv")) - return VIR_DRV_OPEN_DECLINED; - } else { - if (plus - conn->uri->scheme !=3D 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, t= ry again " - "without the transport part"), plus + 1); - return VIR_DRV_OPEN_ERROR; - } - /* Require server part */ if (conn->uri->server =3D=3D NULL) { virReportError(VIR_ERR_INVALID_ARG, "%s", @@ -1685,6 +1666,7 @@ hypervDebugHandler(const char *message, debug_level_e= level, =20 =20 static virConnectDriver hypervConnectDriver =3D { + .uriSchemes =3D (const char *[]){ "hyperv", NULL }, .hypervisorDriver =3D &hypervHypervisorDriver, }; =20 diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interf= ace_backend_netcf.c index 3da958980f..ff3443c8e6 100644 --- a/src/interface/interface_backend_netcf.c +++ b/src/interface/interface_backend_netcf.c @@ -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 =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("interface state driver is not active")); @@ -1221,6 +1218,7 @@ static virHypervisorDriver interfaceHypervisorDriver = =3D { =20 static virConnectDriver interfaceConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "interface", NULL }, .hypervisorDriver =3D &interfaceHypervisorDriver, .interfaceDriver =3D &interfaceDriver, }; diff --git a/src/interface/interface_backend_udev.c b/src/interface/interfa= ce_backend_udev.c index 2b8a9da682..743aafd8ba 100644 --- a/src/interface/interface_backend_udev.c +++ b/src/interface/interface_backend_udev.c @@ -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 =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("interface state driver is not active")); @@ -1292,6 +1289,7 @@ static virHypervisorDriver udevHypervisorDriver =3D { =20 static virConnectDriver udevConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "interface", NULL }, .hypervisorDriver =3D &udevHypervisorDriver, .interfaceDriver =3D &udevIfaceDriver, }; diff --git a/src/libvirt.c b/src/libvirt.c index 2b2b3ed425..cc1387341a 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1073,6 +1073,30 @@ virConnectOpenInternal(const char *name, continue; } =20 + /* Filter drivers based on declared URI schemes */ + if (virConnectDriverTab[i]->uriSchemes && ret->uri) { + bool matchScheme =3D false; + size_t s; + if (!ret->uri->scheme) { + VIR_DEBUG("No URI scheme, skipping driver with URI whiteli= st"); + continue; + } + VIR_DEBUG("Checking for supported URI schemes"); + for (s =3D 0; virConnectDriverTab[i]->uriSchemes[s] !=3D NULL;= s++) { + if (STREQ(ret->uri->scheme, virConnectDriverTab[i]->uriSch= emes[s])) { + VIR_DEBUG("Matched URI scheme '%s'", ret->uri->scheme); + matchScheme =3D 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 =3D virConnectDriverTab[i]->hypervisorDriver; ret->interfaceDriver =3D virConnectDriverTab[i]->interfaceDriver; ret->networkDriver =3D virConnectDriverTab[i]->networkDriver; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index ce4741cf4c..872790e743 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -848,10 +848,6 @@ libxlConnectOpen(virConnectPtr conn, if (conn->uri =3D=3D NULL) { return VIR_DRV_OPEN_DECLINED; } else { - /* Only xen scheme */ - if (conn->uri->scheme =3D=3D NULL || STRNEQ(conn->uri->scheme, "xe= n")) - return VIR_DRV_OPEN_DECLINED; - /* Error if xen or libxl scheme specified but driver not started. = */ if (libxl_driver =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -6579,6 +6575,7 @@ static virHypervisorDriver libxlHypervisorDriver =3D { =20 static virConnectDriver libxlConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "xen", NULL }, .hypervisorDriver =3D &libxlHypervisorDriver, }; =20 diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 7a3e720d16..8b01abf75f 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -173,10 +173,6 @@ static virDrvOpenStatus lxcConnectOpen(virConnectPtr c= onn, if (conn->uri =3D=3D NULL) { return VIR_DRV_OPEN_DECLINED; } else { - if (conn->uri->scheme =3D=3D 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 !=3D NULL && STRNEQ(conn->uri->path, "/") && @@ -5630,6 +5626,7 @@ static virHypervisorDriver lxcHypervisorDriver =3D { =20 static virConnectDriver lxcConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "lxc", NULL }, .hypervisorDriver =3D &lxcHypervisorDriver, }; =20 diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index ca48a0358c..98754d4471 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -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 =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("network state driver is not active")); @@ -5613,6 +5610,7 @@ static virHypervisorDriver networkHypervisorDriver = =3D { =20 static virConnectDriver networkConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "network", NULL }, .hypervisorDriver =3D &networkHypervisorDriver, .networkDriver =3D &networkDriver, }; diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index ad4938fcd6..a3e3d76dfc 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -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 =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nodedev state driver is not active")); diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_devic= e_hal.c index 4c251da88a..2101101bc6 100644 --- a/src/node_device/node_device_hal.c +++ b/src/node_device/node_device_hal.c @@ -784,6 +784,7 @@ static virHypervisorDriver halHypervisorDriver =3D { =20 static virConnectDriver halConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "nodedev", NULL }, .hypervisorDriver =3D &halHypervisorDriver, .nodeDeviceDriver =3D &halNodeDeviceDriver, }; diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index d89b5ff7cc..de01816402 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1958,6 +1958,7 @@ static virHypervisorDriver udevHypervisorDriver =3D { =20 static virConnectDriver udevConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "nodedev", NULL }, .hypervisorDriver =3D &udevHypervisorDriver, .nodeDeviceDriver =3D &udevNodeDeviceDriver, }; diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index 71aca5a968..76289265a2 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -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 =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nwfilter state driver is not active")); @@ -709,6 +706,7 @@ static virHypervisorDriver nwfilterHypervisorDriver =3D= { =20 static virConnectDriver nwfilterConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "nwfilter", NULL }, .hypervisorDriver =3D &nwfilterHypervisorDriver, .nwfilterDriver =3D &nwfilterDriver, }; diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index a56476475e..3eab3e47df 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1446,11 +1446,6 @@ static virDrvOpenStatus openvzConnectOpen(virConnect= Ptr conn, if (conn->uri =3D=3D NULL) { return VIR_DRV_OPEN_DECLINED; } else { - /* If scheme isn't 'openvz', then its for another driver */ - if (conn->uri->scheme =3D=3D NULL || - STRNEQ(conn->uri->scheme, "openvz")) - return VIR_DRV_OPEN_DECLINED; - /* If path isn't /system, then they typoed, so tell them correct p= ath */ if (conn->uri->path =3D=3D NULL || STRNEQ(conn->uri->path, "/system")) { @@ -2656,6 +2651,7 @@ static virHypervisorDriver openvzHypervisorDriver =3D= { =20 static virConnectDriver openvzConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "openvz", NULL }, .hypervisorDriver =3D &openvzHypervisorDriver, }; =20 diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index cce7448abc..ddbd9144bc 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1144,9 +1144,6 @@ phypConnectOpen(virConnectPtr conn, if (!conn || !conn->uri) return VIR_DRV_OPEN_DECLINED; =20 - if (conn->uri->scheme =3D=3D NULL || STRNEQ(conn->uri->scheme, "phyp")) - return VIR_DRV_OPEN_DECLINED; - if (conn->uri->server =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing server name in phyp:// URI")); @@ -3766,6 +3763,7 @@ static virInterfaceDriver phypInterfaceDriver =3D { }; =20 static virConnectDriver phypConnectDriver =3D { + .uriSchemes =3D (const char *[]){ "phyp", NULL }, .hypervisorDriver =3D &phypHypervisorDriver, .interfaceDriver =3D &phypInterfaceDriver, .storageDriver =3D &phypStorageDriver, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ef890916dc..8a6d3f9af0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1146,13 +1146,6 @@ static virDrvOpenStatus qemuConnectOpen(virConnectPt= r conn, if (conn->uri =3D=3D NULL) { return VIR_DRV_OPEN_DECLINED; } else { - /* If URI isn't 'qemu' its definitely not for us */ - if (conn->uri->scheme =3D=3D NULL || - STRNEQ(conn->uri->scheme, "qemu")) { - ret =3D VIR_DRV_OPEN_DECLINED; - goto cleanup; - } - if (qemu_driver =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("qemu state driver is not active")); @@ -21568,6 +21561,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { =20 static virConnectDriver qemuConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "qemu", NULL }, .hypervisorDriver =3D &qemuHypervisorDriver, }; =20 diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c index 06d116f07f..aedfa10dcc 100644 --- a/src/secret/secret_driver.c +++ b/src/secret/secret_driver.c @@ -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 =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("secret state driver is not active")); @@ -659,6 +656,7 @@ static virHypervisorDriver secretHypervisorDriver =3D { =20 static virConnectDriver secretConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "secret", NULL }, .hypervisorDriver =3D &secretHypervisorDriver, .secretDriver =3D &secretDriver, }; diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 7eb5fad929..1a81733842 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -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 =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("storage state driver is not active")); @@ -2852,6 +2849,7 @@ static virHypervisorDriver storageHypervisorDriver = =3D { =20 static virConnectDriver storageConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "storage", NULL }, .hypervisorDriver =3D &storageHypervisorDriver, .storageDriver =3D &storageDriver, }; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index de3943406e..7f9c7f751e 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1457,9 +1457,6 @@ testConnectOpen(virConnectPtr conn, if (!conn->uri) return VIR_DRV_OPEN_DECLINED; =20 - 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] =3D=3D '\0' @@ -7062,6 +7059,7 @@ static virNodeDeviceDriver testNodeDeviceDriver =3D { =20 static virConnectDriver testConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "test", NULL }, .hypervisorDriver =3D &testHypervisorDriver, .interfaceDriver =3D &testInterfaceDriver, .networkDriver =3D &testNetworkDriver, diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 7fae561aff..2315cd4d15 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -1206,10 +1206,6 @@ static virDrvOpenStatus umlConnectOpen(virConnectPtr= conn, if (conn->uri =3D=3D NULL) { return VIR_DRV_OPEN_DECLINED; } else { - if (conn->uri->scheme =3D=3D 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 =3D { =20 static virConnectDriver umlConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "uml", NULL }, .hypervisorDriver =3D ¨HypervisorDriver, }; =20 diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 886b41b0b9..4c4c80d45b 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -520,10 +520,6 @@ vboxConnectOpen(virConnectPtr conn, if (conn->uri =3D=3D NULL) return VIR_DRV_OPEN_DECLINED; =20 - if (conn->uri->scheme =3D=3D NULL || - STRNEQ(conn->uri->scheme, "vbox")) - return VIR_DRV_OPEN_DECLINED; - if (conn->uri->path =3D=3D NULL || STREQ(conn->uri->path, "")) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no VirtualBox driver path specified (try vbox://= /session)")); diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c index e3880b4826..395fa8e3d6 100644 --- a/src/vbox/vbox_driver.c +++ b/src/vbox/vbox_driver.c @@ -58,9 +58,7 @@ static virDrvOpenStatus dummyConnectOpen(virConnectPtr co= nn, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri =3D=3D NULL || - conn->uri->scheme =3D=3D NULL || - STRNEQ(conn->uri->scheme, "vbox")) + if (conn->uri =3D=3D NULL) return VIR_DRV_OPEN_DECLINED; =20 if (conn->uri->path =3D=3D NULL || STREQ(conn->uri->path, "")) { @@ -96,6 +94,7 @@ static virHypervisorDriver vboxDriverDummy =3D { =20 static virConnectDriver vboxConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "vbox", NULL }, .hypervisorDriver =3D NULL, }; =20 diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 435b9ee6ff..6118e6fa13 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -134,12 +134,6 @@ vmwareConnectOpen(virConnectPtr conn, /* @TODO accept */ return VIR_DRV_OPEN_DECLINED; } else { - if (conn->uri->scheme =3D=3D 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 =3D=3D NULL || STRNEQ(conn->uri->path, "/sessi= on")) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1268,6 +1262,7 @@ static virHypervisorDriver vmwareHypervisorDriver =3D= { =20 static virConnectDriver vmwareConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "vmwareplayer", "vmwarews", "vmwaref= usion", NULL }, .hypervisorDriver =3D &vmwareHypervisorDriver, }; =20 diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 8842056ea4..f3047cad6c 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -361,19 +361,6 @@ vzConnectOpen(virConnectPtr conn, if (!conn->uri) return VIR_DRV_OPEN_DECLINED; =20 - 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 =3D { =20 static virConnectDriver vzConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "vz", NULL }, .hypervisorDriver =3D &vzHypervisorDriver, }; =20 @@ -4209,6 +4197,7 @@ vzRegister(void) parallelsHypervisorDriver.name =3D "Parallels"; parallelsConnectDriver =3D vzConnectDriver; parallelsConnectDriver.hypervisorDriver =3D ¶llelsHypervisorDriver; + parallelsConnectDriver.uriSchemes =3D (const char *[]){ "parallels", N= ULL }, if (virRegisterConnectDriver(¶llelsConnectDriver, true) < 0) return -1; =20 diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index fb462cd3a1..86f9e7706d 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -146,10 +146,8 @@ xenapiConnectOpen(virConnectPtr conn, virConnectAuthPt= r auth, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri =3D=3D NULL || conn->uri->scheme =3D=3D NULL || - STRCASENEQ(conn->uri->scheme, "XenAPI")) { + if (conn->uri =3D=3D NULL) return VIR_DRV_OPEN_DECLINED; - } =20 if (conn->uri->server =3D=3D NULL) { xenapiSessionErrorHandler(conn, VIR_ERR_INVALID_ARG, @@ -2075,6 +2073,7 @@ static virHypervisorDriver xenapiHypervisorDriver =3D= { =20 =20 static virConnectDriver xenapiConnectDriver =3D { + .uriSchemes =3D (const char *[]){ "xenapi", NULL }, .hypervisorDriver =3D &xenapiHypervisorDriver, }; =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list