]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu_block: add async domain job support to qemuBlockCommit
authorPavel Hrdina <phrdina@redhat.com>
Mon, 5 Dec 2022 12:11:19 +0000 (13:11 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Mon, 9 Jan 2023 12:32:41 +0000 (13:32 +0100)
This will allow to use it while having async domain job active which we
will use when deleting external snapshots. At the same time we will need
to have the block job started as synchronous.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_block.c
src/qemu/qemu_block.h
src/qemu/qemu_driver.c

index 6d31269dddc36a4fce98a25b369d13eb8ad12bd8..d2a56ba19c8921b2185b54c77806743430c141b1 100644 (file)
@@ -3198,6 +3198,22 @@ qemuBlockExportAddNBD(virDomainObj *vm,
 }
 
 
+/**
+ * qemuBlockCommit:
+ * @vm: domain object
+ * @disk: disk object where we are about to block commit
+ * @baseSource: disk source within backing chain to commit data into
+ * @topSource: disk source within backing chain with data we will commit
+ * @top_parent: disk source that has @topSource as backing disk
+ * @bandwidth: bandwidth limit, flags determine the unit
+ * @asyncJob: qemu async job type
+ * @flags: bitwise-OR of virDomainBlockCommitFlags
+ *
+ * Starts a block commit job for @disk. If @asyncJob is different then
+ * VIR_ASYNC_JOB_NONE the job will be started as synchronous.
+ *
+ * Returns -1 on error, 0 on success.
+ */
 int
 qemuBlockCommit(virDomainObj *vm,
                 virDomainDiskDef *disk,
@@ -3205,6 +3221,7 @@ qemuBlockCommit(virDomainObj *vm,
                 virStorageSource *topSource,
                 virStorageSource *top_parent,
                 unsigned long bandwidth,
+                virDomainAsyncJob asyncJob,
                 unsigned int flags)
 {
     qemuDomainObjPrivate *priv = vm->privateData;
@@ -3336,7 +3353,11 @@ qemuBlockCommit(virDomainObj *vm,
         !(backingPath = qemuBlockGetBackingStoreString(baseSource, false)))
         goto cleanup;
 
-    qemuDomainObjEnterMonitor(vm);
+    if (asyncJob != VIR_ASYNC_JOB_NONE)
+        qemuBlockJobSyncBegin(job);
+
+    if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0)
+        goto cleanup;
 
     ret = qemuMonitorBlockCommit(priv->mon,
                                  qemuDomainDiskGetTopNodename(disk),
index 52deb15a3d894cd5d88aa257ab8049f7380ff2ee..a76d9be71175e3df312acb0a84f532062a87ce22 100644 (file)
@@ -284,6 +284,7 @@ qemuBlockCommit(virDomainObj *vm,
                 virStorageSource *topSource,
                 virStorageSource *top_parent,
                 unsigned long bandwidth,
+                virDomainAsyncJob asyncJob,
                 unsigned int flags);
 
 int
index c35e5e1a31ab34aa179e65560b7d19333a9a25f9..f7a7086b3d1aa0cacecc5a08d75095ee2698edb6 100644 (file)
@@ -15025,7 +15025,8 @@ qemuDomainBlockCommit(virDomainPtr dom,
                                                         base, disk->dst, NULL)))
         goto endjob;
 
-    ret = qemuBlockCommit(vm, disk, baseSource, topSource, top_parent, bandwidth, flags);
+    ret = qemuBlockCommit(vm, disk, baseSource, topSource, top_parent,
+                          bandwidth, VIR_ASYNC_JOB_NONE, flags);
 
  endjob:
     virDomainObjEndJob(vm);