From: Tim Wiederhake Date: Mon, 23 Nov 2020 14:14:24 +0000 (+0100) Subject: cpu_map: sync_qemu_cpu_i386: Factor out translation of vendors X-Git-Tag: v7.0.0-rc1~286 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4d0b1549cc9e30130bd65e41c2f3c59e5a501ac9;p=thirdparty%2Flibvirt.git cpu_map: sync_qemu_cpu_i386: Factor out translation of vendors Signed-off-by: Tim Wiederhake Reviewed-by: Jiri Denemark --- diff --git a/src/cpu_map/sync_qemu_i386.py b/src/cpu_map/sync_qemu_i386.py index 8deda869df..f86cdf969f 100755 --- a/src/cpu_map/sync_qemu_i386.py +++ b/src/cpu_map/sync_qemu_i386.py @@ -8,11 +8,6 @@ import re T = { - # translating qemu -> libvirt cpu vendor names - "CPUID_VENDOR_AMD": "AMD", - "CPUID_VENDOR_INTEL": "Intel", - "CPUID_VENDOR_HYGON": "Hygon", - # translating qemu -> libvirt cpu feature names "CPUID_6_EAX_ARAT": "arat", "CPUID_7_0_EBX_ADX": "adx", @@ -152,6 +147,20 @@ T = { } +def translate_vendor(name): + T = { + "CPUID_VENDOR_AMD": "AMD", + "CPUID_VENDOR_INTEL": "Intel", + "CPUID_VENDOR_HYGON": "Hygon", + } + + if name in T: + return T[name] + + print("warning: Unknown vendor '{}'".format(name)) + return name + + def readline_cont(f): """Read one logical line from a file `f` i.e. continues lines that end in a backslash.""" @@ -264,7 +273,7 @@ def expand_model(model): result = { "name": model.pop(".name"), - "vendor": T[model.pop(".vendor")], + "vendor": translate_vendor(model.pop(".vendor")), "features": set(), "extra": dict()}