From c828f5f8b73c8e51c3d974bb6d58173b0c8729af Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: References: From: Max Reitz Date: Mon, 19 Jan 2015 14:52:08 -0500 Subject: [CHANGE 07/10] block/raw-posix: Fix preallocating write() loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To: rhvirt-patches@redhat.com, jen@redhat.com RH-Author: Max Reitz Message-id: <1421679130-22714-8-git-send-email-mreitz@redhat.com> Patchwork-id: 63367 O-Subject: [RHEL-6.7 qemu-kvm PATCH 7/9] block/raw-posix: Fix preallocating write() loop Bugzilla: 1040220 RH-Acked-by: Fam Zheng RH-Acked-by: Laszlo Ersek RH-Acked-by: Stefan Hajnoczi BZ: 1040220 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 Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf (cherry picked from commit 39411cf3c316de0fe3cbb9585774bacfe3bd8efd) Signed-off-by: Max Reitz --- block/raw-posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Signed-off-by: Jeff E. Nelson --- 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 f54211a..4941a5f 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -676,7 +676,7 @@ static int raw_create(const char *filename, QEMUOptionParameter *options) strerror(-result)); break; } - left -= num; + left -= result; } fsync(fd); g_free(buf); -- 2.1.0