summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2016-06-21 13:13:13 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2016-06-28 13:08:32 +0100
commitedaffd9f0baa32c9524ac8bc80370a7257aa322e (patch)
treeed557dbe105c2383b52b92fe46ea8a1f015cd4ce /hw
parentb234cdda958b329dbbec840702c65432f4907623 (diff)
virtio-blk: associate request with a virtqueue
Multiqueue requires that each request knows to which virtqueue it belongs. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Message-id: 1466511196-12612-5-git-send-email-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/block/virtio-blk.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index bcce3df22d..3c6a1fa4dd 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -29,9 +29,11 @@
#include "hw/virtio/virtio-bus.h"
#include "hw/virtio/virtio-access.h"
-void virtio_blk_init_request(VirtIOBlock *s, VirtIOBlockReq *req)
+void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq,
+ VirtIOBlockReq *req)
{
req->dev = s;
+ req->vq = vq;
req->qiov.size = 0;
req->in_len = 0;
req->next = NULL;
@@ -53,11 +55,11 @@ static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status)
trace_virtio_blk_req_complete(req, status);
stb_p(&req->in->status, status);
- virtqueue_push(s->vq, &req->elem, req->in_len);
+ virtqueue_push(req->vq, &req->elem, req->in_len);
if (s->dataplane_started && !s->dataplane_disabled) {
- virtio_blk_data_plane_notify(s->dataplane, s->vq);
+ virtio_blk_data_plane_notify(s->dataplane, req->vq);
} else {
- virtio_notify(vdev, s->vq);
+ virtio_notify(vdev, req->vq);
}
}
@@ -187,12 +189,12 @@ out:
#endif
-static VirtIOBlockReq *virtio_blk_get_request(VirtIOBlock *s)
+static VirtIOBlockReq *virtio_blk_get_request(VirtIOBlock *s, VirtQueue *vq)
{
- VirtIOBlockReq *req = virtqueue_pop(s->vq, sizeof(VirtIOBlockReq));
+ VirtIOBlockReq *req = virtqueue_pop(vq, sizeof(VirtIOBlockReq));
if (req) {
- virtio_blk_init_request(s, req);
+ virtio_blk_init_request(s, vq, req);
}
return req;
}
@@ -583,7 +585,7 @@ void virtio_blk_handle_vq(VirtIOBlock *s, VirtQueue *vq)
blk_io_plug(s->blk);
- while ((req = virtio_blk_get_request(s))) {
+ while ((req = virtio_blk_get_request(s, vq))) {
virtio_blk_handle_request(req, &mrb);
}
@@ -831,7 +833,7 @@ static int virtio_blk_load_device(VirtIODevice *vdev, QEMUFile *f,
while (qemu_get_sbyte(f)) {
VirtIOBlockReq *req;
req = qemu_get_virtqueue_element(f, sizeof(VirtIOBlockReq));
- virtio_blk_init_request(s, req);
+ virtio_blk_init_request(s, s->vq, req);
req->next = s->rq;
s->rq = req;
}