qemu-kvm using excessive cpu

421 Views Asked by At

I'm looking for a question/answer regarding qemu-system-x86_64 taking an excessive amount of CPU time 400-800%, causing the VM to be unresponsive. It seems like after 10 to 30 minutes it calms down and runs OK at 35 - 50% CPU until the next time I have to reboot or start the host. Restarting qemu or the guest with the Virtual Machine Manager doesn't help. Turns out is isn't just on startup. Sometimes after the guest has been running fine, the host CPU usage goes back up for quite some time. It's currently running at 750 - 800%.

Hardware: Dell Precision M4700, 8 cores, 32 GB RAM Host: ubuntu 22.04 LTS Guest: Windows 10 Version 22H2 QEMU emulator version 6.2.0 (Debian 1:6.2+dfsg-2ubuntu6.15)

I've seen a couple of old postings here, one mentioning using the -enable-kvm option and another mentioning the -machine accel=kvm option. I don't see anything when I run ps aux|grep qemu-system|grep enable-kvm and when I run ps aux|grep qemu-system|grep accel I see "-accel kvm". It looks like -accel kvm is the current syntax according to the man page. My -cpu option is -cpu host,migratable=on,hv-time=on The complete result of ps aux|grep qemu-system is

4699 78.7 14.6 8925332 4783304 ?     Sl   Dec13 2062:19 /usr/bin/qemu-system-x86_64 -name guest=Win10,debug-threads=on -S -object {"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain-1-Win10/master-key.aes"} -machine pc-i440fx-focal,usb=off,vmport=off,dump-guest-core=off,memory-backend=pc.ram -accel kvm -cpu host,migratable=on,hv-time=on -m 6144 -object {"qom-type":"memory-backend-ram","id":"pc.ram","size":6442450944} -overcommit mem-lock=off -smp 16,sockets=2,dies=1,cores=4,threads=2 -uuid 1f385eae-2aa8-4e41-b569-87d876c42746 -no-user-config -nodefaults -chardev socket,id=charmonitor,fd=31,server=on,wait=off -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime -no-shutdown -global PIIX4_PM.disable_s3=1 -global PIIX4_PM.disable_s4=1 -boot strict=on -device qemu-xhci,p2=15,p3=15,id=usb,bus=pci.0,addr=0x5 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x6 -blockdev {"driver":"file","filename":"/var/lib/libvirt/images/Windows10.qcow2","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"} -blockdev {"node-name":"libvirt-1-format","read-only":false,"driver":"qcow2","file":"libvirt-1-storage","backing":null} -device ide-hd,bus=ide.0,unit=0,drive=libvirt-1-format,id=ide0-0-0,bootindex=1 -fsdev local,security_model=mapped,writeout=immediate,id=fsdev-fs0,path=/home/markp/SHARE -device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=/SHARE,bus=pci.0,addr=0x8 -netdev tap,fd=33,id=hostnet0 -device e1000,netdev=hostnet0,id=net0,mac=52:54:00:14:df:da,bus=pci.0,addr=0x3 -chardev spicevmc,id=charchannel0,name=vdagent -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=com.redhat.spice.0 -chardev socket,id=chrtpm,path=/run/libvirt/qemu/swtpm/1-Win10-swtpm.sock -tpmdev emulator,id=tpm-tpm0,chardev=chrtpm -device tpm-tis,tpmdev=tpm-tpm0,id=tpm0 -audiodev {"id":"audio1","driver":"spice"} -spice port=5900,addr=127.0.0.1,disable-ticketing=on,image-compression=off,seamless-migration=on -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,vram64_size_mb=0,vgamem_mb=16,max_outputs=2,bus=pci.0,addr=0x2 -device ich9-intel-hda,id=sound0,bus=pci.0,addr=0x4 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0,audiodev=audio1 -device usb-host,id=hostdev0,bus=usb.0,port=1 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x7 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny -msg timestamp=on

I can't do anything in the Windows VM during this long startup time since it is completely unresponsive.

Q1: would adding the -enable-kvm option help, assuming it is enabled my build of qemu?

Q2: if adding options, where do I do that? I don't know/remember how qemu is started on my machine, but it is automatically started.

Q3: any thoughts on what it is doing during this intense CPU usage period? The enabled Startup processes as listed by the Windows Task Manager are: TightVNC Server, Java Update Scheduler, Slack, Norton Secure Browser, Brave VPN Wireguard Service, Windows Security notification icon and SideSlide.exe (a desktop icon organizer).

Q4: any debugging suggestions?

Thanks for any ideas here.

Mark

I expect the VM to not use such excessive CPU time after a minute or so every time after starting up and periodically while its running. Makes it impractical to use and interrupts my work for apps that won't run under Linux.

1

There are 1 best solutions below

0
On

I may have solved my own performance issue by using the Virtual Machine Manager to undo "Manually set CPU topology" of 2 sockets, 2 cores and 2 threads and having the vCPU allocation at 2 of the 8 logical host CPUs. I'll have to see how it goes.

But I would still like to know how to add or modify the options for qemu-system-x86_64 or answers to any of my other questions.