[libvirt] [PATCH 0/9] Some virsh completion fixes

patch 1 is not about completion, I merge it into this patch set for easy review because it's a tiny fix. Lin Ma (9): virsh: Remove 'id' text from help message for 'domrename' command virsh: Only return active domain names for 'reset' command virsh: Only return active domain names for block* command virsh-network: Create macros for VSH_OT_STRING "network" option virsh-network: Add network name completion to 'net-event' command virsh-network: Add macro VIRSH_COMMON_OPT_NETWORK_FULL virsh-network: Add network name completion to 'net-uuid' command virsh: Introduce virshDomainBlockTargetCompleter virsh: Add target name completion for block device options tools/virsh-completer.c | 48 ++++++++++++++++++++++++++++++++++++++++++++ tools/virsh-completer.h | 4 ++++ tools/virsh-domain-monitor.c | 2 ++ tools/virsh-domain.c | 23 ++++++++++++++------- tools/virsh-network.c | 47 +++++++++++++++++++++++++------------------ 5 files changed, 97 insertions(+), 27 deletions(-) -- 2.16.2

The inactive domains don't have any ID identifier, So adjust the help message. Signed-off-by: Lin Ma <lma@suse.com> --- tools/virsh-domain.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 30da953446..cfeb3484e2 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -10251,7 +10251,8 @@ static const vshCmdInfo info_domrename[] = { }; static const vshCmdOptDef opts_domrename[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_INACTIVE), + VIRSH_COMMON_OPT_DOMAIN(N_("domain name or uuid"), + VIR_CONNECT_LIST_DOMAINS_INACTIVE), {.name = "new-name", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, -- 2.16.2

Signed-off-by: Lin Ma <lma@suse.com> --- tools/virsh-domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index cfeb3484e2..724871d648 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -5892,7 +5892,7 @@ static const vshCmdInfo info_reset[] = { }; static const vshCmdOptDef opts_reset[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), {.name = NULL} }; -- 2.16.2

Signed-off-by: Lin Ma <lma@suse.com> --- tools/virsh-domain.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 724871d648..bc44131fa2 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -1882,7 +1882,7 @@ static const vshCmdInfo info_blockcommit[] = { }; static const vshCmdOptDef opts_blockcommit[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), {.name = "path", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -2107,7 +2107,7 @@ static const vshCmdInfo info_blockcopy[] = { }; static const vshCmdOptDef opts_blockcopy[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), {.name = "path", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -2423,7 +2423,7 @@ static const vshCmdInfo info_blockjob[] = { }; static const vshCmdOptDef opts_blockjob[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), {.name = "path", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -2666,7 +2666,7 @@ static const vshCmdInfo info_blockpull[] = { }; static const vshCmdOptDef opts_blockpull[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), {.name = "path", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -2812,7 +2812,7 @@ static const vshCmdInfo info_blockresize[] = { }; static const vshCmdOptDef opts_blockresize[] = { - VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), {.name = "path", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, -- 2.16.2

Signed-off-by: Lin Ma <lma@suse.com> --- tools/virsh-network.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 3f0923bf0e..7a8bcb1beb 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -43,6 +43,17 @@ .completer_flags = cflags, \ } +#define VIRSH_COMMON_OPT_NETWORK_OT_STRING(_helpstr, cflags) \ + {.name = "network", \ + .type = VSH_OT_STRING, \ + .help = _helpstr, \ + .completer = virshNetworkNameCompleter, \ + .completer_flags = cflags, \ + } + +#define VIRSH_COMMON_OPT_NETWORK_OT_STRING_FULL(cflags) \ + VIRSH_COMMON_OPT_NETWORK_OT_STRING(N_("network name or uuid"), cflags) + virNetworkPtr virshCommandOptNetworkBy(vshControl *ctl, const vshCmd *cmd, const char **name, unsigned int flags) -- 2.16.2

On 05/15/2018 01:10 PM, Lin Ma wrote:
patch 1 is not about completion, I merge it into this patch set for easy review because it's a tiny fix.
Lin Ma (9): virsh: Remove 'id' text from help message for 'domrename' command virsh: Only return active domain names for 'reset' command virsh: Only return active domain names for block* command virsh-network: Create macros for VSH_OT_STRING "network" option virsh-network: Add network name completion to 'net-event' command virsh-network: Add macro VIRSH_COMMON_OPT_NETWORK_FULL virsh-network: Add network name completion to 'net-uuid' command virsh: Introduce virshDomainBlockTargetCompleter virsh: Add target name completion for block device options
tools/virsh-completer.c | 48 ++++++++++++++++++++++++++++++++++++++++++++ tools/virsh-completer.h | 4 ++++ tools/virsh-domain-monitor.c | 2 ++ tools/virsh-domain.c | 23 ++++++++++++++------- tools/virsh-network.c | 47 +++++++++++++++++++++++++------------------ 5 files changed, 97 insertions(+), 27 deletions(-)
Not quite sure how you sent the patches but they are broken in two separate threads. Anyway, ACK to all of them. I've renamed the function from 8/9 and adjusted 9/9 accordingly. Thanks. Also thanks for proving how easy it is to write new completers. Hopefully we can get more of them. Michal
participants (2)
-
Lin Ma
-
Michal Privoznik