diff mbox series

[v3,2/4] scripts/qapi: allow optional experimental enum values

Message ID 20230427202946.1007276-3-vsementsov@yandex-team.ru (mailing list archive)
State New, archived
Headers show
Series COLO: improve build options | expand

Commit Message

Vladimir Sementsov-Ogievskiy April 27, 2023, 8:29 p.m. UTC
We have 'if' feature for some things in QAPI, including enum values.
But currently it doesn't work for experimental enum values, as in
generated QEnumLookup structure, the description for additional
features (for example - "unstable") is not surrounded by corresponding
"#ifdef"s.

So let's fix it.

We are going to use it in the next commit, to make unstable x-colo
migration capability optional:

  { 'name': 'x-colo', 'features': [ 'unstable' ], 'if': 'CONFIG_COLO' }

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
 scripts/qapi/types.py | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py
index c39d054d2c..18f8734047 100644
--- a/scripts/qapi/types.py
+++ b/scripts/qapi/types.py
@@ -61,10 +61,12 @@  def gen_enum_lookup(name: str,
 
         special_features = gen_special_features(memb.features)
         if special_features != '0':
+            feats += memb.ifcond.gen_if()
             feats += mcgen('''
         [%(index)s] = %(special_features)s,
 ''',
                            index=index, special_features=special_features)
+            feats += memb.ifcond.gen_endif()
 
     if feats:
         ret += mcgen('''