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 127.0.0.1 in /etc/hosts. This means
that virGetHostname will do gethostname (and get back
something like
foo.example.com), then resolve it to 127.0.0.1,
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.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
.x-sc_prohibit_gethostname | 2 --
Makefile.am | 1 -
cfg.mk | 5 -----
src/qemu/qemu_driver.c | 12 ++++++------
4 files changed, 6 insertions(+), 14 deletions(-)
delete mode 100644 .x-sc_prohibit_gethostname
diff --git a/.x-sc_prohibit_gethostname b/.x-sc_prohibit_gethostname
deleted file mode 100644
index e7acb03..0000000
--- a/.x-sc_prohibit_gethostname
+++ /dev/null
@@ -1,2 +0,0 @@
-^src/util/util\.c$
-^ChangeLog-old$
diff --git a/Makefile.am b/Makefile.am
index 286b13b..9f2ae9e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -26,7 +26,6 @@ EXTRA_DIST = \
.x-sc_m4_quote_check \
.x-sc_prohibit_asprintf \
.x-sc_prohibit_gethostby \
- .x-sc_prohibit_gethostname \
.x-sc_prohibit_gettext_noop \
.x-sc_prohibit_have_config_h \
.x-sc_prohibit_HAVE_MBRTOWC \
diff --git a/cfg.mk b/cfg.mk
index 1ef73e2..451ce37 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -253,11 +253,6 @@ sc_prohibit_readlink:
halt='use virFileResolveLink, not readlink' \
$(_sc_search_regexp)
-sc_prohibit_gethostname:
- @prohibit='gethostname *\(' \
- halt='use virGetHostname, not gethostname' \
- $(_sc_search_regexp)
-
sc_prohibit_gettext_noop:
@prohibit='gettext_noop *\(' \
halt='use N_, not gettext_noop' \
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6df2356..54703dd 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10022,12 +10022,11 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
virDomainDefPtr def = NULL;
virDomainObjPtr vm = NULL;
int this_port;
- char *hostname;
+ char hostname[HOST_NAME_MAX+1];
char migrateFrom [64];
const char *p;
virDomainEventPtr event = NULL;
int ret = -1;
- int internalret;
*uri_out = NULL;
@@ -10062,8 +10061,11 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
if (port == QEMUD_MIGRATION_NUM_PORTS) port = 0;
/* Get hostname */
- if ((hostname = virGetHostnameLocalhost(0)) == NULL)
+ if (gethostname(hostname, HOST_NAME_MAX) < 0) {
+ virReportSystemError(errno, "%s",
+ _("failed to determine host name"));
goto cleanup;
+ }
/* XXX this really should have been a properly well-formed
* URI, but we can't add in tcp:// now without breaking
@@ -10071,9 +10073,7 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
* new targets accept both syntaxes though.
*/
/* Caller frees */
- internalret = virAsprintf(uri_out, "tcp:%s:%d", hostname, this_port);
- VIR_FREE(hostname);
- if (internalret < 0) {
+ if (virAsprintf(uri_out, "tcp:%s:%d", hostname, this_port) < 0) {
virReportOOMError();
goto cleanup;
}
--
1.6.6.1