提交 4b58fdf2 编写于 作者: P Peter Krempa

qemu: driver: allow remote destinations for block copy

Now that we support blockdev for qemuDomainBlockCopy we can allow
copying to remote destinations as well.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 ce7229a3
...@@ -18236,6 +18236,9 @@ qemuDomainBlockCopyValidateMirror(virStorageSourcePtr mirror, ...@@ -18236,6 +18236,9 @@ qemuDomainBlockCopyValidateMirror(virStorageSourcePtr mirror,
int desttype = virStorageSourceGetActualType(mirror); int desttype = virStorageSourceGetActualType(mirror);
struct stat st; struct stat st;
if (!virStorageSourceIsLocalStorage(mirror))
return 0;
if (virStorageFileAccess(mirror, F_OK) < 0) { if (virStorageFileAccess(mirror, F_OK) < 0) {
if (errno != ENOENT) { if (errno != ENOENT) {
virReportSystemError(errno, "%s", virReportSystemError(errno, "%s",
...@@ -18362,6 +18365,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, ...@@ -18362,6 +18365,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
qemuBlockJobDataPtr job = NULL; qemuBlockJobDataPtr job = NULL;
VIR_AUTOUNREF(virStorageSourcePtr) mirror = mirrorsrc; VIR_AUTOUNREF(virStorageSourcePtr) mirror = mirrorsrc;
bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
bool mirror_initialized = false;
VIR_AUTOPTR(qemuBlockStorageSourceChainData) data = NULL; VIR_AUTOPTR(qemuBlockStorageSourceChainData) data = NULL;
VIR_AUTOPTR(qemuBlockStorageSourceChainData) crdata = NULL; VIR_AUTOPTR(qemuBlockStorageSourceChainData) crdata = NULL;
virStorageSourcePtr n; virStorageSourcePtr n;
...@@ -18434,15 +18438,19 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, ...@@ -18434,15 +18438,19 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
} }
/* Prepare the destination file. */ /* Prepare the destination file. */
/* XXX Allow non-file mirror destinations */ if (!blockdev &&
if (!virStorageSourceIsLocalStorage(mirror)) { !virStorageSourceIsLocalStorage(mirror)) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("non-file destination not supported yet")); _("non-file destination not supported yet"));
goto endjob; goto endjob;
} }
if (qemuDomainStorageFileInit(driver, vm, mirror, NULL) < 0) if (virStorageFileSupportsCreate(mirror) == 1) {
goto endjob; if (qemuDomainStorageFileInit(driver, vm, mirror, NULL) < 0)
goto endjob;
mirror_initialized = true;
}
if (qemuDomainBlockCopyValidateMirror(mirror, disk->dst, &existing) < 0) if (qemuDomainBlockCopyValidateMirror(mirror, disk->dst, &existing) < 0)
goto endjob; goto endjob;
...@@ -18451,12 +18459,19 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, ...@@ -18451,12 +18459,19 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
if (!mirror_reuse) { if (!mirror_reuse) {
mirror->format = disk->src->format; mirror->format = disk->src->format;
} else { } else {
/* If the user passed the REUSE_EXT flag, then either they if (mirror_initialized &&
* can also pass the RAW flag or use XML to tell us the format. virStorageSourceIsLocalStorage(mirror)) {
* So if we get here, we assume it is safe for us to probe the /* If the user passed the REUSE_EXT flag, then either they
* format from the file that we will be using. */ * can also pass the RAW flag or use XML to tell us the format.
mirror->format = virStorageFileProbeFormat(mirror->path, cfg->user, * So if we get here, we assume it is safe for us to probe the
cfg->group); * format from the file that we will be using. */
mirror->format = virStorageFileProbeFormat(mirror->path, cfg->user,
cfg->group);
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("reused mirror destination format must be specified"));
goto endjob;
}
} }
} }
...@@ -18473,12 +18488,14 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, ...@@ -18473,12 +18488,14 @@ 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 (virStorageFileCreate(mirror) < 0) { if (mirror_initialized) {
virReportSystemError(errno, "%s", _("failed to create copy target")); if (virStorageFileCreate(mirror) < 0) {
goto endjob; virReportSystemError(errno, "%s", _("failed to create copy target"));
} goto endjob;
}
need_unlink = true; need_unlink = true;
}
} }
if (mirror->format > 0) if (mirror->format > 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册