Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tools/virsh-completer-network.c | 23 +++++++++++++++++++++++
tools/virsh-completer-network.h | 5 +++++
tools/virsh-network.c | 2 +-
tools/virsh-network.h | 2 ++
4 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/tools/virsh-completer-network.c b/tools/virsh-completer-network.c
index d498f59cb8..d0cf80f22c 100644
--- a/tools/virsh-completer-network.c
+++ b/tools/virsh-completer-network.c
@@ -218,3 +218,26 @@ virshNetworkDhcpMacCompleter(vshControl *ctl,
}
return ret;
}
+
+
+char **
+virshNetworkUpdateCommandCompleter(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_UPDATE_COMMAND_LAST + 1);
+
+ /* The first item in the enum is not accepted by virsh, But there's
"add"
+ * which is accepted an is just an alias to "add-last". */
+ ret[0] = g_strdup("add");
+
+ for (i = 1; i < VIR_NETWORK_UPDATE_COMMAND_LAST; i++)
+ ret[i] = g_strdup(virshNetworkUpdateCommandTypeToString(i));
+
+ return ret;
+}
diff --git a/tools/virsh-completer-network.h b/tools/virsh-completer-network.h
index ffcda68355..7557dfdb0d 100644
--- a/tools/virsh-completer-network.h
+++ b/tools/virsh-completer-network.h
@@ -46,3 +46,8 @@ char **
virshNetworkDhcpMacCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
+
+char **
+virshNetworkUpdateCommandCompleter(vshControl *ctl,
+ const vshCmd *cmd,
+ unsigned int flags);
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 02b22bf912..2a0a24c6d3 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -919,6 +919,7 @@ static const vshCmdOptDef opts_network_update[] = {
{.name = "command",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
+ .completer = virshNetworkUpdateCommandCompleter,
.help = N_("type of update (add-first, add-last (add), delete, or
modify)")
},
{.name = "section",
@@ -943,7 +944,6 @@ static const vshCmdOptDef opts_network_update[] = {
{.name = NULL}
};
-VIR_ENUM_DECL(virshNetworkUpdateCommand);
VIR_ENUM_IMPL(virshNetworkUpdateCommand,
VIR_NETWORK_UPDATE_COMMAND_LAST,
"none", "modify", "delete",
"add-last", "add-first");
diff --git a/tools/virsh-network.h b/tools/virsh-network.h
index 3c786dd7a1..05da736cce 100644
--- a/tools/virsh-network.h
+++ b/tools/virsh-network.h
@@ -44,4 +44,6 @@ typedef struct virshNetworkEventCallback virshNetworkEventCallback;
extern virshNetworkEventCallback virshNetworkEventCallbacks[];
+VIR_ENUM_DECL(virshNetworkUpdateCommand);
+
extern const vshCmdDef networkCmds[];
--
2.34.1