On Thu, Apr 30, 2026 at 13:43:42 +0200, Peter Krempa via Devel wrote:
> From: Peter Krempa <[email protected]>
> 
> The script analyzes the driver implementation source file and generates
> an include file which describes the analyzed driver in terms of:
> 
>  - supported APIs
>  - flags supported for the API (by looking at virCheckFlags)
> 
> The generated structure then will be used to generate the introspection
> XML.
> 
> The script goes through the 'virHypervisorDriver' struct, finds all
> callbacks corresponding to public APIs and then goes through the
> functions finding the 'virCheckFlags' to collect supported flags per
> API.
> 
> Since the migration APIs are public but use internal functions which
> don't map directly, the script tries to find the best matching internal
> API and then infers the flags for the public migration APIs from the
> detected flags.
> 
> The script works only with the contemporary coding style for functions
> due to regex usage so any driver impl file needs to be modernized first.
> 
> As first example, introspection of qemu driver is generated. An excerpt
> from the generated data (which is for internal use, and will be used to
> generate XML):
> 
>     static const virIntrospectionData driver_api_introspection[] =
>     {
>         { .api = "virConnectBaselineCPU",
>           .flags_arg = true,
>           .flags = VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES | 
> VIR_CONNECT_BASELINE_CPU_MIGRATABLE,
>         },
>         { .api = "virConnectBaselineHypervisorCPU",
>           .flags_arg = true,
>           .flags = VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES | 
> VIR_CONNECT_BASELINE_CPU_MIGRATABLE | VIR_CONNECT_BASELINE_CPU_IGNORE_HOST,
>         },
>         { .api = "virConnectClose",
>           .flags_arg = false,
>         },
> 
> Signed-off-by: Peter Krempa <[email protected]>
> ---
>  scripts/genintrospection.py | 220 ++++++++++++++++++++++++++++++++++++
>  scripts/meson.build         |   1 +
>  src/qemu/meson.build        |  18 +++
>  3 files changed, 239 insertions(+)
>  create mode 100644 scripts/genintrospection.py

The following hunks need to be squashed in to make it work on
non-fedora43 systems:

diff --git a/scripts/genintrospection.py b/scripts/genintrospection.py
old mode 100644
new mode 100755
diff --git a/scripts/genintrospection.py b/scripts/genintrospection.py
index 25a17e2b0c..c3ac5c940a 100644
--- a/scripts/genintrospection.py
+++ b/scripts/genintrospection.py
@@ -197,7 +197,7 @@ static const virIntrospectionData 
driver_api_introspection[] =
         outfile.write(f'    {{ .api = "{api}",\n')
         if data.get("flags_arg", False):
             outfile.write("      .flags_arg = true,\n")
-            outfile.write(f"      .flags = {data.get("flags_supported", 
0)},\n")
+            outfile.write(f"      .flags = {data.get('flags_supported', 
0)},\n")
         else:
             outfile.write("      .flags_arg = false,\n")

@@ -213,7 +213,7 @@ for api, data in introspection.items():
         data.get("flags_arg", False) is True
         and data.get("flags_supported", None) is None
     ):
-        print(f"failed to parse flags for '{api}' in '{data.get("callback", 
"")}'")
+        print(f"failed to parse flags for '{api}' in '{data.get('callback', 
'')}'")
         fail = True

 if fail:
diff --git a/src/qemu/meson.build b/src/qemu/meson.build
index a6cc3d1a85..a95ad13b6a 100644
--- a/src/qemu/meson.build
+++ b/src/qemu/meson.build
@@ -54,7 +54,7 @@ introspection_files = custom_target(
     'qemu_driver.c',
   ],
   command: [
-    meson_python_prog, python3_prog, genintrospection_prog,
+    meson_python_prog, genintrospection_prog,
     '--symfile', meson.project_source_root() / 'src' / 'libvirt_public.syms',
     '--symfile', meson.project_source_root() / 'src' / 'libvirt_qemu.syms',
     '--driverfile', meson.project_source_root() / 'src' / 'qemu' / 
'qemu_driver.c',

Reply via email to