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: aliguori@us.ibm.com, eblake@redhat.com,
	Lei Li <lilei@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH 6/6] Expose MemCharDriver via command line
Date: Thu, 23 Aug 2012 13:14:26 +0800	[thread overview]
Message-ID: <1345698866-19794-7-git-send-email-lilei@linux.vnet.ibm.com> (raw)
In-Reply-To: <1345698866-19794-1-git-send-email-lilei@linux.vnet.ibm.com>

Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
---
 qemu-char.c     |   24 ++++++++++++++++++++++++
 qemu-config.c   |    3 +++
 qemu-options.hx |   10 ++++++++++
 3 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/qemu-char.c b/qemu-char.c
index ff6651b..36f4ecc 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -99,6 +99,7 @@
 #include "ui/qemu-spice.h"
 
 #define READ_BUF_LEN 4096
+#define CBUFF_SIZE 65536
 
 /***********************************************************/
 /* character device */
@@ -2647,6 +2648,23 @@ size_t qemu_chr_mem_osize(const CharDriverState *chr)
     return d->cbuf_count;
 }
 
+static CharDriverState *qemu_chr_open_memchr(QemuOpts *opts)
+{
+    CharDriverState *chr;
+    size_t capacity;
+
+    chr = g_malloc0(sizeof(CharDriverState));
+
+    capacity = qemu_opt_get_number(opts, "maxcapacity", 0);
+    if (capacity == 0) {
+        capacity = CBUFF_SIZE;
+    }
+
+    qemu_chr_init_mem(chr, capacity);
+
+    return chr;
+}
+
 void qmp_memchar_write(const char *chardev, int64_t size,
                        const char *data, bool has_format,
                        enum DataFormat format,
@@ -2779,6 +2797,11 @@ QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename)
         qemu_opt_set(opts, "path", p);
         return opts;
     }
+    if (strstart(filename, "memchr", &p)) {
+        qemu_opt_set(opts, "backend", "memchr");
+        qemu_opt_set(opts, "maxcapacity", p);
+        return opts;
+    }
     if (strstart(filename, "tcp:", &p) ||
         strstart(filename, "telnet:", &p)) {
         if (sscanf(p, "%64[^:]:%32[^,]%n", host, port, &pos) < 2) {
@@ -2852,6 +2875,7 @@ static const struct {
     { .name = "udp",       .open = qemu_chr_open_udp },
     { .name = "msmouse",   .open = qemu_chr_open_msmouse },
     { .name = "vc",        .open = text_console_init },
+    { .name = "memchr",    .open = qemu_chr_open_memchr },
 #ifdef _WIN32
     { .name = "file",      .open = qemu_chr_open_win_file_out },
     { .name = "pipe",      .open = qemu_chr_open_win_pipe },
diff --git a/qemu-config.c b/qemu-config.c
index c05ffbc..7118d0e 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -114,6 +114,9 @@ static QemuOptsList qemu_drive_opts = {
             .name = "copy-on-read",
             .type = QEMU_OPT_BOOL,
             .help = "copy read data from backing file into image file",
+        },{
+            .name = "max-capacity",
+            .type = QEMU_OPT_NUMBER,
         },
         { /* end of list */ }
     },
diff --git a/qemu-options.hx b/qemu-options.hx
index 3c411c4..1ccf295 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1647,6 +1647,7 @@ DEF("chardev", HAS_ARG, QEMU_OPTION_chardev,
     "-chardev msmouse,id=id[,mux=on|off]\n"
     "-chardev vc,id=id[[,width=width][,height=height]][[,cols=cols][,rows=rows]]\n"
     "         [,mux=on|off]\n"
+    "-chardev memchr,id=id,max-capacity=max-capacity\n"
     "-chardev file,id=id,path=path[,mux=on|off]\n"
     "-chardev pipe,id=id,path=path[,mux=on|off]\n"
 #ifdef _WIN32
@@ -1685,6 +1686,7 @@ Backend is one of:
 @option{udp},
 @option{msmouse},
 @option{vc},
+@option{memchr},
 @option{file},
 @option{pipe},
 @option{console},
@@ -1791,6 +1793,14 @@ the console, in pixels.
 @option{cols} and @option{rows} specify that the console be sized to fit a text
 console with the given dimensions.
 
+@item -chardev memchr ,id=@var{id} ,max-capacity=@var{max-capacity}
+
+Create a circular buffer with fixed size indicated by optionally @option{max-capacity}
+which will be default 64K if it is not given.
+
+@option{max-capacity} specify the max capacity of the size of circular buffer
+want to create.
+
 @item -chardev file ,id=@var{id} ,path=@var{path}
 
 Log all traffic received from the guest to a file.
-- 
1.7.7.6

  parent reply	other threads:[~2012-08-23  5:15 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-23  5:14 [Qemu-devel] [RFC v2 ATCH 0/4] char: expose MemoryCharDriver to users and provide QMP interface Lei Li
2012-08-23  5:14 ` [Qemu-devel] [PATCH 1/6] qemu-char: Convert MemCharDriver to circular buffer Lei Li
2012-08-30 18:43   ` Luiz Capitulino
2012-08-23  5:14 ` [Qemu-devel] [PATCH 2/6] monitor: Adjust qmp_human_monitor_command to new MemCharDriver Lei Li
2012-08-30 18:51   ` Luiz Capitulino
2012-09-03 16:14     ` Lei Li
2012-09-03 16:21       ` Luiz Capitulino
2012-08-23  5:14 ` [Qemu-devel] [PATCH 3/6] QAPI: Introduce memchar_write QMP command Lei Li
2012-08-23  5:42   ` Eric Blake
2012-08-23  6:40     ` Lei Li
2012-08-31  7:26     ` Markus Armbruster
2012-08-30 19:17   ` Luiz Capitulino
2012-08-31  7:17   ` Markus Armbruster
2012-08-23  5:14 ` [Qemu-devel] [PATCH 4/6] QAPI: Introduce memchar_read " Lei Li
2012-08-23  5:46   ` Eric Blake
2012-08-23  7:30     ` Lei Li
2012-08-23  5:14 ` [Qemu-devel] [PATCH 5/6] Fix enumeration typo error Lei Li
2012-08-23  5:48   ` Eric Blake
2012-08-30 19:20   ` Luiz Capitulino
2012-08-31  6:52   ` Stefan Hajnoczi
2012-08-23  5:14 ` Lei Li [this message]
2012-08-31  7:02   ` [Qemu-devel] [PATCH 6/6] Expose MemCharDriver via command line Markus Armbruster

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=1345698866-19794-7-git-send-email-lilei@linux.vnet.ibm.com \
    --to=lilei@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=eblake@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).