qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Lei Li <lilei@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: Lei Li <lilei@linux.vnet.ibm.com>,
	anthony@codemonkey.ws, lcapitulino@redhat.com
Subject: [Qemu-devel] [PATCH 1/4] monitor: introduce monitor_read_console
Date: Mon,  2 Sep 2013 17:01:45 +0800	[thread overview]
Message-ID: <1378112508-8970-2-git-send-email-lilei@linux.vnet.ibm.com> (raw)
In-Reply-To: <1378112508-8970-1-git-send-email-lilei@linux.vnet.ibm.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 <lilei@linux.vnet.ibm.com>
---
 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

  reply	other threads:[~2013-09-02  9:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-02  9:01 [Qemu-devel] [PATCH 0/4 RFC] Introduce console for ringbuf backend Lei Li
2013-09-02  9:01 ` Lei Li [this message]
2013-09-09 19:13   ` [Qemu-devel] [PATCH 1/4] monitor: introduce monitor_read_console Luiz Capitulino
2013-09-02  9:01 ` [Qemu-devel] [PATCH 2/4] hmp: factor out ringbuf_print_help() Lei Li
2013-09-09 19:15   ` Luiz Capitulino
2013-09-02  9:01 ` [Qemu-devel] [PATCH 3/4] qemu-char: export ringbuf_count Lei Li
2013-09-02  9:01 ` [Qemu-devel] [PATCH 4/4] hmp: add console support for ringbuf backend Lei Li
2013-09-09 20:27   ` Luiz Capitulino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1378112508-8970-2-git-send-email-lilei@linux.vnet.ibm.com \
    --to=lilei@linux.vnet.ibm.com \
    --cc=anthony@codemonkey.ws \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).