Run guest a defined model like:
23 <cpu mode='custom' match='exact' check='partial'>
24 <model fallback='forbid'>SandyBridge-IBRS</model>
25 <vendor>Intel</vendor>
26 </cpu>
In the guest check the cache file update time:
$ sudo ls -laF /var/cache/libvirt/qemu/capabilities/
-rw------- 1 root root 75171 Sep 2 08:58 926803a9278e445ec919c2b6cbd8c1c449c75b26dcb1686b774314180376c725.xml
-rw------- 1 root root 85376 Sep 2 08:58 f11008721aacc79c97e592178e61264d75be551864cd79cc41fe820e31262f27.xml
$ virsh domcapabilities > dpre
$ virsh capabilities > cpre
$ head -n5 /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 42
model name : Intel Xeon E312xx (Sandy Bridge, IBRS update)
Then shutdown and change that to IvyBridge-IBRS (similar but not the same)
When again started it should refresh the cache, as the CPU changed.
But without the fix it hasn't.
While cpuinfo changed, the cache and results didn't.
$ head -n5 /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 58
model name : Intel Xeon E3-12xx v2 (Ivy Bridge, IBRS)
$ virsh domcapabilities > dpost
$ virsh capabilities > cpost
$ md5sum cp* dp*
f0df917463798992d5842297fa039f86 cpost
4f214575cab864502576a0da1bceb031 cpre
94d6fe53ee5f9f6270e001788a225328 dpost
94d6fe53ee5f9f6270e001788a225328 dpre
And after reboot into the other type we see the host section updated.
$ md5sum cp* dp*
4f214575cab864502576a0da1bceb031 cpost
f0df917463798992d5842297fa039f86 cpre
94d6fe53ee5f9f6270e001788a225328 dpost
94d6fe53ee5f9f6270e001788a225328 dpre
-rw------- 1 root root 75171 Sep 2 09:04 926803a9278e445ec919c2b6cbd8c1c449c75b26dcb1686b774314180376c725.xml
-rw------- 1 root root 85376 Sep 2 09:04 f11008721aacc79c97e592178e61264d75be551864cd79cc41fe820e31262f27.xml
There are more complex feature checks that might go deeper e.g. when actually starting a guest and deriving host-model. But this should be ok as a test of the area I hope.
P.S. I've yet to see the "Outdated capabilities for '%s': host CPU changed" message in a debug log, maybe the tests needs to be further adapted for the specific case.
Test the test to be helpful:
Run guest a defined model like: 'forbid' >SandyBridge- IBRS</model> Intel</ vendor>
23 <cpu mode='custom' match='exact' check='partial'>
24 <model fallback=
25 <vendor>
26 </cpu>
In the guest check the cache file update time: libvirt/ qemu/capabiliti es/ ec919c2b6cbd8c1 c449c75b26dcb16 86b774314180376 c725.xml c97e592178e6126 4d75be551864cd7 9cc41fe820e3126 2f27.xml
$ sudo ls -laF /var/cache/
-rw------- 1 root root 75171 Sep 2 08:58 926803a9278e445
-rw------- 1 root root 85376 Sep 2 08:58 f11008721aacc79
$ virsh domcapabilities > dpre
$ virsh capabilities > cpre
$ head -n5 /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 42
model name : Intel Xeon E312xx (Sandy Bridge, IBRS update)
Then shutdown and change that to IvyBridge-IBRS (similar but not the same)
When again started it should refresh the cache, as the CPU changed.
But without the fix it hasn't.
While cpuinfo changed, the cache and results didn't.
$ head -n5 /proc/cpuinfo 2d5842297fa039f 86 cpost 02576a0da1bceb0 31 cpre 270e001788a2253 28 dpost 270e001788a2253 28 dpre
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 58
model name : Intel Xeon E3-12xx v2 (Ivy Bridge, IBRS)
$ virsh domcapabilities > dpost
$ virsh capabilities > cpost
$ md5sum cp* dp*
f0df91746379899
4f214575cab8645
94d6fe53ee5f9f6
94d6fe53ee5f9f6
With the fix:
-rw------- 1 root root 75171 Sep 2 09:04 926803a9278e445 ec919c2b6cbd8c1 c449c75b26dcb16 86b774314180376 c725.xml c97e592178e6126 4d75be551864cd7 9cc41fe820e3126 2f27.xml
-rw------- 1 root root 85376 Sep 2 09:04 f11008721aacc79
And after reboot into the other type we see the host section updated. 02576a0da1bceb0 31 cpost 2d5842297fa039f 86 cpre 270e001788a2253 28 dpost 270e001788a2253 28 dpre ec919c2b6cbd8c1 c449c75b26dcb16 86b774314180376 c725.xml c97e592178e6126 4d75be551864cd7 9cc41fe820e3126 2f27.xml
$ md5sum cp* dp*
4f214575cab8645
f0df91746379899
94d6fe53ee5f9f6
94d6fe53ee5f9f6
-rw------- 1 root root 75171 Sep 2 09:04 926803a9278e445
-rw------- 1 root root 85376 Sep 2 09:04 f11008721aacc79
$ diff -Naur cpre cpost 058268cb- 6229-46c7- 84f8-5cd8edac4c 5d</uuid>
<arch>x86_ 64</arch> IvyBridge- IBRS</model> SandyBridge- IBRS</model>
<vendor> Intel</ vendor>
--- cpre 2020-09-02 09:04:41.058583142 +0000
+++ cpost 2020-09-02 09:05:50.652000000 +0000
@@ -4,10 +4,11 @@
<uuid>
<cpu>
- <model>
+ <model>
<microcode version='1'/>
<topology sockets='1' cores='1' threads='1'/>
+ <feature name='vme'/>
<feature name='osxsave'/>
<feature name='hypervisor'/>
<feature name='arat'/>
There are more complex feature checks that might go deeper e.g. when actually starting a guest and deriving host-model. But this should be ok as a test of the area I hope.
P.S. I've yet to see the "Outdated capabilities for '%s': host CPU changed" message in a debug log, maybe the tests needs to be further adapted for the specific case.