From nobody Mon Feb 9 16:53:57 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584347806; cv=none; d=zohomail.com; s=zohoarc; b=AewX5eHzdKpqnZwpbl//KGo1wtvdnwPos3SgPZCqd1GNzicfHyY/OMJ2FvsUG3xX8yZqNMsk8XIDLK7QKP1HwdNoZRaFcyzd59kd7YyYTXO6FomOpZgSwNqZkQSg/foy4WZI0LhJtohp14brgODOJdsbK1NMzJsWrpIsqmgwYv0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584347806; h=Content-Type:Content-Transfer-Encoding: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; bh=BfkgDnIt+OQCi1iUEQ8GWRk40PIcMVBBPNiQUjAOhb4=; b=Fwmwn7DMRpLOUM8DXrKMTjlPQ/hvrNbMCYBQpw2SfvNaS/x10/dZvLwVZ1XUMDd0Bo/fFKwTD53dXjCARut3VmpS/pAjHPS62s5xilrMm6SLV/LQel5UXJUTuBQhOo854aMYHX9zlwuRP1fbsjYEzJuHkMfQ8bJwiJ2mAqd4PxY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1584347806739956.8787172698559; Mon, 16 Mar 2020 01:36:46 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-39-WFYDPo_VN5W66F5coXgvng-1; Mon, 16 Mar 2020 04:36:43 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 179DB149C5; Mon, 16 Mar 2020 08:36:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D862C8F374; Mon, 16 Mar 2020 08:36:37 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 846F186FE2; Mon, 16 Mar 2020 08:36:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02G8a1ka026197 for ; Mon, 16 Mar 2020 04:36:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7CDB460BFB; Mon, 16 Mar 2020 08:36:01 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0244A60BF3 for ; Mon, 16 Mar 2020 08:36:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584347805; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=BfkgDnIt+OQCi1iUEQ8GWRk40PIcMVBBPNiQUjAOhb4=; b=N9GP24QXSFk0DUkh41kARsFAS5nk3+c/JLgYdNT5xPQgDPPRo5EmaBaqi0gIunDPWgXIz1 pDRpvpIVCKq5x/wnSuIE4ScRW9tuByN6KTuq+q5z6xA/SnUc7l8pF9xOK9cOIu+SIOl30O ffsAEoEDYxm7GquKEjJ0lNsK2T9r9uw= X-MC-Unique: WFYDPo_VN5W66F5coXgvng-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/12] qemuAgentCommand: Wire up suppressing of error reporting for unsupported commands Date: Mon, 16 Mar 2020 09:35:46 +0100 Message-Id: <71172e260c665d07b0ec7457d38018c36d8b556b.1584347691.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In some cases we don't want to log errors if an agent command is unsupported. Wire it up into qemuAgentCheckError via qemuAgentCommandFull and provide a thin wrapper (qemuAgentCommand) to prevent having to fix all callers. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_agent.c | 45 +++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 8790c47b87..bc5d57ab94 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1051,7 +1051,8 @@ qemuAgentCommandName(virJSONValuePtr cmd) static int qemuAgentCheckError(virJSONValuePtr cmd, - virJSONValuePtr reply) + virJSONValuePtr reply, + bool report_unsupported) { if (virJSONValueObjectHasKey(reply, "error")) { virJSONValuePtr error =3D virJSONValueObjectGet(reply, "error"); @@ -1063,15 +1064,25 @@ qemuAgentCheckError(virJSONValuePtr cmd, NULLSTR(cmdstr), NULLSTR(replystr)); /* Only send the user the command name + friendly error */ - if (!error) + if (!error) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to execute QEMU agent command '%s'"), qemuAgentCommandName(cmd)); - else - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unable to execute QEMU agent command '%s': %= s"), - qemuAgentCommandName(cmd), - qemuAgentStringifyError(error)); + return -1; + } + + if (!report_unsupported) { + const char *klass =3D virJSONValueObjectGetString(error, "clas= s"); + + if (STREQ_NULLABLE(klass, "CommandNotFound") || + STREQ_NULLABLE(klass, "CommandDisabled")) + return -2; + } + + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unable to execute QEMU agent command '%s': %s"), + qemuAgentCommandName(cmd), + qemuAgentStringifyError(error)); return -1; } else if (!virJSONValueObjectHasKey(reply, "return")) { @@ -1089,10 +1100,11 @@ qemuAgentCheckError(virJSONValuePtr cmd, } static int -qemuAgentCommand(qemuAgentPtr agent, - virJSONValuePtr cmd, - virJSONValuePtr *reply, - int seconds) +qemuAgentCommandFull(qemuAgentPtr agent, + virJSONValuePtr cmd, + virJSONValuePtr *reply, + int seconds, + bool report_unsupported) { int ret =3D -1; qemuAgentMessage msg; @@ -1143,7 +1155,7 @@ qemuAgentCommand(qemuAgentPtr agent, } *reply =3D msg.rxObject; - ret =3D qemuAgentCheckError(cmd, *reply); + ret =3D qemuAgentCheckError(cmd, *reply, report_unsupported); cleanup: VIR_FREE(cmdstr); @@ -1153,6 +1165,15 @@ qemuAgentCommand(qemuAgentPtr agent, return ret; } +static int +qemuAgentCommand(qemuAgentPtr agent, + virJSONValuePtr cmd, + virJSONValuePtr *reply, + int seconds) +{ + return qemuAgentCommandFull(agent, cmd, reply, seconds, true); +} + static virJSONValuePtr G_GNUC_NULL_TERMINATED qemuAgentMakeCommand(const char *cmdname, ...) --=20 2.24.1