[libvirt] [PATCH] hyperv: Report an error for acceptable URI schemes with a transport

Before, URIs such as hyperv+ssh:// have been declined by the Hyper-V driver resulting in the remote driver trying to connect to an non-existing libvirtd. Now such URIs trigger an error in the Hyper-V driver suggesting to try again without the transport part in the scheme. --- src/hyperv/hyperv_driver.c | 25 ++++++++++++++++++++++--- 1 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index b022fee..c26d29f 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -69,6 +69,7 @@ static virDrvOpenStatus hypervOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags) { virDrvOpenStatus result = VIR_DRV_OPEN_ERROR; + char *plus; hypervPrivate *priv = NULL; char *username = NULL; char *password = NULL; @@ -77,12 +78,30 @@ hypervOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags) virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - /* Decline if the URI is NULL or the scheme is not hyperv */ - if (conn->uri == NULL || conn->uri->scheme == NULL || - STRCASENEQ(conn->uri->scheme, "hyperv")) { + /* Decline if the URI is NULL or the scheme is NULL */ + if (conn->uri == NULL || conn->uri->scheme == 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; + } + + HYPERV_ERROR(VIR_ERR_INVALID_ARG, "%s", + _("Transport in URI scheme is not supported, try again " + "without the transport part")); + return VIR_DRV_OPEN_ERROR; + } + /* Require server part */ if (conn->uri->server == NULL) { HYPERV_ERROR(VIR_ERR_INVALID_ARG, "%s", -- 1.7.4.1

On 09/27/2011 05:14 AM, Matthias Bolte wrote:
Before, URIs such as hyperv+ssh:// have been declined by the Hyper-V driver resulting in the remote driver trying to connect to an non-existing libvirtd.
Now such URIs trigger an error in the Hyper-V driver suggesting to try again without the transport part in the scheme. --- src/hyperv/hyperv_driver.c | 25 ++++++++++++++++++++++--- 1 files changed, 22 insertions(+), 3 deletions(-)
Same review comments and ACK as for esx, regarding the error message quality.
+ + HYPERV_ERROR(VIR_ERR_INVALID_ARG, "%s", + _("Transport in URI scheme is not supported, try again " + "without the transport part"));
-- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

2011/9/27 Eric Blake <eblake@redhat.com>:
On 09/27/2011 05:14 AM, Matthias Bolte wrote:
Before, URIs such as hyperv+ssh:// have been declined by the Hyper-V driver resulting in the remote driver trying to connect to an non-existing libvirtd.
Now such URIs trigger an error in the Hyper-V driver suggesting to try again without the transport part in the scheme. --- src/hyperv/hyperv_driver.c | 25 ++++++++++++++++++++++--- 1 files changed, 22 insertions(+), 3 deletions(-)
Same review comments and ACK as for esx, regarding the error message quality.
And same change applied. Thanks, pushed. -- Matthias Bolte http://photron.blogspot.com
participants (2)
-
Eric Blake
-
Matthias Bolte