提交 65a12c46 编写于 作者: P Peter Krempa

qemu: blockcopy: Allow copy of read-only disks with -blockdev

'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=1832204Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 fe574ea1
......@@ -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);
......
......@@ -18120,6 +18120,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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册