Commit 61643226 authored by Andrea Spadaccini's avatar Andrea Spadaccini
Browse files

Add memory transfer progress info to migration



* hypervisor/hv_kvm.py
  - parse the memory transfer status

* cmdlib.py
  - represent memory transfer info, if available
Signed-off-by: default avatarAndrea Spadaccini <spadaccio@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 6a1434d7
......@@ -7027,7 +7027,8 @@ class TLMigrateInstance(Tasklet):
"""
# Constants
_MIGRATION_POLL_INTERVAL = 0.5
_MIGRATION_POLL_INTERVAL = 1 # seconds
_MIGRATION_FEEDBACK_INTERVAL = 10 # seconds
def __init__(self, lu, instance_name, cleanup=False,
failover=False, fallback=False,
......@@ -7445,6 +7446,7 @@ class TLMigrateInstance(Tasklet):
(instance.name, msg))
self.feedback_fn("* starting memory transfer")
last_feedback = time.time()
while True:
result = self.rpc.call_instance_get_migration_status(source_node,
instance)
......@@ -7463,6 +7465,13 @@ class TLMigrateInstance(Tasklet):
self.feedback_fn("* memory transfer complete")
break
if (utils.TimeoutExpired(last_feedback,
self._MIGRATION_FEEDBACK_INTERVAL) and
ms.transferred_ram is not None):
mem_progress = 100 * float(ms.transferred_ram) / float(ms.total_ram)
self.feedback_fn("* memory transfer progress: %.2f %%" % mem_progress)
last_feedback = time.time()
time.sleep(self._MIGRATION_POLL_INTERVAL)
result = self.rpc.call_instance_finalize_migration_src(source_node,
......
......@@ -476,6 +476,11 @@ class KVMHypervisor(hv_base.BaseHypervisor):
_MIGRATION_STATUS_RE = re.compile("Migration\s+status:\s+(\w+)",
re.M | re.I)
_MIGRATION_PROGRESS_RE = re.compile(
"\s*transferred\s+ram:\s+(?P<transferred>\d+)\s+kbytes\s*\n"
"\s*remaining\s+ram:\s+(?P<remaining>\d+)\s+kbytes\s*\n"
"\s*total\s+ram:\s+(?P<total>\d+)\s+kbytes\s*\n", re.I)
_MIGRATION_INFO_MAX_BAD_ANSWERS = 5
_MIGRATION_INFO_RETRY_DELAY = 2
......@@ -1683,6 +1688,11 @@ class KVMHypervisor(hv_base.BaseHypervisor):
status = match.group(1)
if status in constants.HV_KVM_MIGRATION_VALID_STATUSES:
migration_status = objects.MigrationStatus(status=status)
match = self._MIGRATION_PROGRESS_RE.search(result.stdout)
if match:
migration_status.transferred_ram = match.group("transferred")
migration_status.total_ram = match.group("total")
return migration_status
logging.warning("KVM: unknown migration status '%s'", status)
......
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