[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/4] monitor: introduce monitor_read_console
From: |
Lei Li |
Subject: |
[Qemu-devel] [PATCH 1/4] monitor: introduce monitor_read_console |
Date: |
Mon, 2 Sep 2013 17:01:45 +0800 |
This patch introduces monitor_read_console(), which will drop
into interactive mode with chardev ringbuf backend, and install
a readline handler. When the handler is invoked, the given data
will be written to ringbuf backend.
Signed-off-by: Lei Li <address@hidden>
---
include/monitor/monitor.h | 3 +++
monitor.c | 14 ++++++++++++++
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index 1942cc4..e6a6f47 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -89,6 +89,9 @@ ReadLineState *monitor_get_rs(Monitor *mon);
int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func,
void *opaque);
+int monitor_read_console(Monitor *mon, const char *device,
+ ReadLineFunc *readline_func, void *opaque);
+
int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret);
int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret);
diff --git a/monitor.c b/monitor.c
index 0aeaf6c..531095e 100644
--- a/monitor.c
+++ b/monitor.c
@@ -263,6 +263,20 @@ int monitor_read_password(Monitor *mon, ReadLineFunc
*readline_func,
}
}
+int monitor_read_console(Monitor *mon, const char *device,
+ ReadLineFunc *readline_func, void *opaque)
+{
+ char prompt[60];
+
+ if (!mon->rs) {
+ return -1;
+ }
+
+ snprintf(prompt, sizeof(prompt), "%s: ", device);
+ readline_start(mon->rs, prompt, 0, readline_func, opaque);
+ return 0;
+}
+
static gboolean monitor_unblocked(GIOChannel *chan, GIOCondition cond,
void *opaque)
{
--
1.7.7.6