From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55465) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXvQo-0005dq-Aw for qemu-devel@nongnu.org; Fri, 25 May 2012 10:23:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SXvQh-0002wx-Vv for qemu-devel@nongnu.org; Fri, 25 May 2012 10:23:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46835) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXvQh-0002wj-Nv for qemu-devel@nongnu.org; Fri, 25 May 2012 10:23:47 -0400 Message-ID: <4FBF95EF.9050801@redhat.com> Date: Fri, 25 May 2012 10:23:43 -0400 From: Jeff Cody MIME-Version: 1.0 References: <1337916721-14308-1-git-send-email-akong@redhat.com> <1337916721-14308-3-git-send-email-akong@redhat.com> <4FBF01AE.5000007@redhat.com> <4FBF24B1.8080803@redhat.com> <20120525100054.753cb4de@doriath.home> In-Reply-To: <20120525100054.753cb4de@doriath.home> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 3/3] qapi: convert sendkey Reply-To: jcody@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: aliguori@us.ibm.com, Amos Kong , Eric Blake , qemu-devel@nongnu.org On 05/25/2012 09:00 AM, Luiz Capitulino wrote: > On Fri, 25 May 2012 14:20:33 +0800 > Amos Kong wrote: > >> On 25/05/12 11:51, Eric Blake wrote: >>> On 05/24/2012 09:32 PM, Amos Kong wrote: >>>> Convert 'sendkey' to use. do_sendkey() depends on some variables >>>> in monitor.c, so reserve qmp_sendkey() to monitor.c >>>> Rename 'string' to 'keys', rename 'hold_time' to 'hold-time' >>>> >>>> Signed-off-by: Amos Kong >>> >>>> +## >>>> +# @sendkey: >>>> +# >>>> +# Send keys to VM. >>>> +# >>>> +# @keys: key sequence >>>> +# @hold-time: time to delay key up events >>>> +# >>>> +# Returns: Nothing on success >>>> +# If key is unknown or redundant, QERR_INVALID_PARAMETER >>>> +# If key is invalid, QERR_INVALID_PARAMETER_VALUE >>>> +# >>>> +# Notes: Send @var{keys} to the emulator. @var{keys} could be the name of the >>>> +# key or the raw value in either decimal or hexadecimal format. Use >>>> +# @code{-} to press several keys simultaneously. >>>> +# >>>> +# Since: 0.14.0 >>>> +## >>>> +{ 'command': 'sendkey', 'data': {'keys': 'str', '*hold-time': 'int'} } >>> >>> Rather than making 'keys' a free-form string where qemu then has to >>> parse '-' to separate keys, should we instead make it a JSON array? For >>> example, >> >> >> Anthony, Luiz, Daniel, what's your opinion? > > I agree it's better. > >>> { "execute":"sendkey", "data":{ "keys":["ctrl", "alt", "del"], >>> "hold-time":200 } } >> >> How to make it compatible with hum command? Still use 'ctrl-alt-delete' >> for hum, separate keys and generate an array in hum_sendkey() before >> calling qmp_sendkey()? > > Yes. Basically, you'll move the parsing code to hmp_sendkey() and build > a QList to be passed to qmp_sendkey(). You can take a look at > tests/check-qlist.c for examples on how to work with qlists. > >> And I'm know clear about how to define command in qapi-schema.json, >> I didn't find exist example, any clue? >> >> { 'command': 'sendkey', 'data': { 'keys': [ 'str'], '*hold-time': >> 'int'} } >> -- >> { 'type': 'Key', 'data': {'name': 'str'} } >> { 'command': 'sendkey', 'data': { 'keys': [ 'Key' ], '*hold-time': >> 'int'} } > > Jeff, didn't you implement this? Something similar with group snapshots - it had a command that took an array input. So I think the schema for what Eric had above would be something like: { 'type': 'Sendkey', 'data': {'key': 'str' } } { 'command': 'sendkey', 'data': { 'keylist': [ 'Sendkey' ], '*hold-time': 'int' } } (But after typing this I see Anthony has proposed a schema using enums)