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

Re: [libvirt] Host IP Address

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


> Thanks for such a quick reply.

No problem :)

>> Did I get you right, that you have a 'virDomainPtr' as basis and want a
>> mapping
>> from that to the IP?
> Yes. Thats what I want to do.

>> 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.

> Yes, I thought of this too. But I was hoping that the LibvirtAPI has some
> way of giving me the host IP Address directly, instead of resolving it
> myself.

I don't know of any and I wouldn't know which IP to choose if there
were multiple.

> But then again, how would I resolve the IP Address from the hostname? Can
> you please guide me on this.

In short:

struct hostent *hostent;
hostent = gethostbyname (char *hostname);
if (hostent) {
        for (i = 0; hostent->h_addr_list[i]; i++)
		printf ("%s, ", hostent->h_addr_list[i]);
	printf ("\n");

"Ich habe eher spontan mitbestellt, ohne genau zu wissen, was ich da gerade kaufe.
 Immer noch besser, als Schuhe zu kaufen."
  -- uschebit zum Thema SheevaPlug

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