Commit 6e7275c0 authored by Iustin Pop's avatar Iustin Pop
Browse files

hypervisor: add live migration support

This is just the hypervisor-level migration (e.g. “xm migrate”) not the
whole node coordination work.

Reviewed-by: ultrotter
parent 22985314
......@@ -93,3 +93,16 @@ class BaseHypervisor(object):
"""
raise NotImplementedError
def MigrateInstance(self, name, target, live):
"""Migrate an instance.
Arguments:
- name: the name of the instance
- target: the target of the migration (usually will be IP and not name)
- live: whether to do live migration or not
Returns: none, errors will be signaled by exception.
"""
raise NotImplementedError
......@@ -257,6 +257,31 @@ class XenHypervisor(hv_base.BaseHypervisor):
return disk_data
def MigrateInstance(self, instance, target, live):
"""Migrate an instance to a target node.
Arguments:
- instance: the name of the instance
- target: the ip of the target node
- live: whether to do live migration or not
Returns: none, errors will be signaled by exception.
The migration will not be attempted if the instance is not
currently running.
"""
if self.GetInstanceInfo(instance) is None:
raise errors.HypervisorError("Instance not running, cannot migrate")
args = ["xm", "migrate"]
if live:
args.append("-l")
args.extend([instance, target])
result = utils.RunCmd(args)
if result.failed:
raise errors.HypervisorError("Failed to migrate instance %s: %s" %
(instance, result.output))
class XenPvmHypervisor(XenHypervisor):
"""Xen PVM hypervisor interface"""
......
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