From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:44699) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tm1uF-0008Bh-7x for qemu-devel@nongnu.org; Fri, 21 Dec 2012 07:40:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tm1uB-0001Tl-Sh for qemu-devel@nongnu.org; Fri, 21 Dec 2012 07:40:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40157) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tm1uB-0001Sj-Dr for qemu-devel@nongnu.org; Fri, 21 Dec 2012 07:40:47 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBLCegt4025835 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 21 Dec 2012 07:40:44 -0500 Message-ID: <50D458A9.2060705@redhat.com> Date: Fri, 21 Dec 2012 13:40:09 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1355932747-1755-1-git-send-email-kraxel@redhat.com> <50D2ED39.6010608@redhat.com> <20121220105643.GK25577@redhat.com> <50D2F23D.9000908@redhat.com> <50D2FA5D.30602@redhat.com> <50D30C7B.3030802@redhat.com> <50D44BD5.8040003@redhat.com> <50D44DD0.7030003@redhat.com> <50D4534F.9000107@redhat.com> In-Reply-To: <50D4534F.9000107@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH RfC 0/9] chardev hotplug List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: Michal Privoznik , qemu-devel@nongnu.org Il 21/12/2012 13:17, Gerd Hoffmann ha scritto: > { 'type': 'ChardevDummy', 'data': { } } > > { 'union': 'ChardevBackend', 'data': { 'file' : 'ChardevFile', > 'port' : 'ChardevPort', > 'socket' : 'ChardevSocket', > 'pty' : 'ChardevDummy', > 'null' : 'ChardevDummy' } } > > { 'command': 'chardev-add', 'data': {'id' : 'str', > 'backend' : 'ChardevBackend' }, > > ... should accept ... > > {'id': 'test-null', 'backend': {'data': {}, 'type': 'null'}} > > ... as parameters for chardev-add, no? But I get back ... > > {u'error': {u'class': u'GenericError', u'desc': u"Invalid parameter > 'backend'"}} > > ... and can't see what is wrong there ... Me neither, but this quick test seems to work here: $ tests/test-qmp-commands /gerd: test-null 1 OK diff --git a/qapi-schema-test.json b/qapi-schema-test.json index 9eae350..c2e9316 100644 --- a/qapi-schema-test.json +++ b/qapi-schema-test.json @@ -36,3 +36,12 @@ { 'command': 'user_def_cmd', 'data': {} } { 'command': 'user_def_cmd1', 'data': {'ud1a': 'UserDefOne'} } { 'command': 'user_def_cmd2', 'data': {'ud1a': 'UserDefOne', 'ud1b': 'UserDefOne'}, 'returns': 'UserDefTwo' } + + +{ 'type': 'ChardevDummy', 'data': { } } + +{ 'union': 'ChardevBackend', 'data': { 'pty' : 'ChardevDummy', + 'null' : 'ChardevDummy' } } + +{ 'command': 'chardev-add', 'data': {'id' : 'str', + 'backend' : 'ChardevBackend' } } diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c index 5a3e82a..96396db 100644 --- a/tests/test-qmp-commands.c +++ b/tests/test-qmp-commands.c @@ -55,6 +55,11 @@ static void test_dispatch_cmd(void) QDECREF(req); } +void qmp_chardev_add(const char *id, ChardevBackend *backend, Error **errp) +{ + printf("%s %d\n", id, backend->kind); +} + /* test commands that return an error due to invalid parameters */ static void test_dispatch_cmd_error(void) { @@ -71,6 +76,20 @@ static void test_dispatch_cmd_error(void) QDECREF(req); } +static void test_dispatch_gerd(void) +{ + QObject *req = qobject_from_json( + "{'execute': 'chardev-add', " + " 'arguments': {'id': 'test-null', " + " 'backend': {'data': {}, 'type': 'null'}}} "); + QObject *resp = qmp_dispatch(req); + assert(resp != NULL); + assert(!qdict_haskey(qobject_to_qdict(resp), "error")); + + qobject_decref(resp); + qobject_decref(req); +} + /* test commands that involve both input parameters and return values */ static void test_dispatch_cmd_io(void) { @@ -174,6 +193,7 @@ int main(int argc, char **argv) g_test_add_func("/0.15/dispatch_cmd_io", test_dispatch_cmd_io); g_test_add_func("/0.15/dealloc_types", test_dealloc_types); g_test_add_func("/0.15/dealloc_partial", test_dealloc_partial); + g_test_add_func("/gerd", test_dispatch_gerd); module_call_init(MODULE_INIT_QAPI); g_test_run(); Paolo