qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com
Subject: [Qemu-devel] [PATCH] qcow2: Fix image creation regression
Date: Tue, 23 Feb 2010 16:06:20 +0100	[thread overview]
Message-ID: <1266937580-25915-1-git-send-email-kwolf@redhat.com> (raw)

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>
---
 block/qcow2.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/qcow2.c b/block/qcow2.c
index 6632e6d..0e4cd98 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -986,7 +986,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;
     }
@@ -998,7 +998,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);
-- 
1.6.6.1

             reply	other threads:[~2010-02-23 15:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-23 15:06 Kevin Wolf [this message]
2010-02-23 18:34 ` [Qemu-devel] Re: [PATCH] qcow2: Fix image creation regression Juan Quintela

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1266937580-25915-1-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).