diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 5212ee55e3c0c35ec9efbef344e8967b5fbe2a00..0753c3003fbca9e005e34fc55632e0acfb70c3bd 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14156,6 +14156,7 @@ qemuDomainBlockCopy(virDomainObjPtr vm, struct stat st; bool need_unlink = false; char *mirror = NULL; + int mirrorFormat; virQEMUDriverConfigPtr cfg = NULL; /* Preliminaries: find the disk we are editing, sanity checks */ @@ -14243,10 +14244,10 @@ qemuDomainBlockCopy(virDomainObjPtr vm, goto endjob; VIR_FORCE_CLOSE(fd); if (!format) - disk->mirrorFormat = disk->format; + mirrorFormat = disk->format; } else if (format) { - disk->mirrorFormat = virStorageFileFormatTypeFromString(format); - if (disk->mirrorFormat <= 0) { + mirrorFormat = virStorageFileFormatTypeFromString(format); + if (mirrorFormat <= 0) { virReportError(VIR_ERR_INVALID_ARG, _("unrecognized format '%s'"), format); goto endjob; @@ -14256,11 +14257,11 @@ qemuDomainBlockCopy(virDomainObjPtr vm, * also passed the RAW flag (and format is non-NULL), or it is * safe for us to probe the format from the file that we will * be using. */ - disk->mirrorFormat = virStorageFileProbeFormat(dest, cfg->user, - cfg->group); + mirrorFormat = virStorageFileProbeFormat(dest, cfg->user, + cfg->group); } - if (!format && disk->mirrorFormat > 0) - format = virStorageFileFormatTypeToString(disk->mirrorFormat); + if (!format && mirrorFormat > 0) + format = virStorageFileFormatTypeToString(mirrorFormat); if (VIR_STRDUP(mirror, dest) < 0) goto endjob; @@ -14286,13 +14287,12 @@ qemuDomainBlockCopy(virDomainObjPtr vm, /* Update vm in place to match changes. */ need_unlink = false; disk->mirror = mirror; + disk->mirrorFormat = mirrorFormat; mirror = NULL; endjob: if (need_unlink && unlink(dest)) VIR_WARN("unable to unlink just-created %s", dest); - if (ret < 0 && disk) - disk->mirrorFormat = VIR_STORAGE_FILE_NONE; VIR_FREE(mirror); if (!qemuDomainObjEndJob(driver, vm)) vm = NULL;