diff options
author | Kevin Wolf <kwolf@redhat.com> | 2010-02-23 16:06:20 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2010-02-23 13:23:29 -0600 |
commit | 6f745bdaac26bcbdd7e2ffa2a6ea29aabbbc54e1 (patch) | |
tree | 98785dbac1d0a22e81ed51b4dccd7d623a246fb5 /block | |
parent | 746c3cb5d55a702ba6285e97d2a13671f09285d8 (diff) | |
download | qemu-6f745bdaac26bcbdd7e2ffa2a6ea29aabbbc54e1.zip qemu-6f745bdaac26bcbdd7e2ffa2a6ea29aabbbc54e1.tar.gz qemu-6f745bdaac26bcbdd7e2ffa2a6ea29aabbbc54e1.tar.bz2 |
qcow2: Fix image creation regression
When checking for errors, commit db89119d compares with the wrong values,
failing image creation even when there was no error. Additionally, if an
error has occured, we can't preallocate the image (it's likely broken).
This unbreaks test 023 of qemu-iotests.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/qcow2.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/block/qcow2.c b/block/qcow2.c index 7f3aef5..bf8170e 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -984,7 +984,7 @@ static int qcow_create2(const char *filename, int64_t total_size, lseek(fd, s->refcount_block_offset, SEEK_SET); ret = qemu_write_full(fd, s->refcount_block, ref_clusters * s->cluster_size); - if (ret != s->cluster_size) { + if (ret != ref_clusters * s->cluster_size) { ret = -1; goto exit; } @@ -996,7 +996,7 @@ exit: close(fd); /* Preallocate metadata */ - if (prealloc) { + if (ret == 0 && prealloc) { BlockDriverState *bs; bs = bdrv_new(""); bdrv_open(bs, filename, BDRV_O_CACHE_WB | BDRV_O_RDWR); |