From nobody Sun Nov 24 14:47:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1722535249; cv=none; d=zohomail.com; s=zohoarc; b=lS1mkyzjqBT0xws9ftBnx+0uaXvJ0FaT6cJoO5uafo5wzJDsVeSwp1hPEYODZ5IR3sDPUNngKs8qtzyR3vx0dsPsJKG7QQQ6x/p6v/8SORPnNoXF4tGaOkJqYezQmfFjPXHB5GWRpcBVhk5tlFlk7KysWDHLIc97GH61bRL8pkM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722535249; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=N7HvUIXAXJn9znDcZm8ZI4f/9vM4z7F+XF2q7bM5v1w=; b=SqF77238b+3VdPx9ldXfsWYi5ILZiT5bIGKf0V8SERExqmImeKFunBVLt37kuJAPbcdpMZuTA1U5sS0z+C7VOxJNN6CtjjN8axXhV9Ng0vlX1U4EHMSRG2q4NcszBVuDvVyK/k7jq5yf2wKGpTmAA4mBLyrfCqUHnRH1weLsF+Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172253524952115.172006283494284; Thu, 1 Aug 2024 11:00:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZa5N-0001YJ-MR; Thu, 01 Aug 2024 13:59:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZa5L-0001Ww-G0 for qemu-devel@nongnu.org; Thu, 01 Aug 2024 13:59:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZa5J-0005tv-Du for qemu-devel@nongnu.org; Thu, 01 Aug 2024 13:59:31 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-474-z1ZogPgzPkGsb_dUIKAiLw-1; Thu, 01 Aug 2024 13:59:21 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B950319560A2; Thu, 1 Aug 2024 17:59:20 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.17]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id ED9B119560AA; Thu, 1 Aug 2024 17:59:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722535168; h=from:from: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; bh=N7HvUIXAXJn9znDcZm8ZI4f/9vM4z7F+XF2q7bM5v1w=; b=L6sxR1EC0ieYRu9H6s8whTIJJPGR9Yi/fwISXIkkzvoByTnXV+j9ZwVb8Fvc4kM2B4DPdd Y1vbEptNZOHhuBy1Q7XZV2fyBcP3LbW3EG/6GPLeJkw2JV0cvjUjl5xQmbBI1XibuzDzEb 4TTtzoDPKpTkkymn3/sATjVcPiam1qI= X-MC-Unique: z1ZogPgzPkGsb_dUIKAiLw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Thomas Huth , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Michael Roth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH 1/6] qapi: change 'unsigned special_features' to 'uint64_t features' Date: Thu, 1 Aug 2024 18:59:08 +0100 Message-ID: <20240801175913.669013-2-berrange@redhat.com> In-Reply-To: <20240801175913.669013-1-berrange@redhat.com> References: <20240801175913.669013-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.131, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1722535251086116600 The "special_features" field / parameter holds the subset of schema features that are for internal code use. Specifically 'DEPRECATED' and 'UNSTABLE'. This special casing of internal features is going to be removed, so prepare for that by renaming to 'features'. Using a fixed size type is also best practice for bit fields. Signed-off-by: Daniel P. Berrang=C3=A9 --- include/qapi/compat-policy.h | 2 +- include/qapi/qmp/dispatch.h | 4 ++-- include/qapi/util.h | 4 ++-- include/qapi/visitor-impl.h | 4 ++-- include/qapi/visitor.h | 12 ++++++------ qapi/qapi-forward-visitor.c | 8 ++++---- qapi/qapi-util.c | 6 +++--- qapi/qapi-visit-core.c | 12 ++++++------ qapi/qmp-dispatch.c | 2 +- qapi/qmp-registry.c | 4 ++-- qapi/qobject-input-visitor.c | 4 ++-- qapi/qobject-output-visitor.c | 6 +++--- scripts/qapi/types.py | 2 +- 13 files changed, 35 insertions(+), 35 deletions(-) diff --git a/include/qapi/compat-policy.h b/include/qapi/compat-policy.h index 8b7b25c0b5..ea65e10744 100644 --- a/include/qapi/compat-policy.h +++ b/include/qapi/compat-policy.h @@ -18,7 +18,7 @@ =20 extern CompatPolicy compat_policy; =20 -bool compat_policy_input_ok(unsigned special_features, +bool compat_policy_input_ok(uint64_t features, const CompatPolicy *policy, ErrorClass error_class, const char *kind, const char *name, diff --git a/include/qapi/qmp/dispatch.h b/include/qapi/qmp/dispatch.h index f2e956813a..e0ee1ad3ac 100644 --- a/include/qapi/qmp/dispatch.h +++ b/include/qapi/qmp/dispatch.h @@ -33,7 +33,7 @@ typedef struct QmpCommand /* Runs in coroutine context if QCO_COROUTINE is set */ QmpCommandFunc *fn; QmpCommandOptions options; - unsigned special_features; + uint64_t features; QTAILQ_ENTRY(QmpCommand) node; bool enabled; const char *disable_reason; @@ -43,7 +43,7 @@ typedef QTAILQ_HEAD(QmpCommandList, QmpCommand) QmpComman= dList; =20 void qmp_register_command(QmpCommandList *cmds, const char *name, QmpCommandFunc *fn, QmpCommandOptions options, - unsigned special_features); + uint64_t features); const QmpCommand *qmp_find_command(const QmpCommandList *cmds, const char *name); void qmp_disable_command(QmpCommandList *cmds, const char *name, diff --git a/include/qapi/util.h b/include/qapi/util.h index b8254247b8..b377cb9c70 100644 --- a/include/qapi/util.h +++ b/include/qapi/util.h @@ -14,11 +14,11 @@ typedef enum { QAPI_DEPRECATED, QAPI_UNSTABLE, -} QapiSpecialFeature; +} QapiFeature; =20 typedef struct QEnumLookup { const char *const *array; - const unsigned char *const special_features; + const uint64_t *const features; const int size; } QEnumLookup; =20 diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h index 2badec5ba4..7beb0dbfa5 100644 --- a/include/qapi/visitor-impl.h +++ b/include/qapi/visitor-impl.h @@ -115,11 +115,11 @@ struct Visitor =20 /* Optional */ bool (*policy_reject)(Visitor *v, const char *name, - unsigned special_features, Error **errp); + uint64_t features, Error **errp); =20 /* Optional */ bool (*policy_skip)(Visitor *v, const char *name, - unsigned special_features); + uint64_t features); =20 /* Must be set */ VisitorType type; diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index 27b85d4700..f6a9b0743f 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -463,29 +463,29 @@ bool visit_optional(Visitor *v, const char *name, boo= l *present); /* * Should we reject member @name due to policy? * - * @special_features is the member's special features encoded as a - * bitset of QapiSpecialFeature. + * @features is the member's special features encoded as a + * bitset of QapiFeature. * * @name must not be NULL. This function is only useful between * visit_start_struct() and visit_end_struct(), since only objects * have deprecated members. */ bool visit_policy_reject(Visitor *v, const char *name, - unsigned special_features, Error **errp); + uint64_t features, Error **errp); =20 /* * * Should we skip member @name due to policy? * - * @special_features is the member's special features encoded as a - * bitset of QapiSpecialFeature. + * @features is the member's special features encoded as a + * bitset of QapiFeature. * * @name must not be NULL. This function is only useful between * visit_start_struct() and visit_end_struct(), since only objects * have deprecated members. */ bool visit_policy_skip(Visitor *v, const char *name, - unsigned special_features); + uint64_t features); =20 /* * Set policy for handling deprecated management interfaces. diff --git a/qapi/qapi-forward-visitor.c b/qapi/qapi-forward-visitor.c index e36d9bc9ba..6e9a784a9f 100644 --- a/qapi/qapi-forward-visitor.c +++ b/qapi/qapi-forward-visitor.c @@ -246,7 +246,7 @@ static void forward_field_optional(Visitor *v, const ch= ar *name, bool *present) } =20 static bool forward_field_policy_reject(Visitor *v, const char *name, - unsigned special_features, + uint64_t features, Error **errp) { ForwardFieldVisitor *ffv =3D to_ffv(v); @@ -254,18 +254,18 @@ static bool forward_field_policy_reject(Visitor *v, c= onst char *name, if (!forward_field_translate_name(ffv, &name, errp)) { return true; } - return visit_policy_reject(ffv->target, name, special_features, errp); + return visit_policy_reject(ffv->target, name, features, errp); } =20 static bool forward_field_policy_skip(Visitor *v, const char *name, - unsigned special_features) + uint64_t features) { ForwardFieldVisitor *ffv =3D to_ffv(v); =20 if (!forward_field_translate_name(ffv, &name, NULL)) { return true; } - return visit_policy_skip(ffv->target, name, special_features); + return visit_policy_skip(ffv->target, name, features); } =20 static void forward_field_complete(Visitor *v, void *opaque) diff --git a/qapi/qapi-util.c b/qapi/qapi-util.c index 65a7d18437..3d849fe034 100644 --- a/qapi/qapi-util.c +++ b/qapi/qapi-util.c @@ -37,19 +37,19 @@ static bool compat_policy_input_ok1(const char *adjecti= ve, } } =20 -bool compat_policy_input_ok(unsigned special_features, +bool compat_policy_input_ok(uint64_t features, const CompatPolicy *policy, ErrorClass error_class, const char *kind, const char *name, Error **errp) { - if ((special_features & 1u << QAPI_DEPRECATED) + if ((features & 1u << QAPI_DEPRECATED) && !compat_policy_input_ok1("Deprecated", policy->deprecated_input, error_class, kind, name, errp)) { return false; } - if ((special_features & (1u << QAPI_UNSTABLE)) + if ((features & (1u << QAPI_UNSTABLE)) && !compat_policy_input_ok1("Unstable", policy->unstable_input, error_class, kind, name, errp)) { diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index 6c13510a2b..706c61e026 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -141,21 +141,21 @@ bool visit_optional(Visitor *v, const char *name, boo= l *present) } =20 bool visit_policy_reject(Visitor *v, const char *name, - unsigned special_features, Error **errp) + uint64_t features, Error **errp) { trace_visit_policy_reject(v, name); if (v->policy_reject) { - return v->policy_reject(v, name, special_features, errp); + return v->policy_reject(v, name, features, errp); } return false; } =20 bool visit_policy_skip(Visitor *v, const char *name, - unsigned special_features) + uint64_t features) { trace_visit_policy_skip(v, name); if (v->policy_skip) { - return v->policy_skip(v, name, special_features); + return v->policy_skip(v, name, features); } return false; } @@ -409,8 +409,8 @@ static bool input_type_enum(Visitor *v, const char *nam= e, int *obj, return false; } =20 - if (lookup->special_features - && !compat_policy_input_ok(lookup->special_features[value], + if (lookup->features + && !compat_policy_input_ok(lookup->features[value], &v->compat_policy, ERROR_CLASS_GENERIC_ERROR, "value", enum_str, errp)) { diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index 176b549473..d411eebf4e 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -173,7 +173,7 @@ QDict *coroutine_mixed_fn qmp_dispatch(const QmpCommand= List *cmds, QObject *requ "The command %s has not been found", command); goto out; } - if (!compat_policy_input_ok(cmd->special_features, &compat_policy, + if (!compat_policy_input_ok(cmd->features, &compat_policy, ERROR_CLASS_COMMAND_NOT_FOUND, "command", command, &err)) { goto out; diff --git a/qapi/qmp-registry.c b/qapi/qmp-registry.c index 485bc5e6fc..bfcabec526 100644 --- a/qapi/qmp-registry.c +++ b/qapi/qmp-registry.c @@ -17,7 +17,7 @@ =20 void qmp_register_command(QmpCommandList *cmds, const char *name, QmpCommandFunc *fn, QmpCommandOptions options, - unsigned special_features) + uint64_t features) { QmpCommand *cmd =3D g_malloc0(sizeof(*cmd)); =20 @@ -28,7 +28,7 @@ void qmp_register_command(QmpCommandList *cmds, const cha= r *name, cmd->fn =3D fn; cmd->enabled =3D true; cmd->options =3D options; - cmd->special_features =3D special_features; + cmd->features =3D features; QTAILQ_INSERT_TAIL(cmds, cmd, node); } =20 diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c index f110a804b2..ff9c726de3 100644 --- a/qapi/qobject-input-visitor.c +++ b/qapi/qobject-input-visitor.c @@ -664,10 +664,10 @@ static void qobject_input_optional(Visitor *v, const = char *name, bool *present) } =20 static bool qobject_input_policy_reject(Visitor *v, const char *name, - unsigned special_features, + uint64_t features, Error **errp) { - return !compat_policy_input_ok(special_features, &v->compat_policy, + return !compat_policy_input_ok(features, &v->compat_policy, ERROR_CLASS_GENERIC_ERROR, "parameter", name, errp); } diff --git a/qapi/qobject-output-visitor.c b/qapi/qobject-output-visitor.c index 74770edd73..8902287caa 100644 --- a/qapi/qobject-output-visitor.c +++ b/qapi/qobject-output-visitor.c @@ -210,13 +210,13 @@ static bool qobject_output_type_null(Visitor *v, cons= t char *name, } =20 static bool qobject_output_policy_skip(Visitor *v, const char *name, - unsigned special_features) + uint64_t features) { CompatPolicy *pol =3D &v->compat_policy; =20 - return ((special_features & 1u << QAPI_DEPRECATED) + return ((features & 1u << QAPI_DEPRECATED) && pol->deprecated_output =3D=3D COMPAT_POLICY_OUTPUT_HIDE) - || ((special_features & 1u << QAPI_UNSTABLE) + || ((features & 1u << QAPI_UNSTABLE) && pol->unstable_output =3D=3D COMPAT_POLICY_OUTPUT_HIDE); } =20 diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index 0dd0b00ada..7bc3f8241f 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -71,7 +71,7 @@ def gen_enum_lookup(name: str, if feats: ret +=3D mcgen(''' }, - .special_features =3D (const unsigned char[%(max_index)s]) { + .features =3D (const uint64_t[%(max_index)s]) { ''', max_index=3Dmax_index) ret +=3D feats --=20 2.45.2 From nobody Sun Nov 24 14:47:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1722535284; cv=none; d=zohomail.com; s=zohoarc; b=BLvxwPXQlCy1x6apY+upHvnKkevjzCnlZNbv/rOZQEKXMQ+y8VKeVOhV305PaT+/z7A+y7rbXP8we7lezvec49huGVuWnEjonmDFL/2rCaAitH+ZhkpyKVX4E0RU5QUCFGoQc2I1tP8YYWQue/FOy9qXCXYNSh6UXt3Z83U6gVo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722535284; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qUkIIosbBETnEy5HXrShiEtjaYOvur2tbXwmwlKnd4Y=; b=f1HgDcA67SwT0YC/0Z945ee6Ye9h5Xlrh9bmUDrqX0K0v2X5UAHOELGUjSBzKiuUQcKzhB1DxYAmyROaGHbZwTmTs1Su3jOaUpVc3/CDfXx5XEocqtb1mLMJSSMSJejbpRjOyd+7/NSnwfqB9i0DUZu5ofFWMTiGkJXuSyNdJIM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722535284181857.1140601854704; Thu, 1 Aug 2024 11:01:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZa5Q-0001ZJ-48; Thu, 01 Aug 2024 13:59:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZa5N-0001XR-C6 for qemu-devel@nongnu.org; Thu, 01 Aug 2024 13:59:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZa5K-0005uB-V2 for qemu-devel@nongnu.org; Thu, 01 Aug 2024 13:59:32 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-110-zW22CGDKNCirwD5jdFcW7w-1; Thu, 01 Aug 2024 13:59:25 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5868D1955F06; Thu, 1 Aug 2024 17:59:24 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.17]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 497D019560AA; Thu, 1 Aug 2024 17:59:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722535169; h=from:from: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; bh=qUkIIosbBETnEy5HXrShiEtjaYOvur2tbXwmwlKnd4Y=; b=T9I4gxT6k8s77bOAT44WtU+1z6RA7PswVKNpmS0Ig9rt228DZspRDxQlGEvslaABCZI7EX IKMl437Q/td9kPNi79t0ELFYf1znhEB32AnOcOgeVMTKqTakKQYD5SzF+Qkf+UDjPeBj+s adGqJBfLkqPQy7L17bciNBx/GDUfnsY= X-MC-Unique: zW22CGDKNCirwD5jdFcW7w-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Thomas Huth , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Michael Roth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH 2/6] scripts/qapi: rename 'special_features' to 'features' Date: Thu, 1 Aug 2024 18:59:09 +0100 Message-ID: <20240801175913.669013-3-berrange@redhat.com> In-Reply-To: <20240801175913.669013-1-berrange@redhat.com> References: <20240801175913.669013-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.131, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1722535286328116600 This updates the QAPI code generation to refer to 'features' instead of 'special_features', in preparation for generalizing their exposure. Signed-off-by: Daniel P. Berrang=C3=A9 --- scripts/qapi/commands.py | 4 ++-- scripts/qapi/gen.py | 8 ++++---- scripts/qapi/types.py | 10 +++++----- scripts/qapi/visit.py | 14 +++++++------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index 79951a841f..d629d2d97e 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -25,7 +25,7 @@ QAPIGenC, QAPISchemaModularCVisitor, build_params, - gen_special_features, + gen_features, ifcontext, ) from .schema import ( @@ -298,7 +298,7 @@ def gen_register_command(name: str, ''', name=3Dname, c_name=3Dc_name(name), opts=3D' | '.join(options) or 0, - feats=3Dgen_special_features(features)) + feats=3Dgen_features(features)) return ret =20 =20 diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index 6a8abe0041..e6c80cce23 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -40,10 +40,10 @@ from .source import QAPISourceInfo =20 =20 -def gen_special_features(features: Sequence[QAPISchemaFeature]) -> str: - special_features =3D [f"1u << QAPI_{feat.name.upper()}" - for feat in features if feat.is_special()] - return ' | '.join(special_features) or '0' +def gen_features(features: Sequence[QAPISchemaFeature]) -> str: + features =3D [f"1u << QAPI_{feat.name.upper()}" + for feat in features if feat.is_special()] + return ' | '.join(features) or '0' =20 =20 class QAPIGen: diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index 7bc3f8241f..ade6b7a3d7 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -18,7 +18,7 @@ from .common import c_enum_const, c_name, mcgen from .gen import ( QAPISchemaModularCVisitor, - gen_special_features, + gen_features, ifcontext, ) from .schema import ( @@ -61,12 +61,12 @@ def gen_enum_lookup(name: str, index=3Dindex, name=3Dmemb.name) ret +=3D memb.ifcond.gen_endif() =20 - special_features =3D gen_special_features(memb.features) - if special_features !=3D '0': + features =3D gen_features(memb.features) + if features !=3D '0': feats +=3D mcgen(''' - [%(index)s] =3D %(special_features)s, + [%(index)s] =3D %(features)s, ''', - index=3Dindex, special_features=3Dspecial_featu= res) + index=3Dindex, features=3Dfeatures) =20 if feats: ret +=3D mcgen(''' diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index 12f92e429f..8dbf4ef1c3 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -23,7 +23,7 @@ ) from .gen import ( QAPISchemaModularCVisitor, - gen_special_features, + gen_features, ifcontext, ) from .schema import ( @@ -103,15 +103,15 @@ def gen_visit_object_members(name: str, ''', name=3Dmemb.name, has=3Dhas) indent.increase() - special_features =3D gen_special_features(memb.features) - if special_features !=3D '0': + features =3D gen_features(memb.features) + if features !=3D '0': ret +=3D mcgen(''' - if (visit_policy_reject(v, "%(name)s", %(special_features)s, errp)) { + if (visit_policy_reject(v, "%(name)s", %(features)s, errp)) { return false; } - if (!visit_policy_skip(v, "%(name)s", %(special_features)s)) { + if (!visit_policy_skip(v, "%(name)s", %(features)s)) { ''', - name=3Dmemb.name, special_features=3Dspecial_feat= ures) + name=3Dmemb.name, features=3Dfeatures) indent.increase() ret +=3D mcgen(''' if (!visit_type_%(c_type)s(v, "%(name)s", &obj->%(c_name)s, errp)) { @@ -120,7 +120,7 @@ def gen_visit_object_members(name: str, ''', c_type=3Dmemb.type.c_name(), name=3Dmemb.name, c_name=3Dc_name(memb.name)) - if special_features !=3D '0': + if features !=3D '0': indent.decrease() ret +=3D mcgen(''' } --=20 2.45.2 From nobody Sun Nov 24 14:47:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1722535252; cv=none; d=zohomail.com; s=zohoarc; b=it7DEdBw42VSrXBL0I/Lw3fFusvQgg+dabvRep9947r6aDUSXLnZvCtqr3cc8qb8a+KLjkF3ly4paBybdrrFCIWFyPvTh/CvKldZzAWU+sfIi63B8X+8W2Cg90YmMIPzY8qCOc2lLL2XXFW/3YVxJiLvFWo3z3tFe7NVaeK+wcQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722535252; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gjmXgGzTx2PPKb6vl+5P/ivLVpqgVC1jTbbAHudRTVw=; b=KYAv8wGpL7c3dSUxlDCk9Di8IyJ0A5bHIZzueen7O6iH/JBNns5XnsBHDiyYr1tt4NPTjsLyThu9yXhLZryFEsNFtZ/XbXjNIfCeOHDDZAH8ZaYS6XqDrBw+e+n3aMojzMvjXbUjXcDKo0UxTZqI0zA+InZEkrPqQ+n9AdOHvXk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722535252072912.4858658657431; Thu, 1 Aug 2024 11:00:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZa5R-0001kO-UK; Thu, 01 Aug 2024 13:59:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZa5P-0001ZF-4h for qemu-devel@nongnu.org; Thu, 01 Aug 2024 13:59:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZa5M-0005uM-59 for qemu-devel@nongnu.org; Thu, 01 Aug 2024 13:59:34 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-526-2HESJ0tjPXi3Capv2bcuUg-1; Thu, 01 Aug 2024 13:59:28 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8A1791955D45; Thu, 1 Aug 2024 17:59:27 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.17]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 908D1195605A; Thu, 1 Aug 2024 17:59:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722535171; h=from:from: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; bh=gjmXgGzTx2PPKb6vl+5P/ivLVpqgVC1jTbbAHudRTVw=; b=Jo7IguMd1Pq2yl5w3NqP69WX7c0zJUROxM6DsEunw4PRYbrNp5BEwEGg+fCuevlfmylyOM vGY47G/Yc4C5//wk13Ree4A45R0hfyb7p6HNWTEaMmmNBgoHZ/pThmFrxxhD78QrHqsO5K Wnaoki0zKIFaCtQhzNuB0RkkBm5PHgQ= X-MC-Unique: 2HESJ0tjPXi3Capv2bcuUg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Thomas Huth , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Michael Roth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH 3/6] qapi: use "QAPI_FEATURE" as namespace for features Date: Thu, 1 Aug 2024 18:59:10 +0100 Message-ID: <20240801175913.669013-4-berrange@redhat.com> In-Reply-To: <20240801175913.669013-1-berrange@redhat.com> References: <20240801175913.669013-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.131, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1722535254156116600 This more clearly distinguishes the feature constants from other QAPI constants. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Markus Armbruster --- include/qapi/util.h | 4 ++-- qapi/qapi-util.c | 4 ++-- qapi/qobject-output-visitor.c | 4 ++-- scripts/qapi/gen.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/qapi/util.h b/include/qapi/util.h index b377cb9c70..a693cac9ea 100644 --- a/include/qapi/util.h +++ b/include/qapi/util.h @@ -12,8 +12,8 @@ #define QAPI_UTIL_H =20 typedef enum { - QAPI_DEPRECATED, - QAPI_UNSTABLE, + QAPI_FEATURE_DEPRECATED, + QAPI_FEATURE_UNSTABLE, } QapiFeature; =20 typedef struct QEnumLookup { diff --git a/qapi/qapi-util.c b/qapi/qapi-util.c index 3d849fe034..48c8c867d3 100644 --- a/qapi/qapi-util.c +++ b/qapi/qapi-util.c @@ -43,13 +43,13 @@ bool compat_policy_input_ok(uint64_t features, const char *kind, const char *name, Error **errp) { - if ((features & 1u << QAPI_DEPRECATED) + if ((features & 1u << QAPI_FEATURE_DEPRECATED) && !compat_policy_input_ok1("Deprecated", policy->deprecated_input, error_class, kind, name, errp)) { return false; } - if ((features & (1u << QAPI_UNSTABLE)) + if ((features & (1u << QAPI_FEATURE_UNSTABLE)) && !compat_policy_input_ok1("Unstable", policy->unstable_input, error_class, kind, name, errp)) { diff --git a/qapi/qobject-output-visitor.c b/qapi/qobject-output-visitor.c index 8902287caa..b13c94d913 100644 --- a/qapi/qobject-output-visitor.c +++ b/qapi/qobject-output-visitor.c @@ -214,9 +214,9 @@ static bool qobject_output_policy_skip(Visitor *v, cons= t char *name, { CompatPolicy *pol =3D &v->compat_policy; =20 - return ((features & 1u << QAPI_DEPRECATED) + return ((features & 1u << QAPI_FEATURE_DEPRECATED) && pol->deprecated_output =3D=3D COMPAT_POLICY_OUTPUT_HIDE) - || ((features & 1u << QAPI_UNSTABLE) + || ((features & 1u << QAPI_FEATURE_UNSTABLE) && pol->unstable_output =3D=3D COMPAT_POLICY_OUTPUT_HIDE); } =20 diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index e6c80cce23..0ff29dc776 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -41,7 +41,7 @@ =20 =20 def gen_features(features: Sequence[QAPISchemaFeature]) -> str: - features =3D [f"1u << QAPI_{feat.name.upper()}" + features =3D [f"1u << QAPI_FEATURE_{feat.name.upper()}" for feat in features if feat.is_special()] return ' | '.join(features) or '0' =20 --=20 2.45.2 From nobody Sun Nov 24 14:47:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1722535262; cv=none; d=zohomail.com; s=zohoarc; b=cHNusEPa143mfswAhB/8OScbylfAkUEyu0rZJU6zkjcXc6UPAABFEqeJuHsZxFOZgjwp5lhqFB61AG+EfjDCJo7UJdz+tlZp9Q26Ft21Z6VWMQBb6yecvpFyyTx48NaTbXNpHyG885Kd7SCrxtzwQaQqE+BGb7wUpGCfmN6U64Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722535262; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9zES+mmhVU8SsFPQE0hElHiI8+xOwlfTDlFG7CvA+oM=; b=Jxo+th9nrQWwp7H7oWkvVz/gC+YoX4evB5anw8gJQbkwz9WhfE7vteU47osVs3uR5oSLcSmjBuKRzy6KxE5BPk8yM12lTUbNd3fPHPcdxZiwjh4x32hfxhrbXuqgTlaApxgO+IhN0Xk/XO+T5EDm09HX5F2VUWnC8ad1972iWT8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722535262592223.97460943122417; Thu, 1 Aug 2024 11:01:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZa5S-0001lu-BR; Thu, 01 Aug 2024 13:59:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZa5Q-0001ex-IN for qemu-devel@nongnu.org; Thu, 01 Aug 2024 13:59:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZa5O-0005uU-U8 for qemu-devel@nongnu.org; Thu, 01 Aug 2024 13:59:36 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-561-SMTymVH1Ns21yS_wFyZeFA-1; Thu, 01 Aug 2024 13:59:31 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AEC1B19560AB; Thu, 1 Aug 2024 17:59:30 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.17]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CDD5A195605A; Thu, 1 Aug 2024 17:59:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722535172; h=from:from: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; bh=9zES+mmhVU8SsFPQE0hElHiI8+xOwlfTDlFG7CvA+oM=; b=gSWHu7doMCqspORG1eER09poRUhH6UyuRa7nudcliNBScPx6qSALHSIejZSgThd80LFq6r XrkDahmmqxI5Byu3KH09hatQNl7NMjDYLVtJQIqUYT8Fql3MUkvqDUPslCyaa1/OSGsxAn 6XaDI5qzmR/Am2ohHYXDC5oUAH8MCqY= X-MC-Unique: SMTymVH1Ns21yS_wFyZeFA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Thomas Huth , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Michael Roth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH 4/6] qapi: cope with feature names containing a '-' Date: Thu, 1 Aug 2024 18:59:11 +0100 Message-ID: <20240801175913.669013-5-berrange@redhat.com> In-Reply-To: <20240801175913.669013-1-berrange@redhat.com> References: <20240801175913.669013-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.131, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1722535264230116600 When we shortly expose all feature names to code, it will be valid to include a '-', which must be translated to a '_' for the enum constants. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Markus Armbruster --- scripts/qapi/gen.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index 0ff29dc776..036977d989 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -24,6 +24,7 @@ ) =20 from .common import ( + c_enum_const, c_fname, c_name, guardend, @@ -41,7 +42,7 @@ =20 =20 def gen_features(features: Sequence[QAPISchemaFeature]) -> str: - features =3D [f"1u << QAPI_FEATURE_{feat.name.upper()}" + features =3D [f"1u << {c_enum_const('QAPI_FEATURE', feat.name)}" for feat in features if feat.is_special()] return ' | '.join(features) or '0' =20 --=20 2.45.2 From nobody Sun Nov 24 14:47:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1722535301; cv=none; d=zohomail.com; s=zohoarc; b=YVmTLFTsToDP2y6kHRpq973wyYjUvpzx/mti1ZCaNj0z7lNbLIa+GvE8gsSLEQuFJMnYsMV+y5uZvqkFC+T5dn//nYRdJrwKOIeajioDcxwGJfn/55fybur0GicEE2pOUKZx7nCLtR5opZ9ORKlVkFNsvywy+Rg8RtZdpThDHjo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722535301; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SasQSSECtI5DkO6YiV8MC31dvU9pBpDLxRDKkUkwUys=; b=OnO8Xoqo1zt48UdyzY4G4xnk+Zi+Rw67K4PfIjGtQRImnEzZpYCANH5Db2z+thgTHrnqvj/AhpB6acB2qFzenomA5xbj5MBQ0o4zbl4tbAj7LKvBG7TE3SyCZe1ZIxGDMa2b+/rRIXJc4DiUPCEEOmnhGqLkfDleMD68Yh7i0kI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722535301618349.78377209558585; Thu, 1 Aug 2024 11:01:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZa5X-00028K-Q9; Thu, 01 Aug 2024 13:59:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZa5U-0001x9-Vi for qemu-devel@nongnu.org; Thu, 01 Aug 2024 13:59:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZa5T-0005vG-6e for qemu-devel@nongnu.org; Thu, 01 Aug 2024 13:59:40 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-631-iut_6S-ROiy00YWqmBTNdA-1; Thu, 01 Aug 2024 13:59:35 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 73A7A1955D4D; Thu, 1 Aug 2024 17:59:34 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.17]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EB95B195605A; Thu, 1 Aug 2024 17:59:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722535177; h=from:from: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; bh=SasQSSECtI5DkO6YiV8MC31dvU9pBpDLxRDKkUkwUys=; b=Mv4dAPr21h29YuATuoR7b1gitMTvTOxs0WOndaxrUOai8+xY0i1qWGlNLF6lrk2SGMXTtK 76Z2T+CRtZV7frpiwTQZhh+7fyzzRD3/8H0v7LoBaiHSvqEYP3waFfefqcRvtZuflAJQGd r7BxcaRj/hnBwm22oY8Dy/eT/B5piJs= X-MC-Unique: iut_6S-ROiy00YWqmBTNdA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Thomas Huth , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Michael Roth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH 5/6] qapi: apply schema prefix to QAPI feature enum constants Date: Thu, 1 Aug 2024 18:59:12 +0100 Message-ID: <20240801175913.669013-6-berrange@redhat.com> In-Reply-To: <20240801175913.669013-1-berrange@redhat.com> References: <20240801175913.669013-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.131, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1722535302377116600 This allows us to include multiple QAPI schemas in the same file. Signed-off-by: Daniel P. Berrang=C3=A9 --- scripts/qapi/commands.py | 7 ++++--- scripts/qapi/events.py | 3 ++- scripts/qapi/gen.py | 6 +++--- scripts/qapi/types.py | 5 +++-- scripts/qapi/visit.py | 5 +++-- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index d629d2d97e..81134de6c0 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -280,7 +280,8 @@ def gen_register_command(name: str, success_response: bool, allow_oob: bool, allow_preconfig: bool, - coroutine: bool) -> str: + coroutine: bool, + prefix: str) -> str: options =3D [] =20 if not success_response: @@ -298,7 +299,7 @@ def gen_register_command(name: str, ''', name=3Dname, c_name=3Dc_name(name), opts=3D' | '.join(options) or 0, - feats=3Dgen_features(features)) + feats=3Dgen_features(prefix, features)) return ret =20 =20 @@ -407,7 +408,7 @@ def visit_command(self, with ifcontext(ifcond, self._genh, self._genc): self._genc.add(gen_register_command( name, features, success_response, allow_oob, - allow_preconfig, coroutine)) + allow_preconfig, coroutine, self._prefix)) =20 =20 def gen_commands(schema: QAPISchema, diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index d1f639981a..8a489e559a 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -218,7 +218,8 @@ def visit_end(self) -> None: self._genh.add(gen_enum(self._event_enum_name, self._event_enum_members)) self._genc.add(gen_enum_lookup(self._event_enum_name, - self._event_enum_members)) + self._event_enum_members, + self._prefix)) self._genh.add(mcgen(''' =20 void %(event_emit)s(%(event_enum)s event, QDict *qdict); diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index 036977d989..399a0ae62d 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -41,9 +41,9 @@ from .source import QAPISourceInfo =20 =20 -def gen_features(features: Sequence[QAPISchemaFeature]) -> str: - features =3D [f"1u << {c_enum_const('QAPI_FEATURE', feat.name)}" - for feat in features if feat.is_special()] +def gen_features(prefix, features: Sequence[QAPISchemaFeature]) -> str: + features =3D [f"1u << {c_enum_const(prefix + 'QAPI_FEATURE', feat.name= )}" + for feat in features] return ' | '.join(features) or '0' =20 =20 diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index ade6b7a3d7..b2d26c2ea8 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -43,6 +43,7 @@ =20 def gen_enum_lookup(name: str, members: List[QAPISchemaEnumMember], + modprefix: str, prefix: Optional[str] =3D None) -> str: max_index =3D c_enum_const(name, '_MAX', prefix) feats =3D '' @@ -61,7 +62,7 @@ def gen_enum_lookup(name: str, index=3Dindex, name=3Dmemb.name) ret +=3D memb.ifcond.gen_endif() =20 - features =3D gen_features(memb.features) + features =3D gen_features(modprefix, memb.features) if features !=3D '0': feats +=3D mcgen(''' [%(index)s] =3D %(features)s, @@ -331,7 +332,7 @@ def visit_enum_type(self, prefix: Optional[str]) -> None: with ifcontext(ifcond, self._genh, self._genc): self._genh.preamble_add(gen_enum(name, members, prefix)) - self._genc.add(gen_enum_lookup(name, members, prefix)) + self._genc.add(gen_enum_lookup(name, members, self._prefix, pr= efix)) =20 def visit_array_type(self, name: str, diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index 8dbf4ef1c3..883d720e36 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -62,6 +62,7 @@ def gen_visit_members_decl(name: str) -> str: =20 =20 def gen_visit_object_members(name: str, + prefix: str, base: Optional[QAPISchemaObjectType], members: List[QAPISchemaObjectTypeMember], branches: Optional[QAPISchemaBranches]) -> st= r: @@ -103,7 +104,7 @@ def gen_visit_object_members(name: str, ''', name=3Dmemb.name, has=3Dhas) indent.increase() - features =3D gen_features(memb.features) + features =3D gen_features(prefix, memb.features) if features !=3D '0': ret +=3D mcgen(''' if (visit_policy_reject(v, "%(name)s", %(features)s, errp)) { @@ -402,7 +403,7 @@ def visit_object_type(self, return with ifcontext(ifcond, self._genh, self._genc): self._genh.add(gen_visit_members_decl(name)) - self._genc.add(gen_visit_object_members(name, base, + self._genc.add(gen_visit_object_members(name, self._prefix, ba= se, members, branches)) # TODO Worth changing the visitor signature, so we could # directly use rather than repeat type.is_implicit()? --=20 2.45.2 From nobody Sun Nov 24 14:47:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1722535219; cv=none; d=zohomail.com; s=zohoarc; b=bh74Y93+2+mle3MB/oIjL2DRSF+9v88D1VvosyN3J2XWB4nS9vPZpNMQD1qU6wsHviZ80SaP1APVI2RE2SWSecB4ooQfHC7GJeHTjSNkjCux9NugSKGNx6u8ieOIdWSnASFDJmXBUc3PM7zdU7cmSa8I/nRDpdx6eLK26XSpAx4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722535219; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vKj/R/LTdslBdO3NPUSSDISUWikk5J0XoRlJ1Pv42W4=; b=E5p5PtBby4XYlBVynlSbrgxjUt9m3/UbQzSoNMVntmkvaNNvcDJUAvwZoh1TJr0psxW4TZ4uRA8PqJENvX6wSaLbZ/Cux5qGm/cA1hH/grXetRMDJTFXAj6Rpuau436OSoaYzWPX8xYE9tsNu9d9YkWpFmPM2jTSpV80kTYkNMk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722535219000137.27514291322962; Thu, 1 Aug 2024 11:00:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZa5c-0002Nk-SL; Thu, 01 Aug 2024 13:59:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZa5b-0002KI-2j for qemu-devel@nongnu.org; Thu, 01 Aug 2024 13:59:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZa5X-0005zA-5b for qemu-devel@nongnu.org; Thu, 01 Aug 2024 13:59:45 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-690-M5j83n_QN126TT3PRBeP7g-1; Thu, 01 Aug 2024 13:59:38 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C36D619560A2; Thu, 1 Aug 2024 17:59:37 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.17]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C7D7519560AA; Thu, 1 Aug 2024 17:59:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722535181; h=from:from: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; bh=vKj/R/LTdslBdO3NPUSSDISUWikk5J0XoRlJ1Pv42W4=; b=BFjJ7a4Ywx1rUeywjovfnyBVPDjQxKbBk6nhcxqIkn3xSyBqnzc+EfThc5bGCYMVrfNdgQ v7y+5U2B7KXDkUvBNf44FFFzweAUanMuA9zlwiHIJWVcWZRPkEYNrwadif2+LU0BU9N4+Y 4hOPWHM5jDMCEvYhC/NNUmfa3McBYLE= X-MC-Unique: M5j83n_QN126TT3PRBeP7g-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Thomas Huth , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Michael Roth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH 6/6] qapi: expose all schema features to code Date: Thu, 1 Aug 2024 18:59:13 +0100 Message-ID: <20240801175913.669013-7-berrange@redhat.com> In-Reply-To: <20240801175913.669013-1-berrange@redhat.com> References: <20240801175913.669013-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.131, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1722535221915116600 This removed the QapiFeatures enum and auto-generates an enum which exposes all features defined by the schema to code. The 'deprecated' and 'unstable' features still have a little bit of special handling, being force defined to be the 1st + 2nd features in the enum, regardless of whether they're used in the schema. This is because QAPI common code references these features. Signed-off-by: Daniel P. Berrang=C3=A9 --- include/qapi/util.h | 5 -- meson.build | 1 + scripts/qapi/features.py | 134 +++++++++++++++++++++++++++++++++++++++ scripts/qapi/main.py | 2 + scripts/qapi/schema.py | 5 +- scripts/qapi/types.py | 4 +- 6 files changed, 144 insertions(+), 7 deletions(-) create mode 100644 scripts/qapi/features.py diff --git a/include/qapi/util.h b/include/qapi/util.h index a693cac9ea..9e390486c0 100644 --- a/include/qapi/util.h +++ b/include/qapi/util.h @@ -11,11 +11,6 @@ #ifndef QAPI_UTIL_H #define QAPI_UTIL_H =20 -typedef enum { - QAPI_FEATURE_DEPRECATED, - QAPI_FEATURE_UNSTABLE, -} QapiFeature; - typedef struct QEnumLookup { const char *const *array; const uint64_t *const features; diff --git a/meson.build b/meson.build index 97f63aa86c..40002c59f5 100644 --- a/meson.build +++ b/meson.build @@ -3268,6 +3268,7 @@ qapi_gen_depends =3D [ meson.current_source_dir() / '= scripts/qapi/__init__.py', meson.current_source_dir() / 'scripts/qapi/schema.py', meson.current_source_dir() / 'scripts/qapi/source.py', meson.current_source_dir() / 'scripts/qapi/types.py', + meson.current_source_dir() / 'scripts/qapi/features.p= y', meson.current_source_dir() / 'scripts/qapi/visit.py', meson.current_source_dir() / 'scripts/qapi-gen.py' ] diff --git a/scripts/qapi/features.py b/scripts/qapi/features.py new file mode 100644 index 0000000000..9b77be6310 --- /dev/null +++ b/scripts/qapi/features.py @@ -0,0 +1,134 @@ +""" +QAPI types generator + +Copyright 2024 Red Hat + +This work is licensed under the terms of the GNU GPL, version 2. +# See the COPYING file in the top-level directory. +""" + +from typing import List, Optional + +from .common import c_enum_const, mcgen, c_name +from .gen import QAPISchemaMonolithicCVisitor +from .schema import ( + QAPISchema, + QAPISchemaAlternatives, + QAPISchemaBranches, + QAPISchemaEntity, + QAPISchemaEnumMember, + QAPISchemaFeature, + QAPISchemaIfCond, + QAPISchemaObjectType, + QAPISchemaObjectTypeMember, + QAPISchemaType, + QAPISchemaVariants, +) +from .source import QAPISourceInfo + + +class QAPISchemaGenFeatureVisitor(QAPISchemaMonolithicCVisitor): + + def __init__(self, prefix: str): + super().__init__( + prefix, 'qapi-features', + ' * Schema-defined QAPI features', + __doc__) + + self.features =3D {} + + def visit_end(self) -> None: + features =3D [] + + # We always want special features to have the same + # enum value across all schemas, since they're + # referenced from common code. Put them at the + # start of the list, regardless of whether they + # are actually referenced in the schema + for name in QAPISchemaFeature.SPECIAL_NAMES: + features.append(name) + + features.extend(sorted(self.features.keys())) + + if len(features) > 64: + raise Exception("Maximum of 64 schema features is permitted") + + self._genh.add("typedef enum {\n") + for name in features: + self._genh.add(f" {c_enum_const(self._prefix + 'QAPI_FEATUR= E', name)},\n") + + self._genh.add("} " + c_name(self._prefix + 'QapiFeature') + ";\n") + + def _record(self, features: List[QAPISchemaFeature]): + for f in features: + # Special features are handled separately + if f.name in QAPISchemaFeature.SPECIAL_NAMES: + continue + self.features[f.name] =3D True + + def visit_enum_type(self, + name: str, + info: Optional[QAPISourceInfo], + ifcond: QAPISchemaIfCond, + features: List[QAPISchemaFeature], + members: List[QAPISchemaEnumMember], + prefix: Optional[str]) -> None: + self._record(features) + + def visit_object_type_flat(self, + name: str, + info: Optional[QAPISourceInfo], + ifcond: QAPISchemaIfCond, + features: List[QAPISchemaFeature], + members: List[QAPISchemaObjectTypeMember], + branches: Optional[QAPISchemaBranches]) -> = None: + self._record(features) + + def visit_object_type(self, + name: str, + info: Optional[QAPISourceInfo], + ifcond: QAPISchemaIfCond, + features: List[QAPISchemaFeature], + base: Optional[QAPISchemaObjectType], + members: List[QAPISchemaObjectTypeMember], + branches: Optional[QAPISchemaBranches]) -> None: + self._record(features) + + def visit_alternate_type(self, + name: str, + info: Optional[QAPISourceInfo], + ifcond: QAPISchemaIfCond, + features: List[QAPISchemaFeature], + alternatives: QAPISchemaAlternatives) -> None: + self._record(features) + + def visit_command(self, + name: str, + info: Optional[QAPISourceInfo], + ifcond: QAPISchemaIfCond, + features: List[QAPISchemaFeature], + arg_type: Optional[QAPISchemaObjectType], + ret_type: Optional[QAPISchemaType], + gen: bool, + success_response: bool, + boxed: bool, + allow_oob: bool, + allow_preconfig: bool, + coroutine: bool) -> None: + self._record(features) + + def visit_event(self, + name: str, + info: Optional[QAPISourceInfo], + ifcond: QAPISchemaIfCond, + features: List[QAPISchemaFeature], + arg_type: Optional[QAPISchemaObjectType], + boxed: bool) -> None: + self._record(features) + +def gen_features(schema: QAPISchema, + output_dir: str, + prefix: str) -> None: + vis =3D QAPISchemaGenFeatureVisitor(prefix) + schema.visit(vis) + vis.write(output_dir) diff --git a/scripts/qapi/main.py b/scripts/qapi/main.py index 316736b6a2..2b9a2c0c02 100644 --- a/scripts/qapi/main.py +++ b/scripts/qapi/main.py @@ -18,6 +18,7 @@ from .introspect import gen_introspect from .schema import QAPISchema from .types import gen_types +from .features import gen_features from .visit import gen_visit =20 =20 @@ -49,6 +50,7 @@ def generate(schema_file: str, =20 schema =3D QAPISchema(schema_file) gen_types(schema, output_dir, prefix, builtins) + gen_features(schema, output_dir, prefix) gen_visit(schema, output_dir, prefix, builtins) gen_commands(schema, output_dir, prefix, gen_tracing) gen_events(schema, output_dir, prefix) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index d65c35f6ee..160ce0a7c0 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -933,8 +933,11 @@ def connect_doc(self, doc: Optional[QAPIDoc]) -> None: class QAPISchemaFeature(QAPISchemaMember): role =3D 'feature' =20 + # Features which are standardized across all schemas + SPECIAL_NAMES =3D ['deprecated', 'unstable'] + def is_special(self) -> bool: - return self.name in ('deprecated', 'unstable') + return self.name in QAPISchemaFeature.SPECIAL_NAMES =20 =20 class QAPISchemaObjectTypeMember(QAPISchemaMember): diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index b2d26c2ea8..3435f1b0b0 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -313,7 +313,9 @@ def _begin_user_module(self, name: str) -> None: types=3Dtypes, visit=3Dvisit)) self._genh.preamble_add(mcgen(''' #include "qapi/qapi-builtin-types.h" -''')) +#include "%(prefix)sqapi-features.h" +''', + prefix=3Dself._prefix)) =20 def visit_begin(self, schema: QAPISchema) -> None: # gen_object() is recursive, ensure it doesn't visit the empty type --=20 2.45.2