[libvirt] [PATCH v2 3/5] Remove network constants out of internal.h

Daniel P. Berrange berrange at redhat.com
Mon Jul 10 15:07:08 UTC 2017


On Mon, Jul 10, 2017 at 01:01:26PM +0200, Peter Krempa wrote:
> On Wed, Jul 05, 2017 at 12:58:49 +0100, Daniel Berrange wrote:
> > The HOST_NAME_MAX, INET_ADDRSTRLEN and VIR_LOOPBACK_IPV4_ADDR
> > constants are only used by a handful of files, so are better
> > kept in virsocketaddr.h
> > 
> > Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> > ---
> >  src/internal.h                         | 16 ----------------
> >  src/libxl/libxl_conf.c                 |  1 +
> >  src/nwfilter/nwfilter_dhcpsnoop.c      |  1 +
> >  src/nwfilter/nwfilter_gentech_driver.c |  1 +
> >  src/qemu/qemu_conf.c                   |  1 +
> >  src/util/virsocketaddr.h               | 16 ++++++++++++++++
> >  src/util/virutil.c                     |  1 +
> >  src/vz/vz_sdk.c                        |  1 +
> >  8 files changed, 22 insertions(+), 16 deletions(-)
> > 
> 
> [...]
> 
> > diff --git a/src/util/virsocketaddr.h b/src/util/virsocketaddr.h
> > index 43a3706..ae76166 100644
> > --- a/src/util/virsocketaddr.h
> > +++ b/src/util/virsocketaddr.h
> > @@ -32,6 +32,22 @@
> >  #  include <sys/un.h>
> >  # endif
> >  
> > +/* On architectures which lack these limits, define them (ie. Cygwin).
> > + * Note that the libvirt code should be robust enough to handle the
> > + * case where actual value is longer than these limits (eg. by setting
> > + * length correctly in second argument to gethostname and by always
> > + * using strncpy instead of strcpy).
> > + */
> > +# ifndef HOST_NAME_MAX
> > +#  define HOST_NAME_MAX 256
> 
> I'm not entirely convinced that this semantically belongs to
> virsocketaddr.h
> 
> At least in the virlog.c usage case it is not used in any way in regards
> to network communication.

The constant is used to define a hostname string buffer, which is then
used with the gethostname() system call. That's network related IMHO.

> ACK to the rest though.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the libvir-list mailing list