[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/2] virtio-blk: fix length calculations for wri
From: |
Rusty Russell |
Subject: |
Re: [Qemu-devel] [PATCH 2/2] virtio-blk: fix length calculations for write operations. |
Date: |
Wed, 11 Mar 2015 22:04:02 +1030 |
User-agent: |
Notmuch/0.17 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) |
"Michael S. Tsirkin" <address@hidden> writes:
> On Wed, Mar 11, 2015 at 04:29:32PM +1030, Rusty Russell wrote:
>> We only fill in the 'req->qiov.size' bytes on a (successful) read,
>> not on a write.
>>
>> Signed-off-by: Rusty Russell <address@hidden>
>> ---
>> hw/block/virtio-blk.c | 10 +++++++++-
>> 1 file changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
>> index 258bb4c..98d87a9 100644
>> --- a/hw/block/virtio-blk.c
>> +++ b/hw/block/virtio-blk.c
>> @@ -50,11 +50,19 @@ static void virtio_blk_complete_request(VirtIOBlockReq
>> *req,
>> {
>> VirtIOBlock *s = req->dev;
>> VirtIODevice *vdev = VIRTIO_DEVICE(s);
>> + int type = virtio_ldl_p(VIRTIO_DEVICE(req->dev), &req->out.type);
>>
>> trace_virtio_blk_req_complete(req, status);
>>
>> stb_p(&req->in->status, status);
>> - virtqueue_push(s->vq, &req->elem, req->qiov.size + sizeof(*req->in));
>> +
>> + /* If we didn't succeed, we *may* have written more, but don't
>> + * count on it. */
>
> I wonder about this.
> So length as you specify it is <= actually written length.
> What are the advantages of this approach?
> How about we do the reverse, specify that the length in descriptor
> is >= the size actually written?
>
> If we do this, all these buggy hosts suddenly become correct,
> which seems better.
The point of telling the guest the amount written is that they don't
have to zero the receive buffer beforehand.
Cheers,
Rusty.
- [Qemu-devel] [PATCH 0/2] virtio len fixes for qemu., Rusty Russell, 2015/03/11
- [Qemu-devel] [PATCH 1/2] virtio: make it clear that "len" for a used descriptor is len written., Rusty Russell, 2015/03/11
- [Qemu-devel] [PATCH 2/2] virtio-blk: fix length calculations for write operations., Rusty Russell, 2015/03/11
- Re: [Qemu-devel] [PATCH 0/2] virtio len fixes for qemu., Michael S. Tsirkin, 2015/03/11
- Re: [Qemu-devel] [PATCH 0/2] virtio len fixes for qemu., Fam Zheng, 2015/03/11
- Re: [Qemu-devel] [PATCH 0/2] virtio len fixes for qemu., Michael S. Tsirkin, 2015/03/11
- Re: [Qemu-devel] [PATCH 0/2] virtio len fixes for qemu., Rusty Russell, 2015/03/11
- Re: [Qemu-devel] [PATCH 0/2] virtio len fixes for qemu., Michael S. Tsirkin, 2015/03/11
- Re: [Qemu-devel] [PATCH 0/2] virtio len fixes for qemu., Rusty Russell, 2015/03/11
- Re: [Qemu-devel] [PATCH 0/2] virtio len fixes for qemu., Michael S. Tsirkin, 2015/03/12
- Re: [Qemu-devel] [PATCH 0/2] virtio len fixes for qemu., Rusty Russell, 2015/03/12
- Re: [Qemu-devel] [PATCH 0/2] virtio len fixes for qemu., Michael S. Tsirkin, 2015/03/13
- Re: [Qemu-devel] [PATCH 0/2] virtio len fixes for qemu., Rusty Russell, 2015/03/15