From: Luiz Capitulino <lcapitulino@redhat.com>
To: Lei Li <lilei@linux.vnet.ibm.com>
Cc: blauwirbel@gmail.com, aliguori@us.ibm.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/5] Expose CirMemCharDriver via command line
Date: Mon, 22 Oct 2012 14:31:19 -0200 [thread overview]
Message-ID: <20121022143119.564b486a@doriath.home> (raw)
In-Reply-To: <1350838081-6351-3-git-send-email-lilei@linux.vnet.ibm.com>
On Mon, 22 Oct 2012 00:47:58 +0800
Lei Li <lilei@linux.vnet.ibm.com> wrote:
> Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
> ---
> qemu-char.c | 36 ++++++++++++++++++++++++++++++++++++
> qemu-config.c | 3 +++
> qemu-options.hx | 10 ++++++++++
> 3 files changed, 49 insertions(+), 0 deletions(-)
>
> diff --git a/qemu-char.c b/qemu-char.c
> index b174da1..381bf60 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 */
> @@ -2660,6 +2661,35 @@ static void cirmem_chr_close(struct CharDriverState *chr)
> chr->opaque = NULL;
> }
>
> +static CharDriverState *qemu_chr_open_cirmemchr(QemuOpts *opts)
> +{
> + CharDriverState *chr;
> + CirMemCharDriver *d;
> +
> + chr = g_malloc0(sizeof(CharDriverState));
> + d = g_malloc(sizeof(*d));
> +
> + d->size = qemu_opt_get_number(opts, "maxcapacity", 0);
> + if (d->size == 0) {
> + d->size = CBUFF_SIZE;
> + }
> +
> + if (d->size & (d->size -1)) {
> + return NULL;
> + }
> +
> + d->producer = 0;
> + d->consumer = 0;
> + d->cbuf = g_malloc0(d->size);
> +
> + memset(chr, 0, sizeof(*chr));
This has already been initialized by g_malloc0().
> + chr->opaque = d;
> + chr->chr_write = cirmem_chr_write;
> + chr->chr_close = cirmem_chr_close;
> +
> + return chr;
> +}
> +
> QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename)
> {
> char host[65], port[33], width[8], height[8];
> @@ -2724,6 +2754,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) {
> @@ -2797,6 +2832,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_cirmemchr },
Why not call it "memory"?
> #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 cd1ec21..5553bb6 100644
> --- a/qemu-config.c
> +++ b/qemu-config.c
> @@ -213,6 +213,9 @@ static QemuOptsList qemu_chardev_opts = {
> },{
> .name = "debug",
> .type = QEMU_OPT_NUMBER,
> + },{
> + .name = "maxcapacity",
> + .type = QEMU_OPT_NUMBER,
> },
> { /* end of list */ }
> },
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 7d97f96..4f90f20 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -1684,6 +1684,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,maxcapacity=maxcapacity\n"
> "-chardev file,id=id,path=path[,mux=on|off]\n"
> "-chardev pipe,id=id,path=path[,mux=on|off]\n"
> #ifdef _WIN32
> @@ -1722,6 +1723,7 @@ Backend is one of:
> @option{udp},
> @option{msmouse},
> @option{vc},
> +@option{memchr},
> @option{file},
> @option{pipe},
> @option{console},
> @@ -1828,6 +1830,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} ,maxcapacity=@var{maxcapacity}
> +
> +Create a circular buffer with fixed size indicated by optionally @option{maxcapacity}
> +which will be default 64K if it is not given.
> +
> +@option{maxcapacity} specify the max capacity of the size of circular buffer
> +want to create. Should be power of 2.
> +
> @item -chardev file ,id=@var{id} ,path=@var{path}
>
> Log all traffic received from the guest to a file.
next prev parent reply other threads:[~2012-10-22 18:25 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-21 16:47 [Qemu-devel] [PATCH 0/5 V4] char: add CirMemCharDriver and provide QMP interface Lei Li
2012-10-21 16:47 ` [Qemu-devel] [PATCH 1/5] qemu-char: Add new char backend CircularMemCharDriver Lei Li
2012-10-22 14:08 ` Eric Blake
2012-10-23 5:40 ` Lei Li
2012-10-23 12:42 ` Luiz Capitulino
2012-10-22 18:14 ` Luiz Capitulino
2012-10-23 6:36 ` Lei Li
2012-10-21 16:47 ` [Qemu-devel] [PATCH 2/5] Expose CirMemCharDriver via command line Lei Li
2012-10-22 16:31 ` Luiz Capitulino [this message]
2012-10-21 16:47 ` [Qemu-devel] [PATCH 3/5] QAPI: Introduce memchar-write QMP command Lei Li
2012-10-22 18:37 ` Luiz Capitulino
2012-10-23 6:36 ` Lei Li
2012-10-23 12:44 ` Luiz Capitulino
2012-10-21 16:48 ` [Qemu-devel] [PATCH 4/5] QAPI: Introduce memchar-read " Lei Li
2012-10-22 18:43 ` Luiz Capitulino
2012-10-21 16:48 ` [Qemu-devel] [PATCH 5/5] HMP: Introduce console command Lei Li
2012-10-22 18:59 ` Luiz Capitulino
2012-10-24 7:17 ` Lei Li
2012-10-24 12:55 ` Luiz Capitulino
2012-10-25 19:43 ` Lei Li
2012-10-26 13:56 ` Luiz Capitulino
-- strict thread matches above, loose matches on Subject: below --
2012-09-12 11:57 [Qemu-devel] [RFC v3 ATCH 0/5] char: expose CirMemCharDriver and provide QMP interface Lei Li
2012-09-12 11:57 ` [Qemu-devel] [PATCH 2/5] Expose CirMemCharDriver via command line Lei Li
2012-09-19 17:45 ` 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=20121022143119.564b486a@doriath.home \
--to=lcapitulino@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=blauwirbel@gmail.com \
--cc=lilei@linux.vnet.ibm.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).