What is the best way to ensure a QEMU Guest OS(es) cannot consume Host resources to the point that it affects routing/firewall duties?
As routing/firewall happens in the kernel is it automatically prioritized over the user-space QEMU processes? But what about other 'essential' services like VPN and DNS?
Host is running OpenWRT. Three QEMU guests run on it (web server, print server and Home Assistant). Hardware is a 4 Core Xeon, 64GB ram.
I ask because occasionally HomeAssistant has to compile some C++ binaries for ESP home and when it does this it looks like QEMU is using 100% CPU on all four physical cores.
Obviously could limit QEMU to 2 cores but this is wasteful because it can't use the extra processing power when it needs to. All I want is to ensure that OpenWRT host processes always get priority over the QEMU guest processes. Could this just be done with nice?
Yes, that's common on a computer when compiling. Aren't you able to configure the VM's CPU processing?
TBH, I've never used QEMU with OpenWrt or other non GUI Linux distros; but in all Hypervisors, I've been able to configure the CPU usage percentage, etc. This is a VirtualBox example (which uses QEMU):
You need to add something to your esphome YAML file for the build:
compile_process_limit (Optional, int): The maximum number of simultaneous compile processes to run. Defaults to the number of cores of the CPU which is also the maximum you can set.
Not yet, was going to see if anyone had any other bright ideas. You can limit the CPU% using QEMU but then you are limiting it at all times (essentially wasting spare CPU cycles if the host isn't doing anything).
I think 'nice' is the right answer, but wanted to check.
True, but the proof would be that the router/firewall functions truly do get priority, so I'd need to stress the router at the same time. I'll try streaming some 4K video over a VPN connection and see if it handles that while compiling.