[libvirt PATCH v2 2/3] cpu_map: Add script to sync from QEMU i386 cpu models

Jiri Denemark jdenemar at redhat.com
Tue Nov 3 16:45:24 UTC 2020


On Mon, Oct 19, 2020 at 09:36:16 +0200, Tim Wiederhake wrote:
> This script is intended to help in synchronizing i386 QEMU cpu model
> definitions with libvirt.
> 
> As the QEMU cpu model definitions are post processed by QEMU and not
> meant to be consumed by third parties directly, parsing this
> information is imperfect. Additionally, the libvirt models contain
> information that cannot be generated from the QEMU data, preventing
> fully automated usage. The output should nevertheless be helpful for
> a human in determining potentially interesting changes.
> 
> Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
> ---
>  src/cpu_map/sync_qemu_i386.py | 361 ++++++++++++++++++++++++++++++++++
>  1 file changed, 361 insertions(+)
>  create mode 100755 src/cpu_map/sync_qemu_i386.py

Looks good as in it apparently works for you and it generated good
results, but...

> diff --git a/src/cpu_map/sync_qemu_i386.py b/src/cpu_map/sync_qemu_i386.py
> new file mode 100755
> index 0000000000..c5c1e621a3
> --- /dev/null
> +++ b/src/cpu_map/sync_qemu_i386.py
> @@ -0,0 +1,361 @@
> +#!/usr/bin/env python3
...
> +def read_builtin_x86_defs(filename):
> +    """Extract content between begin_mark and end_mark from file `filename` as
> +    string, while expanding shorthand macros like "I486_FEATURES"."""
> +
> +    begin_mark = "static X86CPUDefinition builtin_x86_defs[] = {\n"
> +    end_mark = "};\n"
> +    shorthand = re.compile("^#define ([A-Z0-9_]+_FEATURES) (.*)$")
> +    lines = list()
> +    shorthands = dict()
> +
> +    with open(filename, "rt") as f:
> +        while (line := readline_cont(f)) != begin_mark:

:= is a new thing introduced in python 3.8 and we still support older
versions (at least 3.6, perhaps even 3.5 or 3.4, I'm not exactly sure
which versions are used by supported OS distributions).

"meson test" would report this and several other issues. But you need to
install flake8 first.

Jirka




More information about the libvir-list mailing list