diff options
author | Anthony Liguori <anthony@codemonkey.ws> | 2013-10-09 07:54:42 -0700 |
---|---|---|
committer | Anthony Liguori <anthony@codemonkey.ws> | 2013-10-09 07:54:42 -0700 |
commit | a107170537abdfec7221c1e0d424c82f5faf2ebe (patch) | |
tree | cf651c928b1cd5c9229c68624f997abe5a76a238 /block/qcow2-cluster.c | |
parent | 80dfc87394ed10f47918299a5192f337a85333d8 (diff) | |
parent | d4cea8dfb99153803164915c7a1109549ad3da9c (diff) | |
download | qemu-a107170537abdfec7221c1e0d424c82f5faf2ebe.zip qemu-a107170537abdfec7221c1e0d424c82f5faf2ebe.tar.gz qemu-a107170537abdfec7221c1e0d424c82f5faf2ebe.tar.bz2 |
Merge remote-tracking branch 'stefanha/block' into staging
# By Max Reitz (5) and others
# Via Stefan Hajnoczi
* stefanha/block:
block: use correct filename
qemu-iotests: Correct 026 output
qcow2: Free allocated L2 cluster on error
qcow2: Switch L1 table in a single sequence
block: vhdx - add migration blocker
block: use correct filename for error report
qcow2: CHECK_OFLAG_COPIED is obsolete
qcow2: Correct endianness in overlap check
Message-id: 1381145289-6591-1-git-send-email-stefanha@redhat.com
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
Diffstat (limited to 'block/qcow2-cluster.c')
-rw-r--r-- | block/qcow2-cluster.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 39323ac..0fd26bb 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -35,6 +35,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, BDRVQcowState *s = bs->opaque; int new_l1_size2, ret, i; uint64_t *new_l1_table; + int64_t old_l1_table_offset, old_l1_size; int64_t new_l1_table_offset, new_l1_size; uint8_t data[12]; @@ -106,11 +107,13 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, goto fail; } g_free(s->l1_table); - qcow2_free_clusters(bs, s->l1_table_offset, s->l1_size * sizeof(uint64_t), - QCOW2_DISCARD_OTHER); + old_l1_table_offset = s->l1_table_offset; s->l1_table_offset = new_l1_table_offset; s->l1_table = new_l1_table; + old_l1_size = s->l1_size; s->l1_size = new_l1_size; + qcow2_free_clusters(bs, old_l1_table_offset, old_l1_size * sizeof(uint64_t), + QCOW2_DISCARD_OTHER); return 0; fail: g_free(new_l1_table); @@ -270,6 +273,10 @@ fail: qcow2_cache_put(bs, s->l2_table_cache, (void**) table); } s->l1_table[l1_index] = old_l2_offset; + if (l2_offset > 0) { + qcow2_free_clusters(bs, l2_offset, s->l2_size * sizeof(uint64_t), + QCOW2_DISCARD_ALWAYS); + } return ret; } |