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

qemu: snapshot: Fix image lock handling when taking a snapshot

When we take a snapshot we must properly remove our locking
infrastructure locks. This was broken by commit 3817fa10 which
attempted to properly track the readonly state for the image as the
locking code was executed after this change. Since we forced the image
which was locked as read-write to read-only prior to unlocking it the
write lock was not dropped.

Fix it by moving the locking code prior to modifying the readonly flag.

https://bugzilla.redhat.com/show_bug.cgi?id=1745618Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 805b4aa2
...@@ -15435,6 +15435,13 @@ qemuDomainSnapshotUpdateDiskSources(virQEMUDriverPtr driver, ...@@ -15435,6 +15435,13 @@ qemuDomainSnapshotUpdateDiskSources(virQEMUDriverPtr driver,
if (qemuSecurityMoveImageMetadata(driver, vm, dd->disk->src, dd->src) < 0) if (qemuSecurityMoveImageMetadata(driver, vm, dd->disk->src, dd->src) < 0)
VIR_WARN("Unable to move disk metadata on vm %s", vm->def->name); VIR_WARN("Unable to move disk metadata on vm %s", vm->def->name);
/* unlock the write lock on the original image as qemu will no longer write to it */
virDomainLockImageDetach(driver->lockManager, vm, dd->disk->src);
/* unlock also the new image if the VM is paused to follow the locking semantics */
if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING)
virDomainLockImageDetach(driver->lockManager, vm, dd->src);
/* the old disk image is now readonly */ /* the old disk image is now readonly */
dd->disk->src->readonly = true; dd->disk->src->readonly = true;
...@@ -15553,23 +15560,8 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver, ...@@ -15553,23 +15560,8 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
ret = 0; ret = 0;
cleanup: cleanup:
if (ret < 0) { if (ret < 0)
virErrorPreserveLast(&orig_err); virErrorPreserveLast(&orig_err);
} else {
/* on successful snapshot we need to remove locks from the now-old
* disks and if the VM is paused release locks on the images since qemu
* stopped using them*/
bool paused = virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING;
for (i = 0; i < ndiskdata; i++) {
if (paused)
virDomainLockImageDetach(driver->lockManager, vm,
diskdata[i].disk->src);
virDomainLockImageDetach(driver->lockManager, vm,
diskdata[i].disk->src->backingStore);
}
}
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0 || if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0 ||
(vm->newDef && virDomainSaveConfig(cfg->configDir, driver->caps, (vm->newDef && virDomainSaveConfig(cfg->configDir, driver->caps,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册