Use async job instead of regular one as we are going to use async job
harness to wait for snapshot-delete job completion in QEMU.
We can use VIR_DOMAIN_JOB_OPERATION_UNKNOWN because it is used only
when reporting job progress and getting job progress is disabled now for
snapshot deletion. It is not clear whether we should add
VIR_DOMAIN_JOB_OPERATION_SNAPSHOT_DELETE and report job progress in future
as snapshot-deletion should not take much time I guess.
Yet using VIR_DOMAIN_JOB_OPERATION_UNKNOWN seems to be brittle.
Signed-off-by: Nikolay Shirokovskiy <nikolay.shirokovskiy(a)openvz.org>
---
src/qemu/qemu_snapshot.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index 878a0abb34..579d744c60 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -177,10 +177,12 @@ qemuSnapshotDiscard(virQEMUDriver *driver,
return -1;
} else {
priv = vm->privateData;
- qemuDomainObjEnterMonitor(driver, vm);
- /* we continue on even in the face of error */
- qemuMonitorDeleteSnapshot(priv->mon, snap->def->name);
- qemuDomainObjExitMonitor(vm);
+ if (qemuDomainObjEnterMonitorAsync(driver, vm,
+ VIR_ASYNC_JOB_SNAPSHOT) == 0) {
+ /* we continue on even in the face of error */
+ qemuMonitorDeleteSnapshot(priv->mon, snap->def->name);
+ qemuDomainObjExitMonitor(vm);
+ }
}
}
@@ -2551,8 +2553,14 @@ qemuSnapshotDelete(virDomainObj *vm,
VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY |
VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY, -1);
- if (qemuDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
+ /*
+ * For snapshot deletion quering stats/aborting is not supported yet
+ * thus disable any parallels jobs.
+ */
+ if (qemuDomainObjBeginAsyncJob(driver, vm, VIR_ASYNC_JOB_SNAPSHOT_DELETE,
+ VIR_DOMAIN_JOB_OPERATION_UNKNOWN, flags) < 0)
return -1;
+ qemuDomainObjSetAsyncJobMask(vm, VIR_JOB_NONE);
if (!(snap = qemuSnapObjFromSnapshot(vm, snapshot)))
goto endjob;
@@ -2624,7 +2632,7 @@ qemuSnapshotDelete(virDomainObj *vm,
}
endjob:
- qemuDomainObjEndJob(vm);
+ qemuDomainObjEndAsyncJob(vm);
return ret;
}
--
2.35.1