qcow2: Restore L1 entry on l2_allocate failure
authorKevin Wolf <kwolf@redhat.com>
Mon, 7 Jun 2010 14:43:22 +0000 (16:43 +0200)
committerKevin Wolf <kwolf@redhat.com>
Tue, 15 Jun 2010 07:41:58 +0000 (09:41 +0200)
If writing the L1 table to disk failed, we need to restore its old content in
memory to avoid inconsistencies.

Reported-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/qcow2-cluster.c

index 03a9f2579943cd10160394f332786ab55e54d0cc..5760ad6d26a737318b8419641a395e647def0401 100644 (file)
@@ -285,6 +285,7 @@ static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t **table)
     return 0;
 
 fail:
+    s->l1_table[l1_index] = old_l2_offset;
     qcow2_l2_cache_reset(bs);
     return ret;
 }