[PATCH 0/3] virsh: Don't expect keyboard input from completers

Michal Privoznik via Devel posted 3 patches 2 weeks, 1 day ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/cover.1778842835.git.mprivozn@redhat.com
src/rpc/virnetlibsshsession.c | 14 +++++++-------
src/rpc/virnetsshsession.c    |  7 -------
tools/virsh.c                 | 10 +++++++++-
3 files changed, 16 insertions(+), 15 deletions(-)
[PATCH 0/3] virsh: Don't expect keyboard input from completers
Posted by Michal Privoznik via Devel 2 weeks, 1 day ago
See 3/3 for in depth explanation.
After this, there's still one problem - the ssh transport (tcp+ssh://...)
because virNetSocketNewConnectSSH() does not really ask for
virConnectAuthCallbackPtr. There should be a way to fix it though: from
bash script parse URI and append ?no_tty=1 at the end of URI. This
directs virNetSocketNewConnectSSH() to execute SSH binary with
BatchMode=yes which is documented to suppress keyboard interaction.

If we find this ^^ needed I can try to write a patch. But for now, let's
fix other transports.

Michal Prívozník (3):
  virnetsshsession: Don't check for auth callbacks in
    virNetSSHAuthenticatePassword()
  virnetlibsshsession: Check later for auth callback in
    virNetLibsshAuthenticatePassword()
  virsh: Provide no auth callbacks for bash completer

 src/rpc/virnetlibsshsession.c | 14 +++++++-------
 src/rpc/virnetsshsession.c    |  7 -------
 tools/virsh.c                 | 10 +++++++++-
 3 files changed, 16 insertions(+), 15 deletions(-)

-- 
2.53.0

Re: [PATCH 0/3] virsh: Don't expect keyboard input from completers
Posted by Richard W.M. Jones via Devel 2 weeks, 1 day ago
On Fri, May 15, 2026 at 01:05:30PM +0200, Michal Privoznik via Devel wrote:
> See 3/3 for in depth explanation.
> After this, there's still one problem - the ssh transport (tcp+ssh://...)
> because virNetSocketNewConnectSSH() does not really ask for
> virConnectAuthCallbackPtr. There should be a way to fix it though: from
> bash script parse URI and append ?no_tty=1 at the end of URI. This
> directs virNetSocketNewConnectSSH() to execute SSH binary with
> BatchMode=yes which is documented to suppress keyboard interaction.
> 
> If we find this ^^ needed I can try to write a patch. But for now, let's
> fix other transports.
> 
> Michal Prívozník (3):
>   virnetsshsession: Don't check for auth callbacks in
>     virNetSSHAuthenticatePassword()
>   virnetlibsshsession: Check later for auth callback in
>     virNetLibsshAuthenticatePassword()
>   virsh: Provide no auth callbacks for bash completer
> 
>  src/rpc/virnetlibsshsession.c | 14 +++++++-------
>  src/rpc/virnetsshsession.c    |  7 -------
>  tools/virsh.c                 | 10 +++++++++-
>  3 files changed, 16 insertions(+), 15 deletions(-)

I tested the series.  I had to use 'build/run bash' to set shell
variables so that the virsh subcommand would use the patched version.
I also strace'd that bash so I could be doubly sure it was running the
'virsh complete' subcommand:

  2600499 execve("/home/rjones/d/libvirt/build/tools/virsh", ["virsh", "-q", "-c", "esx://root@[redacted]"..., "complete", "--", ""], 0x561fdfcd7000 /* 80 vars */) = 0

Anyhow it fixes the issue I was having, so:

Tested-by: Richrad W.M. Jones <rjones@redhat.com>

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
Re: [PATCH 0/3] virsh: Don't expect keyboard input from completers
Posted by Michal Prívozník via Devel 2 weeks, 1 day ago
On 5/15/26 14:19, Richard W.M. Jones wrote:
> On Fri, May 15, 2026 at 01:05:30PM +0200, Michal Privoznik via Devel wrote:
>> See 3/3 for in depth explanation.
>> After this, there's still one problem - the ssh transport (tcp+ssh://...)
>> because virNetSocketNewConnectSSH() does not really ask for
>> virConnectAuthCallbackPtr. There should be a way to fix it though: from
>> bash script parse URI and append ?no_tty=1 at the end of URI. This
>> directs virNetSocketNewConnectSSH() to execute SSH binary with
>> BatchMode=yes which is documented to suppress keyboard interaction.
>>
>> If we find this ^^ needed I can try to write a patch. But for now, let's
>> fix other transports.
>>
>> Michal Prívozník (3):
>>   virnetsshsession: Don't check for auth callbacks in
>>     virNetSSHAuthenticatePassword()
>>   virnetlibsshsession: Check later for auth callback in
>>     virNetLibsshAuthenticatePassword()
>>   virsh: Provide no auth callbacks for bash completer
>>
>>  src/rpc/virnetlibsshsession.c | 14 +++++++-------
>>  src/rpc/virnetsshsession.c    |  7 -------
>>  tools/virsh.c                 | 10 +++++++++-
>>  3 files changed, 16 insertions(+), 15 deletions(-)
> 
> I tested the series.  I had to use 'build/run bash' to set shell
> variables so that the virsh subcommand would use the patched version.

The bash completion script is written in such way that it should execute
ARGV[0]. So in fact all that's needed is:

cd build;
./tools/virsh -c esx://... <TAB><TAB>

> I also strace'd that bash so I could be doubly sure it was running the
> 'virsh complete' subcommand:
> 
>   2600499 execve("/home/rjones/d/libvirt/build/tools/virsh", ["virsh", "-q", "-c", "esx://root@[redacted]"..., "complete", "--", ""], 0x561fdfcd7000 /* 80 vars */) = 0
> 
> Anyhow it fixes the issue I was having, so:
> 
> Tested-by: Richrad W.M. Jones <rjones@redhat.com>

Thanks for testing!

Michal

Re: [PATCH 0/3] virsh: Don't expect keyboard input from completers
Posted by Ján Tomko via Devel 2 weeks, 1 day ago
On a Friday in 2026, Michal Privoznik via Devel wrote:
>See 3/3 for in depth explanation.
>After this, there's still one problem - the ssh transport (tcp+ssh://...)
>because virNetSocketNewConnectSSH() does not really ask for
>virConnectAuthCallbackPtr. There should be a way to fix it though: from
>bash script parse URI and append ?no_tty=1 at the end of URI. This
>directs virNetSocketNewConnectSSH() to execute SSH binary with
>BatchMode=yes which is documented to suppress keyboard interaction.
>
>If we find this ^^ needed I can try to write a patch. But for now, let's
>fix other transports.
>
>Michal Prívozník (3):
>  virnetsshsession: Don't check for auth callbacks in
>    virNetSSHAuthenticatePassword()
>  virnetlibsshsession: Check later for auth callback in
>    virNetLibsshAuthenticatePassword()
>  virsh: Provide no auth callbacks for bash completer
>
> src/rpc/virnetlibsshsession.c | 14 +++++++-------
> src/rpc/virnetsshsession.c    |  7 -------
> tools/virsh.c                 | 10 +++++++++-
> 3 files changed, 16 insertions(+), 15 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano