From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: "John Snow" <jsnow@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
richard.henderson@linaro.org,
"Juan Quintela" <quintela@redhat.com>
Subject: [PULL 4/9] qapi: Tools for sets of special feature flags in generated code
Date: Fri, 29 Oct 2021 21:30:10 +0200 [thread overview]
Message-ID: <20211029193015.1312198-5-armbru@redhat.com> (raw)
In-Reply-To: <20211029193015.1312198-1-armbru@redhat.com>
New enum QapiSpecialFeature enumerates the special feature flags.
New helper gen_special_features() returns code to represent a
collection of special feature flags as a bitset.
The next few commits will put them to use.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Message-Id: <20211028102520.747396-5-armbru@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
include/qapi/util.h | 4 ++++
scripts/qapi/gen.py | 8 ++++++++
scripts/qapi/schema.py | 3 +++
3 files changed, 15 insertions(+)
diff --git a/include/qapi/util.h b/include/qapi/util.h
index 257c600f99..7a8d5c7d72 100644
--- a/include/qapi/util.h
+++ b/include/qapi/util.h
@@ -11,6 +11,10 @@
#ifndef QAPI_UTIL_H
#define QAPI_UTIL_H
+typedef enum {
+ QAPI_DEPRECATED,
+} QapiSpecialFeature;
+
/* QEnumLookup flags */
#define QAPI_ENUM_DEPRECATED 1
diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py
index 2ec1e7b3b6..995a97d2b8 100644
--- a/scripts/qapi/gen.py
+++ b/scripts/qapi/gen.py
@@ -18,6 +18,7 @@
Dict,
Iterator,
Optional,
+ Sequence,
Tuple,
)
@@ -29,6 +30,7 @@
mcgen,
)
from .schema import (
+ QAPISchemaFeature,
QAPISchemaIfCond,
QAPISchemaModule,
QAPISchemaObjectType,
@@ -37,6 +39,12 @@
from .source import QAPISourceInfo
+def gen_special_features(features: Sequence[QAPISchemaFeature]) -> str:
+ special_features = [f"1u << QAPI_{feat.name.upper()}"
+ for feat in features if feat.is_special()]
+ return ' | '.join(special_features) or '0'
+
+
class QAPIGen:
def __init__(self, fname: str):
self.fname = fname
diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index 6d5f46509a..55f82d7389 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -725,6 +725,9 @@ def connect_doc(self, doc):
class QAPISchemaFeature(QAPISchemaMember):
role = 'feature'
+ def is_special(self):
+ return self.name in ('deprecated')
+
class QAPISchemaObjectTypeMember(QAPISchemaMember):
def __init__(self, name, info, typ, optional, ifcond=None, features=None):
--
2.31.1
next prev parent reply other threads:[~2021-10-29 20:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-29 19:30 [PULL 0/9] QAPI patches patches for 2021-10-29 Markus Armbruster
2021-10-29 19:30 ` [PULL 1/9] qapi: New special feature flag "unstable" Markus Armbruster
2021-10-29 19:30 ` [PULL 2/9] qapi: Mark unstable QMP parts with feature 'unstable' Markus Armbruster
2021-10-29 19:30 ` [PULL 3/9] qapi: Eliminate QCO_NO_OPTIONS for a slight simplification Markus Armbruster
2021-10-29 19:30 ` Markus Armbruster [this message]
2021-10-29 19:30 ` [PULL 5/9] qapi: Generalize struct member policy checking Markus Armbruster
2021-10-29 19:30 ` [PULL 6/9] qapi: Generalize command " Markus Armbruster
2021-10-29 19:30 ` [PULL 7/9] qapi: Generalize enum member " Markus Armbruster
2021-10-29 19:30 ` [PULL 8/9] qapi: Factor out compat_policy_input_ok() Markus Armbruster
2021-10-29 19:30 ` [PULL 9/9] qapi: Extend -compat to set policy for unstable interfaces Markus Armbruster
2021-10-30 4:44 ` [PULL 0/9] QAPI patches patches for 2021-10-29 Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211029193015.1312198-5-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=jsnow@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).