qcow2: Restore L1 entry on l2_allocate failure

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>
(cherry picked from commit 68dba0bf45)
This commit is contained in:
Kevin Wolf 2010-06-07 16:43:22 +02:00
parent 6fd82592ce
commit dfe0bb55ee
1 changed files with 1 additions and 0 deletions

View File

@ -266,6 +266,7 @@ static uint64_t *l2_allocate(BlockDriverState *bs, int l1_index)
return l2_table; return l2_table;
fail: fail:
s->l1_table[l1_index] = old_l2_offset;
qcow2_l2_cache_reset(bs); qcow2_l2_cache_reset(bs);
return NULL; return NULL;
} }