Re: [PATCH 1/7] virutil: Introduce virIsValidHostname

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

 




On 04/20/2015 10:34 AM, Peter Krempa wrote:
> On Mon, Apr 20, 2015 at 15:40:32 +0200, Peter Krempa wrote:
>> On Sun, Apr 19, 2015 at 20:49:06 -0400, John Ferlan wrote:
>>> Similar to virGetHostname, but this time taking a parameter which is a
>>> hostname or ipaddress from a <source ... <host name ='%s'.../>... />
>>> XML property and validating that the name can be resolved.
>>>
>>> Return true or false depending on whether we can ascertain the hostname
>>> address from calls to 'getnameinfo' and 'getaddrinfo'. Subsequent patches
>>> will be validating a proposed pool hostname definition against existing
>>> pool hostnames to ensure they are not the same hostname (and thus having
>>> two pools looking at the same data)
>>>
>>> Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
>>> ---
>>>  src/libvirt_private.syms |  1 +
>>>  src/util/virutil.c       | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
>>>  src/util/virutil.h       |  1 +
>>>  3 files changed, 51 insertions(+)
>>>
>>> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
>>> index 8c37303..5ba9635 100644
>>> --- a/src/libvirt_private.syms
>>> +++ b/src/libvirt_private.syms
>>> @@ -2324,6 +2324,7 @@ virIsCapableFCHost;
>>>  virIsCapableVport;
>>>  virIsDevMapperDevice;
>>>  virIsSUID;
>>> +virIsValidHostname;
>>>  virManageVport;
>>>  virMemoryLimitIsSet;
>>>  virMemoryLimitTruncate;
>>> diff --git a/src/util/virutil.c b/src/util/virutil.c
>>> index 79cdb7a..f6cc9af 100644
>>> --- a/src/util/virutil.c
>>> +++ b/src/util/virutil.c
>>> @@ -690,6 +690,55 @@ char *virGetHostname(void)
>>>  }
>>>  
>>>  
>>> +/*
>>> + * virIsValidHostname:
>>> + *
>>> + * Unlike virGetHostname, this variant of the code receives a hostname
>>> + * retrieves the getaddrinfo. If the passed hostname can be successfully
>>> + * and if successfully resolved via getaddrinfo, then success is declared.
>>> + *
>>> + * On error in lookup, if an IP Address is not found, or error formatting
>>> + * the name, an error is generated and a NULL is returned.
>>> + *
>>> + * On success, a pointer to a character representation of the numeric IP
>>> + * Address is returned.
>>> + *
>>> + * It is the caller's responsibility to check for a non NULL return and
>>> + * VIR_FREE the resultant string.
>>
>> This comment does not describe how this function works.
>>

Err... Oh yeah - I changed how I did things, but forget to update the
comment, <sigh>

>>> + */
>>> +bool
>>> +virIsValidHostname(const char *hostname)
> 
> As a hindsight from reviewing 6/7. This function should also be in
> virsocketaddr.c
> 
> 


hmmm.. yes I see.. Guess I got hung up on "virSocketAddr..." and didn't
focus as closely on the implementation where virSocketAddrParse can take
NULL as the first parameter... Guess, that means patches 2-5 can just be
called as:

    if (virSocketAddrParse(NULL, pool->def->source.hosts[0].name,
AF_UNSPEC) < 0)


Tks -

John

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