Re: [PATCH 9/9] qemu: Add -blockdev support for block commit job

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 24, 2019 at 11:07:36PM +0200, Peter Krempa wrote:
Introduce the handler for finalizing a block commit and active bloc
commit job which will allow to use it with blockdev.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
src/qemu/qemu_blockjob.c                      | 212 ++++++++++++++++++
src/qemu/qemu_blockjob.h                      |  18 ++
src/qemu/qemu_domain.c                        |  32 +++
src/qemu/qemu_driver.c                        |  50 +++--
.../blockjob-blockdev-in.xml                  |  15 ++
5 files changed, 311 insertions(+), 16 deletions(-)

diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index a29af7ec48..4cbdc34b66 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -237,6 +237,43 @@ qemuBlockJobDiskNewPull(virDomainObjPtr vm,
}


+qemuBlockJobDataPtr
+qemuBlockJobDiskNewCommit(virDomainObjPtr vm,
+                          virDomainDiskDefPtr disk,
+                          virStorageSourcePtr topparent,
+                          virStorageSourcePtr top,
+                          virStorageSourcePtr base)
+{
+    qemuDomainObjPrivatePtr priv = vm->privateData;
+    VIR_AUTOUNREF(qemuBlockJobDataPtr) job = NULL;
+    VIR_AUTOFREE(char *) jobname = NULL;
+    qemuBlockJobType jobtype = QEMU_BLOCKJOB_TYPE_COMMIT;
+
+    if (topparent == NULL)
+        jobtype = QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT;
+
+    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) {
+        if (virAsprintf(&jobname, "commit-%s-%s", disk->dst, top->nodeformat) < 0)
+            return NULL;
+    } else {
+        if (!(jobname = qemuAliasDiskDriveFromDisk(disk)))
+            return NULL;
+    }
+
+    if (!(job = qemuBlockJobDataNew(jobtype, jobname)))
+        return NULL;
+
+    job->data.commit.topparent = topparent;

/me considers making
 World's Top Parent
T-shirts

+    job->data.commit.top = top;
+    job->data.commit.base = base;
+
+    if (qemuBlockJobRegister(job, vm, disk, true) < 0)
+        return NULL;
+
+    VIR_RETURN_PTR(job);
+}
+
+
/**
 * qemuBlockJobDiskRegisterMirror:
 * @job: block job to register 'mirror' chain on
@@ -18107,15 +18106,34 @@ qemuDomainBlockCommit(virDomainPtr dom,
     * depending on whether the input was specified as relative or
     * absolute (that is, our absolute top_canon may do the wrong
     * thing if the user specified a relative name).  */
+
+    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) {

if (blockdev)

+        persistjob = true;
+        jobname = job->name;
+        nodetop = topSource->nodeformat;
+        nodebase = baseSource->nodeformat;
+        device = disk->src->nodeformat;
+        if (!backingPath && top_parent &&
+            !(backingPath = qemuBlockGetBackingStoreString(baseSource)))
+            goto endjob;
+    } else {
+        device = job->name;
+    }
+
    qemuDomainObjEnterMonitor(driver, vm);
-    basePath = qemuMonitorDiskNameLookup(priv->mon, device, disk->src,
-                                         baseSource);
-    topPath = qemuMonitorDiskNameLookup(priv->mon, device, disk->src,
-                                        topSource);
-    if (basePath && topPath)
-        ret = qemuMonitorBlockCommit(priv->mon, device, NULL, false,
-                                     topPath, NULL, basePath, NULL, backingPath,
-                                     speed);
+
+    if (!jobname) {
+        basePath = qemuMonitorDiskNameLookup(priv->mon, device, disk->src,
+                                             baseSource);
+        topPath = qemuMonitorDiskNameLookup(priv->mon, device, disk->src,
+                                            topSource);
+    }
+
+    if ((basePath && topPath) || jobname)

This is option a) I proposed in the previous patch.

+        ret = qemuMonitorBlockCommit(priv->mon, device, jobname, persistjob,
+                                     topPath, nodetop, basePath, nodebase,
+                                     backingPath, speed);
+

Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx>

Jano

Attachment: signature.asc
Description: PGP signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux