]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virutil: Do not use g_get_host_name() to obtain hostname
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 9 Mar 2021 14:11:23 +0000 (15:11 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 12 Mar 2021 07:45:04 +0000 (08:45 +0100)
commitc2840e90ea9aa86d5e5babd3a9418cb075e50c6d
tree867be4bb72a6b96f8afd8af85bc082f420960bfa
parent2d91b1405d203d45474f341fb69d47ca35aaea0a
virutil: Do not use g_get_host_name() to obtain hostname

The problem is that g_get_host_name() caches the hostname in a
thread local variable. Therefore, it doesn't reflect any
subsequent hostname changes. While this might be acceptable for
logs where the hostname is printed exactly once when the libvirtd
starts up, it is not optimal for virGetHostnameImpl() which is
what our public virConnectGetHostname() API calls. If the
hostname at the moment of the first API invocation happens to
start with "localhost" or contains a dot, then no further
hostname changes will ever be reflected.

This reverts 26d9748ff11, partially.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virutil.c