提交 c554f6e1 编写于 作者: E Eric Blake

snapshot: fix corner case on OOM during creation

Commit 6766ff10 introduced a corner case bug with snapshot creation:
if a snapshot is created, but then we hit OOM while trying to
create the return value of the function, then we have polluted the
internal directory with the snapshot metadata with no way to clean
it up from the running libvirtd.

* src/qemu/qemu_driver.c (qemuDomainSnapshotCreateXML): Don't
write metadata file on OOM condition.
上级 e86789a5
......@@ -8583,18 +8583,20 @@ static virDomainSnapshotPtr qemuDomainSnapshotCreateXML(virDomainPtr domain,
* do; we've successfully taken the snapshot, and we are now running
* on it, so we have to go forward the best we can
*/
if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->snapshotDir) < 0)
goto cleanup;
vm->current_snapshot = snap;
snapshot = virGetDomainSnapshot(domain, snap->def->name);
cleanup:
if (vm) {
if (snapshot)
vm->current_snapshot = snap;
else if (snap)
if (snapshot) {
if (qemuDomainSnapshotWriteMetadata(vm, snap,
driver->snapshotDir) < 0)
VIR_WARN("unable to save metadata for snapshot %s",
snap->def->name);
else
vm->current_snapshot = snap;
} else if (snap) {
virDomainSnapshotObjListRemove(&vm->snapshots, snap);
}
virDomainObjUnlock(vm);
}
virDomainSnapshotDefFree(def);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册