From nobody Sat Feb 7 05:57:24 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1635139591; cv=none; d=zohomail.com; s=zohoarc; b=breQNxYKavwNDGOGrhBuPBVSxh0jFks6Sp8/eDpANx9U487e4gMFjiFgyccVlzYF1gaROZqS5xe/fZQ/hvshzgeOZY8Mi1vyA06ZQwqwjb002AeU3cZ79bz5Ur9YZvP6U1PhuqAvZu0+PVGjUhiL3gSTqaOzNG9t0Pp/W/nxG+E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635139591; 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=Io7pCakK7oxbs6TfwoCw9fOsoLesVQPLShOHgc7y95c=; b=FI1zdD95cdNN2NL0eGWZyKDVG8D0mmTefbPcKIaX0tHigaUi9BX3E2xQljJDZo0Jlmy5XUwV0VjskcJeIEMC5HSelE0xhppJr4pKJpQvkN+/BO5gznIZ7cyKVLyPfZx0BiVG15b6t9M2tWnhXuM4f/pGiIplbysEiQGhWiJFWT0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1635139591580274.2593597682985; Sun, 24 Oct 2021 22:26:31 -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-225-w6ZpZAT3OCCq62ynxyz-nQ-1; Mon, 25 Oct 2021 01:26:27 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 27A1218125C0; Mon, 25 Oct 2021 05:26:22 +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 DEF7A5C1CF; Mon, 25 Oct 2021 05:26:21 +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 873504EA47; Mon, 25 Oct 2021 05:26:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19P5Pumh019979 for ; Mon, 25 Oct 2021 01:25:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 856815E27A; Mon, 25 Oct 2021 05:25:56 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-7.ams2.redhat.com [10.36.112.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 511155DD68; Mon, 25 Oct 2021 05:25:48 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E5C3411380CF; Mon, 25 Oct 2021 07:25:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635139590; 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=Io7pCakK7oxbs6TfwoCw9fOsoLesVQPLShOHgc7y95c=; b=duYDpvWJrgcFA3LWpGic+gQ75GeRSu+mhnPzOK2bpmzm+XIoE/ngOZH1Jw8YT+RspLnqlE fzN5OEtDrP9yZNBjwnGylUu72KhcjuSfpN+AH/SY5c88lRr9SzJXUGBRO4cI48pKatIddw s53oziZJN9cp9wVTmi4J1374BkTDzgY= X-MC-Unique: w6ZpZAT3OCCq62ynxyz-nQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 7/9] qapi: Generalize enum member policy checking Date: Mon, 25 Oct 2021 07:25:30 +0200 Message-Id: <20211025052532.3859634-8-armbru@redhat.com> In-Reply-To: <20211025052532.3859634-1-armbru@redhat.com> References: <20211025052532.3859634-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: kwolf@redhat.com, pkrempa@redhat.com, ehabkost@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, libvir-list@redhat.com, eblake@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com, marcandre.lureau@redhat.com, jsnow@redhat.com, libguestfs@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.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1635139592429100003 Content-Type: text/plain; charset="utf-8" The code to check enumeration value policy can see special feature flag 'deprecated' in QEnumLookup member flags[value]. I want to make feature flag 'unstable' visible there as well, so I can add policy for it. Instead of extending flags[], replace it by @special_features (a bitset of QapiSpecialFeature), because that's how special features get passed around elsewhere. Signed-off-by: Markus Armbruster --- include/qapi/util.h | 5 +---- qapi/qapi-visit-core.c | 3 ++- scripts/qapi/types.py | 22 ++++++++++++---------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/qapi/util.h b/include/qapi/util.h index 7a8d5c7d72..0cc98db9f9 100644 --- a/include/qapi/util.h +++ b/include/qapi/util.h @@ -15,12 +15,9 @@ typedef enum { QAPI_DEPRECATED, } QapiSpecialFeature; =20 -/* QEnumLookup flags */ -#define QAPI_ENUM_DEPRECATED 1 - typedef struct QEnumLookup { const char *const *array; - const unsigned char *const flags; + const unsigned char *const special_features; const int size; } QEnumLookup; =20 diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index b4a81f1757..5572d90efb 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -407,7 +407,8 @@ static bool input_type_enum(Visitor *v, const char *nam= e, int *obj, return false; } =20 - if (lookup->flags && (lookup->flags[value] & QAPI_ENUM_DEPRECATED)) { + if (lookup->special_features + && (lookup->special_features[value] & QAPI_DEPRECATED)) { switch (v->compat_policy.deprecated_input) { case COMPAT_POLICY_INPUT_ACCEPT: break; diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index ab2441adc9..3013329c24 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -16,7 +16,7 @@ from typing import List, Optional =20 from .common import c_enum_const, c_name, mcgen -from .gen import QAPISchemaModularCVisitor, ifcontext +from .gen import QAPISchemaModularCVisitor, gen_special_features, ifcontext from .schema import ( QAPISchema, QAPISchemaEnumMember, @@ -39,7 +39,7 @@ def gen_enum_lookup(name: str, members: List[QAPISchemaEnumMember], prefix: Optional[str] =3D None) -> str: max_index =3D c_enum_const(name, '_MAX', prefix) - flags =3D '' + feats =3D '' ret =3D mcgen(''' =20 const QEnumLookup %(c_name)s_lookup =3D { @@ -54,19 +54,21 @@ def gen_enum_lookup(name: str, ''', index=3Dindex, name=3Dmemb.name) ret +=3D memb.ifcond.gen_endif() - if 'deprecated' in (f.name for f in memb.features): - flags +=3D mcgen(''' - [%(index)s] =3D QAPI_ENUM_DEPRECATED, -''', - index=3Dindex) =20 - if flags: + special_features =3D gen_special_features(memb.features) + if special_features !=3D '0': + feats +=3D mcgen(''' + [%(index)s] =3D %(special_features)s, +''', + index=3Dindex, special_features=3Dspecial_featu= res) + + if feats: ret +=3D mcgen(''' }, - .flags =3D (const unsigned char[%(max_index)s]) { + .special_features =3D (const unsigned char[%(max_index)s]) { ''', max_index=3Dmax_index) - ret +=3D flags + ret +=3D feats =20 ret +=3D mcgen(''' }, --=20 2.31.1