Signed-off-by: Wenchao Xia <xiaw...@linux.vnet.ibm.com> --- block/qcow2-snapshot.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index 4bd494b..c933b7f 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -304,6 +304,13 @@ static int qcow2_write_snapshots(BlockDriverState *bs, Error **errp) PRIi64 " with size %" PRIu64 ":%d (%s)", offsetof(QCowHeader, nb_snapshots), sizeof(header_data), ret, strerror(-ret)); + /* + * If the snapshot data part have been updated on disk, Then the + * clusters at snapshot_offset may be used in next snapshot operation. + * If we free those clusters in fail path, they may be allocated and + * made dirty causing damage, so skip cluster free for safe. + */ + snapshots_offset = 0; goto fail; } -- 1.7.1