From: "Marc Marí" <marc.mari.barcelo@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Marc Marí" <marc.mari.barcelo@gmail.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH v3 6/9] virtio-blk: Correct bug in support for flexible descriptor layout
Date: Fri, 1 Aug 2014 11:34:56 +0200 [thread overview]
Message-ID: <1406885699-4765-7-git-send-email-marc.mari.barcelo@gmail.com> (raw)
In-Reply-To: <1406885699-4765-1-git-send-email-marc.mari.barcelo@gmail.com>
Without this correction, only a three descriptor layout is accepted, and
requests with just two descriptors are not completed and no error message is
displayed.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
---
hw/block/virtio-blk.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index c241c50..302c39e 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -404,19 +404,19 @@ void virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb)
* NB: per existing s/n string convention the string is
* terminated by '\0' only when shorter than buffer.
*/
- strncpy(req->elem.in_sg[0].iov_base,
- s->blk.serial ? s->blk.serial : "",
- MIN(req->elem.in_sg[0].iov_len, VIRTIO_BLK_ID_BYTES));
+ const char *serial = s->blk.serial ? s->blk.serial : "";
+ size_t size = MIN(strlen(serial) + 1,
+ MIN(iov_size(in_iov, in_num),
+ VIRTIO_BLK_ID_BYTES));
+ iov_from_buf(in_iov, in_num, 0, serial, size);
virtio_blk_req_complete(req, VIRTIO_BLK_S_OK);
virtio_blk_free_request(req);
} else if (type & VIRTIO_BLK_T_OUT) {
- qemu_iovec_init_external(&req->qiov, &req->elem.out_sg[1],
- req->elem.out_num - 1);
+ qemu_iovec_init_external(&req->qiov, iov, out_num);
virtio_blk_handle_write(req, mrb);
} else if (type == VIRTIO_BLK_T_IN || type == VIRTIO_BLK_T_BARRIER) {
/* VIRTIO_BLK_T_IN is 0, so we can't just & it. */
- qemu_iovec_init_external(&req->qiov, &req->elem.in_sg[0],
- req->elem.in_num - 1);
+ qemu_iovec_init_external(&req->qiov, in_iov, in_num);
virtio_blk_handle_read(req);
} else {
virtio_blk_req_complete(req, VIRTIO_BLK_S_UNSUPP);
--
1.7.10.4
next prev parent reply other threads:[~2014-08-01 9:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-01 9:34 [Qemu-devel] [PATCH v3 0/9] Virtio PCI libqos driver Marc Marí
2014-08-01 9:34 ` [Qemu-devel] [PATCH v3 1/9] tests: Functions bus_foreach and device_find from libqos virtio API Marc Marí
2014-08-01 9:34 ` [Qemu-devel] [PATCH v3 2/9] tests: Add virtio device initialization Marc Marí
2014-08-01 9:34 ` [Qemu-devel] [PATCH v3 3/9] libqtest: add QTEST_LOG for debugging qtest testcases Marc Marí
2014-08-01 9:34 ` [Qemu-devel] [PATCH v3 4/9] libqos: Correct mask to align size to PAGE_SIZE in malloc-pc Marc Marí
2014-08-01 9:34 ` [Qemu-devel] [PATCH v3 5/9] libqos: Change free function called in malloc Marc Marí
2014-08-01 9:34 ` Marc Marí [this message]
2014-08-01 9:34 ` [Qemu-devel] [PATCH v3 7/9] libqos: Added basic virtqueue support to virtio implementation Marc Marí
2014-08-01 9:34 ` [Qemu-devel] [PATCH v3 8/9] libqos: Added indirect descriptor " Marc Marí
2014-08-01 9:34 ` [Qemu-devel] [PATCH v3 9/9] libqos: Added test case for configuration changes in virtio-blk test Marc Marí
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=1406885699-4765-7-git-send-email-marc.mari.barcelo@gmail.com \
--to=marc.mari.barcelo@gmail.com \
--cc=pbonzini@redhat.com \
--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).