[libvirt] Host IP Address

Maximilian Wilhelm max at rfc2324.org
Wed Jun 23 06:26:28 UTC 2010


Anno domini 2010 IKI-サガル バルウェ scripsit:

Hi!

> I was trying to figure out a way to get the IP Address of the host, in which
> a particular VM is running using the LibvirtAPI. For Eg.; If I have a VM
> object, then I would like to fetch the IP Address of the host in which this
> VM is running, programatically.
> Is there a way to do this using the API?

> Please guide me, if there is some other way to do this also.

Did I get you right, that you have a 'virDomainPtr' as basis and want a mapping
from that to the IP?

I guess one way could be to get the virConnectionPtr
  conn_ptr = virDomainGetConnect (domain_ptr);

And then query the hostname
  virConnectGetHostname (conn_ptr);
or the uri
  virConnectGetURI (conn_ptr);

and resolve the hostname or extract the IP/host from the URI and
resolve that.

HTH
Ciao
Max
-- 
Gib Dein Bestes. Dann übertriff Dich selbst!




More information about the libvir-list mailing list