diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2014-06-11 21:34:08 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2014-06-11 21:34:08 +0100 |
commit | 05fedeef835c3c889e5d2e44f8abb11dcfcadefc (patch) | |
tree | 8dbcf074dec8246cb542e68f6b84c7abf5176e50 /monitor.c | |
parent | 706808585a49bfd266e00b1c7723b6e1b0f4ff35 (diff) | |
parent | a491af471bf8f1188b2665f54d109065d4591e45 (diff) | |
download | hqemu-05fedeef835c3c889e5d2e44f8abb11dcfcadefc.zip hqemu-05fedeef835c3c889e5d2e44f8abb11dcfcadefc.tar.gz |
Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging
* remotes/qmp-unstable/queue/qmp:
json-parser: drop superfluous assignment for token variable
readline: Clear screen on form feed.
monitor: Add delvm and loadvm argument completion
monitor: Add host_net_remove arguments completion
readline: Make completion strings always unique
monitor: Add host_net_add device argument completion
net: Export valid host network devices list
monitor: Add migrate_set_capability completion
monitor: Add watchdog_action argument completion
monitor: Add ringbuf_write and ringbuf_read argument completion
dump: simplify get_len_buf_out()
dump: hoist lzo_init() from get_len_buf_out() to dump_init()
dump: select header bitness based on ELF class, not ELF architecture
dump: eliminate DumpState.page_size ("guest's page size")
dump: eliminate DumpState.page_shift ("guest's page shift")
dump: simplify write_start_flat_header()
dump: fill in the flat header signature more pleasingly to the eye
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'monitor.c')
-rw-r--r-- | monitor.c | 176 |
1 files changed, 176 insertions, 0 deletions
@@ -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) @@ -4412,6 +4413,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; @@ -4520,6 +4560,142 @@ 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"); +} + +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"); + } +} + +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]); + } + } +} + +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 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, |