From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:45993) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4Rsg-0000FR-6s for qemu-devel@nongnu.org; Thu, 23 Aug 2012 03:31:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T4Rsa-0004JD-0U for qemu-devel@nongnu.org; Thu, 23 Aug 2012 03:31:06 -0400 Received: from e28smtp06.in.ibm.com ([122.248.162.6]:39756) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4RsZ-0004Ex-AQ for qemu-devel@nongnu.org; Thu, 23 Aug 2012 03:30:59 -0400 Received: from /spool/local by e28smtp06.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 23 Aug 2012 13:00:56 +0530 Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q7N7UqnD52625452 for ; Thu, 23 Aug 2012 13:00:52 +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 q7N7UqYu011524 for ; Thu, 23 Aug 2012 17:30:52 +1000 Message-ID: <5035DC14.3090603@linux.vnet.ibm.com> Date: Thu, 23 Aug 2012 15:30:28 +0800 From: Lei Li MIME-Version: 1.0 References: <1345698866-19794-1-git-send-email-lilei@linux.vnet.ibm.com> <1345698866-19794-5-git-send-email-lilei@linux.vnet.ibm.com> <5035C3CA.6020503@redhat.com> In-Reply-To: <5035C3CA.6020503@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 4/6] QAPI: Introduce memchar_read QMP command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org On 08/23/2012 01:46 PM, Eric Blake wrote: > On 08/22/2012 11:14 PM, Lei Li wrote: >> Signed-off-by: Lei Li > Again, subject line should use '-' not '_' for QMP. > >> --- >> hmp-commands.hx | 16 ++++++++++++++++ >> hmp.c | 15 +++++++++++++++ >> hmp.h | 1 + >> qapi-schema.json | 23 +++++++++++++++++++++++ >> qemu-char.c | 32 ++++++++++++++++++++++++++++++++ >> qmp-commands.hx | 31 +++++++++++++++++++++++++++++++ >> 6 files changed, 118 insertions(+), 0 deletions(-) >> >> diff --git a/hmp-commands.hx b/hmp-commands.hx >> index 829aea1..9f61633 100644 >> --- a/hmp-commands.hx >> +++ b/hmp-commands.hx >> @@ -813,6 +813,22 @@ to memchr char device with size @var{size}. >> ETEXI >> >> { >> + .name = "memchar-read", > while the HMP command should use '_' not '-'. > >> +++ b/qapi-schema.json >> @@ -264,6 +264,29 @@ >> '*format': 'DataFormat'} } >> >> ## >> +# @memchar-read: >> +# >> +# Provide read interface for memchardev. Read from memchar >> +# char device and return the data. >> +# >> +# @chardev: the name of the memchar char device. > Why two spaces? > >> +# >> +# @size: the size to write in bytes. > s/write/read/ > >> +# >> +# @format: #optional the format of the data want to read from >> +# memchardev, by default is 'utf8'. >> +# >> +# Returns: The data read from memchar as string. >> +# If @chardev is not a valid memchr device, DeviceNotFound >> +# If an I/O error occurs while reading, IOError >> +# >> +# Since: 1.2 > 1.3 > >> +## >> +{ 'command': 'memchar-read', >> + 'data': {'chardev': 'str', 'size': 'int', '*format': 'DataFormat'}, >> + 'returns': 'str' } > While writing can default to UTF-8, I'm worried about reading - does > encoding in UTF-8 allow transmission of NUL bytes through JSON, or do > you have to use base64 to allow full binary data through? What happens > if the data read includes a NUL byte that can't be encoded back into the > requested DataFormat? Yes, you are right. g_base64_encode did not support NULL bytes encoding, so encoding in UTF-8 should not allow transmission of NULL bytes through JSON. Thanks for pointing this out! -- Lei