Skip to content

Instantly share code, notes, and snippets.

@larsks
Created December 15, 2012 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larsks/4300055 to your computer and use it in GitHub Desktop.
Save larsks/4300055 to your computer and use it in GitHub Desktop.
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