[PATCH 04/22] scripts: group-qemu-caps: Add capability name as comment to capability string

Martin Kletzander mkletzan at redhat.com
Mon Aug 16 12:41:38 UTC 2021


On Thu, Aug 12, 2021 at 04:48:57PM +0200, Peter Krempa wrote:
>Add a cross reference of the enum value name with the string
>representation. This allows a quick cross-reference of the values
>without having to open the header and implementation files separately.
>
>To achieve this the python checker code at first obtains a list of the
>flags and cross-references them when checking the grouping in
>syntax-check, thus we are guaranteed to stay in sync.
>
>Signed-off-by: Peter Krempa <pkrempa at redhat.com>
>---
> scripts/group-qemu-caps.py   |  43 +-
> src/qemu/qemu_capabilities.c | 816 +++++++++++++++++------------------
> 2 files changed, 448 insertions(+), 411 deletions(-)
>
>diff --git a/scripts/group-qemu-caps.py b/scripts/group-qemu-caps.py
>index 6fad9afc5b..441f430b94 100755
>--- a/scripts/group-qemu-caps.py
>+++ b/scripts/group-qemu-caps.py
>@@ -27,8 +27,33 @@ import subprocess
> import sys
>
>
>+def load_caps_flags(filename, start_regex, end_regex):
>+    capsflags = []
>+    game_on = False
>+
>+    with open(filename, "r") as fh:
>+        for line in fh:
>+            line = line.rstrip("\n")
>+            if game_on:
>+                if re.search(r'''.*/\* [0-9]+ \*/.*''', line):
>+                    continue
>+                if re.search(r'''^\s*$''', line):
>+                    continue
>+                match = re.search(r'''[ ]+([A-Z_]+)''', line)

Add 0-9 here as well, otherwise it will not work on some of the flags.

>+
>+                if match:
>+                    capsflags.append(match[1])
>+
>+            if re.search(start_regex, line):
>+                game_on = True
>+            elif game_on and re.search(end_regex, line):
>+                game_on = False
>+
>+    return capsflags
>+
>+
> def regroup_caps(check, filename, start_regex, end_regex,
>-                 trailing_newline, counter_prefix):
>+                 trailing_newline, counter_prefix, capsflags):
>     step = 5
>
>     original = []
>@@ -68,6 +93,12 @@ def regroup_caps(check, filename, start_regex, end_regex,
>
>             game_on = False
>
>+        # ensure that flag names in the .c file have the correct flag in the comment
>+        if game_on and capsflags:
>+            flagname = re.search(r'''.*".*",''', line)

Maybe r'''\s*".*",''' but it does not matter, really.

Otherwise looks fine, except the wrong flags, but those will be fixed
together with the first regex.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20210816/167b737d/attachment-0001.sig>


More information about the libvir-list mailing list