* Re: [Qemu-devel] [PATCH 2/7] monitor: Convert help|? to use command_completion. [not found] ` <1398614409-30792-3-git-send-email-kroosec@gmail.com> @ 2014-05-05 19:51 ` Luiz Capitulino 2014-05-07 21:42 ` Hani Benhabiles 0 siblings, 1 reply; 7+ messages in thread From: Luiz Capitulino @ 2014-05-05 19:51 UTC (permalink / raw) To: Hani Benhabiles; +Cc: qemu-devel, stefanha On Sun, 27 Apr 2014 17:00:03 +0100 Hani Benhabiles <kroosec@gmail.com> wrote: > Signed-off-by: Hani Benhabiles <hani@linux.com> > --- > hmp-commands.hx | 1 + > hmp.h | 1 + > monitor.c | 24 +++++++++++++++++------- > 3 files changed, 19 insertions(+), 7 deletions(-) > > diff --git a/hmp-commands.hx b/hmp-commands.hx > index b3f45d6..ba13997 100644 > --- a/hmp-commands.hx > +++ b/hmp-commands.hx > @@ -15,6 +15,7 @@ ETEXI > .params = "[cmd]", > .help = "show the help", > .mhandler.cmd = do_help_cmd, > + .command_completion = help_completion, > }, > > STEXI > diff --git a/hmp.h b/hmp.h > index 12e21e7..55f78fa 100644 > --- a/hmp.h > +++ b/hmp.h > @@ -98,5 +98,6 @@ void object_del_completion(ReadLineState *rs, int nb_args, const char *str); > void device_add_completion(ReadLineState *rs, int nb_args, const char *str); > void device_del_completion(ReadLineState *rs, int nb_args, const char *str); > void sendkey_completion(ReadLineState *rs, int nb_args, const char *str); > +void help_completion(ReadLineState *rs, int nb_args, const char *str); > > #endif > diff --git a/monitor.c b/monitor.c > index 7edfcee..acbbaf8 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -4407,6 +4407,23 @@ void sendkey_completion(ReadLineState *rs, int nb_args, const char *str) > } > } > > +void help_completion(ReadLineState *rs, int nb_args, const char *str) > +{ > + int i; > + size_t len; > + > + if (nb_args != 2) { > + return; > + } > + len = strlen(str); > + readline_set_completion_index(rs, len); > + for (i = 0; mon_cmds[i].name; i++) { > + if (!strncmp(str, mon_cmds[i].name, len)) { > + readline_add_completion(rs, mon_cmds[i].name); > + } > + } > +} > + > static void monitor_find_completion_by_table(Monitor *mon, > const mon_cmd_t *cmd_table, > char **args, > @@ -4473,13 +4490,6 @@ static void monitor_find_completion_by_table(Monitor *mon, > readline_set_completion_index(mon->rs, strlen(str)); > bdrv_iterate(block_completion_it, &mbs); > break; > - case 's': > - case 'S': > - if (!strcmp(cmd->name, "help|?")) { > - monitor_find_completion_by_table(mon, cmd_table, > - &args[1], nb_args - 1); > - } > - break; > default: > break; > } This breaks auto-completion for: (qemu) help info v Which would auto-complete "vnc". IIRC, that's one of the reasons we have monitor_find_completion_by_table(). ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 2/7] monitor: Convert help|? to use command_completion. 2014-05-05 19:51 ` [Qemu-devel] [PATCH 2/7] monitor: Convert help|? to use command_completion Luiz Capitulino @ 2014-05-07 21:42 ` Hani Benhabiles 0 siblings, 0 replies; 7+ messages in thread From: Hani Benhabiles @ 2014-05-07 21:42 UTC (permalink / raw) To: Luiz Capitulino; +Cc: qemu-devel, stefanha On Mon, May 05, 2014 at 03:51:37PM -0400, Luiz Capitulino wrote: > On Sun, 27 Apr 2014 17:00:03 +0100 > Hani Benhabiles <kroosec@gmail.com> wrote: > > > Signed-off-by: Hani Benhabiles <hani@linux.com> > > --- > > hmp-commands.hx | 1 + > > hmp.h | 1 + > > monitor.c | 24 +++++++++++++++++------- > > 3 files changed, 19 insertions(+), 7 deletions(-) > > > > diff --git a/hmp-commands.hx b/hmp-commands.hx > > index b3f45d6..ba13997 100644 > > --- a/hmp-commands.hx > > +++ b/hmp-commands.hx > > @@ -15,6 +15,7 @@ ETEXI > > .params = "[cmd]", > > .help = "show the help", > > .mhandler.cmd = do_help_cmd, > > + .command_completion = help_completion, > > }, > > > > STEXI > > diff --git a/hmp.h b/hmp.h > > index 12e21e7..55f78fa 100644 > > --- a/hmp.h > > +++ b/hmp.h > > @@ -98,5 +98,6 @@ void object_del_completion(ReadLineState *rs, int nb_args, const char *str); > > void device_add_completion(ReadLineState *rs, int nb_args, const char *str); > > void device_del_completion(ReadLineState *rs, int nb_args, const char *str); > > void sendkey_completion(ReadLineState *rs, int nb_args, const char *str); > > +void help_completion(ReadLineState *rs, int nb_args, const char *str); > > > > #endif > > diff --git a/monitor.c b/monitor.c > > index 7edfcee..acbbaf8 100644 > > --- a/monitor.c > > +++ b/monitor.c > > @@ -4407,6 +4407,23 @@ void sendkey_completion(ReadLineState *rs, int nb_args, const char *str) > > } > > } > > > > +void help_completion(ReadLineState *rs, int nb_args, const char *str) > > +{ > > + int i; > > + size_t len; > > + > > + if (nb_args != 2) { > > + return; > > + } > > + len = strlen(str); > > + readline_set_completion_index(rs, len); > > + for (i = 0; mon_cmds[i].name; i++) { > > + if (!strncmp(str, mon_cmds[i].name, len)) { > > + readline_add_completion(rs, mon_cmds[i].name); > > + } > > + } > > +} > > + > > static void monitor_find_completion_by_table(Monitor *mon, > > const mon_cmd_t *cmd_table, > > char **args, > > @@ -4473,13 +4490,6 @@ static void monitor_find_completion_by_table(Monitor *mon, > > readline_set_completion_index(mon->rs, strlen(str)); > > bdrv_iterate(block_completion_it, &mbs); > > break; > > - case 's': > > - case 'S': > > - if (!strcmp(cmd->name, "help|?")) { > > - monitor_find_completion_by_table(mon, cmd_table, > > - &args[1], nb_args - 1); > > - } > > - break; > > default: > > break; > > } > > This breaks auto-completion for: > > (qemu) help info v > > Which would auto-complete "vnc". IIRC, that's one of the reasons we have > monitor_find_completion_by_table(). Thanks for spotting that. Quickly thinking about it, a possible way to solve this is to change command_completion() prototype to be passed the whole args table, and not just a string and then have those "special cases" (like help+info) handled. Better drop patch 02/07 and leave the rest as is for now, I believe. I will send a v2. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 0/7] Miscellaneous command completion patches [not found] <1398614409-30792-1-git-send-email-kroosec@gmail.com> [not found] ` <1398614409-30792-3-git-send-email-kroosec@gmail.com> @ 2014-05-05 19:54 ` Luiz Capitulino [not found] ` <1398614409-30792-6-git-send-email-kroosec@gmail.com> ` (2 subsequent siblings) 4 siblings, 0 replies; 7+ messages in thread From: Luiz Capitulino @ 2014-05-05 19:54 UTC (permalink / raw) To: Hani Benhabiles; +Cc: Markus Armbruster, qemu-devel, stefanha, kraxel On Sun, 27 Apr 2014 17:00:01 +0100 Hani Benhabiles <kroosec@gmail.com> wrote: > Compared to the larger series sent before: > * Patches 01-03 are already in qmp branch. > * Added patches to convert sendkey, help/? to use new completion callback. > * Dropped patch 06 (cpu index completion) as deemed not useful enough. > * netdev_add now uses the same values array as qapi instead of hardcoding them. > * Left patches 10-17 for a separate series to make review process faster. > * wrt. to Luiz' question about set_link patch: It prints both backend and > frontend values because both are accepted by set_link command. > > Hani Benhabiles (7): > monitor: Convert sendkey to use command_completion. > monitor: Convert help|? to use command_completion. > monitor: Add chardev-remove command completion. > monitor: Add chardev-add backend argument completion. > monitor: Add set_link arguments completion. > monitor: Add netdev_add type argument completion. > monitor: Add netdev_del id argument completion. The first patch looks good. The second one has a problem. For the other patches it would help me to get Reviewed-bys by the following people: o Gerd: patch 03/07 and patch 04/07 o Stefan: patches 05/07, 06/07 and 07/07 ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <1398614409-30792-6-git-send-email-kroosec@gmail.com>]
* Re: [Qemu-devel] [PATCH 5/7] monitor: Add set_link arguments completion. [not found] ` <1398614409-30792-6-git-send-email-kroosec@gmail.com> @ 2014-05-07 9:18 ` Stefan Hajnoczi 0 siblings, 0 replies; 7+ messages in thread From: Stefan Hajnoczi @ 2014-05-07 9:18 UTC (permalink / raw) To: Hani Benhabiles; +Cc: qemu-devel, stefanha, lcapitulino On Sun, Apr 27, 2014 at 05:00:06PM +0100, Hani Benhabiles wrote: > Make it possible to query all net clients without specifying an ID when calling > qemu_find_net_clients_except(). > > This also adds the add_completion_option() function which is to be used for > other commands completions as well. > > Signed-off-by: Hani Benhabiles <hani@linux.com> > --- > hmp-commands.hx | 1 + > hmp.h | 1 + > monitor.c | 34 ++++++++++++++++++++++++++++++++++ > net/net.c | 2 +- > 4 files changed, 37 insertions(+), 1 deletion(-) Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <1398614409-30792-7-git-send-email-kroosec@gmail.com>]
* Re: [Qemu-devel] [PATCH 6/7] monitor: Add netdev_add type argument completion. [not found] ` <1398614409-30792-7-git-send-email-kroosec@gmail.com> @ 2014-05-07 9:21 ` Stefan Hajnoczi 0 siblings, 0 replies; 7+ messages in thread From: Stefan Hajnoczi @ 2014-05-07 9:21 UTC (permalink / raw) To: Hani Benhabiles; +Cc: qemu-devel, stefanha, lcapitulino On Sun, Apr 27, 2014 at 05:00:07PM +0100, Hani Benhabiles wrote: > Also update the command's documentation. > > Signed-off-by: Hani Benhabiles <hani@linux.com> > --- > hmp-commands.hx | 3 ++- > hmp.h | 1 + > monitor.c | 15 +++++++++++++++ > 3 files changed, 18 insertions(+), 1 deletion(-) Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <1398614409-30792-8-git-send-email-kroosec@gmail.com>]
* Re: [Qemu-devel] [PATCH 7/7] monitor: Add netdev_del id argument completion. [not found] ` <1398614409-30792-8-git-send-email-kroosec@gmail.com> @ 2014-05-07 9:22 ` Stefan Hajnoczi 0 siblings, 0 replies; 7+ messages in thread From: Stefan Hajnoczi @ 2014-05-07 9:22 UTC (permalink / raw) To: Hani Benhabiles; +Cc: qemu-devel, stefanha, lcapitulino On Sun, Apr 27, 2014 at 05:00:08PM +0100, Hani Benhabiles wrote: > Signed-off-by: Hani Benhabiles <hani@linux.com> > --- > hmp-commands.hx | 1 + > hmp.h | 1 + > monitor.c | 26 ++++++++++++++++++++++++++ > 3 files changed, 28 insertions(+) Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 0/7] monitor: Completion support for various commands. @ 2014-03-09 11:16 Hani Benhabiles 2014-03-09 11:16 ` [Qemu-devel] [PATCH 7/7] monitor: Add netdev_del id argument completion Hani Benhabiles 0 siblings, 1 reply; 7+ messages in thread From: Hani Benhabiles @ 2014-03-09 11:16 UTC (permalink / raw) To: qemu-devel; +Cc: kwolf, imammedo, stefanha, lcapitulino This patch series adds a new callback to mon_cmd_t which will make adding completion support for more commands cleaner. It then adds full or partial arguments completion for 7 different hmp commands. Hani Benhabiles (7): monitor: Add command_completion callback to mon_cmd_t. monitor: Add chardev-remove id argument completion. monitor: Add chardev-add backend argument completion. monitor: Add cpu index argument completion. monitor: Add set_link arguments completion. monitor: Add netdev_add type argument completion. monitor: Add netdev_del id argument completion. hmp-commands.hx | 14 +++- hmp.h | 11 +++ monitor.c | 213 +++++++++++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 211 insertions(+), 27 deletions(-) -- 1.8.3.2 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 7/7] monitor: Add netdev_del id argument completion. 2014-03-09 11:16 [Qemu-devel] [PATCH 0/7] monitor: Completion support for various commands Hani Benhabiles @ 2014-03-09 11:16 ` Hani Benhabiles 0 siblings, 0 replies; 7+ messages in thread From: Hani Benhabiles @ 2014-03-09 11:16 UTC (permalink / raw) To: qemu-devel; +Cc: kwolf, imammedo, stefanha, lcapitulino Signed-off-by: Hani Benhabiles <hani@linux.com> --- hmp-commands.hx | 1 + hmp.h | 1 + monitor.c | 15 +++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index b009561..d252ffc 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1244,6 +1244,7 @@ ETEXI .params = "id", .help = "remove host network device", .mhandler.cmd = hmp_netdev_del, + .command_completion = netdev_del_completion, }, STEXI diff --git a/hmp.h b/hmp.h index cda0943..ef0fcd3 100644 --- a/hmp.h +++ b/hmp.h @@ -101,6 +101,7 @@ void chardev_remove_completion(Monitor *mon, int nb_args, const char *str); void cpu_completion(Monitor *mon, int nb_args, const char *str); void set_link_completion(Monitor *mon, int nb_args, const char *str); void netdev_add_completion(Monitor *mon, int nb_args, const char *str); +void netdev_del_completion(Monitor *mon, int nb_args, const char *str); #endif diff --git a/monitor.c b/monitor.c index b1378c6..3d194fa 100644 --- a/monitor.c +++ b/monitor.c @@ -4516,6 +4516,21 @@ void set_link_completion(Monitor *mon, int nb_args, const char *str) } } +void netdev_del_completion(Monitor *mon, int nb_args, const char *str) +{ + struct NicCompletionData data = { + .mon = mon, + .str = str, + }; + + if (nb_args != 2) { + return; + } + + readline_set_completion_index(mon->rs, strlen(str)); + qemu_foreach_nic(check_nic_completion, &data); +} + static void monitor_find_completion_by_table(Monitor *mon, const mon_cmd_t *cmd_table, char **args, -- 1.8.3.2 ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-05-07 21:42 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <1398614409-30792-1-git-send-email-kroosec@gmail.com> [not found] ` <1398614409-30792-3-git-send-email-kroosec@gmail.com> 2014-05-05 19:51 ` [Qemu-devel] [PATCH 2/7] monitor: Convert help|? to use command_completion Luiz Capitulino 2014-05-07 21:42 ` Hani Benhabiles 2014-05-05 19:54 ` [Qemu-devel] [PATCH 0/7] Miscellaneous command completion patches Luiz Capitulino [not found] ` <1398614409-30792-6-git-send-email-kroosec@gmail.com> 2014-05-07 9:18 ` [Qemu-devel] [PATCH 5/7] monitor: Add set_link arguments completion Stefan Hajnoczi [not found] ` <1398614409-30792-7-git-send-email-kroosec@gmail.com> 2014-05-07 9:21 ` [Qemu-devel] [PATCH 6/7] monitor: Add netdev_add type argument completion Stefan Hajnoczi [not found] ` <1398614409-30792-8-git-send-email-kroosec@gmail.com> 2014-05-07 9:22 ` [Qemu-devel] [PATCH 7/7] monitor: Add netdev_del id " Stefan Hajnoczi 2014-03-09 11:16 [Qemu-devel] [PATCH 0/7] monitor: Completion support for various commands Hani Benhabiles 2014-03-09 11:16 ` [Qemu-devel] [PATCH 7/7] monitor: Add netdev_del id argument completion Hani Benhabiles
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).