From 6f20e092c937e5337352ecfdd1d482e6c785a1a7 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Thu, 4 Mar 2010 23:11:44 -0300 Subject: [PATCH 22/42] qcow2: Fix image creation regression RH-Author: Juan Quintela Message-id: Patchwork-id: 7550 O-Subject: [PATCH 22/32] qcow2: Fix image creation regression Bugzilla: 567099 RH-Acked-by: Kevin Wolf RH-Acked-by: Amit Shah RH-Acked-by: Marcelo Tosatti From: Kevin Wolf 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 Signed-off-by: Anthony Liguori Signed-off-by: Juan Quintela --- block/qcow2.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Signed-off-by: Eduardo Habkost --- block/qcow2.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index f95caf6..48fd06a 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -983,7 +983,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; } @@ -995,7 +995,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); -- 1.6.3.rc4.29.g8146