Re: [PATCH 10/10] remote: Pass 'mode' and 'socket' URI parameters to virt-ssh-helper

2023-02-07 Thread Peter Krempa
On Mon, Feb 06, 2023 at 10:16:58 +0100, Michal Privoznik wrote:
> Even though we have split daemons for some time now, they are not
> the default by far. We've made the change ~1.5 year ago (in
> v7.5.0-rc1~35).
> 
> Therefore, we have some users that use 'mode=legacy' parameter in
> their connection URI. But this parameter is not propagated to
> virt-ssh-helper (and neither is the 'socket=...' parameter).
> 
> But now that virt-ssh-helper parses those URI parameters, we can
> pass them onto the remote host.

This commit message would benefit more from the explanation of how the
parameters are stripped, so you can explain why it's needed to be
skipped.

> 
> Resolves: https://gitlab.com/libvirt/libvirt/-/issues/433
> Signed-off-by: Michal Privoznik 
> ---
>  src/remote/remote_driver.c | 29 +++--
>  1 file changed, 23 insertions(+), 6 deletions(-)

Reviewed-by: Peter Krempa 



[PATCH 10/10] remote: Pass 'mode' and 'socket' URI parameters to virt-ssh-helper

2023-02-06 Thread Michal Privoznik
Even though we have split daemons for some time now, they are not
the default by far. We've made the change ~1.5 year ago (in
v7.5.0-rc1~35).

Therefore, we have some users that use 'mode=legacy' parameter in
their connection URI. But this parameter is not propagated to
virt-ssh-helper (and neither is the 'socket=...' parameter).

But now that virt-ssh-helper parses those URI parameters, we can
pass them onto the remote host.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/433
Signed-off-by: Michal Privoznik 
---
 src/remote/remote_driver.c | 29 +++--
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 7e1a31a5a0..f8f2dc0636 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -695,18 +695,31 @@ remoteConnectSupportsFeatureUnlocked(virConnectPtr conn,
 
 static char *
 remoteConnectFormatURI(virURI *uri,
-   const char *driver_str)
+   const char *driver_str,
+   bool unmask)
 {
+const char *names[] = {"mode", "socket", NULL};
 g_autofree char *query = NULL;
+char *ret = NULL;
 virURI tmpuri = {
 .scheme = (char *)driver_str,
 .path = uri->path,
 .fragment = uri->fragment,
 };
 
+if (unmask) {
+virURIParamsSetIgnore(uri, false, names);
+}
+
 query = tmpuri.query = virURIFormatParams(uri);
 
-return virURIFormat();
+ret = virURIFormat();
+
+if (unmask) {
+virURIParamsSetIgnore(uri, true, names);
+}
+
+return ret;
 }
 
 /*
@@ -754,6 +767,7 @@ doRemoteOpen(virConnectPtr conn,
 g_autofree char *mode_str = NULL;
 g_autofree char *daemon_path = NULL;
 g_autofree char *proxy_str = NULL;
+g_autofree char *virtSshURI = NULL;
 bool sanity = true;
 bool verify = true;
 #ifndef WIN32
@@ -825,7 +839,10 @@ doRemoteOpen(virConnectPtr conn,
 /* Allow remote serve to probe */
 name = g_strdup("");
 } else {
-name = remoteConnectFormatURI(conn->uri, driver_str);
+name = remoteConnectFormatURI(conn->uri, driver_str, false);
+
+/* Preserve mode and socket parameters. */
+virtSshURI = remoteConnectFormatURI(conn->uri, driver_str, 
true);
 
 }
 }
@@ -980,7 +997,7 @@ doRemoteOpen(virConnectPtr conn,
   proxy,
   netcat,
   sockname,
-  name,
+  virtSshURI ? virtSshURI : name,
   flags & REMOTE_DRIVER_OPEN_RO,
   auth,
   conn->uri);
@@ -1004,7 +1021,7 @@ doRemoteOpen(virConnectPtr conn,
  proxy,
  netcat,
  sockname,
- name,
+ virtSshURI ? virtSshURI : name,
  flags & REMOTE_DRIVER_OPEN_RO,
  auth,
  conn->uri);
@@ -1037,7 +1054,7 @@ doRemoteOpen(virConnectPtr conn,
 proxy,
 netcat,
 sockname,
-name,
+virtSshURI ? virtSshURI : name,
 flags & 
REMOTE_DRIVER_OPEN_RO)))
 goto error;
 
-- 
2.39.1