[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] Use gethostname in qemudDomainMigratePrepare2.

On Thu, May 20, 2010 at 11:14:05AM -0400, Chris Lalancette wrote:
> This patch is essentially a revert of commit:
> 180ca598c4517012014d226c78068d4b38ff9e24
> The problem ends up being that virGetHostname is *too* clever,
> and is causing migration problems.  In particular, on
> machines with dynamic networks, the hostname of the machine
> generally gets mapped to in /etc/hosts.  This means
> that virGetHostname will do gethostname (and get back
> something like foo.example.com), then resolve it to,
> and then pass that back to the source of the destination,
> which is bogus.  By being less clever and just using gethostname,
> we avoid the problem.

Why don't we fix virGetHostname(), so all callers benefit instead.

The idea behind calling getaddrinfo() on the result of gethostname() was
to ensure you get the FQDN, instead of just a plain hostname. I'd say we
could be more clever in that respect, eg

    hostname = gethostname()

    if (STRPREFIX(hostname, "localhost")) {
       ...report error...

    if (strchr(hostname, '.'))
      return hostname;

    ...canonicalize hostname...
    if (STRPEFIX(newhostname, "localhost"))
       return hostname

So we'd normally be returning the plain result of gethostname() unless we
saw it needed canonicalization, and if canonicalization results in it
turning into 'localhost', just use the non-canonical hostname instead

|: 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 :|

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]