mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 18:45:16 +00:00
qemu: blockcopy: Don't remove existing disk mirror info
When creating a new disk mirror the new struct is stored in a separate variable until everything went well. The removed hunk would actually remove existing mirror information for example when the api would be run if a mirror still exists. (cherry picked from commit 02b364e186d487f54ed410c01af042f23e812d42) This fixes a regression introduced in commit ff5f30b. Signed-off-by: Eric Blake <eblake@redhat.com> Conflicts: src/qemu/qemu_driver.c - no refactoring of commits 7b7bf001, 4f20226
This commit is contained in:
parent
9b1d093774
commit
69380800fb
@ -14156,6 +14156,7 @@ qemuDomainBlockCopy(virDomainObjPtr vm,
|
|||||||
struct stat st;
|
struct stat st;
|
||||||
bool need_unlink = false;
|
bool need_unlink = false;
|
||||||
char *mirror = NULL;
|
char *mirror = NULL;
|
||||||
|
int mirrorFormat;
|
||||||
virQEMUDriverConfigPtr cfg = NULL;
|
virQEMUDriverConfigPtr cfg = NULL;
|
||||||
|
|
||||||
/* Preliminaries: find the disk we are editing, sanity checks */
|
/* Preliminaries: find the disk we are editing, sanity checks */
|
||||||
@ -14243,10 +14244,10 @@ qemuDomainBlockCopy(virDomainObjPtr vm,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
VIR_FORCE_CLOSE(fd);
|
VIR_FORCE_CLOSE(fd);
|
||||||
if (!format)
|
if (!format)
|
||||||
disk->mirrorFormat = disk->format;
|
mirrorFormat = disk->format;
|
||||||
} else if (format) {
|
} else if (format) {
|
||||||
disk->mirrorFormat = virStorageFileFormatTypeFromString(format);
|
mirrorFormat = virStorageFileFormatTypeFromString(format);
|
||||||
if (disk->mirrorFormat <= 0) {
|
if (mirrorFormat <= 0) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG, _("unrecognized format '%s'"),
|
virReportError(VIR_ERR_INVALID_ARG, _("unrecognized format '%s'"),
|
||||||
format);
|
format);
|
||||||
goto endjob;
|
goto endjob;
|
||||||
@ -14256,11 +14257,11 @@ qemuDomainBlockCopy(virDomainObjPtr vm,
|
|||||||
* also passed the RAW flag (and format is non-NULL), or it is
|
* 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
|
* safe for us to probe the format from the file that we will
|
||||||
* be using. */
|
* be using. */
|
||||||
disk->mirrorFormat = virStorageFileProbeFormat(dest, cfg->user,
|
mirrorFormat = virStorageFileProbeFormat(dest, cfg->user,
|
||||||
cfg->group);
|
cfg->group);
|
||||||
}
|
}
|
||||||
if (!format && disk->mirrorFormat > 0)
|
if (!format && mirrorFormat > 0)
|
||||||
format = virStorageFileFormatTypeToString(disk->mirrorFormat);
|
format = virStorageFileFormatTypeToString(mirrorFormat);
|
||||||
if (VIR_STRDUP(mirror, dest) < 0)
|
if (VIR_STRDUP(mirror, dest) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
@ -14286,13 +14287,12 @@ qemuDomainBlockCopy(virDomainObjPtr vm,
|
|||||||
/* Update vm in place to match changes. */
|
/* Update vm in place to match changes. */
|
||||||
need_unlink = false;
|
need_unlink = false;
|
||||||
disk->mirror = mirror;
|
disk->mirror = mirror;
|
||||||
|
disk->mirrorFormat = mirrorFormat;
|
||||||
mirror = NULL;
|
mirror = NULL;
|
||||||
|
|
||||||
endjob:
|
endjob:
|
||||||
if (need_unlink && unlink(dest))
|
if (need_unlink && unlink(dest))
|
||||||
VIR_WARN("unable to unlink just-created %s", dest);
|
VIR_WARN("unable to unlink just-created %s", dest);
|
||||||
if (ret < 0 && disk)
|
|
||||||
disk->mirrorFormat = VIR_STORAGE_FILE_NONE;
|
|
||||||
VIR_FREE(mirror);
|
VIR_FREE(mirror);
|
||||||
if (!qemuDomainObjEndJob(driver, vm))
|
if (!qemuDomainObjEndJob(driver, vm))
|
||||||
vm = NULL;
|
vm = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user