* [Qemu-devel] [PATCH 1/3] virtio-blk: Factor common checks out of virtio_blk_handle_read/write()
2014-06-05 12:15 [Qemu-devel] [PATCH 0/3] virtio-blk: Suppress error action on r/w beyond end Markus Armbruster
@ 2014-06-05 12:15 ` Markus Armbruster
2014-06-06 3:14 ` Fam Zheng
2014-06-05 12:15 ` [Qemu-devel] [PATCH 2/3] virtio-blk: Bypass error action and I/O accounting on invalid r/w Markus Armbruster
` (5 subsequent siblings)
6 siblings, 1 reply; 18+ messages in thread
From: Markus Armbruster @ 2014-06-05 12:15 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, uobergfe, stefanha
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
hw/block/virtio-blk.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 8a568e5..f2b4dca 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -281,6 +281,18 @@ static void virtio_blk_handle_flush(VirtIOBlockReq *req, MultiReqBuffer *mrb)
bdrv_aio_flush(req->dev->bs, virtio_blk_flush_complete, req);
}
+static bool virtio_blk_sect_range_ok(VirtIOBlock *dev,
+ uint64_t sector, size_t size)
+{
+ if (sector & dev->sector_mask) {
+ return false;
+ }
+ if (size % dev->conf->logical_block_size) {
+ return false;
+ }
+ return true;
+}
+
static void virtio_blk_handle_write(VirtIOBlockReq *req, MultiReqBuffer *mrb)
{
BlockRequest *blkreq;
@@ -292,11 +304,7 @@ static void virtio_blk_handle_write(VirtIOBlockReq *req, MultiReqBuffer *mrb)
trace_virtio_blk_handle_write(req, sector, req->qiov.size / 512);
- if (sector & req->dev->sector_mask) {
- virtio_blk_rw_complete(req, -EIO);
- return;
- }
- if (req->qiov.size % req->dev->conf->logical_block_size) {
+ if (!virtio_blk_sect_range_ok(req->dev, sector, req->qiov.size)) {
virtio_blk_rw_complete(req, -EIO);
return;
}
@@ -326,11 +334,7 @@ static void virtio_blk_handle_read(VirtIOBlockReq *req)
trace_virtio_blk_handle_read(req, sector, req->qiov.size / 512);
- if (sector & req->dev->sector_mask) {
- virtio_blk_rw_complete(req, -EIO);
- return;
- }
- if (req->qiov.size % req->dev->conf->logical_block_size) {
+ if (!virtio_blk_sect_range_ok(req->dev, sector, req->qiov.size)) {
virtio_blk_rw_complete(req, -EIO);
return;
}
--
1.9.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] virtio-blk: Factor common checks out of virtio_blk_handle_read/write()
2014-06-05 12:15 ` [Qemu-devel] [PATCH 1/3] virtio-blk: Factor common checks out of virtio_blk_handle_read/write() Markus Armbruster
@ 2014-06-06 3:14 ` Fam Zheng
0 siblings, 0 replies; 18+ messages in thread
From: Fam Zheng @ 2014-06-06 3:14 UTC (permalink / raw)
To: Markus Armbruster; +Cc: kwolf, qemu-devel, stefanha, uobergfe
On Thu, 06/05 14:15, Markus Armbruster wrote:
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
> hw/block/virtio-blk.c | 24 ++++++++++++++----------
> 1 file changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> index 8a568e5..f2b4dca 100644
> --- a/hw/block/virtio-blk.c
> +++ b/hw/block/virtio-blk.c
> @@ -281,6 +281,18 @@ static void virtio_blk_handle_flush(VirtIOBlockReq *req, MultiReqBuffer *mrb)
> bdrv_aio_flush(req->dev->bs, virtio_blk_flush_complete, req);
> }
>
> +static bool virtio_blk_sect_range_ok(VirtIOBlock *dev,
> + uint64_t sector, size_t size)
> +{
> + if (sector & dev->sector_mask) {
> + return false;
> + }
> + if (size % dev->conf->logical_block_size) {
> + return false;
> + }
> + return true;
> +}
> +
> static void virtio_blk_handle_write(VirtIOBlockReq *req, MultiReqBuffer *mrb)
> {
> BlockRequest *blkreq;
> @@ -292,11 +304,7 @@ static void virtio_blk_handle_write(VirtIOBlockReq *req, MultiReqBuffer *mrb)
>
> trace_virtio_blk_handle_write(req, sector, req->qiov.size / 512);
>
> - if (sector & req->dev->sector_mask) {
> - virtio_blk_rw_complete(req, -EIO);
> - return;
> - }
> - if (req->qiov.size % req->dev->conf->logical_block_size) {
> + if (!virtio_blk_sect_range_ok(req->dev, sector, req->qiov.size)) {
> virtio_blk_rw_complete(req, -EIO);
> return;
> }
> @@ -326,11 +334,7 @@ static void virtio_blk_handle_read(VirtIOBlockReq *req)
>
> trace_virtio_blk_handle_read(req, sector, req->qiov.size / 512);
>
> - if (sector & req->dev->sector_mask) {
> - virtio_blk_rw_complete(req, -EIO);
> - return;
> - }
> - if (req->qiov.size % req->dev->conf->logical_block_size) {
> + if (!virtio_blk_sect_range_ok(req->dev, sector, req->qiov.size)) {
> virtio_blk_rw_complete(req, -EIO);
> return;
> }
> --
> 1.9.3
>
>
Reviewed-by: Fam Zheng <famz@redhat.com>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Qemu-devel] [PATCH 2/3] virtio-blk: Bypass error action and I/O accounting on invalid r/w
2014-06-05 12:15 [Qemu-devel] [PATCH 0/3] virtio-blk: Suppress error action on r/w beyond end Markus Armbruster
2014-06-05 12:15 ` [Qemu-devel] [PATCH 1/3] virtio-blk: Factor common checks out of virtio_blk_handle_read/write() Markus Armbruster
@ 2014-06-05 12:15 ` Markus Armbruster
2014-06-06 3:18 ` Fam Zheng
2014-06-05 12:15 ` [Qemu-devel] [PATCH 3/3] virtio-blk: Treat read/write beyond end as invalid Markus Armbruster
` (4 subsequent siblings)
6 siblings, 1 reply; 18+ messages in thread
From: Markus Armbruster @ 2014-06-05 12:15 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, uobergfe, stefanha
When a device model's I/O operation fails, we execute the error
action. This lets layers above QEMU implement thin provisioning, or
attempt to correct errors before they reach the guest. But when the
I/O operation fails because its invalid, reporting the error to the
guest is the only sensible action.
If the guest's read or write asks for an invalid sector range, fail
the request right away, without considering the error action. No
change with error action BDRV_ACTION_REPORT.
Furthermore, bypass I/O accounting, because we want to track only I/O
that actually reaches the block layer.
The next commit will extend "invalid sector range" to cover attempts
to read/write beyond the end of the medium.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
hw/block/virtio-blk.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index f2b4dca..2c68d0d 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -300,15 +300,16 @@ static void virtio_blk_handle_write(VirtIOBlockReq *req, MultiReqBuffer *mrb)
sector = ldq_p(&req->out->sector);
- bdrv_acct_start(req->dev->bs, &req->acct, req->qiov.size, BDRV_ACCT_WRITE);
-
trace_virtio_blk_handle_write(req, sector, req->qiov.size / 512);
if (!virtio_blk_sect_range_ok(req->dev, sector, req->qiov.size)) {
- virtio_blk_rw_complete(req, -EIO);
+ virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR);
+ g_free(req);
return;
}
+ bdrv_acct_start(req->dev->bs, &req->acct, req->qiov.size, BDRV_ACCT_WRITE);
+
if (mrb->num_writes == 32) {
virtio_submit_multiwrite(req->dev->bs, mrb);
}
@@ -330,14 +331,15 @@ static void virtio_blk_handle_read(VirtIOBlockReq *req)
sector = ldq_p(&req->out->sector);
- bdrv_acct_start(req->dev->bs, &req->acct, req->qiov.size, BDRV_ACCT_READ);
-
trace_virtio_blk_handle_read(req, sector, req->qiov.size / 512);
if (!virtio_blk_sect_range_ok(req->dev, sector, req->qiov.size)) {
- virtio_blk_rw_complete(req, -EIO);
+ virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR);
+ g_free(req);
return;
}
+
+ bdrv_acct_start(req->dev->bs, &req->acct, req->qiov.size, BDRV_ACCT_READ);
bdrv_aio_readv(req->dev->bs, sector, &req->qiov,
req->qiov.size / BDRV_SECTOR_SIZE,
virtio_blk_rw_complete, req);
--
1.9.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 2/3] virtio-blk: Bypass error action and I/O accounting on invalid r/w
2014-06-05 12:15 ` [Qemu-devel] [PATCH 2/3] virtio-blk: Bypass error action and I/O accounting on invalid r/w Markus Armbruster
@ 2014-06-06 3:18 ` Fam Zheng
2014-06-06 3:22 ` Eric Blake
2014-06-06 6:01 ` Markus Armbruster
0 siblings, 2 replies; 18+ messages in thread
From: Fam Zheng @ 2014-06-06 3:18 UTC (permalink / raw)
To: Markus Armbruster; +Cc: kwolf, qemu-devel, stefanha, uobergfe
On Thu, 06/05 14:15, Markus Armbruster wrote:
> When a device model's I/O operation fails, we execute the error
> action. This lets layers above QEMU implement thin provisioning, or
> attempt to correct errors before they reach the guest. But when the
> I/O operation fails because its invalid, reporting the error to the
s/its/it's/ ?
Anyway,
Reviewed-by: Fam Zheng <famz@redhat.com>
> guest is the only sensible action.
>
> If the guest's read or write asks for an invalid sector range, fail
> the request right away, without considering the error action. No
> change with error action BDRV_ACTION_REPORT.
>
> Furthermore, bypass I/O accounting, because we want to track only I/O
> that actually reaches the block layer.
>
> The next commit will extend "invalid sector range" to cover attempts
> to read/write beyond the end of the medium.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
> hw/block/virtio-blk.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> index f2b4dca..2c68d0d 100644
> --- a/hw/block/virtio-blk.c
> +++ b/hw/block/virtio-blk.c
> @@ -300,15 +300,16 @@ static void virtio_blk_handle_write(VirtIOBlockReq *req, MultiReqBuffer *mrb)
>
> sector = ldq_p(&req->out->sector);
>
> - bdrv_acct_start(req->dev->bs, &req->acct, req->qiov.size, BDRV_ACCT_WRITE);
> -
> trace_virtio_blk_handle_write(req, sector, req->qiov.size / 512);
>
> if (!virtio_blk_sect_range_ok(req->dev, sector, req->qiov.size)) {
> - virtio_blk_rw_complete(req, -EIO);
> + virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR);
> + g_free(req);
> return;
> }
>
> + bdrv_acct_start(req->dev->bs, &req->acct, req->qiov.size, BDRV_ACCT_WRITE);
> +
> if (mrb->num_writes == 32) {
> virtio_submit_multiwrite(req->dev->bs, mrb);
> }
> @@ -330,14 +331,15 @@ static void virtio_blk_handle_read(VirtIOBlockReq *req)
>
> sector = ldq_p(&req->out->sector);
>
> - bdrv_acct_start(req->dev->bs, &req->acct, req->qiov.size, BDRV_ACCT_READ);
> -
> trace_virtio_blk_handle_read(req, sector, req->qiov.size / 512);
>
> if (!virtio_blk_sect_range_ok(req->dev, sector, req->qiov.size)) {
> - virtio_blk_rw_complete(req, -EIO);
> + virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR);
> + g_free(req);
> return;
> }
> +
> + bdrv_acct_start(req->dev->bs, &req->acct, req->qiov.size, BDRV_ACCT_READ);
> bdrv_aio_readv(req->dev->bs, sector, &req->qiov,
> req->qiov.size / BDRV_SECTOR_SIZE,
> virtio_blk_rw_complete, req);
> --
> 1.9.3
>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 2/3] virtio-blk: Bypass error action and I/O accounting on invalid r/w
2014-06-06 3:18 ` Fam Zheng
@ 2014-06-06 3:22 ` Eric Blake
2014-06-06 6:01 ` Markus Armbruster
1 sibling, 0 replies; 18+ messages in thread
From: Eric Blake @ 2014-06-06 3:22 UTC (permalink / raw)
To: Fam Zheng, Markus Armbruster; +Cc: kwolf, qemu-devel, stefanha, uobergfe
[-- Attachment #1: Type: text/plain, Size: 578 bytes --]
On 06/05/2014 09:18 PM, Fam Zheng wrote:
> On Thu, 06/05 14:15, Markus Armbruster wrote:
>> When a device model's I/O operation fails, we execute the error
>> action. This lets layers above QEMU implement thin provisioning, or
>> attempt to correct errors before they reach the guest. But when the
>> I/O operation fails because its invalid, reporting the error to the
>
> s/its/it's/ ?
Yes, this is a case where you are contracting "it is" into "it's"
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 2/3] virtio-blk: Bypass error action and I/O accounting on invalid r/w
2014-06-06 3:18 ` Fam Zheng
2014-06-06 3:22 ` Eric Blake
@ 2014-06-06 6:01 ` Markus Armbruster
1 sibling, 0 replies; 18+ messages in thread
From: Markus Armbruster @ 2014-06-06 6:01 UTC (permalink / raw)
To: Fam Zheng; +Cc: kwolf, qemu-devel, stefanha, uobergfe
Fam Zheng <famz@redhat.com> writes:
> On Thu, 06/05 14:15, Markus Armbruster wrote:
>> When a device model's I/O operation fails, we execute the error
>> action. This lets layers above QEMU implement thin provisioning, or
>> attempt to correct errors before they reach the guest. But when the
>> I/O operation fails because its invalid, reporting the error to the
>
> s/its/it's/ ?
Of course. Perhaps it can be fixed on commit.
> Anyway,
>
> Reviewed-by: Fam Zheng <famz@redhat.com>
Thanks!
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Qemu-devel] [PATCH 3/3] virtio-blk: Treat read/write beyond end as invalid
2014-06-05 12:15 [Qemu-devel] [PATCH 0/3] virtio-blk: Suppress error action on r/w beyond end Markus Armbruster
2014-06-05 12:15 ` [Qemu-devel] [PATCH 1/3] virtio-blk: Factor common checks out of virtio_blk_handle_read/write() Markus Armbruster
2014-06-05 12:15 ` [Qemu-devel] [PATCH 2/3] virtio-blk: Bypass error action and I/O accounting on invalid r/w Markus Armbruster
@ 2014-06-05 12:15 ` Markus Armbruster
2014-06-06 3:21 ` Fam Zheng
2014-06-20 4:16 ` Stefan Hajnoczi
2014-06-06 7:36 ` [Qemu-devel] [PATCH 0/3] virtio-blk: Suppress error action on r/w beyond end Paolo Bonzini
` (3 subsequent siblings)
6 siblings, 2 replies; 18+ messages in thread
From: Markus Armbruster @ 2014-06-05 12:15 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, uobergfe, stefanha
The block layer fails such reads and writes just fine. However, they
then get treated like valid operations that fail: the error action
gets executed. Unwanted; reporting the error to the guest is the only
sensible action.
Reject them before passing them to the block layer. This bypasses the
error action and I/O accounting.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
hw/block/virtio-blk.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 2c68d0d..0b38049 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -284,12 +284,19 @@ static void virtio_blk_handle_flush(VirtIOBlockReq *req, MultiReqBuffer *mrb)
static bool virtio_blk_sect_range_ok(VirtIOBlock *dev,
uint64_t sector, size_t size)
{
+ uint64_t nb_sectors = size >> BDRV_SECTOR_BITS;
+ uint64_t total_sectors;
+
if (sector & dev->sector_mask) {
return false;
}
if (size % dev->conf->logical_block_size) {
return false;
}
+ bdrv_get_geometry(dev->bs, &total_sectors);
+ if (sector > total_sectors || nb_sectors > total_sectors - sector) {
+ return false;
+ }
return true;
}
--
1.9.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] virtio-blk: Treat read/write beyond end as invalid
2014-06-05 12:15 ` [Qemu-devel] [PATCH 3/3] virtio-blk: Treat read/write beyond end as invalid Markus Armbruster
@ 2014-06-06 3:21 ` Fam Zheng
2014-06-20 4:16 ` Stefan Hajnoczi
1 sibling, 0 replies; 18+ messages in thread
From: Fam Zheng @ 2014-06-06 3:21 UTC (permalink / raw)
To: Markus Armbruster; +Cc: kwolf, qemu-devel, stefanha, uobergfe
On Thu, 06/05 14:15, Markus Armbruster wrote:
> The block layer fails such reads and writes just fine. However, they
> then get treated like valid operations that fail: the error action
> gets executed. Unwanted; reporting the error to the guest is the only
> sensible action.
>
> Reject them before passing them to the block layer. This bypasses the
> error action and I/O accounting.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
> hw/block/virtio-blk.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> index 2c68d0d..0b38049 100644
> --- a/hw/block/virtio-blk.c
> +++ b/hw/block/virtio-blk.c
> @@ -284,12 +284,19 @@ static void virtio_blk_handle_flush(VirtIOBlockReq *req, MultiReqBuffer *mrb)
> static bool virtio_blk_sect_range_ok(VirtIOBlock *dev,
> uint64_t sector, size_t size)
> {
> + uint64_t nb_sectors = size >> BDRV_SECTOR_BITS;
> + uint64_t total_sectors;
> +
> if (sector & dev->sector_mask) {
> return false;
> }
> if (size % dev->conf->logical_block_size) {
> return false;
> }
> + bdrv_get_geometry(dev->bs, &total_sectors);
> + if (sector > total_sectors || nb_sectors > total_sectors - sector) {
> + return false;
> + }
> return true;
> }
>
> --
> 1.9.3
>
>
Reviewed-by: Fam Zheng <famz@redhat.com>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] virtio-blk: Treat read/write beyond end as invalid
2014-06-05 12:15 ` [Qemu-devel] [PATCH 3/3] virtio-blk: Treat read/write beyond end as invalid Markus Armbruster
2014-06-06 3:21 ` Fam Zheng
@ 2014-06-20 4:16 ` Stefan Hajnoczi
2014-06-23 8:47 ` Markus Armbruster
1 sibling, 1 reply; 18+ messages in thread
From: Stefan Hajnoczi @ 2014-06-20 4:16 UTC (permalink / raw)
To: Markus Armbruster; +Cc: kwolf, qemu-devel, uobergfe
[-- Attachment #1: Type: text/plain, Size: 216 bytes --]
On Thu, Jun 05, 2014 at 02:15:36PM +0200, Markus Armbruster wrote:
> + if (sector > total_sectors || nb_sectors > total_sectors - sector) {
> + return false;
> + }
if (sector >= total_sectors || ...) {
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] virtio-blk: Treat read/write beyond end as invalid
2014-06-20 4:16 ` Stefan Hajnoczi
@ 2014-06-23 8:47 ` Markus Armbruster
2014-06-23 12:57 ` Markus Armbruster
0 siblings, 1 reply; 18+ messages in thread
From: Markus Armbruster @ 2014-06-23 8:47 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: kwolf, qemu-devel, uobergfe
Stefan Hajnoczi <stefanha@redhat.com> writes:
> On Thu, Jun 05, 2014 at 02:15:36PM +0200, Markus Armbruster wrote:
>> + if (sector > total_sectors || nb_sectors > total_sectors - sector) {
>> + return false;
>> + }
>
> if (sector >= total_sectors || ...) {
I suspect reading bdrv_check_byte_request() put the '>' in my brain:
if ((offset > len) || (len - offset < size))
return -EIO;
Don't we need offset >= len here?
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] virtio-blk: Treat read/write beyond end as invalid
2014-06-23 8:47 ` Markus Armbruster
@ 2014-06-23 12:57 ` Markus Armbruster
2014-06-27 9:56 ` Stefan Hajnoczi
0 siblings, 1 reply; 18+ messages in thread
From: Markus Armbruster @ 2014-06-23 12:57 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: kwolf, qemu-devel, uobergfe
Markus Armbruster <armbru@redhat.com> writes:
> Stefan Hajnoczi <stefanha@redhat.com> writes:
>
>> On Thu, Jun 05, 2014 at 02:15:36PM +0200, Markus Armbruster wrote:
>>> + if (sector > total_sectors || nb_sectors > total_sectors - sector) {
>>> + return false;
>>> + }
>>
>> if (sector >= total_sectors || ...) {
>
> I suspect reading bdrv_check_byte_request() put the '>' in my brain:
>
> if ((offset > len) || (len - offset < size))
> return -EIO;
>
> Don't we need offset >= len here?
Just remembered: we don't, because we allow I/O at offset len provided
size is zero.
Same reasoning applies to my patch.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] virtio-blk: Treat read/write beyond end as invalid
2014-06-23 12:57 ` Markus Armbruster
@ 2014-06-27 9:56 ` Stefan Hajnoczi
0 siblings, 0 replies; 18+ messages in thread
From: Stefan Hajnoczi @ 2014-06-27 9:56 UTC (permalink / raw)
To: Markus Armbruster; +Cc: kwolf, qemu-devel, uobergfe
[-- Attachment #1: Type: text/plain, Size: 840 bytes --]
On Mon, Jun 23, 2014 at 02:57:36PM +0200, Markus Armbruster wrote:
> Markus Armbruster <armbru@redhat.com> writes:
>
> > Stefan Hajnoczi <stefanha@redhat.com> writes:
> >
> >> On Thu, Jun 05, 2014 at 02:15:36PM +0200, Markus Armbruster wrote:
> >>> + if (sector > total_sectors || nb_sectors > total_sectors - sector) {
> >>> + return false;
> >>> + }
> >>
> >> if (sector >= total_sectors || ...) {
> >
> > I suspect reading bdrv_check_byte_request() put the '>' in my brain:
> >
> > if ((offset > len) || (len - offset < size))
> > return -EIO;
> >
> > Don't we need offset >= len here?
>
> Just remembered: we don't, because we allow I/O at offset len provided
> size is zero.
>
> Same reasoning applies to my patch.
Okay. I didn't remember the offset=eof length=0 thing.
Stefan
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 0/3] virtio-blk: Suppress error action on r/w beyond end
2014-06-05 12:15 [Qemu-devel] [PATCH 0/3] virtio-blk: Suppress error action on r/w beyond end Markus Armbruster
` (2 preceding siblings ...)
2014-06-05 12:15 ` [Qemu-devel] [PATCH 3/3] virtio-blk: Treat read/write beyond end as invalid Markus Armbruster
@ 2014-06-06 7:36 ` Paolo Bonzini
2014-06-06 8:24 ` Markus Armbruster
2014-06-26 11:26 ` Markus Armbruster
` (2 subsequent siblings)
6 siblings, 1 reply; 18+ messages in thread
From: Paolo Bonzini @ 2014-06-06 7:36 UTC (permalink / raw)
To: Markus Armbruster, qemu-devel; +Cc: kwolf, uobergfe, stefanha
Il 05/06/2014 14:15, Markus Armbruster ha scritto:
> When a device model's I/O operation fails, we execute the error
> action. This lets layers above QEMU implement thin provisioning, or
> attempt to correct errors before they reach the guest. But when the
> I/O operation fails because its invalid, reporting the error to the
> guest is the only sensible action.
>
> This short series does exactly that for virtio-blk. I intend to do
> the same for IDE and SCSI.
Actually SCSI already does it (see check_lba_range in
hw/scsi/scsi-disk.c). Thanks for thinking about it though!
Paolo
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 0/3] virtio-blk: Suppress error action on r/w beyond end
2014-06-06 7:36 ` [Qemu-devel] [PATCH 0/3] virtio-blk: Suppress error action on r/w beyond end Paolo Bonzini
@ 2014-06-06 8:24 ` Markus Armbruster
0 siblings, 0 replies; 18+ messages in thread
From: Markus Armbruster @ 2014-06-06 8:24 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: kwolf, qemu-devel, stefanha, uobergfe
Paolo Bonzini <pbonzini@redhat.com> writes:
> Il 05/06/2014 14:15, Markus Armbruster ha scritto:
>> When a device model's I/O operation fails, we execute the error
>> action. This lets layers above QEMU implement thin provisioning, or
>> attempt to correct errors before they reach the guest. But when the
>> I/O operation fails because its invalid, reporting the error to the
>> guest is the only sensible action.
>>
>> This short series does exactly that for virtio-blk. I intend to do
>> the same for IDE and SCSI.
>
> Actually SCSI already does it (see check_lba_range in
> hw/scsi/scsi-disk.c). Thanks for thinking about it though!
Your hint saved me some digging. Thanks!
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 0/3] virtio-blk: Suppress error action on r/w beyond end
2014-06-05 12:15 [Qemu-devel] [PATCH 0/3] virtio-blk: Suppress error action on r/w beyond end Markus Armbruster
` (3 preceding siblings ...)
2014-06-06 7:36 ` [Qemu-devel] [PATCH 0/3] virtio-blk: Suppress error action on r/w beyond end Paolo Bonzini
@ 2014-06-26 11:26 ` Markus Armbruster
2014-06-27 9:56 ` Stefan Hajnoczi
2014-07-01 8:57 ` Markus Armbruster
6 siblings, 0 replies; 18+ messages in thread
From: Markus Armbruster @ 2014-06-26 11:26 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, uobergfe, stefanha
Ping?
Markus Armbruster <armbru@redhat.com> writes:
> When a device model's I/O operation fails, we execute the error
> action. This lets layers above QEMU implement thin provisioning, or
> attempt to correct errors before they reach the guest. But when the
> I/O operation fails because its invalid, reporting the error to the
> guest is the only sensible action.
>
> This short series does exactly that for virtio-blk. I intend to do
> the same for IDE and SCSI.
>
> Markus Armbruster (3):
> virtio-blk: Factor common checks out of virtio_blk_handle_read/write()
> virtio-blk: Bypass error action and I/O accounting on invalid r/w
> virtio-blk: Treat read/write beyond end as invalid
>
> hw/block/virtio-blk.c | 45 +++++++++++++++++++++++++++++----------------
> 1 file changed, 29 insertions(+), 16 deletions(-)
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 0/3] virtio-blk: Suppress error action on r/w beyond end
2014-06-05 12:15 [Qemu-devel] [PATCH 0/3] virtio-blk: Suppress error action on r/w beyond end Markus Armbruster
` (4 preceding siblings ...)
2014-06-26 11:26 ` Markus Armbruster
@ 2014-06-27 9:56 ` Stefan Hajnoczi
2014-07-01 8:57 ` Markus Armbruster
6 siblings, 0 replies; 18+ messages in thread
From: Stefan Hajnoczi @ 2014-06-27 9:56 UTC (permalink / raw)
To: Markus Armbruster; +Cc: kwolf, qemu-devel, uobergfe
[-- Attachment #1: Type: text/plain, Size: 939 bytes --]
On Thu, Jun 05, 2014 at 02:15:33PM +0200, Markus Armbruster wrote:
> When a device model's I/O operation fails, we execute the error
> action. This lets layers above QEMU implement thin provisioning, or
> attempt to correct errors before they reach the guest. But when the
> I/O operation fails because its invalid, reporting the error to the
> guest is the only sensible action.
>
> This short series does exactly that for virtio-blk. I intend to do
> the same for IDE and SCSI.
>
> Markus Armbruster (3):
> virtio-blk: Factor common checks out of virtio_blk_handle_read/write()
> virtio-blk: Bypass error action and I/O accounting on invalid r/w
> virtio-blk: Treat read/write beyond end as invalid
>
> hw/block/virtio-blk.c | 45 +++++++++++++++++++++++++++++----------------
> 1 file changed, 29 insertions(+), 16 deletions(-)
>
> --
> 1.9.3
>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 0/3] virtio-blk: Suppress error action on r/w beyond end
2014-06-05 12:15 [Qemu-devel] [PATCH 0/3] virtio-blk: Suppress error action on r/w beyond end Markus Armbruster
` (5 preceding siblings ...)
2014-06-27 9:56 ` Stefan Hajnoczi
@ 2014-07-01 8:57 ` Markus Armbruster
6 siblings, 0 replies; 18+ messages in thread
From: Markus Armbruster @ 2014-07-01 8:57 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, uobergfe, stefanha
Please consider for 2.1. It needs git-am -3 by now; if you need a
respin, let me know.
Markus Armbruster <armbru@redhat.com> writes:
> When a device model's I/O operation fails, we execute the error
> action. This lets layers above QEMU implement thin provisioning, or
> attempt to correct errors before they reach the guest. But when the
> I/O operation fails because its invalid, reporting the error to the
> guest is the only sensible action.
>
> This short series does exactly that for virtio-blk. I intend to do
> the same for IDE and SCSI.
>
> Markus Armbruster (3):
> virtio-blk: Factor common checks out of virtio_blk_handle_read/write()
> virtio-blk: Bypass error action and I/O accounting on invalid r/w
> virtio-blk: Treat read/write beyond end as invalid
>
> hw/block/virtio-blk.c | 45 +++++++++++++++++++++++++++++----------------
> 1 file changed, 29 insertions(+), 16 deletions(-)
^ permalink raw reply [flat|nested] 18+ messages in thread