Skip to content

Instantly share code, notes, and snippets.

Created Dec 15, 2012
What would you like to do?
Get the address of a libvirt virtual instance
mac=$(virsh dumpxml $1 |
xml2 |
awk -F= '$1 == "/domain/devices/interface/mac/@address" {print $2; exit}')
ip=$(awk -vmac=$mac '$2 == mac {print $3}' /var/lib/libvirt/dnsmasq/default.leases )
echo $ip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment