From: Manos Pitsidianakis <el13635@mail.ntua.gr>
To: qemu-devel <qemu-devel@nongnu.org>
Cc: qemu-block <qemu-block@nongnu.org>, Kevin Wolf <kwolf@redhat.com>,
Max Reitz <mreitz@redhat.com>, John Snow <jsnow@redhat.com>
Subject: [Qemu-devel] [PATCH 1/2] block/block-backend.c: add blk_check_byte_request call to blk_pread/blk_pwrite
Date: Wed, 20 Sep 2017 14:43:09 +0300 [thread overview]
Message-ID: <20170920114310.13080-2-el13635@mail.ntua.gr> (raw)
In-Reply-To: <20170920114310.13080-1-el13635@mail.ntua.gr>
blk_check_byte_request() is called from the blk_co_pwritev/blk_co_preadv to
check if the request offset and request bytes parameters are valid for the
given Blockbackend. Let's do that in blk_pread/blk_pwrite too.
Signed-off-by: Manos Pitsidianakis <el13635@mail.ntua.gr>
---
block/block-backend.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/block/block-backend.c b/block/block-backend.c
index 45d9101be3..110a52d5b1 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -1288,22 +1288,23 @@ BlockAIOCB *blk_aio_pwrite_zeroes(BlockBackend *blk, int64_t offset,
int blk_pread(BlockBackend *blk, int64_t offset, void *buf, int count)
{
- int ret = blk_prw(blk, offset, buf, count, blk_read_entry, 0);
+ int ret = blk_check_byte_request(blk, offset, count);
if (ret < 0) {
return ret;
}
- return count;
+ ret = blk_prw(blk, offset, buf, count, blk_read_entry, 0);
+ return ret < 0 ? ret : count;
}
int blk_pwrite(BlockBackend *blk, int64_t offset, const void *buf, int count,
BdrvRequestFlags flags)
{
- int ret = blk_prw(blk, offset, (void *) buf, count, blk_write_entry,
- flags);
+ int ret = blk_check_byte_request(blk, offset, count);
if (ret < 0) {
return ret;
}
- return count;
+ ret = blk_prw(blk, offset, (void *) buf, count, blk_write_entry, flags);
+ return ret < 0 ? ret : count;
}
int64_t blk_getlength(BlockBackend *blk)
--
2.11.0
next prev parent reply other threads:[~2017-09-20 13:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-20 11:43 [Qemu-devel] [PATCH 0/2] remove blk_pread_unthrottled() Manos Pitsidianakis
2017-09-20 11:43 ` Manos Pitsidianakis [this message]
2017-09-20 12:24 ` [Qemu-devel] [PATCH 1/2] block/block-backend.c: add blk_check_byte_request call to blk_pread/blk_pwrite Kevin Wolf
2017-09-20 14:35 ` Manos Pitsidianakis
2017-09-20 11:43 ` [Qemu-devel] [PATCH 2/2] block/block-backend.c: remove blk_pread_unthrottled() Manos Pitsidianakis
2017-09-20 12:37 ` Kevin Wolf
2017-09-20 20:10 ` John Snow
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=20170920114310.13080-2-el13635@mail.ntua.gr \
--to=el13635@mail.ntua.gr \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.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).