vshSuspendTargetCompleter returns targets available for suspend. This completer can be used for the command option completion (for dompmsuspend, etc.). --- tools/virsh.c | 28 ++++++++++++++++++++++++++++ tools/virsh.h | 1 + 2 files changed, 29 insertions(+) diff --git a/tools/virsh.c b/tools/virsh.c index af31b9a..f9c9ccb 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -2549,6 +2549,34 @@ cleanup: return NULL; } +char ** +vshSuspendTargetCompleter(unsigned int unused_flags ATTRIBUTE_UNUSED) +{ + const char *targets[] = {"mem", "disk", "hybrid"}; + const unsigned int targets_size = ARRAY_CARDINALITY(targets); + char **names = NULL; + size_t i; + + names = vshMalloc(NULL, sizeof(char *) * (targets_size + 1)); + + if (!names) + return NULL; + + for (i = 0; i < targets_size; i++) { + if (VIR_STRDUP(names[i], targets[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 c4a9c13..5100c4b 100644 --- a/tools/virsh.h +++ b/tools/virsh.h @@ -255,6 +255,7 @@ struct _vshCmdGrp { }; char **vshDomainCompleter(unsigned int flags); +char **vshSuspendTargetCompleter(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