monitor: Command completion for various commands
A set of patches adding completion support for various hmp commands. Following other series that were merged earlier.
Hani Benhabiles (7):
monitor: Add ringbuf_write and ringbuf_read argument completion.
monitor: Add watchdog_action argument completion.
monitor: Add migrate_set_capability completion.
monitor: Add host_net_add device argument completion.
readline: Make completion strings always unique.
monitor: Add host_net_remove arguments completion.
monitor: Add delvm and loadvm argument completion.
hmp-commands.hx | 10 ++- hmp.h | 11 ++++ include/sysemu/char.h | 3 +- monitor.c | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++ qemu-char.c | 2 +- util/readline.c | 6 ++ 6 files changed, 202 insertions(+), 4 deletions(-)
Signature · 1 line
1.8.3.2
PATCH 1/7 monitor: Add ringbuf_write and ringbuf_read argument completion.
Export chr_is_ringbuf() function. Also remove left-over function prototypes while at it.
--- hmp-commands.hx | 2 ++ hmp.h | 2 ++ include/sysemu/char.h | 3 +-- monitor.c | 39 +++++++++++++++++++++++++++++++++++++++ qemu-char.c | 2 +- 5 files changed, 45 insertions(+), 3 deletions(-)
hmp-commands.hx +2 -0
@@ -852,6 +852,7 @@ ETEXI .params = "device data", .help = "Write to a ring buffer character device", .mhandler.cmd = hmp_ringbuf_write, + .command_completion = ringbuf_write_completion, }, STEXI
@@ -868,6 +869,7 @@ ETEXI .params = "device size", .help = "Read from a ring buffer character device", .mhandler.cmd = hmp_ringbuf_read, + .command_completion = ringbuf_write_completion, }, STEXI
hmp.h +2 -0
@@ -103,5 +103,7 @@ void chardev_add_completion(ReadLineState *rs, int nb_args, const char *str);void set_link_completion (ReadLineState *rs,int nb_args,const char *str);void netdev_add_completion (ReadLineState *rs,int nb_args,const char *str);void netdev_del_completion (ReadLineState *rs,int nb_args,const char *str); +void ringbuf_write_completion (ReadLineState *rs,int nb_args,const char *str); +void ringbuf_read_completion (ReadLineState *rs,int nb_args,const char *str);#endif
include/sysemu/char.h +1 -2
@@ -286,9 +286,8 @@ void qemu_chr_add_handlers(CharDriverState *s,void qemu_chr_be_generic_open (CharDriverState *s);void qemu_chr_accept_input (CharDriverState *s);int qemu_chr_add_client (CharDriverState *s,int fd); -void qemu_chr_info_print (Monitor *mon,const QObject *ret_data); -void qemu_chr_info (Monitor *mon,QObject **ret_data);CharDriverState *qemu_chr_find (const char *name); +bool chr_is_ringbuf (const CharDriverState *chr);QemuOpts *qemu_chr_parse_compat (const char *label,const char *filename);
monitor.c +39 -0
@@ -4411,6 +4411,45 @@ void chardev_remove_completion(ReadLineState *rs, int nb_args, const char *str)qapi_free_ChardevInfoList (start); } +static void ringbuf_completion (ReadLineState *rs,const char *str) +{ +size_t len; +ChardevInfoList *list, *start; + + len =strlen (str); +readline_set_completion_index (rs, len); + + start = list =qmp_query_chardev (NULL ); +while (list) { +ChardevInfo *chr_info = list->value; + +if (!strncmp (chr_info->label, str, len)) { +CharDriverState *chr =qemu_chr_find (chr_info->label); +if (chr &&chr_is_ringbuf (chr)) { +readline_add_completion (rs, chr_info->label); + } + } + list = list->next; + } +qapi_free_ChardevInfoList (start); +} + +void ringbuf_read_completion (ReadLineState *rs,int nb_args,const char *str) +{ +if (nb_args !=2 ) { +return ; + } +ringbuf_completion (rs, str); +} + +void ringbuf_write_completion (ReadLineState *rs,int nb_args,const char *str) +{ +if (nb_args !=2 ) { +return ; + } +ringbuf_completion (rs, str); +} +void device_del_completion (ReadLineState *rs,int nb_args,const char *str) {size_t len;
qemu-char.c +1 -1
@@ -2849,7 +2849,7 @@ fail:return NULL ; } -static bool chr_is_ringbuf (const CharDriverState *chr) +bool chr_is_ringbuf (const CharDriverState *chr) {return chr->chr_write == ringbuf_chr_write; }
Signature · 1 line
1.8.3.2
PATCH 2/7 monitor: Add watchdog_action argument completion.
In reply to Hani Benhabiles--- hmp-commands.hx | 1 + hmp.h | 2 ++ monitor.c | 14 ++++++++++++++ 3 files changed, 17 insertions(+)
hmp-commands.hx +1 -0
@@ -1359,6 +1359,7 @@ ETEXI .params = "[reset|shutdown|poweroff|pause|debug|none]", .help = "change watchdog action", .mhandler.cmd = do_watchdog_action, + .command_completion = watchdog_action_completion, }, STEXI
hmp.h +2 -0
@@ -105,5 +105,7 @@ void netdev_add_completion(ReadLineState *rs, int nb_args, const char *str);void netdev_del_completion (ReadLineState *rs,int nb_args,const char *str);void ringbuf_write_completion (ReadLineState *rs,int nb_args,const char *str);void ringbuf_read_completion (ReadLineState *rs,int nb_args,const char *str); +void watchdog_action_completion (ReadLineState *rs,int nb_args, +const char *str);#endif
monitor.c +14 -0
@@ -4558,6 +4558,20 @@ void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str) } } +void watchdog_action_completion (ReadLineState *rs,int nb_args,const char *str) +{ +if (nb_args !=2 ) { +return ; + } +readline_set_completion_index (rs,strlen (str)); +add_completion_option (rs, str,"reset" ); +add_completion_option (rs, str,"shutdown" ); +add_completion_option (rs, str,"poweroff" ); +add_completion_option (rs, str,"pause" ); +add_completion_option (rs, str,"debug" ); +add_completion_option (rs, str,"none" ); +} + static void monitor_find_completion_by_table(Monitor *mon, const mon_cmd_t *cmd_table, char **args,
Signature · 1 line
1.8.3.2
PATCH 3/7 monitor: Add migrate_set_capability completion.
In reply to Hani Benhabiles--- hmp-commands.hx | 1 + hmp.h | 2 ++ monitor.c | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+)
hmp-commands.hx +1 -0
@@ -975,6 +975,7 @@ ETEXI .params = "capability state", .help = "Enable/Disable the usage of a capability for migration", .mhandler.cmd = hmp_migrate_set_capability, + .command_completion = migrate_set_capability_completion, }, STEXI
hmp.h +2 -0
@@ -107,5 +107,7 @@ void ringbuf_write_completion(ReadLineState *rs, int nb_args, const char *str);void ringbuf_read_completion (ReadLineState *rs,int nb_args,const char *str);void watchdog_action_completion (ReadLineState *rs,int nb_args,const char *str); +void migrate_set_capability_completion (ReadLineState *rs,int nb_args, +const char *str);#endif
monitor.c +21 -0
@@ -4572,6 +4572,27 @@ void watchdog_action_completion(ReadLineState *rs, int nb_args, const char *str)add_completion_option (rs, str,"none" ); } +void migrate_set_capability_completion (ReadLineState *rs,int nb_args, +const char *str) +{ +size_t len; + + len =strlen (str); +readline_set_completion_index (rs, len); +if (nb_args ==2 ) { +int i; +for (i =0 ; i <MIGRATION_CAPABILITY_MAX ; i++) { +const char *name = MigrationCapability_lookup[i]; +if (!strncmp (str, name, len)) { +readline_add_completion (rs, name); + } + } + }else if (nb_args ==3 ) { +add_completion_option (rs, str,"on" ); +add_completion_option (rs, str,"off" ); + } +} + static void monitor_find_completion_by_table(Monitor *mon, const mon_cmd_t *cmd_table, char **args,
Signature · 1 line
1.8.3.2
Quoted 3 lines · Hani Benhabiles
A set of patches adding completion support for various hmp commands. Following other series that were merged earlier.
Resent the complete series. Please ignore this incomplete one.
Sorry for the flood.
Quoted 20 lines
Hani Benhabiles (7):
monitor: Addringbuf_writeandringbuf_readargument completion.
monitor: Addwatchdog_actionargument completion.
monitor: Addmigrate_set_capabilitycompletion.
monitor: Addhost_net_adddevice argument completion.
readline: Make completion strings always unique.
monitor: Addhost_net_removearguments completion.
monitor: Add delvm and loadvm argument completion.hmp-commands.hx | 10 ++- hmp.h | 11 ++++ include/sysemu/char.h | 3 +- monitor.c | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++ qemu-char.c | 2 +- util/readline.c | 6 ++ 6 files changed, 202 insertions(+), 4 deletions(-)Signature · 1 line
1.8.3.2