On 1/2/20 4:07 PM, Julio Faracco wrote:
The command `domifaddr` can use three different sources to grab IP
address of a Virtual Machine: lease, agent and arp. This parameter does
not have a completer function to return source options.
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
tools/virsh-completer-domain.c | 17 +++++++++++++++++
tools/virsh-completer-domain.h | 5 +++++
tools/virsh-domain-monitor.c | 1 +
3 files changed, 23 insertions(+)
diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c
index 0311ee50d0..c8709baa38 100644
--- a/tools/virsh-completer-domain.c
+++ b/tools/virsh-completer-domain.c
@@ -296,3 +296,20 @@ virshDomainShutdownModeCompleter(vshControl *ctl,
return virshCommaStringListComplete(mode, modes);
}
+
+
+char **
+virshDomainIfAddrSourceCompleter(vshControl *ctl,
+ const vshCmd *cmd,
+ unsigned int flags)
+{
+ const char *sources[] = {"lease", "agent", "arp",
NULL};
+ const char *source = NULL;
+
+ virCheckFlags(0, NULL);
+
+ if (vshCommandOptStringQuiet(ctl, cmd, "source", &source) < 0)
+ return NULL;
+
+ return virshCommaStringListComplete(source, sources);
Actually, I don't think this is coorect. This helper completes a string
list separated by commas, for instance a shutdown mode where more than
one string (method) can be used:
virsh shutdown --mode acpi,agent,signal
But this is not the case for domifaddr --source, is it? It accepts
exactly one string. I know Erik pushed this, so I will post a fix up
later. Stay tuned.
Michal