[libvirt-users] Guest interface info under ESX driver

Matthias Bolte matthias.bolte at googlemail.com
Mon Jan 31 13:45:22 UTC 2011

2011/1/31 Sengor <sengork at gmail.com>:
> Hi Justin,
> Thanks. I did come across that post, but was hoping there'd be a more
> contained method of finding the domain's IP address without needing to
> do ARP/MAC lookups or query the DHCP server itself.

Currently libvirt doesn't provide a function to get the IP address of
a domain's network interface.

Might be a useful addition as libvirt can know/determine the IP
address in several cases.

> The following does not display the IP either for an ESX guest 'testvm':
> virsh # dumpxml testvm
> ...
>    <interface type='bridge'>
>      <mac address='00:0c:29:09:ab:2c'/>
>      <source bridge='VM Network'/>
>    </interface>
> ...

The domain XML doesn't contain the IP address (yet).

With VMware tools installed in the guest it might be possible to
obtain the IP address via the vSphere API, I didn't test this yet.

But libvirt doesn't have a function to expose this information yet.

> Looking around the libvirt Python bindings reveals class virInterface
> from lib/site-packages/libvirt.py with the following function:
>    def XMLDesc(self, flags):
>        """VIR_INTERFACE_XML_INACTIVE - return the static configuration,
>                                          suitable for use redefining the
>                                          interface via virInterfaceDefineXML()
>        Provide an XML description of the interface. If
>        VIR_INTERFACE_XML_INACTIVE is set, the description may be reused
>        later to redefine the interface with virInterfaceDefineXML(). If it
>        is not set, the ip address and netmask will be the current live
>        setting of the interface, not the settings from the config files. """
>        ret = libvirtmod.virInterfaceGetXMLDesc(self._o, flags)
>        if ret is None: raise libvirtError ('virInterfaceGetXMLDesc()
> failed', net=self)
>        return ret
> This looks promising (if it indeed does work for ESX driver), however
> I've not figured out how to use this particular class/function yet. So
> far unable to find any examples on the web...

virInterface is for the host network interfaces, this is not what
you're looking for.

> Lastly I cannot tell whether this is supported at all for the ESX
> driver given the current driver support matrix:
> http://www.libvirt.org/hvsupport.html

This matrix is quite outdated, and needs to be updated :(


> On Mon, Jan 31, 2011 at 4:22 PM, Justin Clift <jclift at redhat.com> wrote:
>> On 30/01/2011, at 11:19 PM, Sengor wrote:
>>> Hi,
>>> Is there a way to fetch the current IP address of a running guest
>>> domain (with VMware Tools installed) running on an ESX host?
>>> Ideally this would be doable via the libvirt Python bindings.
>> Hi Sengor,
>> Does this help?
>>  https://rwmj.wordpress.com/2010/10/26/tip-find-the-ip-address-of-a-virtual-machine/
>> I'm unsure about it's interaction with vSphere/ESX though.
>> Regards and best wishes,
>> Justin Clift
> --
> sengork
> _______________________________________________
> libvirt-users mailing list
> libvirt-users at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-users

More information about the libvirt-users mailing list