Jean-Pierre Ribeauville
2016-Jan-07 19:31 UTC
[libvirt-users] Unable to retrieve Guest IP Addresses via libvirt API
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 Additionnaly : - IP Addresses are not present within the xmldesc of this Guest.(not sure that they should appear there) I'm running libvirt-1.2.17-13.el7.x86_64 Did I misunderstood something ? As ovirt manager shows the address correctly , it should be possible to get it via libvirt ... Thanks for help. J.P. Ribeauville P: +33.(0).1.47.17.20.49 . Puteaux 3 Etage 5 Bureau 4 jpribeauville@axway.com<mailto:jpribeauville@axway.com> http://www.axway.com<http://www.axway.com/> P Pensez à l'environnement avant d'imprimer.
Martin Kletzander
2016-Jan-08 09:36 UTC
Re: [libvirt-users] Unable to retrieve Guest IP Addresses via libvirt API
On Thu, Jan 07, 2016 at 07:31:57PM +0000, 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 > > >Additionnaly : >- IP Addresses are not present within the xmldesc of this Guest.(not sure that they should appear there) > >I'm running libvirt-1.2.17-13.el7.x86_64 > >Did I misunderstood something ? > >As ovirt manager shows the address correctly , it should be possible to get it via libvirt ... >Can you get them using virsh domifaddr? If yes, look at the code virsh uses. If not, then it might be ovirt's workaround using their agent for older qemu/libvirt/something combinations.>Thanks for help. > > >J.P. Ribeauville > > >P: +33.(0).1.47.17.20.49 >. >Puteaux 3 Etage 5 Bureau 4 > >jpribeauville@axway.com<mailto:jpribeauville@axway.com> >http://www.axway.com<http://www.axway.com/> > > > >P Pensez à l'environnement avant d'imprimer. > > >>_______________________________________________ >libvirt-users mailing list >libvirt-users@redhat.com >https://www.redhat.com/mailman/listinfo/libvirt-users
Jean-Pierre Ribeauville
2016-Jan-08 09:47 UTC
Re: [libvirt-users] Unable to retrieve Guest IP Addresses via libvirt API
Hi, My piece of code is inspired from domifaddr one. Virsh domifaddr doesn't return anything. Then , it could be useful for me to have a look in ovirt sources to understand how it deals with that. As a workaround , it should be possible to combine a dumpxml to retrieve Guest MAC addresses and then issue an "arp -an" to retrieve IP adresses. Regards, J.P. -----Message d'origine----- De : Martin Kletzander [mailto:mkletzan@redhat.com] Envoyé : vendredi 8 janvier 2016 10:36 À : Jean-Pierre Ribeauville Cc : libvirt-users@redhat.com Objet : Re: [libvirt-users] Unable to retrieve Guest IP Addresses via libvirt API On Thu, Jan 07, 2016 at 07:31:57PM +0000, 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 > > >Additionnaly : >- IP Addresses are not present within the xmldesc of this Guest.(not >sure that they should appear there) > >I'm running libvirt-1.2.17-13.el7.x86_64 > >Did I misunderstood something ? > >As ovirt manager shows the address correctly , it should be possible to get it via libvirt ... >Can you get them using virsh domifaddr? If yes, look at the code virsh uses. If not, then it might be ovirt's workaround using their agent for older qemu/libvirt/something combinations.>Thanks for help. > > >J.P. Ribeauville > > >P: +33.(0).1.47.17.20.49 >. >Puteaux 3 Etage 5 Bureau 4 > >jpribeauville@axway.com<mailto:jpribeauville@axway.com> >http://www.axway.com<http://www.axway.com/> > > > >P Pensez à l'environnement avant d'imprimer. > > >>_______________________________________________ >libvirt-users mailing list >libvirt-users@redhat.com >https://www.redhat.com/mailman/listinfo/libvirt-users
Michal Privoznik
2016-Jan-11 11:41 UTC
Re: [libvirt-users] Unable to retrieve Guest IP Addresses via libvirt API
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 -1You 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