[libvirt] [PATCH 04/36] cpu_x86: Do not cache microcode version

Jiri Denemark posted 36 patches 6 years, 10 months ago
[libvirt] [PATCH 04/36] cpu_x86: Do not cache microcode version
Posted by Jiri Denemark 6 years, 10 months ago
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>
---
 src/cpu/cpu_x86.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index add889c9a8..3b87386270 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -166,7 +166,6 @@ struct _virCPUx86Map {
 };
 
 static virCPUx86MapPtr cpuMap;
-static unsigned int microcodeVersion;
 
 int virCPUx86DriverOnceInit(void);
 VIR_ONCE_GLOBAL_INIT(virCPUx86Driver);
@@ -1424,8 +1423,6 @@ virCPUx86DriverOnceInit(void)
     if (!(cpuMap = virCPUx86LoadMap()))
         return -1;
 
-    microcodeVersion = virHostCPUGetMicrocodeVersion();
-
     return 0;
 }
 
@@ -2507,7 +2504,7 @@ virCPUx86GetHost(virCPUDefPtr cpu,
         goto cleanup;
 
     ret = x86DecodeCPUData(cpu, cpuData, models);
-    cpu->microcodeVersion = microcodeVersion;
+    cpu->microcodeVersion = virHostCPUGetMicrocodeVersion();
 
  cleanup:
     virCPUx86DataFree(cpuData);
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 04/36] cpu_x86: Do not cache microcode version
Posted by Ján Tomko 6 years, 10 months ago
On Mon, Apr 08, 2019 at 10:42:08AM +0200, Jiri Denemark wrote:
>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>
>---
> src/cpu/cpu_x86.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list