From patchwork Wed Aug 1 09:48:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lei Li X-Patchwork-Id: 174425 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 533532C00AF for ; Wed, 1 Aug 2012 19:49:54 +1000 (EST) Received: from localhost ([::1]:35900 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwVYu-00059S-Bi for incoming@patchwork.ozlabs.org; Wed, 01 Aug 2012 05:49:52 -0400 Received: from eggs.gnu.org ([208.118.235.92]:59469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwVYW-0004lf-02 for qemu-devel@nongnu.org; Wed, 01 Aug 2012 05:49:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SwVYR-0000vs-JE for qemu-devel@nongnu.org; Wed, 01 Aug 2012 05:49:27 -0400 Received: from e28smtp08.in.ibm.com ([122.248.162.8]:58285) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwVYQ-0000vR-W3 for qemu-devel@nongnu.org; Wed, 01 Aug 2012 05:49:23 -0400 Received: from /spool/local by e28smtp08.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 1 Aug 2012 15:19:21 +0530 Received: from d28relay02.in.ibm.com (9.184.220.59) by e28smtp08.in.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 1 Aug 2012 15:19:18 +0530 Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay02.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q719nHOc24576132 for ; Wed, 1 Aug 2012 15:19:17 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q719nGwV002034 for ; Wed, 1 Aug 2012 19:49:16 +1000 Received: from localhost.localdomain.cn.ibm.com ([9.115.122.84]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q719nCjD001796; Wed, 1 Aug 2012 19:49:15 +1000 From: Lei Li To: qemu-devel@nongnu.org Date: Wed, 1 Aug 2012 17:48:57 +0800 Message-Id: <1343814538-27591-4-git-send-email-lilei@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1343814538-27591-1-git-send-email-lilei@linux.vnet.ibm.com> References: <1343814538-27591-1-git-send-email-lilei@linux.vnet.ibm.com> x-cbid: 12080109-2000-0000-0000-0000088FA02D X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 122.248.162.8 Cc: aliguori@us.ibm.com, stefanha@linux.vnet.ibm.com, Lei Li Subject: [Qemu-devel] [RFC PATCH 3/4] qmp: Introduce memchar_write QMP command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Lei Li --- 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,