From nobody Mon Feb 9 08:11:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509962134984549.3615101796663; Mon, 6 Nov 2017 01:55:34 -0800 (PST) Received: from localhost ([::1]:47206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBe7r-0001nX-5U for importer@patchew.org; Mon, 06 Nov 2017 04:55:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48699) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBe21-0005Cu-H9 for qemu-devel@nongnu.org; Mon, 06 Nov 2017 04:49:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBe20-0004Zt-I7 for qemu-devel@nongnu.org; Mon, 06 Nov 2017 04:49:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39306) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBe20-0004Yw-An for qemu-devel@nongnu.org; Mon, 06 Nov 2017 04:49:24 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4C33280491; Mon, 6 Nov 2017 09:49:23 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-165.pek2.redhat.com [10.72.12.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E3436A02F; Mon, 6 Nov 2017 09:49:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4C33280491 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=peterx@redhat.com From: Peter Xu To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 17:46:28 +0800 Message-Id: <20171106094643.14881-13-peterx@redhat.com> In-Reply-To: <20171106094643.14881-1-peterx@redhat.com> References: <20171106094643.14881-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 06 Nov 2017 09:49:23 +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 v3 12/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 , Jiri Denemark , "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 7255c110f9..dd192b6b91 100644 --- a/monitor.c +++ b/monitor.c @@ -3944,12 +3944,23 @@ void monitor_resume(Monitor *mon) =20 static QObject *get_qmp_greeting(void) { + QDict *result =3D qdict_new(), *qmp =3D qdict_new(); + QList *cap_list =3D qlist_new(); QObject *ver =3D NULL; + QMPCapability cap; + + qdict_put(result, "QMP", qmp); =20 qmp_marshal_query_version(NULL, &ver, NULL); + qdict_put_obj(qmp, "version", ver); + + for (cap =3D 0; cap < QMP_CAPABILITY__MAX; cap++) { + qlist_append(cap_list, qstring_from_str( + QMPCapability_str(cap))); + } + qdict_put(qmp, "capabilities", cap_list); =20 - return qobject_from_jsonf("{'QMP': {'version': %p, 'capabilities': []}= }", - ver); + return QOBJECT(result); } =20 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' } =20 ## +# @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" =20 const char common_args[] =3D "-nodefaults -machine none"; =20 @@ -75,6 +76,8 @@ static void test_qmp_protocol(void) { QDict *resp, *q, *ret; QList *capabilities; + const QListEntry *entry; + QString *qstr; =20 global_qtest =3D qtest_init_without_qmp_handshake(common_args); =20 @@ -84,7 +87,12 @@ static void test_qmp_protocol(void) g_assert(q); test_version(qdict_get(q, "version")); capabilities =3D qdict_get_qlist(q, "capabilities"); - g_assert(capabilities && qlist_empty(capabilities)); + g_assert(capabilities); + entry =3D qlist_first(capabilities); + g_assert(entry); + qstr =3D qobject_to_qstring(entry->value); + g_assert(qstr); + g_assert_cmpstr(qstring_get_str(qstr), =3D=3D, "oob"); QDECREF(resp); =20 /* Test valid command before handshake */ --=20 2.13.5