From d968b4b85c567897376a4b94ef3ef580a63c67e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Mon, 24 May 2021 16:35:19 +0100 Subject: [PATCH] remote: move proxy/mode defaults after URI parsing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently the defaults for the proxy/mode settings are set before parsing URI parameters. A following commit will introduce a dependancy on the URI parsing for the defaults, so they need to move. Reviewed-by: Ján Tomko Signed-off-by: Daniel P. Berrangé --- src/remote/remote_driver.c | 50 ++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 0bacd0bc4b..856909fc60 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -780,20 +780,6 @@ doRemoteOpen(virConnectPtr conn, size_t i; int proxy; - if (inside_daemon && !conn->uri->server) { - mode = REMOTE_DRIVER_MODE_DIRECT; - } else { - mode = REMOTE_DRIVER_MODE_AUTO; - } - - /* Historically we didn't allow ssh tunnel with session mode, - * since we can't construct the accurate path remotely, - * so we can default to modern virt-ssh-helper */ - if (flags & VIR_DRV_OPEN_REMOTE_USER) - proxy = VIR_NET_CLIENT_PROXY_NATIVE; - else - proxy = VIR_NET_CLIENT_PROXY_AUTO; - /* We handle *ALL* URIs here. The caller has rejected any * URIs we don't care about */ @@ -880,22 +866,38 @@ doRemoteOpen(virConnectPtr conn, virConfGetValueString(conf, "remote_mode", &mode_str) < 0) goto failed; - if (mode_str && - (mode = remoteDriverModeTypeFromString(mode_str)) < 0) { - virReportError(VIR_ERR_INVALID_ARG, - _("Unknown remote mode '%s'"), mode_str); - goto failed; + if (mode_str) { + if ((mode = remoteDriverModeTypeFromString(mode_str)) < 0) { + virReportError(VIR_ERR_INVALID_ARG, + _("Unknown remote mode '%s'"), mode_str); + goto failed; + } + } else { + if (inside_daemon && !conn->uri->server) { + mode = REMOTE_DRIVER_MODE_DIRECT; + } else { + mode = REMOTE_DRIVER_MODE_AUTO; + } } if (conf && !proxy_str && virConfGetValueString(conf, "remote_proxy", &proxy_str) < 0) goto failed; - if (proxy_str && - (proxy = virNetClientProxyTypeFromString(proxy_str)) < 0) { - virReportError(VIR_ERR_INVALID_ARG, - _("Unnkown proxy type '%s'"), proxy_str); - goto failed; + if (proxy_str) { + if ((proxy = virNetClientProxyTypeFromString(proxy_str)) < 0) { + virReportError(VIR_ERR_INVALID_ARG, + _("Unnkown proxy type '%s'"), proxy_str); + goto failed; + } + } else { + /* Historically we didn't allow ssh tunnel with session mode, + * since we can't construct the accurate path remotely, + * so we can default to modern virt-ssh-helper */ + if (flags & VIR_DRV_OPEN_REMOTE_USER) + proxy = VIR_NET_CLIENT_PROXY_NATIVE; + else + proxy = VIR_NET_CLIENT_PROXY_AUTO; } /* Sanity check that nothing requested !direct mode by mistake */