From 19078ccc1e2160dcb4b223097c6bbc032567514b Mon Sep 17 00:00:00 2001
From: Feng Ni <fengni@huawei.com>
Date: Thu, 25 Jul 2019 20:43:07 +0800
Subject: [PATCH] qemu: fix a concurrent operation situation

Migrate vm and shutdown in guestos, interface do not return occasionally.
In function qemuMigrationSrcNBDStorageCopy, it may be alays in while loop
if qemu exits.

Signed-off-by: Feng Ni <fengni@huawei.com>
---
 src/qemu/qemu_migration.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 2436f50..c6f2436 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1032,6 +1032,11 @@ qemuMigrationSrcNBDStorageCopy(virQEMUDriverPtr driver,
         if (rv < 0)
             goto cleanup;
 
+        if (!virDomainObjIsActive(vm)) {
+            VIR_ERROR(_("domain is no longer running, migrate will end"));
+            goto cleanup;
+        }
+
         if (priv->job.abortJob) {
             priv->job.current->status = QEMU_DOMAIN_JOB_STATUS_CANCELED;
             virReportError(VIR_ERR_OPERATION_ABORTED, _("%s: %s"),
-- 
2.19.1

