Skip to content

Instantly share code, notes, and snippets.

@larsks
Created December 15, 2012 22:47
Get the address of a libvirt virtual instance
#!/bin/sh
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