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 f9c9ccb..13d66c7 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -2577,6 +2577,34 @@ cleanup: 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 5100c4b..803d858 100644 --- a/tools/virsh.h +++ b/tools/virsh.h @@ -256,6 +256,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 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list