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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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);
+}
diff --git a/tools/virsh-completer-domain.h b/tools/virsh-completer-domain.h
index 083ab327cc..f5e5625051 100644
--- a/tools/virsh-completer-domain.h
+++ b/tools/virsh-completer-domain.h
@@ -53,3 +53,8 @@ char ** virshDomainDeviceAliasCompleter(vshControl *ctl,
 char ** virshDomainShutdownModeCompleter(vshControl *ctl,
                                          const vshCmd *cmd,
                                          unsigned int flags);
+
+char **
+virshDomainIfAddrSourceCompleter(vshControl *ctl,
+                                 const vshCmd *cmd,
+                                 unsigned int flags);
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 30b186ffd1..1d1f87eb9e 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -2346,6 +2346,7 @@ static const vshCmdOptDef opts_domifaddr[] = {
     {.name = "source",
      .type = VSH_OT_STRING,
      .flags = VSH_OFLAG_NONE,
+     .completer = virshDomainIfAddrSourceCompleter,
      .help = N_("address source: 'lease', 'agent', or 'arp'")},
     {.name = NULL}
 };
-- 
2.20.1


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux