You can use this script with your qemu kvm instances that configured by libvirt. It will add itself to crontab as 1 minute job.
cd /
wget https://raw.githubusercontent.com/Scispow/auto-ballooning-kvm/master/auto-balloon.bash
chmod +x auto-balloon.bash
bash auto-balloon.bash