[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 10/17] monitor: Add ringbuf_write and ringbuf_rea
From: |
Hani Benhabiles |
Subject: |
[Qemu-devel] [PATCH v2 10/17] monitor: Add ringbuf_write and ringbuf_read argument completion. |
Date: |
Sun, 30 Mar 2014 11:58:32 +0100 |
Export chr_is_ringbuf() function. Also remove left-over function prototypes
while at it.
Signed-off-by: Hani Benhabiles <address@hidden>
---
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(-)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index d252ffc..300be4e 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
diff --git a/hmp.h b/hmp.h
index c98722b..d7d0770 100644
--- a/hmp.h
+++ b/hmp.h
@@ -103,5 +103,7 @@ void cpu_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
diff --git a/include/sysemu/char.h b/include/sysemu/char.h
index b81a6ff..7f5eeb3 100644
--- a/include/sysemu/char.h
+++ b/include/sysemu/char.h
@@ -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);
diff --git a/monitor.c b/monitor.c
index d1b0d6c..839f8f1 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4421,6 +4421,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;
diff --git a/qemu-char.c b/qemu-char.c
index 54ed244..34c8f08 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -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;
}
--
1.8.3.2
- [Qemu-devel] [PATCH v2 00/17] monitor: Completion support for various commands, Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 01/17] monitor: Fix drive_del id argument type completion., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 02/17] monitor: Add command_completion callback to mon_cmd_t., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 03/17] monitor: Add device_add and device_del completion., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 04/17] monitor: Add chardev-remove id argument completion., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 05/17] monitor: Add chardev-add backend argument completion., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 06/17] monitor: Add cpu index argument completion., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 07/17] monitor: Add set_link arguments completion., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 08/17] monitor: Add netdev_add type argument completion., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 09/17] monitor: Add netdev_del id argument completion., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 10/17] monitor: Add ringbuf_write and ringbuf_read argument completion.,
Hani Benhabiles <=
- [Qemu-devel] [PATCH v2 11/17] monitor: Add watchdog_action argument completion., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 12/17] monitor: Add migrate_set_capability completion., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 13/17] monitor: Add host_net_add device argument completion., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 14/17] readline: Make completion strings always unique., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 15/17] monitor: Add host_net_remove arguments completion., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 16/17] monitor: Add mouse_set index argument completion., Hani Benhabiles, 2014/03/30
- [Qemu-devel] [PATCH v2 17/17] monitor: Add delvm and loadvm argument completion., Hani Benhabiles, 2014/03/30