From nobody Tue Nov 4 19:05:30 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 1530548680175388.1562798934117; Mon, 2 Jul 2018 09:24:40 -0700 (PDT) Received: from localhost ([::1]:34099 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa1d0-0005h6-Sl for importer@patchew.org; Mon, 02 Jul 2018 12:24:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42442) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa1aq-0004R0-E8 for qemu-devel@nongnu.org; Mon, 02 Jul 2018 12:22:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa1ap-0006bZ-2j for qemu-devel@nongnu.org; Mon, 02 Jul 2018 12:22:24 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47582 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 1fa1ao-0006bB-T7 for qemu-devel@nongnu.org; Mon, 02 Jul 2018 12:22:23 -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 8ACD17CBBA for ; Mon, 2 Jul 2018 16:22:22 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-58.ams2.redhat.com [10.36.116.58]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3EC942166B5D; Mon, 2 Jul 2018 16:22:22 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 818EC1132D75; Mon, 2 Jul 2018 18:22:18 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 2 Jul 2018 18:21:55 +0200 Message-Id: <20180702162218.13678-10-armbru@redhat.com> In-Reply-To: <20180702162218.13678-1-armbru@redhat.com> References: <20180702162218.13678-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.2]); Mon, 02 Jul 2018 16:22:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 02 Jul 2018 16:22:22 +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] [PATCH 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: , Cc: stefanha@redhat.com, peterx@redhat.com, dgilbert@redhat.com 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 --- monitor.c | 14 ++++++++------ qapi/qmp-dispatch.c | 2 -- tests/test-qga.c | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/monitor.c b/monitor.c index b7d74b01b4..4659399b55 100644 --- a/monitor.c +++ b/monitor.c @@ -4263,7 +4263,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; @@ -4278,6 +4278,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) { @@ -4289,16 +4295,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 4edd35535d..564a4594b5 100644 --- a/tests/test-qga.c +++ b/tests/test-qga.c @@ -229,16 +229,16 @@ static void test_qga_ping(gconstpointer fix) =20 static void test_qga_invalid_id(gconstpointer fix) { - /* FIXME "id" is ignored; it should be rejected */ 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