Patchwork qcow2: Fix snapshot restoration in snapshot_create

login
register
mail settings
Submitter Max Reitz
Date Oct. 9, 2013, 12:42 p.m.
Message ID <1381322520-18656-1-git-send-email-mreitz@redhat.com>
Download mbox | patch
Permalink /patch/281886/
State New
Headers show

Comments

Max Reitz - Oct. 9, 2013, 12:42 p.m.
If the new snapshot table could not be written in qcow2_snapshot_create,
the old snapshot table has to be restored in memory and the new one
released. This should include restoration of the old snapshot count as
well, which is added by this patch.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/qcow2-snapshot.c | 1 +
 1 file changed, 1 insertion(+)
Kevin Wolf - Oct. 9, 2013, 1:21 p.m.
Am 09.10.2013 um 14:42 hat Max Reitz geschrieben:
> If the new snapshot table could not be written in qcow2_snapshot_create,
> the old snapshot table has to be restored in memory and the new one
> released. This should include restoration of the old snapshot count as
> well, which is added by this patch.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>

Thanks, applied to the block branch.

Kevin

Patch

diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
index 812dab2..fe7e14c 100644
--- a/block/qcow2-snapshot.c
+++ b/block/qcow2-snapshot.c
@@ -433,6 +433,7 @@  int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
     if (ret < 0) {
         g_free(s->snapshots);
         s->snapshots = old_snapshot_list;
+        s->nb_snapshots--;
         goto fail;
     }