vshRebootShutdownModeCompleter returns available modes
for reboot/shutdown commands.
---
tools/virsh.c | 28 ++++++++++++++++++++++++++++
tools/virsh.h | 1 +
2 files changed, 29 insertions(+)
diff --git a/tools/virsh.c b/tools/virsh.c
index 85d74ad..965b141 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2578,6 +2578,34 @@ error:
return NULL;
}
+char **
+vshRebootShutdownModeCompleter(unsigned int unused_flags ATTRIBUTE_UNUSED)
+{
+ const char *modes[] = {"acpi", "agent", "initctl",
"signal"};
+ const unsigned int modes_size = ARRAY_CARDINALITY(modes);
+ char **names = NULL;
+ size_t i;
+
+ names = vshMalloc(NULL, sizeof(char *) * (modes_size + 1));
+
+ if (!names)
+ return NULL;
+
+ for (i = 0; i < modes_size; i++) {
+ if (VIR_STRDUP(names[i], modes[i]) < 0)
+ goto cleanup;
+ }
+
+ names[i] = NULL;
+ return names;
+
+cleanup:
+ for (i = 0; names[i]; i++)
+ VIR_FREE(names[i]);
+ VIR_FREE(names);
+ return NULL;
+}
+
/* -----------------
* Readline stuff
* -----------------
diff --git a/tools/virsh.h b/tools/virsh.h
index 6767e65..61510b0 100644
--- a/tools/virsh.h
+++ b/tools/virsh.h
@@ -257,6 +257,7 @@ struct _vshCmdGrp {
char **vshDomainCompleter(unsigned int flags);
char **vshSuspendTargetCompleter(unsigned int unused_flags);
+char **vshRebootShutdownModeCompleter(unsigned int unused_flags);
void vshError(vshControl *ctl, const char *format, ...)
ATTRIBUTE_FMT_PRINTF(2, 3);
--
1.8.3.1