aboutsummaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authorHani Benhabiles <kroosec@gmail.com>2014-05-27 23:39:30 +0100
committerLuiz Capitulino <lcapitulino@redhat.com>2014-06-11 10:10:28 -0400
commit8e5977797d76e33856506c9a0c454ae9ab23034c (patch)
tree32b650618339e5b561b869d1dbfc23e0efd06a72 /monitor.c
parentb87ef3518b2eeb9a57ee0d06d7e82a07ab5e4ffd (diff)
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 <hani@linux.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/monitor.c b/monitor.c
index 0565816910..e539e40b83 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4412,6 +4412,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;