[PATCH 2/2] virsh: Introduce net-update --section completer

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

 



Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 tools/virsh-completer-network.c | 20 ++++++++++++++++++++
 tools/virsh-completer-network.h |  5 +++++
 tools/virsh-network.c           |  2 +-
 tools/virsh-network.h           |  1 +
 4 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/tools/virsh-completer-network.c b/tools/virsh-completer-network.c
index d0cf80f22c..839d71e961 100644
--- a/tools/virsh-completer-network.c
+++ b/tools/virsh-completer-network.c
@@ -241,3 +241,23 @@ virshNetworkUpdateCommandCompleter(vshControl *ctl G_GNUC_UNUSED,
 
     return ret;
 }
+
+
+char **
+virshNetworkUpdateSectionCompleter(vshControl *ctl G_GNUC_UNUSED,
+                                   const vshCmd *cmd G_GNUC_UNUSED,
+                                   unsigned int flags)
+{
+    char **ret = NULL;
+    size_t i;
+
+    virCheckFlags(0, NULL);
+
+    ret = g_new0(char *, VIR_NETWORK_SECTION_LAST);
+
+    /* The first item in the enum is not accepted by virsh. */
+    for (i = 1; i < VIR_NETWORK_SECTION_LAST; i++)
+        ret[i - 1] = g_strdup(virshNetworkSectionTypeToString(i));
+
+    return ret;
+}
diff --git a/tools/virsh-completer-network.h b/tools/virsh-completer-network.h
index 7557dfdb0d..c7ceff0b13 100644
--- a/tools/virsh-completer-network.h
+++ b/tools/virsh-completer-network.h
@@ -51,3 +51,8 @@ char **
 virshNetworkUpdateCommandCompleter(vshControl *ctl,
                                    const vshCmd *cmd,
                                    unsigned int flags);
+
+char **
+virshNetworkUpdateSectionCompleter(vshControl *ctl,
+                                   const vshCmd *cmd,
+                                   unsigned int flags);
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 2a0a24c6d3..5f574be78c 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -925,6 +925,7 @@ static const vshCmdOptDef opts_network_update[] = {
     {.name = "section",
      .type = VSH_OT_DATA,
      .flags = VSH_OFLAG_REQ,
+     .completer = virshNetworkUpdateSectionCompleter,
      .help = N_("which section of network configuration to update")
     },
     {.name = "xml",
@@ -948,7 +949,6 @@ VIR_ENUM_IMPL(virshNetworkUpdateCommand,
               VIR_NETWORK_UPDATE_COMMAND_LAST,
               "none", "modify", "delete", "add-last", "add-first");
 
-VIR_ENUM_DECL(virshNetworkSection);
 VIR_ENUM_IMPL(virshNetworkSection,
               VIR_NETWORK_SECTION_LAST,
               "none", "bridge", "domain", "ip", "ip-dhcp-host",
diff --git a/tools/virsh-network.h b/tools/virsh-network.h
index 05da736cce..ffd157f054 100644
--- a/tools/virsh-network.h
+++ b/tools/virsh-network.h
@@ -45,5 +45,6 @@ typedef struct virshNetworkEventCallback virshNetworkEventCallback;
 extern virshNetworkEventCallback virshNetworkEventCallbacks[];
 
 VIR_ENUM_DECL(virshNetworkUpdateCommand);
+VIR_ENUM_DECL(virshNetworkSection);
 
 extern const vshCmdDef networkCmds[];
-- 
2.34.1




[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