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, peter.maydell@linaro.org, mreitz@redhat.com
Subject: [Qemu-devel] [PULL 4/6] block/raw-posix: Fix preallocating write() loop
Date: Tue, 18 Nov 2014 12:35:06 +0100	[thread overview]
Message-ID: <1416310508-5122-5-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1416310508-5122-1-git-send-email-kwolf@redhat.com>

From: Max Reitz <mreitz@redhat.com>

write() may write less bytes than requested; in this case, the number of
bytes written is returned. This is the byte count we should be
subtracting from the number of bytes still to be written, and not the
byte count we requested to write.

Reported-by: László Érsek <lersek@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/raw-posix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/raw-posix.c b/block/raw-posix.c
index 414e6d1..e0e48c5 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1451,7 +1451,7 @@ static int raw_create(const char *filename, QemuOpts *opts, Error **errp)
                                  "Could not write to the new file");
                 break;
             }
-            left -= num;
+            left -= result;
         }
         fsync(fd);
         g_free(buf);
-- 
1.8.3.1

  parent reply	other threads:[~2014-11-18 11:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-18 11:35 [Qemu-devel] [PULL 0/6] Block patches for 2.2.0-rc2 Kevin Wolf
2014-11-18 11:35 ` [Qemu-devel] [PULL 1/6] raw-posix: Fix comment for raw_co_get_block_status() Kevin Wolf
2014-11-18 11:35 ` [Qemu-devel] [PULL 2/6] raw-posix: SEEK_HOLE suffices, get rid of FIEMAP Kevin Wolf
2014-11-18 11:35 ` [Qemu-devel] [PULL 3/6] raw-posix: The SEEK_HOLE code is flawed, rewrite it Kevin Wolf
2014-11-18 11:35 ` Kevin Wolf [this message]
2014-11-18 11:35 ` [Qemu-devel] [PULL 5/6] block/raw-posix: Only sync after successful preallocation Kevin Wolf
2014-11-18 11:35 ` [Qemu-devel] [PULL 6/6] block/raw-posix: Catch fsync() errors Kevin Wolf
2014-11-18 14:46 ` [Qemu-devel] [PULL 0/6] Block patches for 2.2.0-rc2 Peter Maydell

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=1416310508-5122-5-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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).