Deleting external snapshots will require to run it as async domain job,
the same way as we do for snapshot creation.
For internal snapshots modify the job mask in order to forbid any other
job to be started.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/qemu/qemu_snapshot.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index adcd4eb73a..97df448363 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -2361,11 +2361,16 @@ qemuSnapshotDiscard(virQEMUDriver *driver,
if (qemuDomainSnapshotForEachQcow2(driver, def, snap, "-d", true)
< 0)
return -1;
} else {
+ /* Similarly as internal snapshot creation we would use a regular job
+ * here so set a mask to forbid any other job. */
+ qemuDomainObjSetAsyncJobMask(vm, VIR_JOB_NONE);
priv = vm->privateData;
- qemuDomainObjEnterMonitor(vm);
+ if (qemuDomainObjEnterMonitorAsync(vm, VIR_ASYNC_JOB_SNAPSHOT) < 0)
+ return -1;
/* we continue on even in the face of error */
qemuMonitorDeleteSnapshot(priv->mon, snap->def->name);
qemuDomainObjExitMonitor(vm);
+ qemuDomainObjSetAsyncJobMask(vm, VIR_JOB_DEFAULT_MASK);
}
}
@@ -2565,8 +2570,11 @@ qemuSnapshotDelete(virDomainObj *vm,
VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY |
VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY, -1);
- if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
+ if (virDomainObjBeginAsyncJob(vm, VIR_ASYNC_JOB_SNAPSHOT,
+ VIR_DOMAIN_JOB_OPERATION_SNAPSHOT_DELETE,
+ flags) < 0) {
return -1;
+ }
if (!(snap = qemuSnapObjFromSnapshot(vm, snapshot)))
goto endjob;
@@ -2584,7 +2592,7 @@ qemuSnapshotDelete(virDomainObj *vm,
}
endjob:
- virDomainObjEndJob(vm);
+ virDomainObjEndAsyncJob(vm);
return ret;
}
--
2.38.1