提交 6519c1b5 编写于 作者: P Peter Krempa

qemu: blockcopy: Fix conditions when virStorageSource should be initialized

Commit 4b58fdf2 which enabled block copy also for network
destinations needed to limit when the 'mirror' storage source is
initialized in cases when we e.g. don't have an appropriate backend.

Limiting it just to virStorageFileSupportsCreate is too restrictive as
for example we can't precreate block devices and thus wouldn't
initialize the 'mirror' but since it's a local source we'd try to
examine it. This would fail since it wouldn't be initialized.

Fix it by introducing a more granular check whether certain operations
are supported and fix the check interlocks.

https://bugzilla.redhat.com/show_bug.cgi?id=1778058Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 c958b8eb
...@@ -18009,7 +18009,9 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, ...@@ -18009,7 +18009,9 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
qemuBlockJobDataPtr job = NULL; qemuBlockJobDataPtr job = NULL;
g_autoptr(virStorageSource) mirror = mirrorsrc; g_autoptr(virStorageSource) mirror = mirrorsrc;
bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
bool mirror_initialized = false; bool supports_create = false;
bool supports_access = false;
bool supports_detect = false;
g_autoptr(qemuBlockStorageSourceChainData) data = NULL; g_autoptr(qemuBlockStorageSourceChainData) data = NULL;
g_autoptr(qemuBlockStorageSourceChainData) crdata = NULL; g_autoptr(qemuBlockStorageSourceChainData) crdata = NULL;
virStorageSourcePtr n; virStorageSourcePtr n;
...@@ -18090,14 +18092,17 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, ...@@ -18090,14 +18092,17 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
goto endjob; goto endjob;
} }
if (virStorageFileSupportsCreate(mirror) == 1) { supports_access = virStorageFileSupportsAccess(mirror) == 1;
supports_create = virStorageFileSupportsCreate(mirror) == 1;
supports_detect = virStorageFileSupportsBackingChainTraversal(mirror) == 1;
if (supports_access || supports_create || supports_detect) {
if (qemuDomainStorageFileInit(driver, vm, mirror, NULL) < 0) if (qemuDomainStorageFileInit(driver, vm, mirror, NULL) < 0)
goto endjob; goto endjob;
mirror_initialized = true;
} }
if (qemuDomainBlockCopyValidateMirror(mirror, disk->dst, &existing) < 0) if (supports_access &&
qemuDomainBlockCopyValidateMirror(mirror, disk->dst, &existing) < 0)
goto endjob; goto endjob;
if (!mirror->format) { if (!mirror->format) {
...@@ -18108,7 +18113,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, ...@@ -18108,7 +18113,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
* can also pass the RAW flag or use XML to tell us the format. * can also pass the RAW flag or use XML to tell us the format.
* So if we get here, we assume it is safe for us to probe the * So if we get here, we assume it is safe for us to probe the
* format from the file that we will be using. */ * format from the file that we will be using. */
if (!mirror_initialized || if (!supports_detect ||
!virStorageSourceIsLocalStorage(mirror) || !virStorageSourceIsLocalStorage(mirror) ||
(mirror->format = virStorageFileProbeFormat(mirror->path, cfg->user, (mirror->format = virStorageFileProbeFormat(mirror->path, cfg->user,
cfg->group)) < 0) { cfg->group)) < 0) {
...@@ -18132,7 +18137,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, ...@@ -18132,7 +18137,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
/* pre-create the image file. In case when 'blockdev' is used this is /* pre-create the image file. In case when 'blockdev' is used this is
* required so that libvirt can properly label the image for access by qemu */ * required so that libvirt can properly label the image for access by qemu */
if (!existing) { if (!existing) {
if (mirror_initialized) { if (supports_create) {
if (virStorageFileCreate(mirror) < 0) { if (virStorageFileCreate(mirror) < 0) {
virReportSystemError(errno, "%s", _("failed to create copy target")); virReportSystemError(errno, "%s", _("failed to create copy target"));
goto endjob; goto endjob;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册