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

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



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 redhat com>
> > ---
> >  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.
> 
> > + */
> > +bool
> > +virIsValidHostname(const char *hostname)

As a hindsight from reviewing 6/7. This function should also be in
virsocketaddr.c

Peter

Attachment: signature.asc
Description: Digital signature


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