Commit 50716be0 authored by Iustin Pop's avatar Iustin Pop
Browse files

Migration: add check for listening target



This patch adds a check for listening on the remote port in Xen and KVM
migrations. This will be generating a single “load of migration failed”
message for KVM, but otherwise not prevent the migration. For Xen (which
has a dedicated, always listening daemon) this should not create any
problems.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 78212a5d
......@@ -624,14 +624,18 @@ class KVMHypervisor(hv_base.BaseHypervisor):
"""
instance_name = instance.name
port = instance.hvparams[constants.HV_MIGRATION_PORT]
pidfile, pid, alive = self._InstancePidAlive(instance_name)
if not alive:
raise errors.HypervisorError("Instance not running, cannot migrate")
if not utils.TcpPing(target, port, live_port_needed=True):
raise errors.HypervisorError("Remote host %s not listening on port"
" %s, cannot migrate" % (target, port))
if not live:
self._CallMonitorCommand(instance_name, 'stop')
port = instance.hvparams[constants.HV_MIGRATION_PORT]
migrate_command = 'migrate -d tcp:%s:%s' % (target, port)
self._CallMonitorCommand(instance_name, migrate_command)
......
......@@ -402,7 +402,13 @@ class XenHypervisor(hv_base.BaseHypervisor):
"""
if self.GetInstanceInfo(instance.name) is None:
raise errors.HypervisorError("Instance not running, cannot migrate")
port = instance.hvparams[constants.HV_MIGRATION_PORT]
if not utils.TcpPing(target, port, live_port_needed=True):
raise errors.HypervisorError("Remote host %s not listening on port"
" %s, cannot migrate" % (target, port))
args = ["xm", "migrate", "-p", "%d" % port]
if live:
args.append("-l")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment