[libvirt] [PATCH RFC 0/2] virsh: Introduce basic autocompletion

Peter Krempa pkrempa at redhat.com
Tue Oct 31 13:43:27 UTC 2017


On Tue, Oct 31, 2017 at 14:10:25 +0100, Michal Privoznik wrote:
> This is supposed to go on the top of:
> 
> https://www.redhat.com/archives/libvir-list/2017-October/msg01367.html
> 
> Before digging any deeper to this hole I want to make sure that
> this approach is acceptable.
> 
> So how does this work. The idea is to have handful of generic
> functions that fetch names (so called completers). Basically, one
> completer per each libvirt object. The returned names are then
> matched against (partial) user input and only matching strings
> are then offered to the user. Moreover, among having .completer
> each option has .completer_flags which can refine the completer's
> behaviour.
> 
> For instance, in 2/2 I'm introducing virshDomainNameCompleter()
> which does nothing more than virConnectListAllDomains(). However,
> since it doesn't make much sense to start already running domain,
> for the 'start' command .completer_flags is set to
> VIR_CONNECT_LIST_DOMAINS_INACTIVE so that only inactive domains
> are returned in the list.
> 
> 
> What is missing?
> What is implemented here are vshCmdOptDef completers. The general
> vshCmdDef completers are still missing. Therefore:
> 
> virsh # start --domain<TAB><TAB>
> 
> works and lists inactive domains, but:
> 
> virsh # start<TAB><TAB>
> 
> doesn't (well, apart from offering options for the 'start'
> command). While that would be certainly nice feature to have,
> it'd require more work, because some arguments are "implicit"
> based on position. For instance:
> 
> virsh # attach-interface fedora network default
> 
> which is equivalent to:
> 
> virsh # attach-interface --domain fedora --type network --source default
> 
> 
> Also, bash autocompletion is missing. The idea there is to have
> an unlisted virsh command that the bash script can call in order
> to fetch list of options. But again, no movement in that area
> yet.

I think we need a way to determine whether the autocompletion is
possible without any user input. For bash autocompletion you will invoke
virsh to get any other params, but that means that for connections
requiring authentication you'd get stuck waiting for input (or openning
an ssh connection) which may throw off users.

This might happen too often on RHEV boxes since they use polkit auth.

It might be possible to work around polkit by connecting without auth
callbacks, but for qemu+ssh you don't really have options IMO.

Maybe you'll need to specifically disable it on ssh connections using
the default transport.

For libssh and libssh2 you can allow that but it's rather expensive to
instantiate the connection just to query a list of VMs after you press
tab.

Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20171031/28227690/attachment-0001.sig>


More information about the libvir-list mailing list