[PATCH 4/5] qemu: blockcopy: Allow copy of read-only disks with -blockdev

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

 



'blockdev-mirror' requires the write permission internally to do the
copy. This means that we have to force the image to be read-write for
the duration of the copy and can fix it after the copy is done.

https://bugzilla.redhat.com/show_bug.cgi?id=1832204

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_blockjob.c | 5 +++++
 src/qemu/qemu_driver.c   | 9 +++++++++
 2 files changed, 14 insertions(+)

diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index b9eecd3f98..e51499532f 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -1282,6 +1282,7 @@ qemuBlockJobProcessEventConcludedCopyPivot(virQEMUDriverPtr driver,
                                            qemuBlockJobDataPtr job,
                                            qemuDomainAsyncJob asyncJob)
 {
+    qemuDomainObjPrivatePtr priv = vm->privateData;
     VIR_DEBUG("copy job '%s' on VM '%s' pivoted", job->name, vm->def->name);

     /* mirror may be NULL for copy job corresponding to migration */
@@ -1297,6 +1298,10 @@ qemuBlockJobProcessEventConcludedCopyPivot(virQEMUDriverPtr driver,
         !virStorageSourceIsBacking(job->disk->mirror->backingStore))
         job->disk->mirror->backingStore = g_steal_pointer(&job->disk->src->backingStore);

+    if (job->disk->src->readonly &&
+        virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN))
+        ignore_value(qemuBlockReopenReadOnly(vm, job->disk->mirror, asyncJob));
+
     qemuBlockJobRewriteConfigDiskSource(vm, job->disk, job->disk->mirror);

     qemuBlockJobEventProcessConcludedRemoveChain(driver, vm, asyncJob, job->disk->src);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 29d964f1e8..1c73604249 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -18110,6 +18110,15 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
                                          keepParentLabel) < 0)
         goto endjob;

+    if (mirror->readonly) {
+        if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN)) {
+            virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+                           _("copy of read-only disks is not supported"));
+            goto endjob;
+        }
+        mirror->readonly = false;
+    }
+
     /* we must initialize XML-provided chain prior to detecting to keep semantics
      * with VM startup */
     if (blockdev) {
-- 
2.26.2




[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