]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cpu_x86: Do not cache microcode version
authorJiri Denemark <jdenemar@redhat.com>
Fri, 5 Apr 2019 09:33:32 +0000 (11:33 +0200)
committerDaniel P. Berrangé <berrange@redhat.com>
Tue, 14 May 2019 18:21:48 +0000 (19:21 +0100)
The microcode version checks are used to invalidate cached CPU data we
get from QEMU. To minimize /proc/cpuinfo parsing the microcode version
was only read when libvirtd started and cached for the daemon's
lifetime. However, the CPU microcode can change anytime (updating the
microcode package can automatically upload it to the CPU) and we need to
stop caching it to avoid using stale CPU model data.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit be46f613261d3b655a1f15afd635087e68a9c39b)

src/cpu/cpu_x86.c

index d3a88da21d30efdacc064514efaabfb67ed30c77..470de83a8707abcba24dfe2bb3caee47e5a0f2c2 100644 (file)
@@ -165,7 +165,6 @@ struct _virCPUx86Map {
 };
 
 static virCPUx86MapPtr cpuMap;
-static unsigned int microcodeVersion;
 
 int virCPUx86DriverOnceInit(void);
 VIR_ONCE_GLOBAL_INIT(virCPUx86Driver);
@@ -1332,8 +1331,6 @@ virCPUx86DriverOnceInit(void)
     if (!(cpuMap = virCPUx86LoadMap()))
         return -1;
 
-    microcodeVersion = virHostCPUGetMicrocodeVersion();
-
     return 0;
 }
 
@@ -2373,7 +2370,7 @@ virCPUx86GetHost(virCPUDefPtr cpu,
         goto cleanup;
 
     ret = x86DecodeCPUData(cpu, cpuData, models);
-    cpu->microcodeVersion = microcodeVersion;
+    cpu->microcodeVersion = virHostCPUGetMicrocodeVersion();
 
  cleanup:
     virCPUx86DataFree(cpuData);