]> git.ipfire.org Git - thirdparty/libvirt.git/commit
Fix failing virGetHostname.
authorChris Lalancette <clalance@redhat.com>
Thu, 20 May 2010 17:16:30 +0000 (13:16 -0400)
committerChris Lalancette <clalance@redhat.com>
Wed, 26 May 2010 12:59:31 +0000 (08:59 -0400)
commit0117b7da68fdb7435655318881fc925d43396e26
tree70608825ee8abbfa8f9ee875f34d735910c4999c
parent33737db1bec97f3ccfaa27da9af62d0ee74e336e
Fix failing virGetHostname.

We've been running into a lot of situations where
virGetHostname() is returning "localhost", where a plain
gethostname() would have returned the correct thing.  This
is because virGetHostname() is *always* trying to canonicalize
the name returned from gethostname(), even when it doesn't
have to.

This patch changes virGetHostname so that if the value returned
from gethostname() is already FQDN or localhost, it returns
that string directly.  If the value returned from gethostname()
is a shortened hostname, then we try to canonicalize it.  If
that succeeds, we returned the canonicalized hostname.  If
that fails, and/or returns "localhost", then we just return
the original string we got from gethostname() and hope for
the best.

Note that after this patch it is up to clients to check whether
"localhost" is an allowed return value.  The only place
where it's currently not is in qemu migration.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
src/libvirt_private.syms
src/qemu/qemu_driver.c
src/util/util.c
src/util/util.h