From nobody Mon Feb 9 14:15:06 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1635416765; cv=none; d=zohomail.com; s=zohoarc; b=EWICf4s84s6daOlbjoZ3iMxw9OJkdTdNyrgKnNGFmzZD2hlfBdiViqoH/T9KxQHi2ODRriHJK+bCg4EJ+kN234LpIOfpCLaDotfN9oQSMAvfqm6DSvLu3QnZMheuTzIPvgb+3QtHu1eF9yRGSNyDAJma1139f02QHZ+q7WhtcGw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635416765; 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=Ucsc0op5freB/08okZxxMNbAEARxymAF+C85pXO3aiw=; b=GYsk1UIK35S63hTAVP+K/jLD5Ej1p4ULQc8KrpWLNbZ9DbSfod5CT2S3yb01+1qKZ+i8aEyNeSE4zg4AKwHEHVkXkrXPopQrYfftQop/otbTnsnZ8L7ZaTW4Q7DoIiavd6S62J7iDjddzbVlnboPZTiSVRQE9CJjUmNxv+2mRmk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1635416765802214.34567906868733; Thu, 28 Oct 2021 03:26:05 -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-148-GIlCA5rcNJqD5ALwQwWrgw-1; Thu, 28 Oct 2021 06:26:00 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AA336806688; Thu, 28 Oct 2021 10:25:55 +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 C6BCF26379; Thu, 28 Oct 2021 10:25:53 +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 65E5F4EA2A; Thu, 28 Oct 2021 10:25:52 +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 19SAPnZM007443 for ; Thu, 28 Oct 2021 06:25:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5774361082; Thu, 28 Oct 2021 10:25:49 +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 66A5460CA0; Thu, 28 Oct 2021 10:25:44 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4F7EF11380CF; Thu, 28 Oct 2021 12:25:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635416764; 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=Ucsc0op5freB/08okZxxMNbAEARxymAF+C85pXO3aiw=; b=KslqTvR5SEYsZ35x0B0xV1pnEBj4mTY/Ibl9kPfw9dmpH32oUIxutUOmZpHkAwwnPeUdJu KYGbPMCCGgeMH5J7c3wGFYICMnT5eDGxO/Nwj2dkoF+pij3IlVplOVPkdDjtd7DnETvNHy N36tkaYxqAuknEmiDklbm6+ArhJgqkw= X-MC-Unique: GIlCA5rcNJqD5ALwQwWrgw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 7/9] qapi: Generalize enum member policy checking Date: Thu, 28 Oct 2021 12:25:18 +0200 Message-Id: <20211028102520.747396-8-armbru@redhat.com> In-Reply-To: <20211028102520.747396-1-armbru@redhat.com> References: <20211028102520.747396-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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, philmd@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.84 on 10.5.11.23 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: 1635416766882100002 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 Acked-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 f95503cbec..34c59286b2 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -408,7 +408,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