Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
Reviewed-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_block.c | 32 ++++++++++++++++++++++++++++++++
src/qemu/qemu_block.h | 5 +++++
2 files changed, 37 insertions(+)
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index da3a1e8557..70811aa861 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -3525,3 +3525,35 @@ qemuBlockPivot(virDomainObj *vm,
return ret;
}
+
+
+/**
+ * qemuBlockFinalize:
+ * @vm: domain object
+ * @job: qemu block job data object
+ * @asyncJob: qemu async job type
+ *
+ * When qemu job is started with autofinalize disabled it will wait in pending
+ * state for block job finalize to be called manually in order to finish the
+ * job. This is useful when we are running jobs on multiple disks to make
+ * a synchronization point before we finish.
+ *
+ * Return -1 on error, 0 on success.
+ */
+int
+qemuBlockFinalize(virDomainObj *vm,
+ qemuBlockJobData *job,
+ virDomainAsyncJob asyncJob)
+{
+ int ret;
+ qemuDomainObjPrivate *priv = vm->privateData;
+
+ if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0)
+ return -1;
+
+ ret = qemuMonitorJobFinalize(priv->mon, job->name);
+
+ qemuDomainObjExitMonitor(vm);
+
+ return ret;
+}
diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h
index 7b6aec2a7d..c169432d9c 100644
--- a/src/qemu/qemu_block.h
+++ b/src/qemu/qemu_block.h
@@ -293,3 +293,8 @@ qemuBlockPivot(virDomainObj *vm,
qemuBlockJobData *job,
virDomainAsyncJob asyncJob,
virDomainDiskDef *disk);
+
+int
+qemuBlockFinalize(virDomainObj *vm,
+ qemuBlockJobData *job,
+ virDomainAsyncJob asyncJob);
--
2.39.0