提交 f8b6c11a 编写于 作者: P Peter Krempa

qemu: blockcopy: reuse storage driver APIs to pre-create copy target

Rather than using the local-file only implementation 'qemuOpenFile'
switch to the imagelabel aware storage driver implementation.
上级 060d4ec6
...@@ -16785,6 +16785,10 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, ...@@ -16785,6 +16785,10 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
_("non-file destination not supported yet")); _("non-file destination not supported yet"));
goto endjob; goto endjob;
} }
if (qemuDomainStorageFileInit(driver, vm, mirror) < 0)
goto endjob;
if (stat(mirror->path, &st) < 0) { if (stat(mirror->path, &st) < 0) {
if (errno != ENOENT) { if (errno != ENOENT) {
virReportSystemError(errno, _("unable to stat for disk %s: %s"), virReportSystemError(errno, _("unable to stat for disk %s: %s"),
...@@ -16832,12 +16836,12 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, ...@@ -16832,12 +16836,12 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
/* pre-create the image file */ /* pre-create the image file */
if (!reuse) { if (!reuse) {
int fd = qemuOpenFile(driver, vm, mirror->path, if (virStorageFileCreate(mirror) < 0) {
O_WRONLY | O_TRUNC | O_CREAT, virReportSystemError(errno, "%s", _("failed to create copy target"));
&need_unlink, NULL);
if (fd < 0)
goto endjob; goto endjob;
VIR_FORCE_CLOSE(fd); }
need_unlink = true;
} }
if (mirror->format > 0) if (mirror->format > 0)
...@@ -16869,6 +16873,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, ...@@ -16869,6 +16873,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
/* Update vm in place to match changes. */ /* Update vm in place to match changes. */
need_unlink = false; need_unlink = false;
virStorageFileDeinit(mirror);
disk->mirror = mirror; disk->mirror = mirror;
mirror = NULL; mirror = NULL;
disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_COPY; disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_COPY;
...@@ -16879,8 +16884,9 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, ...@@ -16879,8 +16884,9 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
vm->def->name); vm->def->name);
endjob: endjob:
if (need_unlink && unlink(mirror->path)) if (need_unlink && virStorageFileUnlink(mirror) < 0)
VIR_WARN("unable to unlink just-created %s", mirror->path); VIR_WARN("%s", _("unable to remove just-created copy target"));
virStorageFileDeinit(mirror);
qemuDomainObjEndJob(driver, vm); qemuDomainObjEndJob(driver, vm);
if (monitor_error) { if (monitor_error) {
virSetError(monitor_error); virSetError(monitor_error);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册