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@xxxxxxxxxx> --- src/bhyve/bhyve_driver.c | 26 +++++++---------- src/esx/esx_driver.c | 4 --- src/hyperv/hyperv_driver.c | 4 --- src/interface/interface_backend_netcf.c | 40 +++++++++++-------------- src/interface/interface_backend_udev.c | 40 +++++++++++-------------- src/libvirt.c | 6 +++- src/libxl/libxl_driver.c | 34 ++++++++++----------- src/lxc/lxc_driver.c | 33 +++++++++------------ src/network/bridge_driver.c | 40 +++++++++++-------------- src/node_device/node_device_driver.c | 40 +++++++++++-------------- src/nwfilter/nwfilter_driver.c | 26 +++++++---------- src/openvz/openvz_driver.c | 38 +++++++++++------------- src/phyp/phyp_driver.c | 3 -- src/qemu/qemu_driver.c | 52 +++++++++++++++------------------ src/secret/secret_driver.c | 40 +++++++++++-------------- src/storage/storage_driver.c | 40 +++++++++++-------------- src/test/test_driver.c | 4 --- src/uml/uml_driver.c | 44 +++++++++++++--------------- src/vbox/vbox_common.c | 3 -- src/vbox/vbox_driver.c | 3 -- src/vmware/vmware_driver.c | 17 ++++------- src/vz/vz_driver.c | 3 -- src/xenapi/xenapi_driver.c | 3 -- 23 files changed, 224 insertions(+), 319 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 21754dfc10..7d6439d79d 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -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) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 9b6944ba59..335d9a970d 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -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'", diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 4ad8855dcc..d02c0ac373 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -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", diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interface_backend_netcf.c index ff3443c8e6..cc2402febb 100644 --- a/src/interface/interface_backend_netcf.c +++ b/src/interface/interface_backend_netcf.c @@ -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; } } diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c index 743aafd8ba..4b975ae4b4 100644 --- a/src/interface/interface_backend_udev.c +++ b/src/interface/interface_backend_udev.c @@ -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; } } diff --git a/src/libvirt.c b/src/libvirt.c index cc1387341a..30345af10d 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -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; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 872790e743..45d0c99902 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -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) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 8b01abf75f..2079dd0704 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -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) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 98754d4471..2e9191f75d 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -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; } } diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index a3e3d76dfc..61afa1f8eb 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -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; } } diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index 76289265a2..542de03596 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -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) diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 3eab3e47df..33893ac009 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1443,29 +1443,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 diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index ddbd9144bc..55d459df5c 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -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")); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8a6d3f9af0..e677bf13b5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -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; } } diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c index aedfa10dcc..02fcaece35 100644 --- a/src/secret/secret_driver.c +++ b/src/secret/secret_driver.c @@ -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; } } diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 1a81733842..6104276730 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -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; } } diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 7f9c7f751e..56d496a849 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -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')) { diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 2315cd4d15..ac168ce77b 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -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; diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 4c4c80d45b..05cf9ad0de 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -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)")); diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c index 395fa8e3d6..9e95ab01c5 100644 --- a/src/vbox/vbox_driver.c +++ b/src/vbox/vbox_driver.c @@ -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)")); diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 6118e6fa13..de3708aab3 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -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 diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index f3047cad6c..5867f1c911 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -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, diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index 86f9e7706d..42b305d316 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -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")); -- 2.14.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list