summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Forbes <jforbes@redhat.com>2011-08-14 10:55:05 -0500
committerJustin M. Forbes <jforbes@redhat.com>2011-08-14 10:55:05 -0500
commite62ad8314a52ce155cff07d105e50e565b9f1ea6 (patch)
tree3f3bb64a7a998e4825a2c305278b7848ae10f797
parent4bea41dbaa2eb3a57005bb3c4a4af2a55b9fcc21 (diff)
parent76e4e1d23711750f777333654f13cf6baf8d01f1 (diff)
downloadqemu-e62ad8314a52ce155cff07d105e50e565b9f1ea6.tar.gz
Merge branch 'stable-0.15' of git://git.qemu.org/qemu
-rw-r--r--VERSION2
-rw-r--r--block/qcow2-snapshot.c16
2 files changed, 12 insertions, 6 deletions
diff --git a/VERSION b/VERSION
index dc82dfd475..a551051694 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.14.92
+0.15.0
diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
index 74823a5ebf..e32bcf084c 100644
--- a/block/qcow2-snapshot.c
+++ b/block/qcow2-snapshot.c
@@ -317,7 +317,8 @@ int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id)
{
BDRVQcowState *s = bs->opaque;
QCowSnapshot *sn;
- int i, snapshot_index, l1_size2;
+ int i, snapshot_index;
+ int cur_l1_bytes, sn_l1_bytes;
snapshot_index = find_snapshot_by_id_or_name(bs, snapshot_id);
if (snapshot_index < 0)
@@ -330,14 +331,19 @@ int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id)
if (qcow2_grow_l1_table(bs, sn->l1_size, true) < 0)
goto fail;
- s->l1_size = sn->l1_size;
- l1_size2 = s->l1_size * sizeof(uint64_t);
+ cur_l1_bytes = s->l1_size * sizeof(uint64_t);
+ sn_l1_bytes = sn->l1_size * sizeof(uint64_t);
+
+ if (cur_l1_bytes > sn_l1_bytes) {
+ memset(s->l1_table + sn->l1_size, 0, cur_l1_bytes - sn_l1_bytes);
+ }
+
/* copy the snapshot l1 table to the current l1 table */
if (bdrv_pread(bs->file, sn->l1_table_offset,
- s->l1_table, l1_size2) != l1_size2)
+ s->l1_table, sn_l1_bytes) < 0)
goto fail;
if (bdrv_pwrite_sync(bs->file, s->l1_table_offset,
- s->l1_table, l1_size2) < 0)
+ s->l1_table, cur_l1_bytes) < 0)
goto fail;
for(i = 0;i < s->l1_size; i++) {
be64_to_cpus(&s->l1_table[i]);