Bash script to start a KVM domain on a failed connection attempt as reported by "auth.log":
Jan 1 23:46:09 bastion systemd-logind[1086]: New session 73 of user maurits.
Jan 1 23:46:12 bastion sshd[10206]: error: connect_to win10-vm1 port 3389: failed.
Jan 1 23:46:12 bastion sshd[10206]: channel_by_id: 0: bad id: channel free
This script will issue a "virsh start win10-vm1" command based on the "error: connect_to win10-vm1 port 3389: failed" message.
In case there is no /var/log/auth.log file then run:
apt-get install rsyslog
Related blog post: https://tqdev.com/2022-boot-rdp-connected-vm-on-demand