qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Fam Zheng <famz@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Anthony Liguori <aliguori@amazon.com>
Subject: [Qemu-devel] [PULL v2 37/37] block: Round up total_sectors
Date: Fri,  8 Nov 2013 11:12:31 +0100	[thread overview]
Message-ID: <1383905551-16411-38-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1383905551-16411-1-git-send-email-stefanha@redhat.com>

From: Fam Zheng <famz@redhat.com>

Since b94a2610, bdrv_getlength() is omitted when probing image. VMDK
monolithicFlat is broken by that because a file < 512 bytes can't be
read with its total_sectors truncated to 0. This patch round up the size
to BDRV_SECTOR_SIZE, when a image size is not sector aligned.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block.c b/block.c
index 0e96a22..6d5c804 100644
--- a/block.c
+++ b/block.c
@@ -640,7 +640,7 @@ static int refresh_total_sectors(BlockDriverState *bs, int64_t hint)
         if (length < 0) {
             return length;
         }
-        hint = length >> BDRV_SECTOR_BITS;
+        hint = DIV_ROUND_UP(length, BDRV_SECTOR_SIZE);
     }
 
     bs->total_sectors = hint;
-- 
1.8.3.1

      parent reply	other threads:[~2013-11-08 10:14 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-08 10:11 [Qemu-devel] [PULL v2 00/37] Block patches Stefan Hajnoczi
2013-11-08 10:11 ` [Qemu-devel] [PULL v2 01/37] qapi: Fix comment for create-type to match code Stefan Hajnoczi
2013-11-08 10:11 ` [Qemu-devel] [PULL v2 02/37] qemu-iotests: Filter out actual image size in 067 Stefan Hajnoczi
2013-11-08 10:11 ` [Qemu-devel] [PULL v2 03/37] block/raw-posix: fix FreeBSD compilation Stefan Hajnoczi
2013-11-08 10:11 ` [Qemu-devel] [PULL v2 04/37] block: qemu-iotests, add quotes to $TEST_IMG usage io pattern tests Stefan Hajnoczi
2013-11-08 10:11 ` [Qemu-devel] [PULL v2 05/37] block: qemu-iotests, fix _make_test_img() to work with spaced pathnames Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 06/37] block: qemu-iotests, add quotes to $TEST_IMG.base usage in 017 Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 07/37] block: qemu-iotests, add quotes to $TEST_IMG usage in 019 Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 08/37] block: qemu-iotests, removes duplicate double quotes in 039 Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 09/37] block: qemu-iotests, add quotes to $TEST_IMG usage for 051 Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 10/37] block: qemu-iotests, add quotes to $TEST_IMG usage in 061 Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 11/37] blockdev: fix drive_init() opts and bs_opts leaks Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 12/37] libqtest: rename qmp() to qmp_discard_response() Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 13/37] libqtest: add qmp(fmt, ...) -> QDict* function Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 14/37] blockdev-test: add test case for drive_add duplicate IDs Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 15/37] qdev-monitor-test: add device_add leak test cases Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 16/37] block: Save errno before error_setg_errno Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 17/37] block/vpc: fix virtual size for images created with disk2vhd Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 18/37] block: vhdx - minor comments and typo correction Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 19/37] block: vhdx - add header update capability Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 20/37] block: vhdx code movement - VHDXMetadataEntries and BDRVVHDXState to header Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 21/37] block: vhdx - log support struct and defines Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 22/37] block: vhdx - break endian translation functions out Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 23/37] block: vhdx - update log guid in header, and first write tracker Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 24/37] block: vhdx code movement - move vhdx_close() above vhdx_open() Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 25/37] block: vhdx - log parsing, replay, and flush support Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 26/37] block: vhdx - add region overlap detection for image files Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 27/37] block: vhdx - add log write support Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 28/37] block: vhdx " Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 29/37] block: vhdx - remove BAT file offset bit shifting Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 30/37] block: vhdx - move more endian translations to vhdx-endian.c Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 31/37] block: vhdx - break out code operations to functions Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 32/37] block: vhdx - fix comment typos in header, fix incorrect struct fields Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 33/37] block: vhdx - add .bdrv_create() support Stefan Hajnoczi
2014-02-21 12:06   ` Alexander Graf
2014-02-21 14:15     ` Jeff Cody
2014-02-24  8:47       ` Stefan Hajnoczi
2014-03-03 19:58     ` Jeff Cody
2014-03-04  0:10       ` Alexander Graf
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 34/37] block: vhdx - update _make_test_img() to filter out vhdx options Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 35/37] block: qemu-iotests for vhdx, add write test support Stefan Hajnoczi
2013-11-08 10:12 ` [Qemu-devel] [PULL v2 36/37] block: vhdx qemu-iotest - log replay of data sector Stefan Hajnoczi
2013-11-08 10:12 ` Stefan Hajnoczi [this message]

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=1383905551-16411-38-git-send-email-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=famz@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).