From 641ae041e7dd64c3cfeadf62a49d7ee4ae03d720 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Wed, 4 Nov 2009 12:48:10 +0100
Subject: [PATCH] hypervisors: switch to using HV_MIGRATION_PORT

This changes KVM to use HV_MIGRATION_PORT instead of KVM_MIGRATION_PORT
and enables passing the port for Xen migrations.

Since KVM_MIGRATION_PORT is not used anymore, we stop exporting it from
constants.py.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 lib/constants.py         | 1 -
 lib/hypervisor/hv_kvm.py | 6 +++---
 lib/hypervisor/hv_xen.py | 3 ++-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/constants.py b/lib/constants.py
index 96454e7ab..049b0783e 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -165,7 +165,6 @@ XEN_INITRD = _autoconf.XEN_INITRD
 
 KVM_PATH = _autoconf.KVM_PATH
 SOCAT_PATH = _autoconf.SOCAT_PATH
-KVM_MIGRATION_PORT = _autoconf.KVM_MIGRATION_PORT
 
 VALUE_DEFAULT = "default"
 VALUE_AUTO = "auto"
diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py
index 6da5bd594..eee6fe10c 100644
--- a/lib/hypervisor/hv_kvm.py
+++ b/lib/hypervisor/hv_kvm.py
@@ -592,7 +592,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
 
     """
     kvm_runtime = self._LoadKVMRuntime(instance, serialized_runtime=info)
-    incoming_address = (target, constants.KVM_MIGRATION_PORT)
+    incoming_address = (target, instance.hvparams[constants.HV_MIGRATION_PORT])
     self._ExecuteKVMRuntime(instance, kvm_runtime, incoming=incoming_address)
 
   def FinalizeMigration(self, instance, info, success):
@@ -631,8 +631,8 @@ class KVMHypervisor(hv_base.BaseHypervisor):
     if not live:
       self._CallMonitorCommand(instance_name, 'stop')
 
-    migrate_command = ('migrate -d tcp:%s:%s' %
-                       (target, constants.KVM_MIGRATION_PORT))
+    port = instance.hvparams[constants.HV_MIGRATION_PORT]
+    migrate_command = 'migrate -d tcp:%s:%s' % (target, port)
     self._CallMonitorCommand(instance_name, migrate_command)
 
     info_command = 'info migrate'
diff --git a/lib/hypervisor/hv_xen.py b/lib/hypervisor/hv_xen.py
index 5a4eb6462..e29d4cab9 100644
--- a/lib/hypervisor/hv_xen.py
+++ b/lib/hypervisor/hv_xen.py
@@ -402,7 +402,8 @@ class XenHypervisor(hv_base.BaseHypervisor):
     """
     if self.GetInstanceInfo(instance.name) is None:
       raise errors.HypervisorError("Instance not running, cannot migrate")
-    args = ["xm", "migrate"]
+    port = instance.hvparams[constants.HV_MIGRATION_PORT]
+    args = ["xm", "migrate", "-p", "%d" % port]
     if live:
       args.append("-l")
     args.extend([instance.name, target])
-- 
GitLab