From nobody Sun Feb 8 19:59:59 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 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=1571920569; cv=none; d=zoho.com; s=zohoarc; b=kcJ3SCz9P6XeZa5Cy5+wpK7K6S0iykY9Y5Z/4aZKJzqW26IN4mXQ/m7gD4SGJLxyiEqJwdV03HDNeRiKzDvbJlojXqDGq9eDpTGZRURxWtLvYdA/DB3M+WD+OrhOL2ZZIbHll6bgoRHNFHIJb/0XOymvwRWNiEr37Xivp+KEwVA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571920569; h=Content-Type: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; bh=aasGP68poqHNgPWiovdNiTbbIbH25VqckB+BhIQNShU=; b=olPmXJf9rIuY4KW9npX4gRRA5MY+KDzN0lu5+FXj8tsSkPuQMaNcRO9on+/Nig0y4rOYjK6i6WD5n5Iliyrd4iWq6kCRpLv/bpEM+zqfI77tseDC4FoHx+o4z2ttFfrbPSHQYcBO/voV8D6n8vHB0rau8CNlk7GLuy6bDFqquMA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1571920569618465.4757438963545; Thu, 24 Oct 2019 05:36:09 -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-310-CZxDSGIcOB-NvKBS013AOg-1; Thu, 24 Oct 2019 08:35:33 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BD4A71800E0D; Thu, 24 Oct 2019 12:35:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 90F8210027AD; Thu, 24 Oct 2019 12:35:26 +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 45C7D180BA9E; Thu, 24 Oct 2019 12:35:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9OCZAsZ004511 for ; Thu, 24 Oct 2019 08:35:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 021D660167; Thu, 24 Oct 2019 12:35:10 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.36.118.123]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9CC7760166; Thu, 24 Oct 2019 12:35:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 37D1D112FB55; Thu, 24 Oct 2019 14:34:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571920568; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=aasGP68poqHNgPWiovdNiTbbIbH25VqckB+BhIQNShU=; b=UgTPn/RczXs01wruiPbYR4EKw2ovDWX0ajekYGE1jcXUHvqzrFpv+HtZYKtqsrqYqfMH5W +e1sLxtNjylNsc4mR/+YKYwyKUy+KL6VMM+Dw1Njiy1tcW8fbTluk0z19hf/czkwgWFey9 JaEPoU+onagoq46ig7cPTfvTF/d/ir4= From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 24 Oct 2019 14:34:58 +0200 Message-Id: <20191024123458.13505-20-armbru@redhat.com> In-Reply-To: <20191024123458.13505-1-armbru@redhat.com> References: <20191024123458.13505-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 19/19] qapi: Implement -compat deprecated-output=hide for events 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.84 on 10.5.11.22 X-MC-Unique: CZxDSGIcOB-NvKBS013AOg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This policy suppresses deprecated events, and thus permits "testing the future". No QMP event is deprecated right now. Signed-off-by: Markus Armbruster --- qapi/common.json | 4 ++-- tests/test-qmp-event.c | 17 +++++++++++++++++ qemu-options.hx | 4 +++- scripts/qapi/events.py | 14 ++++++++++++-- 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/qapi/common.json b/qapi/common.json index 06e54642bb..4e3da4beee 100644 --- a/qapi/common.json +++ b/qapi/common.json @@ -167,14 +167,14 @@ # Policy for handling "funny" output. # # @accept: Pass on unchanged -# TODO @hide: Filter out +# @hide: Filter out # # FIXME Guidance on intended use. # # Since: 4.2 ## { 'enum': 'CompatPolicyOutput', - 'data': [ 'accept' ] } + 'data': [ 'accept', 'hide' ] } =20 ## # @CompatPolicy: diff --git a/tests/test-qmp-event.c b/tests/test-qmp-event.c index 7dd0053190..303c8d6382 100644 --- a/tests/test-qmp-event.c +++ b/tests/test-qmp-event.c @@ -14,6 +14,7 @@ #include "qemu/osdep.h" =20 #include "qemu-common.h" +#include "qapi/compat-policy.h" #include "qapi/error.h" #include "qapi/qmp/qbool.h" #include "qapi/qmp/qdict.h" @@ -140,6 +141,21 @@ static void test_event_d(TestEventData *data, qobject_unref(data->expect); } =20 +static void test_event_deprecated(TestEventData *data, const void *unused) +{ + data->expect =3D qdict_from_jsonf_nofail("{ 'event': 'TEST-EVENT-FEATU= RES1' }"); + + qapi_event_send_test_event_features1(); + g_assert(data->emitted); + + qapi_compat_policy.deprecated_output =3D COMPAT_POLICY_OUTPUT_HIDE; + data->emitted =3D false; + qapi_event_send_test_event_features1(); + g_assert(!data->emitted); + + qobject_unref(data->expect); +} + int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); @@ -148,6 +164,7 @@ int main(int argc, char **argv) event_test_add("/event/event_b", test_event_b); event_test_add("/event/event_c", test_event_c); event_test_add("/event/event_d", test_event_d); + event_test_add("/event/deprecated", test_event_deprecated); g_test_run(); =20 return 0; diff --git a/qemu-options.hx b/qemu-options.hx index 645629457a..c0128813c6 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3320,7 +3320,7 @@ STEXI ETEXI =20 DEF("compat", HAS_ARG, QEMU_OPTION_compat, - "-compat [deprecated-input=3Daccept|reject|crash][,deprecated-output= =3Daccept]\n" + "-compat [deprecated-input=3Daccept|reject|crash][,deprecated-output= =3Daccept|hide]\n" " Policy for handling deprecated management interfaces\= n", QEMU_ARCH_ALL) STEXI @@ -3337,6 +3337,8 @@ Reject deprecated commands Crash on deprecated command @item deprecated-output=3Daccept (default) Emit deprecated events +@item deprecated-output=3Dhide +Suppress deprecated events @end table FIXME Guidance on intended use ETEXI diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index f64e61076e..5778fa1a0d 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -61,7 +61,8 @@ def gen_param_var(typ): return ret =20 =20 -def gen_event_send(name, arg_type, boxed, event_enum_name, event_emit): +def gen_event_send(name, arg_type, features, boxed, + event_enum_name, event_emit): # FIXME: Our declaration of local variables (and of 'errp' in the # parameter list) can collide with exploded members of the event's # data type passed in as parameters. If this collision ever hits in @@ -86,6 +87,14 @@ def gen_event_send(name, arg_type, boxed, event_enum_nam= e, event_emit): if not boxed: ret +=3D gen_param_var(arg_type) =20 + if 'deprecated' in [f.name for f in features]: + ret +=3D mcgen(''' + + if (qapi_compat_policy.deprecated_output =3D=3D COMPAT_POLICY_OUTPUT_H= IDE) { + return; + } +''') + ret +=3D mcgen(''' =20 qmp =3D qmp_event_build_dict("%(name)s"); @@ -154,6 +163,7 @@ class QAPISchemaGenEventVisitor(QAPISchemaModularCVisit= or): #include "%(prefix)sqapi-emit-events.h" #include "%(events)s.h" #include "%(visit)s.h" +#include "qapi/compat-policy.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" #include "qapi/qobject-output-visitor.h" @@ -192,7 +202,7 @@ void %(event_emit)s(%(event_enum)s event, QDict *qdict); def visit_event(self, name, info, ifcond, features, arg_type, boxed): with ifcontext(ifcond, self._genh, self._genc): self._genh.add(gen_event_send_decl(name, arg_type, boxed)) - self._genc.add(gen_event_send(name, arg_type, boxed, + self._genc.add(gen_event_send(name, arg_type, features, boxed, self._event_enum_name, self._event_emit_name)) # Note: we generate the enum member regardless of @ifcond, to --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list