Few days ago libvirt has started to behave erratically on my laptop. It consumes a high amount of CPU without any apparent reason. ALL my VMs are shutoff, why is libvirt using up to 100% CPU if no VMs are running?
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
203328 root 20 0 1640992 37056 22308 R 86,1 0,1 22:57.03 libvirtd
Killing the process makes my laptop happy. Problem comes back as soon as the process is started again. No idea how to debug or fix this, any help is welcome.
Using up to date Ubuntu 21.10, kernel 5.13.0-30-generic.
Profile the process to find what exactly is on CPU.
Install debug symbols for libvirt, to get function names.
Watch real time performance counter with
perf top --freq=999 --pid==$(pgrep libvirtd)
Orperf record
to save to file for analysis later. Frequency one off a multiple of ten is to not be locked to things on the second, got this from Gregg.Analyzing the results of what is on CPU requires some thought. At a high level, what is it doing? How can that be made more efficient? This probably requires talking to OS (Ubuntu) and/or libvirt support channels.
If this is contributes to unacceptable power or thermal demands on your laptop, consider moving the VM to be hosted somewhere else.