From c087266cb225a6203c0f1bb3ae746f3b4dcd8bbb Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Wed, 21 Jan 2009 18:23:44 +0000
Subject: [PATCH] KVM live migration: handle failure

If the KVM live migration ends up in a 'failed' state it has been
aborted at the kvm level, and the machine is still running locally.
We support also the 'cancelled' state even though there should be no way
of reaching it, without manual intervention.

Reviewed-by: iustinp
---
 lib/hypervisor/hv_kvm.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py
index ba5b39d2d..028e6754c 100644
--- a/lib/hypervisor/hv_kvm.py
+++ b/lib/hypervisor/hv_kvm.py
@@ -506,6 +506,11 @@ class KVMHypervisor(hv_base.BaseHypervisor):
           done = True
         elif status == 'active':
           time.sleep(2)
+        elif status == 'failed' or status == 'cancelled':
+          if not live:
+            self._CallMonitorCommand(instance_name, 'cont')
+          raise errors.HypervisorError("Migration %s at the kvm level" %
+                                       status)
         else:
           logging.info("KVM: unknown migration status '%s'" % status)
           time.sleep(2)
-- 
GitLab