From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49789) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGQ2k-0003cm-I8 for qemu-devel@nongnu.org; Mon, 02 Sep 2013 05:03:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VGQ2a-0001K6-6V for qemu-devel@nongnu.org; Mon, 02 Sep 2013 05:03:30 -0400 Received: from e23smtp02.au.ibm.com ([202.81.31.144]:47960) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGQ2Z-0001HX-KA for qemu-devel@nongnu.org; Mon, 02 Sep 2013 05:03:20 -0400 Received: from /spool/local by e23smtp02.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 2 Sep 2013 18:51:43 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 204FD3578050 for ; Mon, 2 Sep 2013 19:03:14 +1000 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r828kqT231916184 for ; Mon, 2 Sep 2013 18:46:53 +1000 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r8293D2r010426 for ; Mon, 2 Sep 2013 19:03:13 +1000 From: Lei Li Date: Mon, 2 Sep 2013 17:01:45 +0800 Message-Id: <1378112508-8970-2-git-send-email-lilei@linux.vnet.ibm.com> In-Reply-To: <1378112508-8970-1-git-send-email-lilei@linux.vnet.ibm.com> References: <1378112508-8970-1-git-send-email-lilei@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 1/4] monitor: introduce monitor_read_console List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Lei Li , anthony@codemonkey.ws, lcapitulino@redhat.com 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 --- 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