]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: Introduce net-update --section completer
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 10 Jan 2022 11:44:23 +0000 (12:44 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 19 Jan 2022 15:48:33 +0000 (16:48 +0100)
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tools/virsh-completer-network.c
tools/virsh-completer-network.h
tools/virsh-network.c
tools/virsh-network.h

index d0cf80f22cb0af3cf8667992a34f1593119c1071..839d71e9616b4924dc51bbff4b71aafd2452fe35 100644 (file)
@@ -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;
+}
index 7557dfdb0dc23b237a93e42de5b9987256e12cd7..c7ceff0b1354afd18dcc9d77a226aa6e62bdaf93 100644 (file)
@@ -51,3 +51,8 @@ char **
 virshNetworkUpdateCommandCompleter(vshControl *ctl,
                                    const vshCmd *cmd,
                                    unsigned int flags);
+
+char **
+virshNetworkUpdateSectionCompleter(vshControl *ctl,
+                                   const vshCmd *cmd,
+                                   unsigned int flags);
index 2a0a24c6d3f5ef2b006a0e8bedeb40dc5ccb4885..5f574be78cf5cbed97cd8f29c9d955df162a24bd 100644 (file)
@@ -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",
index 05da736cce1588b6efe9ab330eae406557f714f5..ffd157f054792d43fdbf3525ea1739226f24f5f8 100644 (file)
@@ -45,5 +45,6 @@ typedef struct virshNetworkEventCallback virshNetworkEventCallback;
 extern virshNetworkEventCallback virshNetworkEventCallbacks[];
 
 VIR_ENUM_DECL(virshNetworkUpdateCommand);
+VIR_ENUM_DECL(virshNetworkSection);
 
 extern const vshCmdDef networkCmds[];