]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: Don't return success if creation of snapshot save file fails
authorPeter Krempa <pkrempa@redhat.com>
Thu, 17 Jan 2013 13:04:01 +0000 (14:04 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 21 Jan 2013 10:48:45 +0000 (11:48 +0100)
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.

src/qemu/qemu_driver.c

index 44f233d4045ba7b4dec591b2c07dc0cf05265164..2f3fb9e92edf924766d58afacfe9d5237fb4bbe2 100644 (file)
@@ -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;