RFE: Expose tb-size option for accel=tcg in qemu
Software environment
- Operating system: any
- Architecture: x86_64
- kernel version: any
- libvirt version: any
- Hypervisor and version: qemu >= 5.0
Description of problem
When running with qemu but without kvm, i.e. accel=tcg, qemu since 5.0 uses much more memory than before, leading to issues in some situations, in particular when trying to run a larger number of small guests, as is happening in some CI environments.
Steps to reproduce
See qemu-project/qemu#693 (closed)
Additional information
With qemu-project/qemu@600e17b2 qemu has increased the default tb-size for x86_64 hosts from 32MB to 1024MB. This increases performance for most applications, but leads to memory pressure for some cases. In particular it was seen in the OpenStack Upstream CI (where we cannot use nested-kvm due to unstable support by the different cloud providers), that when running on Debian 11 (Bullseye), which has qemu-5.2 containing the above patch, there are regular OOM failures when running multiple tempest tests in parallel. After discussing in qemu-project/qemu#693 (closed), it seems that the way forward would be allow to override the default tb-size in such a situation, since automatic tuning doesn't seem feasible. It was suggested that the resulting XML could look like this:
<domain type='tcg'>
....
<features>
<tcg>
<tb-cache size="100" units="MiB"/>
</tcg>
</features>
....
</domain>