From nobody Sat Apr 27 20:57:06 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=1567070128; cv=none; d=zoho.com; s=zohoarc; b=d8B5q8PleFwPp4wKHZJQZ02iSwHfBQB9wyZnUUVAUymulql6mZl1GAPTuvQ4/G/eWbcU8sI6cpXVwa3V5u1bs4070jrwg9YH6qwT+ZJ1Fkru6BEitNKVuCalfDUvZ9A1GJGBvIzrLkICuRMGjQuitalvwLV9fv+ld1GuMoKRzBE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567070128; 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=rhSo4XK/7r3AqTWSdjoOybsW2KhHGpG/eCo6UCqV0Bk=; b=FvjSPpYPDNyqufI9Gn5TwjWHRrZCR1Ks8wrKcc07VJO8KWoVqsegVPiSlvBw/bSC7LMG30toMiXC5eQl9yxd46OcHeGwQhGFwNNzXYW1FGLZ6IwBV/SR48Ut59eUY1YZe+rVxBThJWu3JIyzXS6k0isugKc9c6TqzFy6gx9e0Jk= 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 1567070128434865.8660638598955; Thu, 29 Aug 2019 02:15:28 -0700 (PDT) Received: from localhost ([::1]:47154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i3GWd-00087H-9H for importer@patchew.org; Thu, 29 Aug 2019 05:15:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35262) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i3GVp-0007hA-Ci for qemu-devel@nongnu.org; Thu, 29 Aug 2019 05:14:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i3GVn-0007qK-PN for qemu-devel@nongnu.org; Thu, 29 Aug 2019 05:14:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36244) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i3GVn-0007pd-Hv for qemu-devel@nongnu.org; Thu, 29 Aug 2019 05:14:35 -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 019EE3082145; Thu, 29 Aug 2019 09:14:34 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F9F860872; Thu, 29 Aug 2019 09:14:30 +0000 (UTC) From: Michal Privoznik To: qemu-devel@nongnu.org Date: Thu, 29 Aug 2019 11:14:14 +0200 Message-Id: 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.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 29 Aug 2019 09:14:34 +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] qapi: Reintroduce CommandDisabled error class 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: lcapitulino@redhat.com, armbru@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" If there was a disabled command, then qemu-ga used to report CommandDisabled error class (among with human readable description). This changed in v1.2.0-rc0~28^2~16 in favor of GenericError class. While the change might work for other classes, this one should not have been dropped because it helps callers distinguish the root cause of the error. A bit of background: up until very recently libvirt used qemu-ga in all or nothing way. It didn't care why a qemu-ga command failed. But very recently a new API was introduced which implements 'best effort' approach (in some cases) and thus libvirt must differentiate between: {CommandNotFound, CommandDisabled} and some generic error. While the former classes mean the API can issue some other commands the latter raises a red flag causing the API to fail. This reverts df1e608a01 partially. Signed-off-by: Michal Privoznik --- include/qapi/error.h | 1 + qapi/error.json | 4 +++- qapi/qmp-dispatch.c | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/qapi/error.h b/include/qapi/error.h index 3f95141a01..7116b86a92 100644 --- a/include/qapi/error.h +++ b/include/qapi/error.h @@ -129,6 +129,7 @@ typedef enum ErrorClass { ERROR_CLASS_GENERIC_ERROR =3D QAPI_ERROR_CLASS_GENERICERROR, ERROR_CLASS_COMMAND_NOT_FOUND =3D QAPI_ERROR_CLASS_COMMANDNOTFOUND, + ERROR_CLASS_COMMAND_DISABLED =3D QAPI_ERROR_CLASS_COMMANDDISABLED, ERROR_CLASS_DEVICE_NOT_ACTIVE =3D QAPI_ERROR_CLASS_DEVICENOTACTIVE, ERROR_CLASS_DEVICE_NOT_FOUND =3D QAPI_ERROR_CLASS_DEVICENOTFOUND, ERROR_CLASS_KVM_MISSING_CAP =3D QAPI_ERROR_CLASS_KVMMISSINGCAP, diff --git a/qapi/error.json b/qapi/error.json index 3fad08f506..334d481399 100644 --- a/qapi/error.json +++ b/qapi/error.json @@ -14,6 +14,8 @@ # # @CommandNotFound: the requested command has not been found # +# @CommandDisabled: the requested command has been disabled +# # @DeviceNotActive: a device has failed to be become active # # @DeviceNotFound: the requested device has not been found @@ -25,5 +27,5 @@ ## { 'enum': 'QapiErrorClass', # Keep this in sync with ErrorClass in error.h - 'data': [ 'GenericError', 'CommandNotFound', + 'data': [ 'GenericError', 'CommandNotFound', 'CommandDisabled', 'DeviceNotActive', 'DeviceNotFound', 'KVMMissingCap' ] } diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index 3037d353a4..913b3363cb 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_DISABLED, + "The command %s has been disabled for this instance", + command); return NULL; } if (oob && !(cmd->options & QCO_ALLOW_OOB)) { --=20 2.21.0