summaryrefslogtreecommitdiffstats
path: root/hw/block/dataplane
diff options
context:
space:
mode:
authorFam Zheng2014-06-11 06:11:46 +0200
committerKevin Wolf2014-06-27 18:18:20 +0200
commit04af2d70c58136be57d798ad684e1924dcde93f5 (patch)
tree0acbd8928f7a77488a76c2d33978debe25cc3a38 /hw/block/dataplane
parentvirtio-blk: Drop VirtIOBlockRequest.read (diff)
downloadqemu-04af2d70c58136be57d798ad684e1924dcde93f5.tar.gz
qemu-04af2d70c58136be57d798ad684e1924dcde93f5.tar.xz
qemu-04af2d70c58136be57d798ad684e1924dcde93f5.zip
virtio-blk: Replace VirtIOBlockRequest with VirtIOBlockReq
Field "inhdr" is added temporarily for a more mechanical change, and will be dropped in the next commit. Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/block/dataplane')
-rw-r--r--hw/block/dataplane/virtio-blk.c34
1 files changed, 15 insertions, 19 deletions
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index 4e5e4589bd..70e8c1452b 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -24,13 +24,6 @@
#include "hw/virtio/virtio-bus.h"
#include "qom/object_interfaces.h"
-typedef struct {
- VirtIOBlockDataPlane *s;
- QEMUIOVector *inhdr; /* iovecs for virtio_blk_inhdr */
- VirtQueueElement *elem; /* saved data from the virtqueue */
- QEMUIOVector qiov; /* original request iovecs */
-} VirtIOBlockRequest;
-
struct VirtIOBlockDataPlane {
bool started;
bool starting;
@@ -68,7 +61,7 @@ static void notify_guest(VirtIOBlockDataPlane *s)
static void complete_rdwr(void *opaque, int ret)
{
- VirtIOBlockRequest *req = opaque;
+ VirtIOBlockReq *req = opaque;
struct virtio_blk_inhdr hdr;
int len;
@@ -80,7 +73,8 @@ static void complete_rdwr(void *opaque, int ret)
len = 0;
}
- trace_virtio_blk_data_plane_complete_request(req->s, req->elem->index, ret);
+ trace_virtio_blk_data_plane_complete_request(req->dev->dataplane,
+ req->elem->index, ret);
qemu_iovec_from_buf(req->inhdr, 0, &hdr, sizeof(hdr));
qemu_iovec_destroy(req->inhdr);
@@ -90,9 +84,9 @@ static void complete_rdwr(void *opaque, int ret)
* written to, but for virtio-blk it seems to be the number of bytes
* transferred plus the status bytes.
*/
- vring_push(&req->s->vring, req->elem, len + sizeof(hdr));
- notify_guest(req->s);
- g_slice_free(VirtIOBlockRequest, req);
+ vring_push(&req->dev->dataplane->vring, req->elem, len + sizeof(hdr));
+ notify_guest(req->dev->dataplane);
+ g_slice_free(VirtIOBlockReq, req);
}
static void complete_request_early(VirtIOBlockDataPlane *s, VirtQueueElement *elem,
@@ -128,14 +122,15 @@ static void do_rdwr_cmd(VirtIOBlockDataPlane *s, bool read,
int64_t sector_num, VirtQueueElement *elem,
QEMUIOVector *inhdr)
{
- VirtIOBlockRequest *req = g_slice_new0(VirtIOBlockRequest);
+ VirtIOBlock *dev = VIRTIO_BLK(s->vdev);
+ VirtIOBlockReq *req = g_slice_new0(VirtIOBlockReq);
QEMUIOVector *qiov;
int nb_sectors;
/* Fill in virtio block metadata needed for completion */
- req->s = s;
req->elem = elem;
req->inhdr = inhdr;
+ req->dev = dev;
qemu_iovec_init_external(&req->qiov, iov, iov_cnt);
qiov = &req->qiov;
@@ -153,7 +148,7 @@ static void do_rdwr_cmd(VirtIOBlockDataPlane *s, bool read,
static void complete_flush(void *opaque, int ret)
{
- VirtIOBlockRequest *req = opaque;
+ VirtIOBlockReq *req = opaque;
unsigned char status;
if (ret == 0) {
@@ -162,15 +157,16 @@ static void complete_flush(void *opaque, int ret)
status = VIRTIO_BLK_S_IOERR;
}
- complete_request_early(req->s, req->elem, req->inhdr, status);
- g_slice_free(VirtIOBlockRequest, req);
+ complete_request_early(req->dev->dataplane, req->elem, req->inhdr, status);
+ g_slice_free(VirtIOBlockReq, req);
}
static void do_flush_cmd(VirtIOBlockDataPlane *s, VirtQueueElement *elem,
QEMUIOVector *inhdr)
{
- VirtIOBlockRequest *req = g_slice_new(VirtIOBlockRequest);
- req->s = s;
+ VirtIOBlock *dev = VIRTIO_BLK(s->vdev);
+ VirtIOBlockReq *req = g_slice_new0(VirtIOBlockReq);
+ req->dev = dev;
req->elem = elem;
req->inhdr = inhdr;