> I am a novice like yourself ...
> Can it be that the guest OS is going to "hibernate" or "suspend" or so automatically after a defined period of inactivity and you just misinterpret this as kvm/qemu behavior?
> best ... Gunnar
In order to remove this possibility, I ran the following command in my LUbunutu vm and restarted the vm :
>> systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
Unfortunately, the system still slows down when it is in the background.
> I think what they're observing, and I may be wrong, is that either their desktop environment, or Qemu, or their OS, is de-prioritizing Qemu when it loses foreground focus, and causing it to see timer events and processing time at a much lower priority than when it is in the foreground.
> Alternative suggestion: Try running the VM either as a user mode or system mode libvirt guest with Qemu?
To address the concern that the OS (in my case OSX) may be deprioritizing the process, I changed by start.sh script to the following:
nice -n -20 qemu-system-x86_64 \
-m 4G \
-net nic -net user,hostfwd=tcp::2222-:22 \
-vga virtio \
-display default,show-cursor=on \
-usb \
-device usb-tablet \
-machine type=q35,accel=hvf \
-smp 2 \
-drive file=ubuntu-16.04.7-desktop-amd64.qcow2,if=virtio \
-cpu host \
And ran it with sudo, and it still slowed down after a few minutes.
I am not sure how to run the VM as user mode. I am assuming the above script is running as system mode?