From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [RFC PATCH 7/9] scsi: push qiov to SCSIRequest
Date: Mon, 6 Jun 2011 18:26:58 +0200 [thread overview]
Message-ID: <1307377620-7538-8-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1307377620-7538-1-git-send-email-pbonzini@redhat.com>
The simplest place to put an QEMUIOVec for the HBA is the SCSIRequest.
So, push the SCSIDisk's qiov member up and make it visible to the targets.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/scsi-bus.c | 4 +++-
hw/scsi-disk.c | 19 +++++++++----------
hw/scsi.h | 1 +
3 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index ad6a730..3b545ed 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -148,7 +148,9 @@ SCSIRequest *scsi_req_alloc(size_t size, SCSIDevice *d, uint32_t tag, uint32_t l
SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, uint32_t lun)
{
- return d->info->alloc_req(d, tag, lun);
+ SCSIRequest *req = d->info->alloc_req(d, tag, lun);
+ qemu_iovec_reset(&req->qiov);
+ return req;
}
uint8_t *scsi_req_get_buf(SCSIRequest *req)
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index bc6003c..4f5ba1c 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -56,7 +56,6 @@ typedef struct SCSIDiskReq {
uint32_t sector_count;
uint32_t buflen;
struct iovec iov;
- QEMUIOVector qiov;
uint32_t status;
} SCSIDiskReq;
@@ -145,8 +144,8 @@ static uint32_t scsi_init_iovec(SCSIDiskReq *r)
r->iov.iov_base = qemu_blockalign(s->bs, r->buflen);
}
r->iov.iov_len = MIN(r->sector_count * 512, r->buflen);
- qemu_iovec_init_external(&r->qiov, &r->iov, 1);
- return r->qiov.size / 512;
+ qemu_iovec_init_external(&r->req.qiov, &r->iov, 1);
+ return r->req.qiov.size / 512;
}
static void scsi_read_complete(void * opaque, int ret)
@@ -164,10 +163,10 @@ static void scsi_read_complete(void * opaque, int ret)
DPRINTF("Data ready tag=0x%x len=%zd\n", r->req.tag, r->iov.iov_len);
- n = r->qiov.size / 512;
+ n = r->req.qiov.size / 512;
r->sector += n;
r->sector_count -= n;
- scsi_req_data(&r->req, r->qiov.size);
+ scsi_req_data(&r->req, r->req.qiov.size);
}
@@ -200,7 +199,7 @@ static void scsi_read_data(SCSIRequest *req)
}
n = scsi_init_iovec(r);
- r->req.aiocb = bdrv_aio_readv(s->bs, r->sector, &r->qiov, n,
+ r->req.aiocb = bdrv_aio_readv(s->bs, r->sector, &r->req.qiov, n,
scsi_read_complete, r);
if (r->req.aiocb == NULL) {
scsi_read_complete(r, -EIO);
@@ -263,7 +262,7 @@ static void scsi_write_complete(void * opaque, int ret)
}
}
- n = r->qiov.size / 512;
+ n = r->req.qiov.size / 512;
r->sector += n;
r->sector_count -= n;
if (r->sector_count == 0) {
@@ -271,7 +270,7 @@ static void scsi_write_complete(void * opaque, int ret)
} else {
len = scsi_init_iovec(r);
DPRINTF("Write complete tag=0x%x more=%d\n", r->req.tag, len);
- scsi_req_data(&r->req, r->qiov.size);
+ scsi_req_data(&r->req, r->req.qiov.size);
}
}
@@ -290,9 +289,9 @@ static void scsi_write_data(SCSIRequest *req)
return;
}
- n = r->qiov.size / 512;
+ n = r->req.qiov.size / 512;
if (n) {
- r->req.aiocb = bdrv_aio_writev(s->bs, r->sector, &r->qiov, n,
+ r->req.aiocb = bdrv_aio_writev(s->bs, r->sector, &r->req.qiov, n,
scsi_write_complete, r);
if (r->req.aiocb == NULL) {
scsi_write_complete(r, -ENOMEM);
diff --git a/hw/scsi.h b/hw/scsi.h
index c1dca35..b551b57 100644
--- a/hw/scsi.h
+++ b/hw/scsi.h
@@ -30,6 +30,7 @@ typedef struct SCSISense {
struct SCSIRequest {
SCSIBus *bus;
SCSIDevice *dev;
+ QEMUIOVector qiov;
uint32_t refcount;
uint32_t tag;
uint32_t lun;
--
1.7.4.4
next prev parent reply other threads:[~2011-06-06 16:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-06 16:26 [Qemu-devel] [RFC PATCH 0/9] scsi: support s/g operation without a bounce buffer Paolo Bonzini
2011-06-06 16:26 ` [Qemu-devel] [RFC PATCH 1/9] make qbus_reset_all public Paolo Bonzini
2011-06-06 16:26 ` [Qemu-devel] [RFC PATCH 2/9] pvscsi: first commit Paolo Bonzini
2011-06-06 16:26 ` [Qemu-devel] [RFC PATCH 3/9] pvscsi: check validity of DMA addresses in advance Paolo Bonzini
2011-06-06 16:26 ` [Qemu-devel] [RFC PATCH 4/9] scsi: always use get_sense Paolo Bonzini
2011-06-06 16:26 ` [Qemu-devel] [RFC PATCH 5/9] scsi-disk: lazily allocate bounce buffer Paolo Bonzini
2011-06-06 16:26 ` [Qemu-devel] [RFC PATCH 6/9] allow switching a qiov between internal and external storage Paolo Bonzini
2011-06-06 16:26 ` Paolo Bonzini [this message]
2011-06-06 16:26 ` [Qemu-devel] [RFC PATCH 8/9] scsi: add get_iovec/unmap_iovec to SCSIBusOps Paolo Bonzini
2011-06-06 16:27 ` [Qemu-devel] [RFC PATCH 9/9] pvscsi: implement s/g operation without a bounce buffer Paolo Bonzini
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=1307377620-7538-8-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).