Autotest always uses "-incoming tcp:0:$port" to start dest vm,
and migrate with "migrate -d tcp:localhost:$port",
or "migrate -d tcp:$dest_host:$port"

Upstream qemu already supports IPv6 migration, current autotest
would fail to migrate in localhost.

'localhost' has multiple aliases (::1 and 127.0.0.1) in /etc/hosts.
getaddrinfo() returns an address list, "::1" is the first item
of the list, "127.0.0.1" is the second item. First available
addr will be choosen to connect. But "0" will be parsed to 127.0.0.1
It caused localhost migration fails, multiple host migration
is fine.

For resolving localhost migration issue, we can listen by
'-incoming tcp:localhost:$port' and migrate by 'migrate
-d tcp:localhost:$port'. Or listen by '-incoming tcp:0:$port'
and migrate by 'migrate -d tcp:0:$port'
This patch uses second resolution.

Signed-off-by: Amos Kong <ak...@redhat.com>
---
 client/virt/kvm_vm.py          |    2 +-
 client/virt/virt_test_utils.py |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/client/virt/kvm_vm.py b/client/virt/kvm_vm.py
index 3429630..eb760fc 100644
--- a/client/virt/kvm_vm.py
+++ b/client/virt/kvm_vm.py
@@ -1849,7 +1849,7 @@ class VM(virt_vm.BaseVM):
         try:
             if protocol == "tcp":
                 if local:
-                    uri = "tcp:localhost:%d" % clone.migration_port
+                    uri = "tcp:0:%d" % clone.migration_port
                 else:
                     uri = "tcp:%s:%d" % (dest_host, remote_port)
             elif protocol == "unix":
diff --git a/client/virt/virt_test_utils.py b/client/virt/virt_test_utils.py
index 988ce7f..83a6761 100644
--- a/client/virt/virt_test_utils.py
+++ b/client/virt/virt_test_utils.py
@@ -213,7 +213,7 @@ def migrate(vm, env=None, mig_timeout=3600, 
mig_protocol="tcp",
         try:
             if mig_protocol == "tcp":
                 if dest_host == 'localhost':
-                    uri = "tcp:localhost:%d" % dest_vm.migration_port
+                    uri = "tcp:0:%d" % dest_vm.migration_port
                 else:
                     uri = 'tcp:%s:%d' % (dest_host, mig_port)
             elif mig_protocol == "unix":

_______________________________________________
Autotest mailing list
Autotest@test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to