virsh list --all; # show all available vms (if the list is empty check this article)
virsh start vmname; # start the vm
virsh dominfo vmname; # get info on vm

Id: 2
Name: vmname
UUID: 84bb8e99-2fb2-499a-9ca1-xxxxxxxxxxxx
OS Type: hvm
State: running
CPU(s): 4
CPU time: 2.4s
Max memory: 4194304 KiB
Used memory: 4194304 KiB
Persistent: yes
Autostart: disable
Managed save: no
Security model: apparmor
Security DOI: 0
Security label: libvirt-84bb8e99-2fb2-499a-9ca1-xxxxxxxxxxxx (enforcing)
Messages: tainted: potentially unsafe use of host CPU passthrough

virsh domdisplay vmname; # get more info on vm
spice://127.0.0.1:5901

remote-viewer 'spice://127.0.0.1:5901'; # connect to display of vm

virt-viewer 'spice://127.0.0.1:5901'; # also try this

# script it v1, tested once (seems to work, no guarantees)
VMNAME="name_of_the_vm"
virsh start $VMNAME;
VM_IP=$(virsh domifaddr $VMNAME --source lease | awk '/ipv4/ {print $4}' | cut -d/ -f1)
VM_CONNECTION=$(virsh domdisplay $VMNAME)
VM_VNCPORT=${VM_CONNECTION##*:};
echo "waiting for $VMNAME ($VM_IP) to be up, then connecting to $VM_VNCPORT..."
until ping -c1 -W1 $VM_IP >/dev/null 2>&1; do sleep 1; done && remote-viewer "spice://127.0.0.1:$VM_VNCPORT"

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!
admin