Re: RFC: Implement virDomainGetIPAddress()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 14, 2011 at 05:14:57PM +0200, Michal Novotny wrote:
> Hi guys,
> some time ago I've been investigating the options to get the guest's IP
> address information without having to connect to guest's VNC window or
> console. It was for one project I've been working on and I found that
> the solution lies in the procfs, precisely in the /proc/{PID}/net/arp...
> 
> The format is as follows:
> 
> $ cat /proc/{PID}/net/arp
> IP address       HW type     Flags       HW address            Mask    
> Device
> 192.168.122.36   0x1         0x2         52:54:00:35:76:e6     *       
> virbr0
> 
> where the HW address matches the MAC address associated to the guest's
> NIC. Implementing such an API shouldn't be a big problem however I know
> that there's some option to run libvirt on Windows machines. It should
> be just the client so it shouldn't really matter however I'd like to ask
> you whether it's really not an issue.
> 
> The function should return a string of the guest's IP address as read
> from the procfs or return a NULL value if there's no IP address
> associated with the guest.
> 
> If the multiple NICs are being used by the guest then the function
> should return either the IP address matching the MAC address passed to
> the function or the first IP address if omitted.
> 
> The prototype should be:
> 
> char *virDomainGetIPAddress(virDomainPtr domain, char *devmac);
> 
> For this the internal information about PID of the process spawned
> should be used (this is already being tracked and stored by libvirt
> IMHO) to access the /proc/{PID}/net/arp file.
> 
> This API function would be very useful since it would give libvirt users
> option to get the information of the guest's IP address without having
> to connect to guest's VNC window or console.
> 
> For virsh this could be implemented directly into the dominfo subcommand.
> 
> What do you think about implementing this ?

I'm not entirely convinced was want to have this in our APIs, since the
arp probing is not really a reliable basis for reporting guest IP details.
In the near future there will be guest agents for QEMU which can report
this information reliably and I think they're a better bet for any app
which would want this information.

Regards,
Daniel
--
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]