On Sun, Apr 19, 2015 at 08:49:06PM -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) Why do we need this function? The failure to resolve the host is already handled by the underlying commands. I don't think adding all this code just to save us a fork on wrong input is worth it. > +bool > +virIsValidHostname(const char *hostname) > +{ > + int r; > + struct addrinfo hints, *info; > + > + if (STRPREFIX(hostname, "localhost") || > + STREQ(hostname, "127.0.0.1") || STREQ(hostname, "::1")) getaddrinfo handles these two numeric representations of localhost just fine, just as the rest of them (see DO_TEST_LOCALHOST in sockettest.c for a few interesting examples) Jan
Attachment:
signature.asc
Description: Digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list