From patchwork Thu Nov 16 13:05:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 10061133 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B380760230 for ; Thu, 16 Nov 2017 13:19:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A41A227F10 for ; Thu, 16 Nov 2017 13:19:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9914D2AA29; Thu, 16 Nov 2017 13:19:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4194227F10 for ; Thu, 16 Nov 2017 13:19:31 +0000 (UTC) Received: from localhost ([::1]:40827 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eFK4o-0000xx-DX for patchwork-qemu-devel@patchwork.kernel.org; Thu, 16 Nov 2017 08:19:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eFJt8-0008Lv-Lh for qemu-devel@nongnu.org; Thu, 16 Nov 2017 08:07:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eFJt7-0007Cc-KT for qemu-devel@nongnu.org; Thu, 16 Nov 2017 08:07:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54438) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eFJt7-0007Bf-Br for qemu-devel@nongnu.org; Thu, 16 Nov 2017 08:07:25 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 93323285BA; Thu, 16 Nov 2017 13:07:24 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-111.nay.redhat.com [10.66.14.111]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA35E605D8; Thu, 16 Nov 2017 13:07:20 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 16 Nov 2017 21:05:54 +0800 Message-Id: <20171116130610.23582-12-peterx@redhat.com> In-Reply-To: <20171116130610.23582-1-peterx@redhat.com> References: <20171116130610.23582-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 16 Nov 2017 13:07:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v4 11/27] qmp: introduce QMPCapability X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Fam Zheng , Juan Quintela , mdroth@linux.vnet.ibm.com, peterx@redhat.com, Markus Armbruster , marcandre.lureau@redhat.com, Stefan Hajnoczi , Paolo Bonzini , "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP There was no QMP capabilities defined. Define the first "oob" as capability to allow out-of-band messages. Also, touch up qmp-test.c to test the new bits. Signed-off-by: Peter Xu --- monitor.c | 15 +++++++++++++-- qapi-schema.json | 13 +++++++++++++ tests/qmp-test.c | 10 +++++++++- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/monitor.c b/monitor.c index 685938b9f2..468303b472 100644 --- a/monitor.c +++ b/monitor.c @@ -3944,12 +3944,23 @@ void monitor_resume(Monitor *mon) static QObject *get_qmp_greeting(void) { + QDict *result = qdict_new(), *qmp = qdict_new(); + QList *cap_list = qlist_new(); QObject *ver = NULL; + QMPCapability cap; + + qdict_put(result, "QMP", qmp); qmp_marshal_query_version(NULL, &ver, NULL); + qdict_put_obj(qmp, "version", ver); + + for (cap = 0; cap < QMP_CAPABILITY__MAX; cap++) { + qlist_append(cap_list, qstring_from_str( + QMPCapability_str(cap))); + } + qdict_put(qmp, "capabilities", cap_list); - return qobject_from_jsonf("{'QMP': {'version': %p, 'capabilities': []}}", - ver); + return QOBJECT(result); } static void monitor_qmp_event(void *opaque, int event) diff --git a/qapi-schema.json b/qapi-schema.json index 18457954a8..03201578b4 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -119,6 +119,19 @@ { 'command': 'qmp_capabilities' } ## +# @QMPCapability: +# +# QMP supported capabilities to be broadcasted to the clients. +# +# @oob: QMP ability to support Out-Of-Band requests. +# +# Since: 2.12 +# +## +{ 'enum': 'QMPCapability', + 'data': [ 'oob' ] } + +## # @VersionTriple: # # A three-part version number. diff --git a/tests/qmp-test.c b/tests/qmp-test.c index c5a5c10b41..292c5f135a 100644 --- a/tests/qmp-test.c +++ b/tests/qmp-test.c @@ -17,6 +17,7 @@ #include "qapi/qobject-input-visitor.h" #include "qapi/util.h" #include "qapi/visitor.h" +#include "qapi/qmp/qstring.h" const char common_args[] = "-nodefaults -machine none"; @@ -75,6 +76,8 @@ static void test_qmp_protocol(void) { QDict *resp, *q, *ret; QList *capabilities; + const QListEntry *entry; + QString *qstr; global_qtest = qtest_init_without_qmp_handshake(common_args); @@ -84,7 +87,12 @@ static void test_qmp_protocol(void) g_assert(q); test_version(qdict_get(q, "version")); capabilities = qdict_get_qlist(q, "capabilities"); - g_assert(capabilities && qlist_empty(capabilities)); + g_assert(capabilities); + entry = qlist_first(capabilities); + g_assert(entry); + qstr = qobject_to_qstring(entry->value); + g_assert(qstr); + g_assert_cmpstr(qstring_get_str(qstr), ==, "oob"); QDECREF(resp); /* Test valid command before handshake */