diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index eee6fe10c2bea3c93501dc8ad5b278772de9d7f3..11d25bd48c8f9cfaa445c784b771fbc14d29f66d 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -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) diff --git a/lib/hypervisor/hv_xen.py b/lib/hypervisor/hv_xen.py index e29d4cab99aa4eb504f5db1d8dfdc794926b2f42..1addef7a32175049fe5438a3b8afeb02e54a590a 100644 --- a/lib/hypervisor/hv_xen.py +++ b/lib/hypervisor/hv_xen.py @@ -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")