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, stefanha@linux.vnet.ibm.com,
	Lei Li <lilei@linux.vnet.ibm.com>
Subject: [Qemu-devel] [RFC PATCH 3/4] qmp: Introduce memchar_write QMP command
Date: Wed,  1 Aug 2012 17:48:57 +0800	[thread overview]
Message-ID: <1343814538-27591-4-git-send-email-lilei@linux.vnet.ibm.com> (raw)
In-Reply-To: <1343814538-27591-1-git-send-email-lilei@linux.vnet.ibm.com>

Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
---
 qapi-schema.json |   20 ++++++++++++++++++++
 qemu-char.c      |   19 +++++++++++++++++++
 qmp-commands.hx  |   29 +++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index bc55ed2..3c8530f 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -206,6 +206,26 @@
 { 'command': 'query-chardev', 'returns': ['ChardevInfo'] }
 
 ##
+# @memchar_write:
+#
+# Provide writing interface for memchardev. Write data to memchar
+# char device.
+#
+# @chardev: the name of the memchar char device.
+#
+# @size: the size to write in bytes.
+#
+# @data: the source data write to memchar.
+#
+# Returns: Nothing on success
+#          If an I/O error occurs while writing, IOError
+#
+# Since: 1.2
+##
+{ 'command': 'memchar_write',
+  'data': {'chardev': 'str', 'size': 'int', 'data': 'str'} }
+
+##
 # @CommandInfo:
 #
 # Information about a QMP command
diff --git a/qemu-char.c b/qemu-char.c
index 087c92d..1012e65 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2636,6 +2636,25 @@ size_t qemu_chr_mem_osize(const CharDriverState *chr)
     return d->cbuf_count;
 }
 
+void qmp_memchar_write(const char *chardev, int64_t size,
+                       uint8_t *data, Error **errp)
+{
+    CharDriverState *chr;
+    int ret;
+
+    chr = qemu_chr_find(chardev);
+
+    if(!chr) {
+        qemu_chr_init_mem(chr, size);
+    }
+
+    ret = mem_chr_write(chr, data, size);
+    if (ret <= 0) {
+        error_set(errp, QERR_IO_ERROR);
+        return;
+    }
+}
+
 QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename)
 {
     char host[65], port[33], width[8], height[8];
diff --git a/qmp-commands.hx b/qmp-commands.hx
index e3cf3c5..182f1e6 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -441,6 +441,35 @@ Note: inject-nmi is only supported for x86 guest currently, it will
 EQMP
 
     {
+        .name       = "memchar_write",
+        .args_type  = "chardev:s,size:i,data:s",
+        .mhandler.cmd_new = qmp_marshal_input_memchar_write,
+    },
+
+SQMP
+memchar_write
+-------------
+
+Provide writing interface for memchardev. Write data to memchar
+char device.
+
+Arguments:
+
+- "chardev": the name of the char device, must be unique (json-string)
+- "size": the memory size, in bytes (json-int)
+- "data": the source data writed to memchar (json-string)
+
+Example:
+
+-> { "execute": "memchar_write",
+                "arguments": { "chardev": foo,
+                               "size": 1000,
+                               "data": "data string" } }
+<- { "return": {} }
+
+EQMP
+
+    {
         .name       = "xen-save-devices-state",
         .args_type  = "filename:F",
     .mhandler.cmd_new = qmp_marshal_input_xen_save_devices_state,
-- 
1.7.7.6

  parent reply	other threads:[~2012-08-01  9:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-01  9:48 [Qemu-devel] [RFC PATCH 0/4] char: expose MemoryCharDriver to users and provide QMP interface Lei Li
2012-08-01  9:48 ` [Qemu-devel] [RFC PATCH 1/4] qemu-char: Convert MemCharDriver to circular buffer Lei Li
2012-08-01 21:30   ` Anthony Liguori
2012-08-06 10:57     ` Lei Li
2012-08-01  9:48 ` [Qemu-devel] [RFC PATCH 2/4] monitor: Adjust qmp_human_monitor_command to new MemCharDriver Lei Li
2012-08-01  9:48 ` Lei Li [this message]
2012-08-01 15:50   ` [Qemu-devel] [RFC PATCH 3/4] qmp: Introduce memchar_write QMP command Eric Blake
2012-08-01 21:33   ` Anthony Liguori
2012-08-01  9:48 ` [Qemu-devel] [RFC PATCH 4/4] qmp: Introduce memchar_read " Lei Li
2012-08-01 15:51   ` Eric Blake
2012-08-01 21:39 ` [Qemu-devel] [RFC PATCH 0/4] char: expose MemoryCharDriver to users and provide QMP interface Anthony Liguori

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=1343814538-27591-4-git-send-email-lilei@linux.vnet.ibm.com \
    --to=lilei@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@linux.vnet.ibm.com \
    /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).