Spice display bash function

I’ve found myself using virsh more and more to manage my libvirt based virtual machines, as working from a CLI based shell is easier for me.  virt-manager is nice, but not all of the libvirt features are exposed in its GUI for vm management.    However, I didn’t see a virsh command for launching a running vm’s display.

I wrote a short bash function to launch the spice display for a vm.  Here’s what it looks like:

    `virsh -c qemu:///system domdisplay $1 | \
        sed -r 's#spice://([0-9|.]*)\?port=([0-9]*)#spicec -h \1 -p \2#'` &

Make sure you have installed the spice-client package, and then you can launch the graphical display for one of your running domains by executing:

$ spicedisplay <dom-name>

Leave a Reply