[libvirt-users] Unable to retrieve Guest IP Addresses via libvirt API

Michal Privoznik mprivozn at redhat.com
Mon Jan 11 11:41:50 UTC 2016


On 07.01.2016 20:31, Jean-Pierre Ribeauville wrote:
> Hi ,
> 
> Despite the fact that my Guest has an IP address , by running  this piece of code on a KVM host :
> 
>      ifaces_count = F_virDomainInterfaceAddresses(domain, &ifaces,VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE, NULL);
>      ifaces_count = F_virDomainInterfaceAddresses(domain, &ifaces,VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT, NULL);
> 
> 
> I'm not able to get a  ifaces_count  different from -1

You should have also obtained a stringified error that explains what
went wrong. That might give you hint.

> 
> 
> Additionnaly :
> -  IP Addresses are not present within the xmldesc of this Guest.(not sure that they should appear there)

No. Guest can reconfigure its NICs into something completely different
that does not even match domain XML. For instance - it can create a
bonding over two vNICs. In that case none of vNICs has an IP address -
it's the bonding device that has it. However, the bonding device itself
is not reported in the domain XML.

But maybe more importantly, I consider IP address as a guest runtime
setting, not a part of hardware. And as such it falls out of domain XML
scope where domain HW is configured. If we were reporting IP addresses
there why stop only there and why not report other runtime info too?
E.g. some /sys /proc values?

Having said that, I am against reporting IP addresses in domain XML.

Michal




More information about the libvirt-users mailing list