Use kernel specific for virtualization
Use linux-image-kvm kernel which is designed for KVM virtualization.
For example, in Ubuntu, you should execute following commands:
apt install linux-image-kvm apt purge linux-image-generic
Clean up before publishing a template
# removes logs journalctl --vacuum-size=1 # removes user history history -c
(as root) rm /root/.bash_history