mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-11-03 20:01:16 +00:00
qemu: snapshot: Fix inactive external snapshots when backing chain is present
The inactive external snapshot code replaced the file name in the virStorageSource but did not touch the backing files. This meant that after an inactive snapshot the backing chain recorded in the inactive XML (which is used with -blockdev) would be incorrect. Fix it by adding a new layer if there is an existing chain and replacing the virStorageSource struct fully when there is no chain. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
b036834eae
commit
f6cccece48
@ -14613,18 +14613,31 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
/* update disk definitions */
|
/* update disk definitions */
|
||||||
for (i = 0; i < snapdef->ndisks; i++) {
|
for (i = 0; i < snapdef->ndisks; i++) {
|
||||||
|
g_autoptr(virStorageSource) newsrc = NULL;
|
||||||
|
|
||||||
snapdisk = &(snapdef->disks[i]);
|
snapdisk = &(snapdef->disks[i]);
|
||||||
defdisk = vm->def->disks[snapdisk->idx];
|
defdisk = vm->def->disks[snapdisk->idx];
|
||||||
|
|
||||||
if (snapdisk->snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) {
|
if (snapdisk->snapshot != VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL)
|
||||||
VIR_FREE(defdisk->src->path);
|
continue;
|
||||||
defdisk->src->path = g_strdup(snapdisk->src->path);
|
|
||||||
defdisk->src->format = snapdisk->src->format;
|
if (!(newsrc = virStorageSourceCopy(snapdisk->src, false)))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (virStorageSourceInitChainElement(newsrc, defdisk->src, false) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (virStorageSourceHasBacking(defdisk->src)) {
|
||||||
|
newsrc->backingStore = g_steal_pointer(&defdisk->src);
|
||||||
|
} else {
|
||||||
|
virObjectUnref(defdisk->src);
|
||||||
|
}
|
||||||
|
|
||||||
|
defdisk->src = g_steal_pointer(&newsrc);
|
||||||
|
}
|
||||||
|
|
||||||
if (virDomainSaveConfig(cfg->configDir, driver->caps, vm->def) < 0)
|
if (virDomainSaveConfig(cfg->configDir, driver->caps, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user