4 # This script will attempt to get the ip address of the a given libvirt guest.
6 PATH=$PATH:/usr/sbin:/sbin
10 # Get the MAC address of the first interface by looking for looking for the
11 # `<mac address...` line. Yes, we're parsing XML with awk. It's probably
12 # safe (because the XML is coming from libvirt, so we can be reasonably
13 # confident that the formatting will remain the same).
14 mac=$(virsh dumpxml $VMNAME | awk -F "'" '/mac address/ { print $2; exit }')
16 # Look up the MAC address in the ARP table.
17 ip=$(ip neigh | grep $mac | awk '{print $1;}')
20 echo "vm ip is not available" >&2