From nobody Wed Nov 12 10:08:41 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569696120; cv=none; d=zoho.com; s=zohoarc; b=QXdX6+juvPRJ4V9vi0dge8KihXfhAMQJ0GcAWZdG2IQXuOhjcv0tcOUj6g95OlTnWo4SzwZxeWNdZO+ooyzcOs8WrHRQD92GFgedSo/JazTKKyaXyLWkAq7uMxq40JL7SHTqkTPAOwZs8yJvSSFt1b2WRIdl12Gi5hLDp71PhyA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569696120; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=hBUqu7Ey60FPR6S5HIhG2NUuUmdLiCVnUf2eT+8b3FE=; b=JsWI/CY8MWfbMCtbIw1Lvogn/YgXhuhWRvJ4sHdSU8FSCdBzFat7Teev+Hq16Sw5Onl6M8i/k85CEp4+DLT6HDdp0LwxMS2ydeRpKaLiIGRyn3Rfmns7EkjUV4f69EXipJLgAvO69B7TTm2cR3M7aRhuEAZwSJgohBzAeqAtrsY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156969612052278.35085730092032; Sat, 28 Sep 2019 11:42:00 -0700 (PDT) Received: from localhost ([::1]:34360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iEHfF-0001t1-Jx for importer@patchew.org; Sat, 28 Sep 2019 14:41:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43841) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iEHd6-0008PY-57 for qemu-devel@nongnu.org; Sat, 28 Sep 2019 14:39:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iEHd3-0003pH-Kx for qemu-devel@nongnu.org; Sat, 28 Sep 2019 14:39:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46884) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iEHd3-0003ny-EA for qemu-devel@nongnu.org; Sat, 28 Sep 2019 14:39:37 -0400 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 ADF1F20FC for ; Sat, 28 Sep 2019 18:39:36 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-117-142.ams2.redhat.com [10.36.117.142]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7D25260852; Sat, 28 Sep 2019 18:39:35 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2B750113865F; Sat, 28 Sep 2019 20:39:34 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 01/27] qmp-dispatch: Use CommandNotFound error for disabled commands Date: Sat, 28 Sep 2019 20:39:08 +0200 Message-Id: <20190928183934.12459-2-armbru@redhat.com> In-Reply-To: <20190928183934.12459-1-armbru@redhat.com> References: <20190928183934.12459-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.71]); Sat, 28 Sep 2019 18:39:36 +0000 (UTC) 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: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal Privoznik Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Michal Privoznik If a command is disabled an error is reported. But due to usage of error_setg() the class of the error is GenericError which does not help callers in distinguishing this case from a case where a qmp command fails regularly due to other reasons. We used to use class CommandDisabled until the great error simplification (commit de253f1491 for QMP and commit 93b91c59db for qemu-ga, both v1.2.0). Use CommandNotFound error class, which is close enough. Signed-off-by: Michal Privoznik Message-Id: Reviewed-by: Eric Blake [Test update squashed in, commit message tweaked] Signed-off-by: Markus Armbruster --- qapi/qmp-dispatch.c | 5 +++-- tests/test-qga.c | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index 3037d353a4..bc264b3c9b 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -104,8 +104,9 @@ static QObject *do_qmp_dispatch(QmpCommandList *cmds, Q= Object *request, return NULL; } if (!cmd->enabled) { - error_setg(errp, "The command %s has been disabled for this instan= ce", - command); + error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND, + "The command %s has been disabled for this instance", + command); return NULL; } if (oob && !(cmd->options & QCO_ALLOW_OOB)) { diff --git a/tests/test-qga.c b/tests/test-qga.c index 891aa3d322..1ca49bbced 100644 --- a/tests/test-qga.c +++ b/tests/test-qga.c @@ -668,7 +668,7 @@ static void test_qga_blacklist(gconstpointer data) error =3D qdict_get_qdict(ret, "error"); class =3D qdict_get_try_str(error, "class"); desc =3D qdict_get_try_str(error, "desc"); - g_assert_cmpstr(class, =3D=3D, "GenericError"); + g_assert_cmpstr(class, =3D=3D, "CommandNotFound"); g_assert_nonnull(g_strstr_len(desc, -1, "has been disabled")); qobject_unref(ret); =20 @@ -677,7 +677,7 @@ static void test_qga_blacklist(gconstpointer data) error =3D qdict_get_qdict(ret, "error"); class =3D qdict_get_try_str(error, "class"); desc =3D qdict_get_try_str(error, "desc"); - g_assert_cmpstr(class, =3D=3D, "GenericError"); + g_assert_cmpstr(class, =3D=3D, "CommandNotFound"); g_assert_nonnull(g_strstr_len(desc, -1, "has been disabled")); qobject_unref(ret); =20 --=20 2.21.0