[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH V3 1/7] qcow2: restore nb_snapshots when fail in sna
From: |
Wenchao Xia |
Subject: |
[Qemu-devel] [PATCH V3 1/7] qcow2: restore nb_snapshots when fail in snapshot creation |
Date: |
Mon, 9 Sep 2013 10:57:56 +0800 |
If it is not restored after qcow2_write_snapshots() fail, a core
dump will happen in bdrv_close() since access of invalid pointer.
Signed-off-by: Wenchao Xia <address@hidden>
---
block/qcow2-snapshot.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
index e7e6013..40393b2 100644
--- a/block/qcow2-snapshot.c
+++ b/block/qcow2-snapshot.c
@@ -331,7 +331,7 @@ int qcow2_snapshot_create(BlockDriverState *bs,
QEMUSnapshotInfo *sn_info)
QCowSnapshot *new_snapshot_list = NULL;
QCowSnapshot *old_snapshot_list = NULL;
QCowSnapshot sn1, *sn = &sn1;
- int i, ret;
+ int i, ret, old_snapshot_num = 0;
uint64_t *l1_table = NULL;
int64_t l1_table_offset;
@@ -403,6 +403,7 @@ int qcow2_snapshot_create(BlockDriverState *bs,
QEMUSnapshotInfo *sn_info)
memcpy(new_snapshot_list, s->snapshots,
s->nb_snapshots * sizeof(QCowSnapshot));
old_snapshot_list = s->snapshots;
+ old_snapshot_num = s->nb_snapshots;
}
s->snapshots = new_snapshot_list;
s->snapshots[s->nb_snapshots++] = *sn;
@@ -411,6 +412,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 = old_snapshot_num;
goto fail;
}
--
1.7.1
- [Qemu-devel] [PATCH V3 0/7] qcow2: rollback the modification on fail in snapshot creation, Wenchao Xia, 2013/09/08
- [Qemu-devel] [PATCH V3 3/7] qcow2: cancel the modification on fail in qcow2_snapshot_create(), Wenchao Xia, 2013/09/08
- [Qemu-devel] [PATCH V3 2/7] qcow2: free allocated cluster on fail in qcow2_write_snapshots(), Wenchao Xia, 2013/09/08
- [Qemu-devel] [PATCH V3 6/7] qcow2: print message for error path in snapshot creation, Wenchao Xia, 2013/09/08
- [Qemu-devel] [PATCH V3 1/7] qcow2: restore nb_snapshots when fail in snapshot creation,
Wenchao Xia <=
- [Qemu-devel] [PATCH V3 4/7] blkdebug: add debug events for snapshot, Wenchao Xia, 2013/09/08
- [Qemu-devel] [PATCH V3 7/7] qemu-iotests: add test for qcow2 snapshot, Wenchao Xia, 2013/09/08
- [Qemu-devel] [PATCH V3 5/7] qcow2: use debug events for snapshot, Wenchao Xia, 2013/09/08
- Re: [Qemu-devel] [PATCH V3 0/7] qcow2: rollback the modification on fail in snapshot creation, Wenchao Xia, 2013/09/23