[SOLVED] Custom CPU model is behaving abnormally.

masato

Member
Mar 4, 2023
26
4
8
Even if you create a custom CPU model based on qemu64 and run it, it will not start with the CPU flags you set.

cpu-models.conf
-----
cpu-model: x86-64_fix
flags +vme;+svm;+abm;+aes;+avx;+avx2;+avx512bw;+avx512cd;+avx512dq;+avx512f;+avx512vl;+bmi1;+bmi2;enforce;+f16c;+fma;hv_ipi;hv_relaxed;hv_reset;hv_runtime;hv_spinlocks=0x1fff;hv_stimer;hv_synic;hv_time;hv_vapic;hv_vpindex;+kvm_pv_eoi;+kvm_pv_unhalt;+movbe;+pni;+popcnt;+sse4.1;+sse4.2;+ssse3;+xsave
hidden 1
reported-model qemu64
-----

qemu-system-x86_64 command Line
-----
-cpu qemu64,enforce,hv_ipi,hv_relaxed,hv_reset,hv_runtime,hv_spilocks=0x1fff,hv_stimer,hv_synic,hv_time,hv_vapic,hv_vpindex,kvm=off,+kvm_pv_eoi,+kvm_pv_unhalt
-----
 
Could you post the config of the affected VM in its entirety? That would be helpful to see if some other options may interfere here. Please provide the output of the following two commands: qm config <VMID> and qm showcmd <VMID>, replace <VMID> with the ID of an affected VM. Thanks!
 
Last edited:
I found the cause.
It seems that setting flags to "enforce", "hv_relaxed", etc. causes a regex error.
If I set it to "+hv_relaxed", the regex doesn't cause an error, but the qemu command still causes an error.

qm config 1033001
Code:
file /etc/pve/virtual-guest/cpu-models.conf line 2 (section 'x86-64_fix') - unable to parse value of 'flags': value does not match the regex pattern
agent: 1
bios: ovmf
boot: order=scsi0;sata0;net0
cores: 32
cpu: custom-x86-64_fix
efidisk0: local-zfs:vm-1033001-disk-0,efitype=4m,pre-enrolled-keys=1,size=4M
hookscript: local:snippets/pcie_hostdev.sh
hostpci0: 0000:13:00.0,pcie=1
hostpci1: 0000:7b:00.3,pcie=1
hostpci2: 0000:7b:00.4,pcie=1
hostpci3: 0000:01:00.0,pcie=1
hostpci4: 0000:01:00.1,pcie=1
machine: pc-q35-9.2+pve1
memory: 16384
meta: creation-qemu=9.2.0,ctime=1749808390
name: Win11
net0: virtio=BC:24:11:DF:82:CC,bridge=vmbr0
numa: 1
ostype: win11
parent: init_setup
sata0: local:iso/Win11_23H2_Japanese_x64v2.iso,media=cdrom,size=6561616K
scsi0: local-zfs:vm-1033001-disk-1,size=1000G,ssd=1
scsihw: virtio-scsi-single
smbios1: uuid=f56e328f-f1fe-4b46-a074-67df8448e164
sockets: 1
tpmstate0: local-zfs:vm-1033001-disk-2,size=4M,version=v2.0
vcpus: 32
vga: std
vmgenid: c85a2eac-bdb9-4f93-a4d7-1a96e2607913
 
It seems that setting flags to "enforce", "hv_relaxed", etc. causes a regex error.
If I set it to "+hv_relaxed", the regex doesn't cause an error, but the qemu command still causes an error.
Yes that makes sense, I'm assuming this fixes the issue for you? If so, please mark this thread as solved by adding the “Solved” prefix via the “Edit Thread” menu above. Thanks!
 
Does this mean that they have no intention of supporting flags without "+" or "-"?
I think the problem is that they don't support the strings that are supported as arguments to "-CPU".
 
Does this mean that they have no intention of supporting flags without "+" or "-"?
I think the problem is that they don't support the strings that are supported as arguments to "-CPU".
I think you are just misunderstanding the format here. The documentation [1] here mentions that each flag you want to specify, needs to be prefixed by either a “+” or a “-”. If you prefix the flag with a “+” it will be enabled. If the flag is otherwise enabled, prefixing it with “-” would disable it.

So yes, the format is not identical to the one that you pass to -cpu, but it should be fairly straight forward.

[1]: https://pve.proxmox.com/wiki/Manual:_cpu-models.conf
 
This is probably a request.

If you want to change the value of "hv_spinlocks=0x1fff", please allow "+hv_spinlocks=xxxx", and if the parameter does not require a "+" in the CPU flag, please pass the parameter without the "+".

+hv_spinlocks=xxxx -> hv_spinlocks=xxxx
+hv_reset -> hv_reset
 
So I looked into the “CPU Flags” you mention here are “Hyper-V Enlightenments” (hv_spinlocks, hv_reset) [1]. Can you try simply adding this line to your config:

Code:
args: -cpu host,vme,svm,abm,aes,avx,avx2,avx512bw,avx512cd,avx512dq,avx512f,avx512vl,bmi1,bmi2,enforce,f16c,fma,hv_ipi,hv_relaxed,hv_reset,hv_runtime,hv_spinlocks=0x1fff,hv_stimer,hv_synic,hv_time,hv_vapic,hv_vpindex,kvm_pv_eoi,kvm_pv_unhalt,movbe,pni,popcnts,se4.1,sse4.2,ssse3,xsave

Although this should not be necessary for VMs that are not running Hyper-V to my understanding.

[1]: https://www.qemu.org/docs/master/system/i386/hyperv.html