c401cc
From 8bbc1788803c0b97e067ae545f17154012f51fdc Mon Sep 17 00:00:00 2001
c401cc
Message-Id: <8bbc1788803c0b97e067ae545f17154012f51fdc.1385135432.git.jdenemar@redhat.com>
c401cc
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
c401cc
Date: Fri, 22 Nov 2013 16:29:11 +0100
c401cc
Subject: [PATCH] Don't start a nested job in qemuMigrationPrepareAny
c401cc
c401cc
This nested job is canceled by the first ExitMonitor call (even though
c401cc
it was not created by the corresponding EnterMonitor call), and
c401cc
again in qemuMigrationPrepareAny if qemuProcessStart failed.
c401cc
This can lead to a crash if the vm object was disposed of before calling
c401cc
qemuDomainRemoveInactive:
c401cc
0  ..62bc in virClassIsDerivedFrom (klass=0xdeadbeef,
c401cc
   parent=0x7ffce4cdd270) at util/virobject.c:166
c401cc
1 ..6666 in virObjectIsClass at util/virobject.c:362
c401cc
2 ..66b4 in virObjectLock at util/virobject.c:314
c401cc
3 ..477e in virDomainObjListRemove at conf/domain_conf.c:2359
c401cc
4 ..7a64 in qemuDomainRemoveInactive at qemu/qemu_domain.c:2087
c401cc
5 ..956c in qemuMigrationPrepareAny at qemu/qemu_migration.c:2469
c401cc
c401cc
This was added by commit e4e2822, exposed by 5a4c237 and c7ac251.
c401cc
c401cc
https://bugzilla.redhat.com/show_bug.cgi?id=1018267
c401cc
(cherry picked from commit 98464021167377bc7373b4d3951b1e868f8db291)
c401cc
c401cc
Conflicts:
c401cc
	src/qemu/qemu_migration.c - commit 6cd1548 not backported
c401cc
c401cc
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c401cc
---
c401cc
 src/qemu/qemu_migration.c | 8 +-------
c401cc
 1 file changed, 1 insertion(+), 7 deletions(-)
c401cc
c401cc
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
c401cc
index 32ffde7..18f74c3 100644
c401cc
--- a/src/qemu/qemu_migration.c
c401cc
+++ b/src/qemu/qemu_migration.c
c401cc
@@ -2358,10 +2358,6 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
c401cc
         goto endjob;
c401cc
     }
c401cc
 
c401cc
-    if (qemuDomainObjBeginNestedJob(driver, vm,
c401cc
-                                    QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
c401cc
-        goto endjob;
c401cc
-
c401cc
     /* Start the QEMU daemon, with the same command-line arguments plus
c401cc
      * -incoming $migrateFrom
c401cc
      */
c401cc
@@ -2370,8 +2366,6 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
c401cc
                          VIR_QEMU_PROCESS_START_PAUSED |
c401cc
                          VIR_QEMU_PROCESS_START_AUTODESTROY) < 0) {
c401cc
         virDomainAuditStart(vm, "migrated", false);
c401cc
-        if (qemuDomainObjEndJob(driver, vm) < 0)
c401cc
-            vm = NULL;
c401cc
         goto endjob;
c401cc
     }
c401cc
 
c401cc
@@ -2474,7 +2468,7 @@ stop:
c401cc
     qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, 0);
c401cc
 
c401cc
 endjob:
c401cc
-    if (vm && !qemuMigrationJobFinish(driver, vm)) {
c401cc
+    if (!qemuMigrationJobFinish(driver, vm)) {
c401cc
         vm = NULL;
c401cc
     }
c401cc
     goto cleanup;
c401cc
-- 
c401cc
1.8.4.4
c401cc