Files
qemu/scripts/qemu-plugin-symbols.py
Thomas Huth 6f028a17a9 tests/vm: Update netbsd VM to version 10.1
NetBSD 10.1 has been released since more than a year, so it's time to
update our VM to that version.
Apart from the usual changes in the installation process, we also have
to disable the installation of the "jpeg" package now, otherwise the
package installation fails with an error message like this:

 pkg_add: jpeg-9fnb1: conflicts with `libjpeg-turbo-[0-9]*', and
 `libjpeg-turbo-3.1.3' is installed.

We also have to drop the executable bits from scripts/qemu-plugin-symbols.py
to force meson to use the detected Python interpreter instead of executing
the file directly (which tries to use the Python interpreter from the file's
shebang line).

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20260113193554.123082-1-thuth@redhat.com>
2026-01-27 15:20:43 +01:00

45 lines
1.3 KiB
Python

#!/usr/bin/env python3
#
# Extract QEMU Plugin API symbols from a header file
#
# Copyright 2024 Linaro Ltd
#
# Author: Pierrick Bouvier <pierrick.bouvier@linaro.org>
#
# This work is licensed under the terms of the GNU GPL, version 2 or later.
# See the COPYING file in the top-level directory.
#
# SPDX-License-Identifier: GPL-2.0-or-later
import argparse
import re
def extract_symbols(plugin_header):
with open(plugin_header) as file:
content = file.read()
# Remove QEMU_PLUGIN_API macro definition.
content = content.replace('#define QEMU_PLUGIN_API', '')
expected = content.count('QEMU_PLUGIN_API')
# Find last word between QEMU_PLUGIN_API and (, matching on several lines.
# We use *? non-greedy quantifier.
syms = re.findall(r'QEMU_PLUGIN_API.*?(\w+)\s*\(', content, re.DOTALL)
syms.sort()
# Ensure we found as many symbols as API markers.
assert len(syms) == expected
return syms
def main() -> None:
parser = argparse.ArgumentParser(description='Extract QEMU plugin symbols')
parser.add_argument('plugin_header', help='Path to QEMU plugin header.')
args = parser.parse_args()
syms = extract_symbols(args.plugin_header)
print('{')
for s in syms:
print(" {};".format(s))
print('};')
if __name__ == '__main__':
main()