On Fri, May 21, 2010 at 12:27:27PM -0400, Cole Robinson wrote:
On 05/20/2010 03:57 PM, Chris Lalancette wrote:
> 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(a)redhat.com>
Hmm, why isn't one of the fallback options:
if (conn)
hostname = parse_uri(conn.get_uri())
if hostname != "localhost":
return hostname
Seems like if MigratePrepare2 dconn is the remote connection, we are
guaranteed to have a resolvable hostname in the URI (well, resolvable to
the source connection at least).
In the context of migration, the 'dconn' hostname is potentially troublesome.
For normal migration, the hostname is what the libvirt client app needs,
which may not be relevant for the source host. eg I use SSH based connections
for all my machines, and have aliases in $HOME/.ssh/config. So I just use
qemu+ssh://machinealias/system where 'machinealias' is only meaningful
wrt to my $HOME/.ssh/config. Similar problems occur if you use a SSH tunnel.
If doing PEER2PEER migration, then we probably could more reasonably rely on
the dconn hostname, since that's got to be suitable for the source host to
use.
Daniel
--
|: Red Hat, Engineering, London -o-
http://people.redhat.com/berrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org -o-
http://deltacloud.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|