[PATCH v2 4/8] virt-ssh-helper: Accept ?mode= in connection URI

Michal Privoznik mprivozn at redhat.com
Wed Feb 8 15:19:10 UTC 2023


When split daemons were introduced, we also made connection URI
accept new parameter: mode={auto,legacy,direct} so that a client
can force connecting to either old, monolithic daemon, or to
split daemon (see v5.7.0-rc1~257 for more info).

Now, the change was done to the remote driver, but not to
virt-ssh-helper. True, our remote driver code still does not pass
the 'mode' parameter, but that will be addressed in next commits.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/remote/remote_ssh_helper.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/remote/remote_ssh_helper.c b/src/remote/remote_ssh_helper.c
index b4735027be..8adc62acf2 100644
--- a/src/remote/remote_ssh_helper.c
+++ b/src/remote/remote_ssh_helper.c
@@ -354,6 +354,8 @@ int main(int argc, char **argv)
     g_autoptr(virURI) uri = NULL;
     g_autofree char *driver = NULL;
     remoteDriverTransport transport;
+    int mode = REMOTE_DRIVER_MODE_AUTO;
+    const char *mode_str = NULL;
     gboolean version = false;
     gboolean readonly = false;
     g_autofree char *sock_path = NULL;
@@ -367,6 +369,7 @@ int main(int argc, char **argv)
         { NULL, '\0', 0, 0, NULL, NULL, NULL }
     };
     unsigned int flags;
+    size_t i;
 
     context = g_option_context_new("URI - libvirt socket proxy");
     g_option_context_set_summary(context,
@@ -429,8 +432,23 @@ int main(int argc, char **argv)
     if (readonly)
         flags |= REMOTE_DRIVER_OPEN_RO;
 
+    for (i = 0; i < uri->paramsCount; i++) {
+        virURIParam *var = &uri->params[i];
+
+        if (STRCASEEQ(var->name, "mode")) {
+            mode_str = var->value;
+            continue;
+        }
+    }
+
+    if (mode_str &&
+        (mode = remoteDriverModeTypeFromString(mode_str)) < 0) {
+        g_printerr(_("%s: unknown remote mode '%s'"), argv[0], mode_str);
+        exit(EXIT_FAILURE);
+    }
+
     sock_path = remoteGetUNIXSocket(transport,
-                                    REMOTE_DRIVER_MODE_AUTO,
+                                    mode,
                                     driver,
                                     flags,
                                     &daemon_path);
-- 
2.39.1



More information about the libvir-list mailing list