[libvirt] [PATCH] virConnectGetHostname: return a fully qualified hostname
Jim Meyering
jim at meyering.net
Thu Dec 11 09:18:21 UTC 2008
David Lutterkort <lutter at redhat.com> wrote:
> The attached patch makes virConnectGetHostname try a little harder to get a
> FQDN on systems where gethostname only returns a short name without a
> domain (which is pretty useless). The behavior is equivalent to 'hostname
> --fqdn'.
Hi David,
ACK, modulo some nits:
>> From 2ae57d0c8c68c453b3f9715fcc9f83af0ebe84a0 Mon Sep 17 00:00:00 2001
> From: David Lutterkort <lutter at redhat.com>
> Date: Wed, 10 Dec 2008 18:34:39 -0800
> Subject: [PATCH] virConnectGetHostname: return a fully qualified hostname
...
> diff --git a/src/libvirt_sym.version.in b/src/libvirt_sym.version.in
> index de0bc4a..f02d9e0 100644
> --- a/src/libvirt_sym.version.in
> +++ b/src/libvirt_sym.version.in
> @@ -594,6 +594,7 @@ LIBVIRT_PRIVATE_ at VERSION@ {
> virFileReadLimFD;
> virFileReadPid;
> virFileLinkPointsTo;
> + virGetHostname;
While all the C code uses spaces for indentation,
this file uses TABs, so using spaces here looks weird when quoted.
> virParseNumber;
> virRun;
> virSkipSpaces;
...
> diff --git a/src/util.c b/src/util.c
...
> +char *virGetHostname(void)
> +{
> + int r;
> + char hostname[HOST_NAME_MAX+1], *str;
> + struct hostent *he;
> +
> + r = gethostname (hostname, HOST_NAME_MAX+1);
Avoid duplicating constants like that:
s/HOST_NAME_MAX+1/sizeof hostname/
More information about the libvir-list
mailing list