[libvirt PATCH v2 3/6] virnetclient: Handle netcatPath presence all at once

Andrea Bolognani abologna at redhat.com
Mon Feb 14 16:03:32 UTC 2022


Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 src/rpc/virnetclient.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index 7e7e9d52a6..9c7047c7f8 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -425,13 +425,17 @@ virNetClientSSHHelperCommand(virNetClientProxy proxy,
     g_autofree char *nccmd = NULL;
     g_autofree char *helpercmd = NULL;
 
-    /* If user gave a 'netcat' path in the URI, we must
-     * assume they want the legacy 'nc' based proxy, not
-     * our new virt-ssh-helper
-     */
-    if (proxy == VIR_NET_CLIENT_PROXY_AUTO &&
-        netcatPath != NULL) {
-        proxy = VIR_NET_CLIENT_PROXY_NETCAT;
+    if (netcatPath) {
+        if (proxy == VIR_NET_CLIENT_PROXY_AUTO) {
+            /* If user gave a 'netcat' path in the URI, we must
+             * assume they want the legacy 'nc' based proxy, not
+             * our new virt-ssh-helper */
+            proxy = VIR_NET_CLIENT_PROXY_NETCAT;
+        } else if (proxy == VIR_NET_CLIENT_PROXY_NATIVE) {
+            virReportError(VIR_ERR_INVALID_ARG, "%s",
+                           _("netcat path not valid with native proxy mode"));
+            return NULL;
+        }
     }
 
     nccmd = g_strdup_printf(
@@ -459,11 +463,6 @@ virNetClientSSHHelperCommand(virNetClientProxy proxy,
         return g_strdup_printf("sh -c '%s'", nccmd);
 
     case VIR_NET_CLIENT_PROXY_NATIVE:
-        if (netcatPath) {
-            virReportError(VIR_ERR_INVALID_ARG, "%s",
-                           _("netcat path not valid with native proxy mode"));
-            return NULL;
-        }
         return g_strdup_printf("sh -c '%s'", helpercmd);
 
     case VIR_NET_CLIENT_PROXY_LAST:
-- 
2.35.1




More information about the libvir-list mailing list