[libvirt] [PATCH] virsh: Add a completer for `domifaddr` --source parameter.

Michal Prívozník mprivozn at redhat.com
Sat Jan 4 08:13:02 UTC 2020


On 1/3/20 4:56 PM, Julio Faracco wrote:
> Michal,
> 
> This case of comma separated options, can we include a comma after
> completion by default?
> I.e.:
> 
> virsh # domifaddr 1 --source [TAB]
> agent  arp    lease
> virsh # domifaddr 1 --source ar[TAB]
> virsh # domifaddr 1 --source arp,
> 
> This is easy to test and avoid mistakes.

BTW: --source doesn't accept multiple values.

But anyway, for that we would need to change the way we parse the
argument value because for instance:

  virsh shutdown --mode agent, fedora

is not viewed as valid command by current implementation:

  error: Unknown mode  value, expecting 'acpi', 'agent', 'initctl',
'signal', or 'paravirt'


The fix for this is pretty simple:

index 9315755990..e3daa7d015 100644
--- i/tools/virsh-domain.c
+++ w/tools/virsh-domain.c
@@ -5847 +5847 @@ cmdShutdown(vshControl *ctl, const vshCmd *cmd)
-    while (tmp && *tmp) {
+    while (tmp && *tmp && **tmp) {


But the question is, should we? I mean, this way of accepting multiple
values is pretty unique. I haven't seen any other CLI tool like it
(except for QEMU obviously) so I don't see any behaviour we could mimic.
And I find comma at the end a bit ugly looking.

Michal




More information about the libvir-list mailing list