From nobody Sun Oct 5 19:23:35 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 1522161879863103.42056475485754; Tue, 27 Mar 2018 07:44:39 -0700 (PDT) Received: from localhost ([::1]:34681 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0pq3-0001pz-3M for importer@patchew.org; Tue, 27 Mar 2018 10:44:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49266) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0pcO-0007Um-RX for qemu-devel@nongnu.org; Tue, 27 Mar 2018 10:30:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f0pcK-0004yE-Oq for qemu-devel@nongnu.org; Tue, 27 Mar 2018 10:30:32 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49334 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 1f0pcK-0004xx-GP for qemu-devel@nongnu.org; Tue, 27 Mar 2018 10:30:28 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1D7CD4072CC5 for ; Tue, 27 Mar 2018 14:30:28 +0000 (UTC) Received: from red.redhat.com (ovpn-121-135.rdu2.redhat.com [10.10.121.135]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A40A8442C; Tue, 27 Mar 2018 14:30:25 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Tue, 27 Mar 2018 09:30:06 -0500 Message-Id: <20180327143014.1767669-7-eblake@redhat.com> In-Reply-To: <20180327143014.1767669-1-eblake@redhat.com> References: <20180327143014.1767669-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 27 Mar 2018 14:30:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 27 Mar 2018 14:30:28 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eblake@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable 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 06/14] qmp: fix qmp_capabilities error regression 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: "Dr. David Alan Gilbert" , Peter Xu , Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Peter Xu When someone sends a command before QMP handshake, the error used to be like this: {"execute": "query-cpus"} {"error": {"class": "CommandNotFound", "desc": "Expecting capabilities negotiation with 'qmp_capabilities'"}} While after cf869d5317 it becomes: {"execute": "query-cpus"} {"error": {"class": "CommandNotFound", "desc": "The command query-cpus has not been found"}} Fix it back to the nicer one. Fixes: cf869d5317 ("qmp: support out-of-band (oob) execution", 2018-03-19) Reported-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Peter Xu Message-Id: <20180326063901.27425-2-peterx@redhat.com> Reported-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eric Blake [eblake: commit message grammar tweaks] Signed-off-by: Eric Blake Reviewed-by (not x2 Reported-by ;) --- monitor.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/monitor.c b/monitor.c index de709fc2e5d..3b1ef34711b 100644 --- a/monitor.c +++ b/monitor.c @@ -1203,8 +1203,14 @@ static bool qmp_cmd_oob_check(Monitor *mon, QDict *r= eq, Error **errp) cmd =3D qmp_find_command(mon->qmp.commands, command); if (!cmd) { - error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND, - "The command %s has not been found", command); + if (mon->qmp.commands =3D=3D &qmp_cap_negotiation_commands) { + error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND, + "Expecting capabilities negotiation " + "with 'qmp_capabilities'"); + } else { + error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND, + "The command %s has not been found", command); + } return false; } @@ -4027,7 +4033,6 @@ static void monitor_qmp_dispatch_one(QMPRequest *req_= obj) { Monitor *mon, *old_mon; QObject *req, *rsp =3D NULL, *id; - QDict *qdict =3D NULL; bool need_resume; req =3D req_obj->req; @@ -4050,18 +4055,6 @@ static void monitor_qmp_dispatch_one(QMPRequest *req= _obj) cur_mon =3D old_mon; - if (mon->qmp.commands =3D=3D &qmp_cap_negotiation_commands) { - qdict =3D qdict_get_qdict(qobject_to(QDict, rsp), "error"); - if (qdict - && !g_strcmp0(qdict_get_try_str(qdict, "class"), - QapiErrorClass_str(ERROR_CLASS_COMMAND_NOT_FOUND))) { - /* Provide a more useful error message */ - qdict_del(qdict, "desc"); - qdict_put_str(qdict, "desc", "Expecting capabilities negotiati= on" - " with 'qmp_capabilities'"); - } - } - /* Respond if necessary */ monitor_qmp_respond(mon, rsp, NULL, id); --=20 2.14.3