[libvirt] [PATCH 00/17] virsh bash completion improvements

Lin Ma (17): virshDomainNameCompleter: Add some of VIR_CONNECT_LIST_DOMAINS_ flags virsh: snapshot: Only return domains that have snapshot images virsh: managedsave-*: Only return domains that have a managed save image virsh: checkpoint: Only return domains that have checkpoints virsh: Add event completer to --enable/--disable args of perf command vshReadlineParse: Ignore vshReadlineOptionsGenerator for VSH_OT_INT options virsh: Add network uuid completion to network-name command virsh: Add domain uuid completion to domname command virsh: Add iothread IDs completion to iothread* commands virsh: Add completion for --iothread argument of attach-disk command virsh: Add vcpu IDs completion to vcpupin command virsh: Add vcpu list completion to setvcpu command virsh: Add logical CPU list completion for --cpulist argument virsh: limit completion of net-dhcp-leases to active networks virsh: limit completion of net-port* to active networks virsh: limit completion of backup-{begin, dumpxml} to active domains virsh: limit completion of checkpoint-{create, delete} to active domains tools/virsh-backup.c | 4 +- tools/virsh-checkpoint.c | 17 +- tools/virsh-completer-domain.c | 264 +++++++++++++++++++++++++++++++- tools/virsh-completer-domain.h | 31 ++++ tools/virsh-completer-network.c | 42 +++++ tools/virsh-completer-network.h | 4 + tools/virsh-domain.c | 33 +++- tools/virsh-network.c | 12 +- tools/virsh-snapshot.c | 16 +- tools/vsh.c | 1 + 10 files changed, 395 insertions(+), 29 deletions(-) -- 2.26.0

Commit 3b225256 removed unused VIR_CONNECT_LIST_DOMAINS_* flags, But some of them will be used in upcoming patches, So add some of them back. Signed-off-by: Lin Ma <lma@suse.de> --- tools/virsh-completer-domain.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 4472ee08f2..4c1261b06b 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -48,7 +48,10 @@ virshDomainNameCompleter(vshControl *ctl, VIR_CONNECT_LIST_DOMAINS_PAUSED | VIR_CONNECT_LIST_DOMAINS_PERSISTENT | VIR_CONNECT_LIST_DOMAINS_RUNNING | - VIR_CONNECT_LIST_DOMAINS_SHUTOFF, + VIR_CONNECT_LIST_DOMAINS_SHUTOFF | + VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE | + VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT | + VIR_CONNECT_LIST_DOMAINS_HAS_CHECKPOINT, NULL); if (!priv->conn || virConnectIsAlive(priv->conn) <= 0) -- 2.26.0

Signed-off-by: Lin Ma <lma@suse.de> --- tools/virsh-snapshot.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index 8b16d77b56..99e3d98c6f 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -511,7 +511,7 @@ static const vshCmdInfo info_snapshot_edit[] = { }; static const vshCmdOptDef opts_snapshot_edit[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT), {.name = "snapshotname", .type = VSH_OT_STRING, .help = N_("snapshot name"), @@ -624,7 +624,7 @@ static const vshCmdInfo info_snapshot_current[] = { }; static const vshCmdOptDef opts_snapshot_current[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT), {.name = "name", .type = VSH_OT_BOOL, .help = N_("list the name, rather than the full xml") @@ -856,7 +856,7 @@ static const vshCmdInfo info_snapshot_info[] = { }; static const vshCmdOptDef opts_snapshot_info[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT), {.name = "snapshotname", .type = VSH_OT_STRING, .help = N_("snapshot name"), @@ -1406,7 +1406,7 @@ static const vshCmdInfo info_snapshot_list[] = { }; static const vshCmdOptDef opts_snapshot_list[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT), {.name = "parent", .type = VSH_OT_BOOL, .help = N_("add a column showing parent snapshot") @@ -1669,7 +1669,7 @@ static const vshCmdInfo info_snapshot_dumpxml[] = { }; static const vshCmdOptDef opts_snapshot_dumpxml[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT), {.name = "snapshotname", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -1733,7 +1733,7 @@ static const vshCmdInfo info_snapshot_parent[] = { }; static const vshCmdOptDef opts_snapshot_parent[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT), {.name = "snapshotname", .type = VSH_OT_STRING, .help = N_("find parent of snapshot name"), @@ -1793,7 +1793,7 @@ static const vshCmdInfo info_snapshot_revert[] = { }; static const vshCmdOptDef opts_snapshot_revert[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT), {.name = "snapshotname", .type = VSH_OT_STRING, .help = N_("snapshot name"), @@ -1878,7 +1878,7 @@ static const vshCmdInfo info_snapshot_delete[] = { }; static const vshCmdOptDef opts_snapshot_delete[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT), {.name = "snapshotname", .type = VSH_OT_STRING, .help = N_("snapshot name"), -- 2.26.0

Signed-off-by: Lin Ma <lma@suse.de> --- tools/virsh-domain.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index d1d3f8e566..68600d728a 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -4848,7 +4848,7 @@ static const vshCmdInfo info_managedsaveremove[] = { }; static const vshCmdOptDef opts_managedsaveremove[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE), {.name = NULL} }; @@ -4903,7 +4903,7 @@ static const vshCmdInfo info_managed_save_edit[] = { }; static const vshCmdOptDef opts_managed_save_edit[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE), {.name = "running", .type = VSH_OT_BOOL, .help = N_("set domain to be running on start") @@ -4969,7 +4969,7 @@ static const vshCmdInfo info_managed_save_dumpxml[] = { }; static const vshCmdOptDef opts_managed_save_dumpxml[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE), {.name = "security-info", .type = VSH_OT_BOOL, .help = N_("include security sensitive information in XML dump") @@ -5017,7 +5017,7 @@ static const vshCmdInfo info_managed_save_define[] = { }; static const vshCmdOptDef opts_managed_save_define[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE), {.name = "xml", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, -- 2.26.0

Signed-off-by: Lin Ma <lma@suse.de> --- tools/virsh-checkpoint.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/virsh-checkpoint.c b/tools/virsh-checkpoint.c index 411eac7fc8..c4ff863802 100644 --- a/tools/virsh-checkpoint.c +++ b/tools/virsh-checkpoint.c @@ -332,7 +332,7 @@ static const vshCmdInfo info_checkpoint_edit[] = { }; static const vshCmdOptDef opts_checkpoint_edit[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_HAS_CHECKPOINT), {.name = "checkpointname", .type = VSH_OT_STRING, .help = N_("checkpoint name"), @@ -452,7 +452,7 @@ static const vshCmdInfo info_checkpoint_info[] = { }; static const vshCmdOptDef opts_checkpoint_info[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_HAS_CHECKPOINT), {.name = "checkpointname", .type = VSH_OT_STRING, .help = N_("checkpoint name"), @@ -662,7 +662,7 @@ static const vshCmdInfo info_checkpoint_list[] = { }; static const vshCmdOptDef opts_checkpoint_list[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_HAS_CHECKPOINT), {.name = "parent", .type = VSH_OT_BOOL, .help = N_("add a column showing parent checkpoint") @@ -879,7 +879,7 @@ static const vshCmdInfo info_checkpoint_dumpxml[] = { }; static const vshCmdOptDef opts_checkpoint_dumpxml[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_HAS_CHECKPOINT), {.name = "checkpointname", .type = VSH_OT_STRING, .help = N_("checkpoint name"), @@ -954,7 +954,7 @@ static const vshCmdInfo info_checkpoint_parent[] = { }; static const vshCmdOptDef opts_checkpoint_parent[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_HAS_CHECKPOINT), {.name = "checkpointname", .type = VSH_OT_STRING, .help = N_("find parent of checkpoint name"), @@ -1015,7 +1015,7 @@ static const vshCmdInfo info_checkpoint_delete[] = { }; static const vshCmdOptDef opts_checkpoint_delete[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_HAS_CHECKPOINT), {.name = "checkpointname", .type = VSH_OT_STRING, .help = N_("checkpoint name"), -- 2.26.0

Signed-off-by: Lin Ma <lma@suse.de> --- tools/virsh-completer-domain.c | 49 ++++++++++++++++++++++++++++++++++ tools/virsh-completer-domain.h | 8 ++++++ tools/virsh-domain.c | 2 ++ 3 files changed, 59 insertions(+) diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 4c1261b06b..122a9d5f66 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -29,6 +29,7 @@ #include "virsh.h" #include "virstring.h" #include "virxml.h" +#include "conf/domain_conf.h" char ** virshDomainNameCompleter(vshControl *ctl, @@ -338,3 +339,51 @@ virshDomainHostnameSourceCompleter(vshControl *ctl G_GNUC_UNUSED, return ret; } + + +char ** +virshDomainPerfEnableCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags) +{ + size_t i = 0; + VIR_AUTOSTRINGLIST events = NULL; + const char *event = NULL; + + virCheckFlags(0, NULL); + + if (VIR_ALLOC_N(events, VIR_PERF_EVENT_LAST + 1) < 0) + return NULL; + + for (i = 0; i < VIR_PERF_EVENT_LAST; i++) + events[i] = g_strdup(virPerfEventTypeToString(i)); + + if (vshCommandOptStringQuiet(ctl, cmd, "enable", &event) < 0) + return NULL; + + return virshCommaStringListComplete(event, (const char **)events); +} + + +char ** +virshDomainPerfDisableCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags) +{ + size_t i = 0; + VIR_AUTOSTRINGLIST events = NULL; + const char *event = NULL; + + virCheckFlags(0, NULL); + + if (VIR_ALLOC_N(events, VIR_PERF_EVENT_LAST + 1) < 0) + return NULL; + + for (i = 0; i < VIR_PERF_EVENT_LAST; i++) + events[i] = g_strdup(virPerfEventTypeToString(i)); + + if (vshCommandOptStringQuiet(ctl, cmd, "disable", &event) < 0) + return NULL; + + return virshCommaStringListComplete(event, (const char **)events); +} diff --git a/tools/virsh-completer-domain.h b/tools/virsh-completer-domain.h index b00b05e3bd..e3375c3c65 100644 --- a/tools/virsh-completer-domain.h +++ b/tools/virsh-completer-domain.h @@ -62,3 +62,11 @@ virshDomainInterfaceAddrSourceCompleter(vshControl *ctl, char ** virshDomainHostnameSourceCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); + +char ** virshDomainPerfEnableCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); + +char ** virshDomainPerfDisableCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 68600d728a..1ba536466a 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -9333,10 +9333,12 @@ static const vshCmdOptDef opts_perf[] = { VIRSH_COMMON_OPT_DOMAIN_FULL(0), {.name = "enable", .type = VSH_OT_STRING, + .completer = virshDomainPerfEnableCompleter, .help = N_("perf events which will be enabled") }, {.name = "disable", .type = VSH_OT_STRING, + .completer = virshDomainPerfDisableCompleter, .help = N_("perf events which will be disabled") }, VIRSH_COMMON_OPT_DOMAIN_CONFIG, -- 2.26.0

On 9/11/20 9:13 AM, Lin Ma wrote:
Signed-off-by: Lin Ma <lma@suse.de> --- tools/virsh-completer-domain.c | 49 ++++++++++++++++++++++++++++++++++ tools/virsh-completer-domain.h | 8 ++++++ tools/virsh-domain.c | 2 ++ 3 files changed, 59 insertions(+)
diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 4c1261b06b..122a9d5f66 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -29,6 +29,7 @@ #include "virsh.h" #include "virstring.h" #include "virxml.h" +#include "conf/domain_conf.h"
Including domain_conf.h looks like too much. IIUC, you need virPerfEventTypeToString() prototype - that lives in virperf.h so including just that should be fine.
char ** virshDomainNameCompleter(vshControl *ctl, @@ -338,3 +339,51 @@ virshDomainHostnameSourceCompleter(vshControl *ctl G_GNUC_UNUSED,
return ret; } + + +char ** +virshDomainPerfEnableCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags) +{ + size_t i = 0; + VIR_AUTOSTRINGLIST events = NULL; + const char *event = NULL; + + virCheckFlags(0, NULL); + + if (VIR_ALLOC_N(events, VIR_PERF_EVENT_LAST + 1) < 0) + return NULL; + + for (i = 0; i < VIR_PERF_EVENT_LAST; i++) + events[i] = g_strdup(virPerfEventTypeToString(i)); + + if (vshCommandOptStringQuiet(ctl, cmd, "enable", &event) < 0) + return NULL; + + return virshCommaStringListComplete(event, (const char **)events); +} + + +char ** +virshDomainPerfDisableCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags) +{ + size_t i = 0; + VIR_AUTOSTRINGLIST events = NULL; + const char *event = NULL; + + virCheckFlags(0, NULL); + + if (VIR_ALLOC_N(events, VIR_PERF_EVENT_LAST + 1) < 0) + return NULL; + + for (i = 0; i < VIR_PERF_EVENT_LAST; i++) + events[i] = g_strdup(virPerfEventTypeToString(i)); + + if (vshCommandOptStringQuiet(ctl, cmd, "disable", &event) < 0) + return NULL; + + return virshCommaStringListComplete(event, (const char **)events); +} diff --git a/tools/virsh-completer-domain.h b/tools/virsh-completer-domain.h index b00b05e3bd..e3375c3c65 100644 --- a/tools/virsh-completer-domain.h +++ b/tools/virsh-completer-domain.h @@ -62,3 +62,11 @@ virshDomainInterfaceAddrSourceCompleter(vshControl *ctl, char ** virshDomainHostnameSourceCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); + +char ** virshDomainPerfEnableCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); + +char ** virshDomainPerfDisableCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 68600d728a..1ba536466a 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -9333,10 +9333,12 @@ static const vshCmdOptDef opts_perf[] = { VIRSH_COMMON_OPT_DOMAIN_FULL(0), {.name = "enable", .type = VSH_OT_STRING, + .completer = virshDomainPerfEnableCompleter, .help = N_("perf events which will be enabled") }, {.name = "disable", .type = VSH_OT_STRING, + .completer = virshDomainPerfDisableCompleter, .help = N_("perf events which will be disabled") }, VIRSH_COMMON_OPT_DOMAIN_CONFIG,
Michal

Commit c7151b0 added the completion for VSH_OT_INT options, say '--cellno' and '--pagesize', So we need to ignore VSH_OT_INT otherwise we get the incorrect completion. before: # virsh freepages --pagesize <TAB><TAB> --all --cellno 1GiB 2MiB 4KiB after: # virsh freepages --pagesize <TAB><TAB> 1GiB 2MiB 4KiB Signed-off-by: Lin Ma <lma@suse.de> --- tools/vsh.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/vsh.c b/tools/vsh.c index 0e8edcd78c..8b50e20a5a 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -2780,6 +2780,7 @@ vshReadlineParse(const char *text, int state) } else { if (!opt || (opt->type != VSH_OT_DATA && opt->type != VSH_OT_STRING && + opt->type != VSH_OT_INT && opt->type != VSH_OT_ARGV)) list = vshReadlineOptionsGenerator(text, cmd, partial); -- 2.26.0

Signed-off-by: Lin Ma <lma@suse.de> --- tools/virsh-completer-network.c | 42 +++++++++++++++++++++++++++++++++ tools/virsh-completer-network.h | 4 ++++ tools/virsh-network.c | 2 ++ 3 files changed, 48 insertions(+) diff --git a/tools/virsh-completer-network.c b/tools/virsh-completer-network.c index 8f0048ed6f..22ab4a80c3 100644 --- a/tools/virsh-completer-network.c +++ b/tools/virsh-completer-network.c @@ -137,3 +137,45 @@ virshNetworkPortUUIDCompleter(vshControl *ctl, VIR_FREE(ret); return NULL; } + + +char ** +virshNetworkUUIDCompleter(vshControl *ctl, + const vshCmd *cmd G_GNUC_UNUSED, + unsigned int flags) +{ + virshControlPtr priv = ctl->privData; + virNetworkPtr *nets = NULL; + int nnets = 0; + size_t i = 0; + char **ret = NULL; + VIR_AUTOSTRINGLIST tmp = NULL; + + virCheckFlags(0, NULL); + + if (!priv->conn || virConnectIsAlive(priv->conn) <= 0) + return NULL; + + if ((nnets = virConnectListAllNetworks(priv->conn, &nets, flags)) < 0) + return NULL; + + if (VIR_ALLOC_N(tmp, nnets + 1) < 0) + goto cleanup; + + for (i = 0; i < nnets; i++) { + char uuid[VIR_UUID_STRING_BUFLEN]; + if (virNetworkGetUUIDString(nets[i], uuid) < 0) { + vshError(ctl, "%s", _("Failed to get network's UUID")); + goto cleanup; + } + tmp[i] = g_strdup(uuid); + } + + ret = g_steal_pointer(&tmp); + + cleanup: + for (i = 0; i < nnets; i++) + virNetworkFree(nets[i]); + VIR_FREE(nets); + return ret; +} diff --git a/tools/virsh-completer-network.h b/tools/virsh-completer-network.h index e317e483c1..8910e4525c 100644 --- a/tools/virsh-completer-network.h +++ b/tools/virsh-completer-network.h @@ -33,3 +33,7 @@ char ** virshNetworkEventNameCompleter(vshControl *ctl, char ** virshNetworkPortUUIDCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); + +char ** virshNetworkUUIDCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-network.c b/tools/virsh-network.c index f0f5358625..f488e840ac 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -806,6 +806,8 @@ static const vshCmdOptDef opts_network_name[] = { {.name = "network", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, + .completer = virshNetworkUUIDCompleter, + .completer_flags = 0, .help = N_("network uuid") }, {.name = NULL} -- 2.26.0

On 9/11/20 9:13 AM, Lin Ma wrote:
Signed-off-by: Lin Ma <lma@suse.de> --- tools/virsh-completer-network.c | 42 +++++++++++++++++++++++++++++++++ tools/virsh-completer-network.h | 4 ++++ tools/virsh-network.c | 2 ++ 3 files changed, 48 insertions(+)
diff --git a/tools/virsh-completer-network.c b/tools/virsh-completer-network.c index 8f0048ed6f..22ab4a80c3 100644 --- a/tools/virsh-completer-network.c +++ b/tools/virsh-completer-network.c @@ -137,3 +137,45 @@ virshNetworkPortUUIDCompleter(vshControl *ctl, VIR_FREE(ret); return NULL; } + + +char ** +virshNetworkUUIDCompleter(vshControl *ctl, + const vshCmd *cmd G_GNUC_UNUSED, + unsigned int flags) +{ + virshControlPtr priv = ctl->privData; + virNetworkPtr *nets = NULL; + int nnets = 0; + size_t i = 0; + char **ret = NULL; + VIR_AUTOSTRINGLIST tmp = NULL; + + virCheckFlags(0, NULL); + + if (!priv->conn || virConnectIsAlive(priv->conn) <= 0) + return NULL; + + if ((nnets = virConnectListAllNetworks(priv->conn, &nets, flags)) < 0) + return NULL; + + if (VIR_ALLOC_N(tmp, nnets + 1) < 0) + goto cleanup; + + for (i = 0; i < nnets; i++) { + char uuid[VIR_UUID_STRING_BUFLEN]; + if (virNetworkGetUUIDString(nets[i], uuid) < 0) { + vshError(ctl, "%s", _("Failed to get network's UUID"));
We don't like completers to report any kind of error because that would harm the user experience. For instance it doesn't print the error on an empty line: virsh # net-name --network error: Failed to get ... It's acceptable if completer returns nothing when failing.
+ goto cleanup; + } + tmp[i] = g_strdup(uuid); + } + + ret = g_steal_pointer(&tmp); + + cleanup: + for (i = 0; i < nnets; i++) + virNetworkFree(nets[i]); + VIR_FREE(nets); + return ret; +} diff --git a/tools/virsh-completer-network.h b/tools/virsh-completer-network.h index e317e483c1..8910e4525c 100644 --- a/tools/virsh-completer-network.h +++ b/tools/virsh-completer-network.h @@ -33,3 +33,7 @@ char ** virshNetworkEventNameCompleter(vshControl *ctl, char ** virshNetworkPortUUIDCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); + +char ** virshNetworkUUIDCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-network.c b/tools/virsh-network.c index f0f5358625..f488e840ac 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -806,6 +806,8 @@ static const vshCmdOptDef opts_network_name[] = { {.name = "network", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, + .completer = virshNetworkUUIDCompleter, + .completer_flags = 0,
This is not needed. flags are zero by default.
.help = N_("network uuid") }, {.name = NULL}
I see you used the same pattern for next patches - the same comment applies to them. Michal

Signed-off-by: Lin Ma <lma@suse.de> --- tools/virsh-completer-domain.c | 52 ++++++++++++++++++++++++++++++++++ tools/virsh-completer-domain.h | 4 +++ tools/virsh-domain.c | 8 +++++- 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 122a9d5f66..ae8baa52e3 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -80,6 +80,58 @@ virshDomainNameCompleter(vshControl *ctl, } +char ** +virshDomainUUIDCompleter(vshControl *ctl, + const vshCmd *cmd G_GNUC_UNUSED, + unsigned int flags) +{ + virshControlPtr priv = ctl->privData; + virDomainPtr *domains = NULL; + int ndomains = 0; + size_t i = 0; + char **ret = NULL; + VIR_AUTOSTRINGLIST tmp = NULL; + + virCheckFlags(VIR_CONNECT_LIST_DOMAINS_ACTIVE | + VIR_CONNECT_LIST_DOMAINS_INACTIVE | + VIR_CONNECT_LIST_DOMAINS_OTHER | + VIR_CONNECT_LIST_DOMAINS_PAUSED | + VIR_CONNECT_LIST_DOMAINS_PERSISTENT | + VIR_CONNECT_LIST_DOMAINS_RUNNING | + VIR_CONNECT_LIST_DOMAINS_SHUTOFF | + VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE | + VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT | + VIR_CONNECT_LIST_DOMAINS_HAS_CHECKPOINT, + NULL); + + if (!priv->conn || virConnectIsAlive(priv->conn) <= 0) + return NULL; + + if ((ndomains = virConnectListAllDomains(priv->conn, &domains, flags)) < 0) + return NULL; + + if (VIR_ALLOC_N(tmp, ndomains + 1) < 0) + goto cleanup; + + for (i = 0; i < ndomains; i++) { + char uuid[VIR_UUID_STRING_BUFLEN]; + if (virDomainGetUUIDString(domains[i], uuid) < 0) { + vshError(ctl, "%s", _("Failed to get domain's UUID")); + goto cleanup; + } + tmp[i] = g_strdup(uuid); + } + + ret = g_steal_pointer(&tmp); + + cleanup: + for (i = 0; i < ndomains; i++) + virshDomainFree(domains[i]); + VIR_FREE(domains); + return ret; +} + + char ** virshDomainInterfaceCompleter(vshControl *ctl, const vshCmd *cmd, diff --git a/tools/virsh-completer-domain.h b/tools/virsh-completer-domain.h index e3375c3c65..9a8b962cb7 100644 --- a/tools/virsh-completer-domain.h +++ b/tools/virsh-completer-domain.h @@ -70,3 +70,7 @@ char ** virshDomainPerfEnableCompleter(vshControl *ctl, char ** virshDomainPerfDisableCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); + +char ** virshDomainUUIDCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 1ba536466a..c07c8c3527 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -10370,7 +10370,13 @@ static const vshCmdInfo info_domname[] = { }; static const vshCmdOptDef opts_domname[] = { - VIRSH_COMMON_OPT_DOMAIN(N_("domain id or uuid"), 0), + {.name = "domain", + .type = VSH_OT_DATA, + .flags = VSH_OFLAG_REQ, + .completer = virshDomainUUIDCompleter, + .completer_flags = 0, + .help = N_("domain id or uuid") + }, {.name = NULL} }; -- 2.26.0

Signed-off-by: Lin Ma <lma@suse.de> --- tools/virsh-completer-domain.c | 37 ++++++++++++++++++++++++++++++++++ tools/virsh-completer-domain.h | 4 ++++ tools/virsh-domain.c | 6 ++++++ 3 files changed, 47 insertions(+) diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index ae8baa52e3..56f014ae40 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -439,3 +439,40 @@ virshDomainPerfDisableCompleter(vshControl *ctl, return virshCommaStringListComplete(event, (const char **)events); } + + +char ** +virshDomainIOThreadIdCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags) +{ + virDomainPtr dom; + size_t niothreads = 0; + g_autofree virDomainIOThreadInfoPtr *info = NULL; + size_t i; + int rc; + char **ret = NULL; + VIR_AUTOSTRINGLIST tmp = NULL; + + virCheckFlags(0, NULL); + + if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) + return NULL; + + if ((rc = virDomainGetIOThreadInfo(dom, &info, flags)) < 0) + goto cleanup; + + niothreads = rc; + + if (VIR_ALLOC_N(tmp, niothreads + 1) < 0) + goto cleanup; + + for (i = 0; i < niothreads; i++) + tmp[i] = g_strdup_printf("%u", info[i]->iothread_id); + + ret = g_steal_pointer(&tmp); + + cleanup: + virshDomainFree(dom); + return ret; +} diff --git a/tools/virsh-completer-domain.h b/tools/virsh-completer-domain.h index 9a8b962cb7..91731da778 100644 --- a/tools/virsh-completer-domain.h +++ b/tools/virsh-completer-domain.h @@ -74,3 +74,7 @@ char ** virshDomainPerfDisableCompleter(vshControl *ctl, char ** virshDomainUUIDCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); + +char ** virshDomainIOThreadIdCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index c07c8c3527..5222bbb566 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -7749,6 +7749,8 @@ static const vshCmdOptDef opts_iothreadpin[] = { {.name = "iothread", .type = VSH_OT_INT, .flags = VSH_OFLAG_REQ, + .completer = virshDomainIOThreadIdCompleter, + .completer_flags = 0, .help = N_("IOThread ID number") }, {.name = "cpulist", @@ -7897,6 +7899,8 @@ static const vshCmdOptDef opts_iothreadset[] = { {.name = "id", .type = VSH_OT_INT, .flags = VSH_OFLAG_REQ, + .completer = virshDomainIOThreadIdCompleter, + .completer_flags = 0, .help = N_("iothread id of existing IOThread") }, {.name = "poll-max-ns", @@ -8000,6 +8004,8 @@ static const vshCmdOptDef opts_iothreaddel[] = { {.name = "id", .type = VSH_OT_INT, .flags = VSH_OFLAG_REQ, + .completer = virshDomainIOThreadIdCompleter, + .completer_flags = 0, .help = N_("iothread_id for the IOThread to delete") }, VIRSH_COMMON_OPT_DOMAIN_CONFIG, -- 2.26.0

Signed-off-by: Lin Ma <lma@suse.de> --- tools/virsh-domain.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 5222bbb566..6f8424ec14 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -243,6 +243,8 @@ static const vshCmdOptDef opts_attach_disk[] = { }, {.name = "iothread", .type = VSH_OT_STRING, + .completer = virshDomainIOThreadIdCompleter, + .completer_flags = 0, .help = N_("IOThread to be used by supported device") }, {.name = "cache", -- 2.26.0

Signed-off-by: Lin Ma <lma@suse.de> --- tools/virsh-completer-domain.c | 42 ++++++++++++++++++++++++++++++++++ tools/virsh-completer-domain.h | 5 ++++ tools/virsh-domain.c | 2 ++ 3 files changed, 49 insertions(+) diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 56f014ae40..9b22db2119 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -476,3 +476,45 @@ virshDomainIOThreadIdCompleter(vshControl *ctl, virshDomainFree(dom); return ret; } + + +char ** +virshDomainVcpuCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags) +{ + virDomainPtr dom; + xmlDocPtr xml = NULL; + xmlXPathContextPtr ctxt = NULL; + int nvcpus = 0; + unsigned int id; + char **ret = NULL; + VIR_AUTOSTRINGLIST tmp = NULL; + + virCheckFlags(0, NULL); + + if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) + return NULL; + + if (virshDomainGetXMLFromDom(ctl, dom, VIR_DOMAIN_XML_INACTIVE, + &xml, &ctxt) < 0) + goto cleanup; + + /* Query the max rather than the current vcpu count */ + if (virXPathInt("string(/domain/vcpu)", ctxt, &nvcpus) < 0) + goto cleanup; + + if (VIR_ALLOC_N(tmp, nvcpus + 1) < 0) + goto cleanup; + + for (id = 0; id < nvcpus; id++) + tmp[id] = g_strdup_printf("%u", id); + + ret = g_steal_pointer(&tmp); + + cleanup: + xmlXPathFreeContext(ctxt); + xmlFreeDoc(xml); + virshDomainFree(dom); + return ret; +} diff --git a/tools/virsh-completer-domain.h b/tools/virsh-completer-domain.h index 91731da778..7c3b4c3cc0 100644 --- a/tools/virsh-completer-domain.h +++ b/tools/virsh-completer-domain.h @@ -78,3 +78,8 @@ char ** virshDomainUUIDCompleter(vshControl *ctl, char ** virshDomainIOThreadIdCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); + +char ** +virshDomainVcpuCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 6f8424ec14..7dd566b573 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -7004,6 +7004,8 @@ static const vshCmdOptDef opts_vcpupin[] = { VIRSH_COMMON_OPT_DOMAIN_FULL(0), {.name = "vcpu", .type = VSH_OT_INT, + .completer = virshDomainVcpuCompleter, + .completer_flags = 0, .help = N_("vcpu number") }, {.name = "cpulist", -- 2.26.0

Signed-off-by: Lin Ma <lma@suse.de> --- tools/virsh-completer-domain.c | 46 ++++++++++++++++++++++++++++++++++ tools/virsh-completer-domain.h | 5 ++++ tools/virsh-domain.c | 2 ++ 3 files changed, 53 insertions(+) diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 9b22db2119..218f10e5ba 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -518,3 +518,49 @@ virshDomainVcpuCompleter(vshControl *ctl, virshDomainFree(dom); return ret; } + + +char ** +virshDomainVcpulistCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags) +{ + virDomainPtr dom; + xmlDocPtr xml = NULL; + xmlXPathContextPtr ctxt = NULL; + int nvcpus = 0; + unsigned int id; + VIR_AUTOSTRINGLIST vcpulist = NULL; + const char *vcpuid = NULL; + char **ret = NULL; + + virCheckFlags(0, NULL); + + if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) + return NULL; + + if (virshDomainGetXMLFromDom(ctl, dom, VIR_DOMAIN_XML_INACTIVE, + &xml, &ctxt) < 0) + goto cleanup; + + /* Query the max rather than the current vcpu count */ + if (virXPathInt("string(/domain/vcpu)", ctxt, &nvcpus) < 0) + goto cleanup; + + if (VIR_ALLOC_N(vcpulist, nvcpus + 1) < 0) + goto cleanup; + + for (id = 0; id < nvcpus; id++) + vcpulist[id] = g_strdup_printf("%u", id); + + if (vshCommandOptStringQuiet(ctl, cmd, "vcpulist", &vcpuid) < 0) + goto cleanup; + + ret = virshCommaStringListComplete(vcpuid, (const char **)vcpulist); + + cleanup: + xmlXPathFreeContext(ctxt); + xmlFreeDoc(xml); + virshDomainFree(dom); + return ret; +} diff --git a/tools/virsh-completer-domain.h b/tools/virsh-completer-domain.h index 7c3b4c3cc0..84219ab088 100644 --- a/tools/virsh-completer-domain.h +++ b/tools/virsh-completer-domain.h @@ -83,3 +83,8 @@ char ** virshDomainVcpuCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); + +char ** +virshDomainVcpulistCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 7dd566b573..c3ac28cab0 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -7525,6 +7525,8 @@ static const vshCmdOptDef opts_setvcpu[] = { {.name = "vcpulist", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, + .completer = virshDomainVcpulistCompleter, + .completer_flags = 0, .help = N_("ids of vcpus to manipulate") }, {.name = "enable", -- 2.26.0

Currently this patch works for the commands emulatorpin, iothreadpin and vcpupin. Signed-off-by: Lin Ma <lma@suse.de> --- tools/virsh-completer-domain.c | 33 +++++++++++++++++++++++++++++++++ tools/virsh-completer-domain.h | 5 +++++ tools/virsh-domain.c | 3 +++ 3 files changed, 41 insertions(+) diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 218f10e5ba..e02c3b0c31 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -564,3 +564,36 @@ virshDomainVcpulistCompleter(vshControl *ctl, virshDomainFree(dom); return ret; } + + +char ** +virshDomainCpulistCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags G_GNUC_UNUSED) +{ + int i, cpunum; + unsigned char *cpumap = NULL; + unsigned int online; + VIR_AUTOSTRINGLIST cpulist = NULL; + const char *cpuid = NULL; + char **ret = NULL; + virshControlPtr priv = ctl->privData; + + if ((cpunum = virNodeGetCPUMap(priv->conn, &cpumap, &online, 0)) < 0) + goto cleanup; + + if (VIR_ALLOC_N(cpulist, cpunum + 1) < 0) + goto cleanup; + + for (i = 0; i < cpunum; i++) + cpulist[i] = g_strdup_printf("%u", i); + + if (vshCommandOptStringQuiet(ctl, cmd, "cpulist", &cpuid) < 0) + goto cleanup; + + ret = virshCommaStringListComplete(cpuid, (const char **)cpulist); + + cleanup: + VIR_FREE(cpumap); + return ret; +} diff --git a/tools/virsh-completer-domain.h b/tools/virsh-completer-domain.h index 84219ab088..a5477c4ae5 100644 --- a/tools/virsh-completer-domain.h +++ b/tools/virsh-completer-domain.h @@ -88,3 +88,8 @@ char ** virshDomainVcpulistCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); + +char ** +virshDomainCpulistCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index c3ac28cab0..6b2787b8d5 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -7011,6 +7011,7 @@ static const vshCmdOptDef opts_vcpupin[] = { {.name = "cpulist", .type = VSH_OT_STRING, .flags = VSH_OFLAG_EMPTY_OK, + .completer = virshDomainCpulistCompleter, .help = N_("host cpu number(s) to set, or omit option to query") }, VIRSH_COMMON_OPT_DOMAIN_CONFIG, @@ -7238,6 +7239,7 @@ static const vshCmdOptDef opts_emulatorpin[] = { {.name = "cpulist", .type = VSH_OT_STRING, .flags = VSH_OFLAG_EMPTY_OK, + .completer = virshDomainCpulistCompleter, .help = N_("host cpu number(s) to set, or omit option to query") }, VIRSH_COMMON_OPT_DOMAIN_CONFIG, @@ -7762,6 +7764,7 @@ static const vshCmdOptDef opts_iothreadpin[] = { {.name = "cpulist", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, + .completer = virshDomainCpulistCompleter, .help = N_("host cpu number(s) to set") }, VIRSH_COMMON_OPT_DOMAIN_CONFIG, -- 2.26.0

Signed-off-by: Lin Ma <lma@suse.de> --- tools/virsh-network.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virsh-network.c b/tools/virsh-network.c index f488e840ac..592b08528b 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -1373,7 +1373,7 @@ static const vshCmdInfo info_network_dhcp_leases[] = { }; static const vshCmdOptDef opts_network_dhcp_leases[] = { - VIRSH_COMMON_OPT_NETWORK_FULL(0), + VIRSH_COMMON_OPT_NETWORK_FULL(VIR_CONNECT_LIST_NETWORKS_ACTIVE), {.name = "mac", .type = VSH_OT_STRING, .flags = VSH_OFLAG_NONE, -- 2.26.0

Signed-off-by: Lin Ma <lma@suse.de> --- tools/virsh-network.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 592b08528b..b131851a0d 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -1486,7 +1486,7 @@ static const vshCmdInfo info_network_port_create[] = { }; static const vshCmdOptDef opts_network_port_create[] = { - VIRSH_COMMON_OPT_NETWORK_FULL(0), + VIRSH_COMMON_OPT_NETWORK_FULL(VIR_CONNECT_LIST_NETWORKS_ACTIVE), VIRSH_COMMON_OPT_FILE(N_("file containing an XML network port description")), {.name = NULL} }; @@ -1546,7 +1546,7 @@ static const vshCmdInfo info_network_port_dumpxml[] = { }; static const vshCmdOptDef opts_network_port_dumpxml[] = { - VIRSH_COMMON_OPT_NETWORK_FULL(0), + VIRSH_COMMON_OPT_NETWORK_FULL(VIR_CONNECT_LIST_NETWORKS_ACTIVE), VIRSH_COMMON_OPT_NETWORK_PORT(0), {.name = NULL} }; @@ -1598,7 +1598,7 @@ static const vshCmdInfo info_network_port_delete[] = { }; static const vshCmdOptDef opts_network_port_delete[] = { - VIRSH_COMMON_OPT_NETWORK_FULL(0), + VIRSH_COMMON_OPT_NETWORK_FULL(VIR_CONNECT_LIST_NETWORKS_ACTIVE), VIRSH_COMMON_OPT_NETWORK_PORT(0), {.name = NULL} }; @@ -1733,7 +1733,7 @@ static const vshCmdInfo info_network_port_list[] = { }; static const vshCmdOptDef opts_network_port_list[] = { - VIRSH_COMMON_OPT_NETWORK_FULL(0), + VIRSH_COMMON_OPT_NETWORK_FULL(VIR_CONNECT_LIST_NETWORKS_ACTIVE), {.name = "uuid", .type = VSH_OT_BOOL, .help = N_("list uuid's only") -- 2.26.0

Signed-off-by: Lin Ma <lma@suse.de> --- tools/virsh-backup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/virsh-backup.c b/tools/virsh-backup.c index 04464c6bff..9125b7da97 100644 --- a/tools/virsh-backup.c +++ b/tools/virsh-backup.c @@ -36,7 +36,7 @@ static const vshCmdInfo info_backup_begin[] = { }; static const vshCmdOptDef opts_backup_begin[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), {.name = "backupxml", .type = VSH_OT_STRING, .help = N_("domain backup XML"), @@ -112,7 +112,7 @@ static const vshCmdInfo info_backup_dumpxml[] = { }; static const vshCmdOptDef opts_backup_dumpxml[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), {.name = NULL} }; -- 2.26.0

Signed-off-by: Lin Ma <lma@suse.de> --- tools/virsh-checkpoint.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/virsh-checkpoint.c b/tools/virsh-checkpoint.c index c4ff863802..33e70515ad 100644 --- a/tools/virsh-checkpoint.c +++ b/tools/virsh-checkpoint.c @@ -90,7 +90,7 @@ static const vshCmdInfo info_checkpoint_create[] = { }; static const vshCmdOptDef opts_checkpoint_create[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), {.name = "xmlfile", .type = VSH_OT_STRING, .help = N_("domain checkpoint XML") @@ -201,7 +201,7 @@ static const vshCmdInfo info_checkpoint_create_as[] = { }; static const vshCmdOptDef opts_checkpoint_create_as[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), {.name = "name", .type = VSH_OT_STRING, .help = N_("name of checkpoint") @@ -1015,7 +1015,8 @@ static const vshCmdInfo info_checkpoint_delete[] = { }; static const vshCmdOptDef opts_checkpoint_delete[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_HAS_CHECKPOINT), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_HAS_CHECKPOINT | + VIR_CONNECT_LIST_DOMAINS_ACTIVE), {.name = "checkpointname", .type = VSH_OT_STRING, .help = N_("checkpoint name"), -- 2.26.0

On 9/11/20 9:13 AM, Lin Ma wrote:
Lin Ma (17): virshDomainNameCompleter: Add some of VIR_CONNECT_LIST_DOMAINS_ flags virsh: snapshot: Only return domains that have snapshot images virsh: managedsave-*: Only return domains that have a managed save image virsh: checkpoint: Only return domains that have checkpoints virsh: Add event completer to --enable/--disable args of perf command vshReadlineParse: Ignore vshReadlineOptionsGenerator for VSH_OT_INT options virsh: Add network uuid completion to network-name command virsh: Add domain uuid completion to domname command virsh: Add iothread IDs completion to iothread* commands virsh: Add completion for --iothread argument of attach-disk command virsh: Add vcpu IDs completion to vcpupin command virsh: Add vcpu list completion to setvcpu command virsh: Add logical CPU list completion for --cpulist argument virsh: limit completion of net-dhcp-leases to active networks virsh: limit completion of net-port* to active networks virsh: limit completion of backup-{begin, dumpxml} to active domains virsh: limit completion of checkpoint-{create, delete} to active domains
tools/virsh-backup.c | 4 +- tools/virsh-checkpoint.c | 17 +- tools/virsh-completer-domain.c | 264 +++++++++++++++++++++++++++++++- tools/virsh-completer-domain.h | 31 ++++ tools/virsh-completer-network.c | 42 +++++ tools/virsh-completer-network.h | 4 + tools/virsh-domain.c | 33 +++- tools/virsh-network.c | 12 +- tools/virsh-snapshot.c | 16 +- tools/vsh.c | 1 + 10 files changed, 395 insertions(+), 29 deletions(-)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal
participants (2)
-
Lin Ma
-
Michal Privoznik