From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 05/12] raw_bsd: don't check size alignment when only offset is set
Date: Fri, 11 Nov 2016 17:55:04 +0100 [thread overview]
Message-ID: <1478883311-24052-6-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1478883311-24052-1-git-send-email-kwolf@redhat.com>
From: Tomáš Golembiovský <tgolembi@redhat.com>
We make sure that the size is aligned to sector length to prevent any
round ups. Otherwise we could end up reading/writing data outside the
area specified by user. This is only needed when user supplies the size
option to avoid any surprises. It is not necessary when only offset is
set.
More over, the check made it difficult to use the offset option without
size option. The check puts unneeded restriction on the offset which had
to be aligned too. Because bdrv_getlength() returns aligned value having
unaligned offset would make the check fail.
Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/raw_bsd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/raw_bsd.c b/block/raw_bsd.c
index cf7a560..8a5b9b0 100644
--- a/block/raw_bsd.c
+++ b/block/raw_bsd.c
@@ -119,7 +119,7 @@ static int raw_read_options(QDict *options, BlockDriverState *bs,
/* Make sure size is multiple of BDRV_SECTOR_SIZE to prevent rounding
* up and leaking out of the specified area. */
- if (!QEMU_IS_ALIGNED(s->size, BDRV_SECTOR_SIZE)) {
+ if (s->has_size && !QEMU_IS_ALIGNED(s->size, BDRV_SECTOR_SIZE)) {
error_setg(errp, "Specified size is not multiple of %llu",
BDRV_SECTOR_SIZE);
ret = -EINVAL;
--
1.8.3.1
next prev parent reply other threads:[~2016-11-11 16:55 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-11 16:54 [Qemu-devel] [PULL 00/12] Block layer patches for 2.8.0-rc0 Kevin Wolf
2016-11-11 16:55 ` [Qemu-devel] [PULL 01/12] block/nbd: Fix the leaked visitor Kevin Wolf
2016-11-11 16:55 ` [Qemu-devel] [PULL 02/12] block/ssh: Code cleanup for unused parameter Kevin Wolf
2016-11-11 16:55 ` [Qemu-devel] [PULL 03/12] hmp: Make block_stream set an explicit job ID Kevin Wolf
2016-11-11 16:55 ` [Qemu-devel] [PULL 04/12] raw_bsd: move check to prevent overflow Kevin Wolf
2016-11-11 16:55 ` Kevin Wolf [this message]
2016-11-11 16:55 ` [Qemu-devel] [PULL 06/12] qcow2: Remove stale FIXME comment Kevin Wolf
2016-11-11 16:55 ` [Qemu-devel] [PULL 07/12] nfs: Fix memory leak in nfs_file_create() Kevin Wolf
2016-11-11 16:55 ` [Qemu-devel] [PULL 08/12] block: Fix bdrv_iterate_format() sorting Kevin Wolf
2016-11-11 16:55 ` [Qemu-devel] [PULL 09/12] block: Emit modules in bdrv_iterate_format() Kevin Wolf
2016-11-11 16:55 ` [Qemu-devel] [PULL 10/12] iotests: Skip test 162 if there is no SSH support Kevin Wolf
2016-11-11 16:55 ` [Qemu-devel] [PULL 11/12] iotests: Always use -machine accel=qtest Kevin Wolf
2016-11-11 16:55 ` [Qemu-devel] [PULL 12/12] raw-posix: Rename 'raw_s' to 'rs' Kevin Wolf
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=1478883311-24052-6-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).