From nobody Tue Nov 4 18:29:23 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153065493949289.41388025774961; Tue, 3 Jul 2018 14:55:39 -0700 (PDT) Received: from localhost ([::1]:42961 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faTGs-00073q-Mt for importer@patchew.org; Tue, 03 Jul 2018 17:55:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50359) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSxv-00085O-GN for qemu-devel@nongnu.org; Tue, 03 Jul 2018 17:36:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faSxr-00069i-MI for qemu-devel@nongnu.org; Tue, 03 Jul 2018 17:36:03 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45976 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faSxr-00068f-Ea for qemu-devel@nongnu.org; Tue, 03 Jul 2018 17:35:59 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F31F0400589B for ; Tue, 3 Jul 2018 21:35:58 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-126.ams2.redhat.com [10.36.116.126]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B1A542166BA9 for ; Tue, 3 Jul 2018 21:35:58 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 954941132D75; Tue, 3 Jul 2018 23:35:56 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 3 Jul 2018 23:35:33 +0200 Message-Id: <20180703213556.20619-10-armbru@redhat.com> In-Reply-To: <20180703213556.20619-1-armbru@redhat.com> References: <20180703213556.20619-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 03 Jul 2018 21:35:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 03 Jul 2018 21:35:59 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'armbru@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL v2 09/32] qmp qemu-ga: Revert change that accidentally made qemu-ga accept "id" 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: , 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" Commit cf869d53172 "qmp: support out-of-band (oob) execution" changed how we check "id": Note that in the patch I exported qmp_dispatch_check_obj() to be used to check the request earlier, and at the same time allowed "id" field to be there since actually we always allow that. The part after "and" is ill-advised: it makes qemu-ga accept and ignore "id". Revert. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20180703085358.13941-10-armbru@redhat.com> --- monitor.c | 14 ++++++++------ qapi/qmp-dispatch.c | 2 -- tests/test-qga.c | 13 +++++-------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/monitor.c b/monitor.c index 0dd6e22463..7245ee37ce 100644 --- a/monitor.c +++ b/monitor.c @@ -4264,7 +4264,7 @@ static void monitor_qmp_bh_dispatcher(void *data) static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens) { QObject *req, *id =3D NULL; - QDict *qdict =3D NULL; + QDict *qdict; MonitorQMP *mon_qmp =3D container_of(parser, MonitorQMP, parser); Monitor *mon =3D container_of(mon_qmp, Monitor, qmp); Error *err =3D NULL; @@ -4279,6 +4279,12 @@ static void handle_qmp_command(JSONMessageParser *pa= rser, GQueue *tokens) goto err; } =20 + qdict =3D qobject_to(QDict, req); + if (qdict) { + id =3D qobject_ref(qdict_get(qdict, "id")); + qdict_del(qdict, "id"); + } /* else will fail qmp_dispatch() */ + /* Check against the request in general layout */ qdict =3D qmp_dispatch_check_obj(req, &err); if (!qdict) { @@ -4290,16 +4296,12 @@ static void handle_qmp_command(JSONMessageParser *p= arser, GQueue *tokens) goto err; } =20 - id =3D qdict_get(qdict, "id"); - req_obj =3D g_new0(QMPRequest, 1); req_obj->mon =3D mon; - req_obj->id =3D qobject_ref(id); + req_obj->id =3D id; req_obj->req =3D req; req_obj->need_resume =3D false; =20 - qdict_del(qdict, "id"); - if (qmp_is_oob(qdict)) { /* Out-of-band (OOB) requests are executed directly in parser. */ trace_monitor_qmp_cmd_out_of_band(qobject_get_try_str(req_obj->id) diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index 935f9e159c..3d5d5e110f 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -52,8 +52,6 @@ QDict *qmp_dispatch_check_obj(const QObject *request, Err= or **errp) "QMP input member 'arguments' must be an object= "); return NULL; } - } else if (!strcmp(arg_name, "id")) { - continue; } else if (!strcmp(arg_name, "control")) { if (qobject_type(arg_obj) !=3D QTYPE_QDICT) { error_setg(errp, diff --git a/tests/test-qga.c b/tests/test-qga.c index 6b632e3da4..564a4594b5 100644 --- a/tests/test-qga.c +++ b/tests/test-qga.c @@ -229,19 +229,16 @@ static void test_qga_ping(gconstpointer fix) =20 static void test_qga_invalid_id(gconstpointer fix) { - /* - * FIXME "id" is ignored; it should either be repeated in the - * reply, or rejected on input - */ const TestFixture *fixture =3D fix; - QDict *ret, *val; + QDict *ret, *error; + const char *class; =20 ret =3D qmp_fd(fixture->fd, "{'execute': 'guest-ping', 'id': 1}"); g_assert_nonnull(ret); - qmp_assert_no_error(ret); =20 - val =3D qdict_get_qdict(ret, "return"); - g_assert(!qdict_haskey(val, "id")); + error =3D qdict_get_qdict(ret, "error"); + class =3D qdict_get_try_str(error, "class"); + g_assert_cmpstr(class, =3D=3D, "GenericError"); =20 qobject_unref(ret); } --=20 2.17.1