qemu: fix concurrency crash bug in force snapshot revert

This patch is just revert of [1]. Actually we should NOT pass
QEMU_ASYNC_JOB_NONE as that patch suggests while we are in async job in order
to acquire nested jobs correctly. The patch tries to fix issues introduced by
another patch [2] where jobs are mistakenly cleared out in qemuProcessStop.
Later patch [3] fixed the issue introduced by patch [2]. Now we need to revert
[1] as well as we now still have same concurrency crash issues as [3] described
but for the force revert.

[1] 0c4408c83: qemu: Don't use asyncJob after stop during snapshot revert
[2] 888aa4b6b: qemuDomainObjPrivateDataClear: Don't leak @migParams
[3] d75f865fb: qemu: fix concurrency crash bug in snapshot revert

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Nikolay Shirokovskiy 2020-09-14 14:58:05 +03:00
parent 1e18d3b833
commit 5756a7bf2a

View File

@ -1719,7 +1719,6 @@ qemuSnapshotRevert(virDomainObjPtr vm,
qemuDomainSaveCookiePtr cookie; qemuDomainSaveCookiePtr cookie;
virCPUDefPtr origCPU = NULL; virCPUDefPtr origCPU = NULL;
unsigned int start_flags = VIR_QEMU_PROCESS_START_GEN_VMID; unsigned int start_flags = VIR_QEMU_PROCESS_START_GEN_VMID;
qemuDomainAsyncJob jobType = QEMU_ASYNC_JOB_START;
bool defined = false; bool defined = false;
virCheckFlags(VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING | virCheckFlags(VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING |
@ -1899,9 +1898,6 @@ qemuSnapshotRevert(virDomainObjPtr vm,
VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED,
detail); detail);
virObjectEventStateQueue(driver->domainEventState, event); virObjectEventStateQueue(driver->domainEventState, event);
/* Start after stop won't be an async start job, so
* reset to none */
jobType = QEMU_ASYNC_JOB_NONE;
goto load; goto load;
} }
} }
@ -1968,7 +1964,7 @@ qemuSnapshotRevert(virDomainObjPtr vm,
rc = qemuProcessStart(snapshot->domain->conn, driver, vm, rc = qemuProcessStart(snapshot->domain->conn, driver, vm,
cookie ? cookie->cpu : NULL, cookie ? cookie->cpu : NULL,
jobType, NULL, -1, NULL, snap, QEMU_ASYNC_JOB_START, NULL, -1, NULL, snap,
VIR_NETDEV_VPORT_PROFILE_OP_CREATE, VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
start_flags); start_flags);
virDomainAuditStart(vm, "from-snapshot", rc >= 0); virDomainAuditStart(vm, "from-snapshot", rc >= 0);
@ -2003,7 +1999,7 @@ qemuSnapshotRevert(virDomainObjPtr vm,
} }
rc = qemuProcessStartCPUs(driver, vm, rc = qemuProcessStartCPUs(driver, vm,
VIR_DOMAIN_RUNNING_FROM_SNAPSHOT, VIR_DOMAIN_RUNNING_FROM_SNAPSHOT,
jobType); QEMU_ASYNC_JOB_START);
if (rc < 0) if (rc < 0)
goto endjob; goto endjob;
virObjectUnref(event); virObjectUnref(event);