[libvirt PATCH v2 2/9] cpu_map: sync_qemu_cpu_i386: Factor out translation of vendors

Tim Wiederhake twiederh at redhat.com
Wed Nov 18 15:24:11 UTC 2020


Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
---
 src/cpu_map/sync_qemu_i386.py | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/cpu_map/sync_qemu_i386.py b/src/cpu_map/sync_qemu_i386.py
index 82413d831e..fe95f26511 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()}
 
-- 
2.26.2




More information about the libvir-list mailing list