virsh show ifs

A handy script for showing the vms configured in libvirt.

While playing with virsh, I’m always interested in finding out the macs, networks and vnc port of the configured virtual machines.

Thus virsh_show_ifs.

#!/bin/bash

for x in $(virsh list --all | awk '{ if (NR > 2 && $2 != "") {print $2} }') ; do \
    v=$(virsh vncdisplay $x 2> /dev/null || true)
    echo "vm name: $x vnc: ${v:--}"
    virsh domiflist $x | awk '{ if (NR > 2) {print $0} }'
done

If this is useful to you, put it in your path. And feel free to share it with your geek friends. :)

comments powered by Disqus