]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vsh: cmdComplete: Don't exit when connecting to the daemon fails
authorPeter Krempa <pkrempa@redhat.com>
Wed, 29 Apr 2026 10:22:35 +0000 (12:22 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 5 May 2026 05:32:11 +0000 (07:32 +0200)
Invoke the 'connHandler' without checking return value. 'virsh complete'
can provide useful completions even when the daemon connection is
broken.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tools/vsh.c

index c84d17a3327f6d49497e4634cee103c59cc91f58..ccf2f21d64c143d127cfcfd9b805ce331f99abff 100644 (file)
@@ -3584,8 +3584,11 @@ cmdComplete(vshControl *ctl, const vshCmd *cmd)
         ctl->stderr_closed = true;
     }
 
-    if (!(hooks && hooks->connHandler && hooks->connHandler(ctl)))
-        return false;
+    /* Attempt connecting so that we can also do completions based on e.g.
+     * object names work. Failure to connect is not fatal because we want
+     * at least argument completion */
+    if (hooks && hooks->connHandler)
+        ignore_value(hooks->connHandler(ctl));
 
     vshReadlineInit(ctl);