From nobody Sun May 5 20:15:43 2024 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=1567172086; cv=none; d=zoho.com; s=zohoarc; b=dFx7OODuYEG+zEnM1SjsiIs/zePQkZB+uZK+D6MyDfTgnL+GICh+3A+wl6843T99IOH1v4I9j5++FdfhCT5jRHY0QJHnL/+2Q7C7uzcogt0dLk/f/FC1kTesBnmac0DsVbzz1+9YIEZ6qGEPOuXOHodrCHWetCx8UhGCNUmWuBU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567172086; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=LK0ehfQoLC3t36H021btryR1nfMF6yrQK+kmIuOxQeM=; b=NijFK14y1qfixqB52mQVNM3/AAQIvx0PuxIlLK+75epteeE60Ngsln+jYrbjX5KFWZKPSM3YPetCc0iY4QEXtM1R8zNpw9lcaHfWuG2j5rT0bVJO7/z3iQJc+jcXzhsSVVvlgEywS6hleY/nn/Nokfv5RySHvzrWHL/oMRKiBbw= 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 156717208666648.2195825097474; Fri, 30 Aug 2019 06:34:46 -0700 (PDT) Received: from localhost ([::1]:58748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i3h37-0001SK-2f for importer@patchew.org; Fri, 30 Aug 2019 09:34:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56079) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i3gyb-0007EZ-QN for qemu-devel@nongnu.org; Fri, 30 Aug 2019 09:30:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i3gyV-0004W5-W6 for qemu-devel@nongnu.org; Fri, 30 Aug 2019 09:30:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47830) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i3gyV-0004Mz-Cf for qemu-devel@nongnu.org; Fri, 30 Aug 2019 09:29:59 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0898D7F75F; Fri, 30 Aug 2019 13:29:56 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83B6960C80; Fri, 30 Aug 2019 13:29:52 +0000 (UTC) From: Michal Privoznik To: qemu-devel@nongnu.org Date: Fri, 30 Aug 2019 15:29:45 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.71]); Fri, 30 Aug 2019 13:29:56 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2] qapi/qmp-dispatch: Fix error class for reporting disabled commands 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: armbru@redhat.com, mdroth@linux.vnet.ibm.com, lcapitulino@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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. Use CommandNotFound error class which is much closer to the actual root cause. Signed-off-by: Michal Privoznik Reviewed-by: Eric Blake --- This is a v2 of: https://lists.nongnu.org/archive/html/qemu-devel/2019-08/msg06327.html diff to v1: - Don't introduce new error class (CommandDisabled) - Use CommandNotFound error class qapi/qmp-dispatch.c | 5 +++-- 1 file changed, 3 insertions(+), 2 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)) { --=20 2.21.0