diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c index 6fb56ebfdcf3f180d1f36b63acc1cb991bf5ab1c..050278203343826d409b639e5dac79699b80ed5f 100644 --- a/tools/virsh-completer.c +++ b/tools/virsh-completer.c @@ -703,3 +703,29 @@ virshDomainEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED, virStringListFree(ret); return NULL; } + + +char ** +virshPoolEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED, + const vshCmd *cmd ATTRIBUTE_UNUSED, + unsigned int flags) +{ + size_t i = 0; + char **ret = NULL; + + virCheckFlags(0, NULL); + + if (VIR_ALLOC_N(ret, VIR_STORAGE_POOL_EVENT_ID_LAST) < 0) + goto error; + + for (i = 0; i < VIR_STORAGE_POOL_EVENT_ID_LAST; i++) { + if (VIR_STRDUP(ret[i], virshPoolEventCallbacks[i].name) < 0) + goto error; + } + + return ret; + + error: + virStringListFree(ret); + return NULL; +} diff --git a/tools/virsh-completer.h b/tools/virsh-completer.h index 8763c4e2edb301f2bb9656e9754d657a0f346b6d..b02b49ce4ab0b4239794efd6fd384b7896703701 100644 --- a/tools/virsh-completer.h +++ b/tools/virsh-completer.h @@ -86,4 +86,8 @@ char ** virshDomainEventNameCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); +char ** virshPoolEventNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); + #endif diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 0145b4430b5e869d512b4b4e18489a14785e47fe..cc49a5b96d0a10421e3b249a20b56985d3cd8a2a 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -2098,6 +2098,7 @@ static const vshCmdOptDef opts_pool_event[] = { }, {.name = "event", .type = VSH_OT_STRING, + .completer = virshPoolEventNameCompleter, .help = N_("which event type to wait for") }, {.name = "loop",