From 8e5977797d76e33856506c9a0c454ae9ab23034c Mon Sep 17 00:00:00 2001 From: Hani Benhabiles Date: Tue, 27 May 2014 23:39:30 +0100 Subject: monitor: Add ringbuf_write and ringbuf_read argument completion Export chr_is_ringbuf() function. Also remove left-over function prototypes while at it. Signed-off-by: Hani Benhabiles Signed-off-by: Luiz Capitulino --- hmp-commands.hx | 2 ++ 1 file changed, 2 insertions(+) (limited to 'hmp-commands.hx') diff --git a/hmp-commands.hx b/hmp-commands.hx index 2e462c04aa..dcec5efab7 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -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 -- cgit 1.4.1 From d0ece345cbe3a58a9952f0f539641009bfd7ddf9 Mon Sep 17 00:00:00 2001 From: Hani Benhabiles Date: Tue, 27 May 2014 23:39:31 +0100 Subject: monitor: Add watchdog_action argument completion Signed-off-by: Hani Benhabiles Signed-off-by: Luiz Capitulino --- hmp-commands.hx | 1 + hmp.h | 2 ++ monitor.c | 14 ++++++++++++++ 3 files changed, 17 insertions(+) (limited to 'hmp-commands.hx') diff --git a/hmp-commands.hx b/hmp-commands.hx index dcec5efab7..45e1763fbe 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -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 diff --git a/hmp.h b/hmp.h index 212e5d2ae6..a70804db46 100644 --- a/hmp.h +++ b/hmp.h @@ -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 diff --git a/monitor.c b/monitor.c index e539e40b83..68d74cd351 100644 --- a/monitor.c +++ b/monitor.c @@ -4559,6 +4559,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, -- cgit 1.4.1 From c68a0409b388c30c7f4ee8be44081c143f280279 Mon Sep 17 00:00:00 2001 From: Hani Benhabiles Date: Tue, 27 May 2014 23:39:32 +0100 Subject: monitor: Add migrate_set_capability completion Signed-off-by: Hani Benhabiles Signed-off-by: Luiz Capitulino --- hmp-commands.hx | 1 + hmp.h | 2 ++ monitor.c | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+) (limited to 'hmp-commands.hx') diff --git a/hmp-commands.hx b/hmp-commands.hx index 45e1763fbe..919af6eaf1 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -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 diff --git a/hmp.h b/hmp.h index a70804db46..0c814d07bd 100644 --- a/hmp.h +++ b/hmp.h @@ -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 diff --git a/monitor.c b/monitor.c index 68d74cd351..709425ddb0 100644 --- a/monitor.c +++ b/monitor.c @@ -4573,6 +4573,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, -- cgit 1.4.1 From e3bb532cc795a394b74d08c9d5eb1d95bb0e1e86 Mon Sep 17 00:00:00 2001 From: Hani Benhabiles Date: Tue, 27 May 2014 23:39:34 +0100 Subject: monitor: Add host_net_add device argument completion Also fix the parameters documentation. Signed-off-by: Hani Benhabiles Reviewed-by: Stefan Hajnoczi Signed-off-by: Luiz Capitulino --- hmp-commands.hx | 3 ++- hmp.h | 1 + monitor.c | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) (limited to 'hmp-commands.hx') diff --git a/hmp-commands.hx b/hmp-commands.hx index 919af6eaf1..aab9cf59bb 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1209,9 +1209,10 @@ ETEXI { .name = "host_net_add", .args_type = "device:s,opts:s?", - .params = "tap|user|socket|vde|netmap|dump [options]", + .params = "tap|user|socket|vde|netmap|bridge|dump [options]", .help = "add host VLAN client", .mhandler.cmd = net_host_device_add, + .command_completion = host_net_add_completion, }, STEXI diff --git a/hmp.h b/hmp.h index 0c814d07bd..22ee836469 100644 --- a/hmp.h +++ b/hmp.h @@ -109,5 +109,6 @@ 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); +void host_net_add_completion(ReadLineState *rs, int nb_args, const char *str); #endif diff --git a/monitor.c b/monitor.c index 709425ddb0..0189bf879c 100644 --- a/monitor.c +++ b/monitor.c @@ -4594,6 +4594,22 @@ void migrate_set_capability_completion(ReadLineState *rs, int nb_args, } } +void host_net_add_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; host_net_devices[i]; i++) { + if (!strncmp(host_net_devices[i], str, len)) { + readline_add_completion(rs, host_net_devices[i]); + } + } +} + static void monitor_find_completion_by_table(Monitor *mon, const mon_cmd_t *cmd_table, char **args, -- cgit 1.4.1 From ddd6b45ce25281a5894e2df0f7af014e83af19f7 Mon Sep 17 00:00:00 2001 From: Hani Benhabiles Date: Tue, 27 May 2014 23:39:36 +0100 Subject: monitor: Add host_net_remove arguments completion Relies on readline unique completion strings patch to make the added vlan/hub completion values unique, instead of using something like a hash table. Signed-off-by: Hani Benhabiles Reviewed-by: Stefan Hajnoczi Signed-off-by: Luiz Capitulino --- hmp-commands.hx | 1 + hmp.h | 2 ++ monitor.c | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) (limited to 'hmp-commands.hx') diff --git a/hmp-commands.hx b/hmp-commands.hx index aab9cf59bb..f99da0efe4 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1227,6 +1227,7 @@ ETEXI .params = "vlan_id name", .help = "remove host VLAN client", .mhandler.cmd = net_host_device_remove, + .command_completion = host_net_remove_completion, }, STEXI diff --git a/hmp.h b/hmp.h index 22ee836469..a53ad51602 100644 --- a/hmp.h +++ b/hmp.h @@ -110,5 +110,7 @@ void watchdog_action_completion(ReadLineState *rs, int nb_args, void migrate_set_capability_completion(ReadLineState *rs, int nb_args, const char *str); void host_net_add_completion(ReadLineState *rs, int nb_args, const char *str); +void host_net_remove_completion(ReadLineState *rs, int nb_args, + const char *str); #endif diff --git a/monitor.c b/monitor.c index 0189bf879c..d6c4f85909 100644 --- a/monitor.c +++ b/monitor.c @@ -4610,6 +4610,44 @@ void host_net_add_completion(ReadLineState *rs, int nb_args, const char *str) } } +void host_net_remove_completion(ReadLineState *rs, int nb_args, const char *str) +{ + NetClientState *ncs[255]; + int count, i, len; + + len = strlen(str); + readline_set_completion_index(rs, len); + if (nb_args == 2) { + count = qemu_find_net_clients_except(NULL, ncs, + NET_CLIENT_OPTIONS_KIND_NONE, 255); + for (i = 0; i < count; i++) { + int id; + char name[16]; + + if (net_hub_id_for_client(ncs[i], &id)) { + continue; + } + snprintf(name, sizeof(name), "%d", id); + if (!strncmp(str, name, len)) { + readline_add_completion(rs, name); + } + } + return; + } else if (nb_args == 3) { + count = qemu_find_net_clients_except(NULL, ncs, + NET_CLIENT_OPTIONS_KIND_NIC, 255); + for (i = 0; i < count; i++) { + const char *name; + + name = ncs[i]->name; + if (!strncmp(str, name, len)) { + readline_add_completion(rs, name); + } + } + return; + } +} + static void monitor_find_completion_by_table(Monitor *mon, const mon_cmd_t *cmd_table, char **args, -- cgit 1.4.1 From b21631f3b5cdecd14114034cd9e4e7f63ed7fde1 Mon Sep 17 00:00:00 2001 From: Hani Benhabiles Date: Tue, 27 May 2014 23:39:37 +0100 Subject: monitor: Add delvm and loadvm argument completion Signed-off-by: Hani Benhabiles Signed-off-by: Luiz Capitulino --- hmp-commands.hx | 2 ++ hmp.h | 2 ++ monitor.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) (limited to 'hmp-commands.hx') diff --git a/hmp-commands.hx b/hmp-commands.hx index f99da0efe4..5f1a677b85 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -335,6 +335,7 @@ ETEXI .params = "tag|id", .help = "restore a VM snapshot from its tag or id", .mhandler.cmd = do_loadvm, + .command_completion = loadvm_completion, }, STEXI @@ -350,6 +351,7 @@ ETEXI .params = "tag|id", .help = "delete a VM snapshot from its tag or id", .mhandler.cmd = do_delvm, + .command_completion = delvm_completion, }, STEXI diff --git a/hmp.h b/hmp.h index a53ad51602..2d9b0a2b0b 100644 --- a/hmp.h +++ b/hmp.h @@ -112,5 +112,7 @@ void migrate_set_capability_completion(ReadLineState *rs, int nb_args, void host_net_add_completion(ReadLineState *rs, int nb_args, const char *str); void host_net_remove_completion(ReadLineState *rs, int nb_args, const char *str); +void delvm_completion(ReadLineState *rs, int nb_args, const char *str); +void loadvm_completion(ReadLineState *rs, int nb_args, const char *str); #endif diff --git a/monitor.c b/monitor.c index d6c4f85909..ee9390f659 100644 --- a/monitor.c +++ b/monitor.c @@ -70,6 +70,7 @@ #include "qmp-commands.h" #include "hmp.h" #include "qemu/thread.h" +#include "block/qapi.h" /* for pic/irq_info */ #if defined(TARGET_SPARC) @@ -4648,6 +4649,53 @@ void host_net_remove_completion(ReadLineState *rs, int nb_args, const char *str) } } +static void vm_completion(ReadLineState *rs, const char *str) +{ + size_t len; + BlockDriverState *bs = NULL; + + len = strlen(str); + readline_set_completion_index(rs, len); + while ((bs = bdrv_next(bs))) { + SnapshotInfoList *snapshots, *snapshot; + + if (!bdrv_can_snapshot(bs)) { + continue; + } + if (bdrv_query_snapshot_info_list(bs, &snapshots, NULL)) { + continue; + } + snapshot = snapshots; + while (snapshot) { + char *completion = snapshot->value->name; + if (!strncmp(str, completion, len)) { + readline_add_completion(rs, completion); + } + completion = snapshot->value->id; + if (!strncmp(str, completion, len)) { + readline_add_completion(rs, completion); + } + snapshot = snapshot->next; + } + qapi_free_SnapshotInfoList(snapshots); + } + +} + +void delvm_completion(ReadLineState *rs, int nb_args, const char *str) +{ + if (nb_args == 2) { + vm_completion(rs, str); + } +} + +void loadvm_completion(ReadLineState *rs, int nb_args, const char *str) +{ + if (nb_args == 2) { + vm_completion(rs, str); + } +} + static void monitor_find_completion_by_table(Monitor *mon, const mon_cmd_t *cmd_table, char **args, -- cgit 1.4.1