Find Guest IP address using QEMU Guest Agent

Ever needed to find the IP address of a particular guest? Of course, the answer is “yes”. For the most part I have either resorted to going in through the console of the VM to find this information or used some nifty little script like the one described here by Richard Jones. However, if you have qemu Guest Agent set up ( I covered this briefly in a previous post ), then you can just query this information using the guest-network-get-interfaces qemu-ga command:

[root@host ~]# virsh qemu-agent-command Fedora19 \
'{"execute":"guest-network-get-interfaces"}' | python -mjson.tool
{
"return": [
{
{
"prefix": 8
},
{
"prefix": 128
}
],
"name": "lo"
},
{
{
"prefix": 24
},
{