From: Peter Krempa Date: Thu, 17 Jan 2013 13:04:01 +0000 (+0100) Subject: qemu: Don't return success if creation of snapshot save file fails X-Git-Tag: v1.0.2-rc1~70 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=27054e1217e2787b1806f55c5f6eb8908612d690;p=thirdparty%2Flibvirt.git qemu: Don't return success if creation of snapshot save file fails When the snapshot definition can't be saved, the qemuDomainSnapshotCreate function succeeded without filling some of the fields in the internal definition. This patch removes the snapshot and returns failure if the XML file cannot be written. --- diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 44f233d404..2f3fb9e92e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -11598,8 +11598,14 @@ cleanup: if (snapshot && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) { if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->snapshotDir) < 0) { - VIR_WARN("unable to save metadata for snapshot %s", - snap->def->name); + /* if writing of metadata fails, error out rather than trying + * to silently carry on without completing the snapshot */ + virDomainSnapshotFree(snapshot); + snapshot = NULL; + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unable to save metadata for snapshot %s"), + snap->def->name); + virDomainSnapshotObjListRemove(vm->snapshots, snap); } else { if (update_current) vm->current_snapshot = snap;