* label cleanup renamed to error * vshSuspendTargetCompleter added to opts_dom_pm_suspend --- tools/virsh-domain.c | 3 ++- tools/virsh.c | 28 ++++++++++++++++++++++++++++ tools/virsh.h | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 5d4913d..a2002c5 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -2756,7 +2756,8 @@ static const vshCmdOptDef opts_dom_pm_suspend[] = { .flags = VSH_OFLAG_REQ, .help = N_("mem(Suspend-to-RAM), " "disk(Suspend-to-Disk), " - "hybrid(Hybrid-Suspend)") + "hybrid(Hybrid-Suspend)"), + .completer = vshSuspendTargetCompleter }, {.name = NULL} }; diff --git a/tools/virsh.c b/tools/virsh.c index 13c27df..85d74ad 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -2550,6 +2550,34 @@ error: 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 error; + } + + names[i] = NULL; + return names; + +error: + 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 68414e4..6767e65 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); 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