From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39110) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZRa6M-00023g-Be for qemu-devel@nongnu.org; Tue, 18 Aug 2015 02:10:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZRa6I-0004zt-Ul for qemu-devel@nongnu.org; Tue, 18 Aug 2015 02:10:26 -0400 Received: from mx2.suse.de ([195.135.220.15]:45343) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZRa6I-0004zd-La for qemu-devel@nongnu.org; Tue, 18 Aug 2015 02:10:22 -0400 Message-ID: <55D2CC4D.7060908@suse.de> Date: Tue, 18 Aug 2015 08:10:21 +0200 From: Hannes Reinecke MIME-Version: 1.0 References: <1439854945-5597-1-git-send-email-abezzubikov@ispras.ru> <1439854945-5597-5-git-send-email-abezzubikov@ispras.ru> In-Reply-To: <1439854945-5597-5-git-send-email-abezzubikov@ispras.ru> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH RFC 04/11] scsi: Added function to enable ATAPI-SCSI bridge send SCSI requests List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Bezzubikov , qemu-devel@nongnu.org Cc: jsnow@redhat.com, abezzubikov@ispras.ru On 08/18/2015 01:42 AM, Alexander Bezzubikov wrote: > Signed-off-by: Alexander Bezzubikov > --- > hw/ide/internal.h | 2 +- > hw/scsi/scsi-disk.c | 43 ++++++++++++++++++++++++++++++++++++++++++= + > include/hw/scsi/scsi.h | 3 +++ > 3 files changed, 47 insertions(+), 1 deletion(-) >=20 > diff --git a/hw/ide/internal.h b/hw/ide/internal.h > index 3ebc63c..fd385bc 100644 > --- a/hw/ide/internal.h > +++ b/hw/ide/internal.h > @@ -495,7 +495,7 @@ struct IDEDevice { > char *serial; > char *model; > uint64_t wwn; > - SCSIBus *scsi_bus; > + SCSIBus scsi_bus; > }; > =20 > /* These are used for the error_status field of IDEBus */ > diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c > index 64f0694..f67d816 100644 > --- a/hw/scsi/scsi-disk.c > +++ b/hw/scsi/scsi-disk.c > @@ -2440,6 +2440,49 @@ static SCSIRequest *scsi_new_request(SCSIDevice = *d, uint32_t tag, uint32_t lun, > return req; > } > =20 > +SCSIRequest *scsi_new_request_from_bridge(SCSIDevice *d, uint32_t tag, > + uint32_t lun, uint8_t *buf, > + void *hba_private) > +{ > + SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, d); > + SCSIDeviceClass *sc =3D SCSI_DEVICE_GET_CLASS(d); > + SCSIRequest *req; > + const SCSIReqOps *ops; > + uint8_t command; > + > + command =3D buf[0]; > + ops =3D scsi_disk_reqops_dispatch[command]; > + if (!ops) { > + ops =3D &scsi_disk_emulate_reqops; > + } > + req =3D scsi_req_alloc(ops, &s->qdev, tag, lun, hba_private); > + memcpy(req->cmd.buf, buf, 16); > + > + SCSICommand cmd =3D { .len =3D 0 }; > + > + if (ops !=3D NULL || !sc->parse_cdb) { > + scsi_req_parse_cdb(d, &cmd, buf); > + } else { > + sc->parse_cdb(d, &cmd, buf, hba_private); > + } > + > + req->cmd =3D cmd; > + req->resid =3D req->cmd.xfer; > + > + #ifdef DEBUG_SCSI > + DPRINTF("Command: lun=3D%d tag=3D0x%x data=3D0x%02x", lun, tag, bu= f[0]); > + { > + int i; > + for (i =3D 1; i < scsi_cdb_length(buf); i++) { > + printf(" 0x%02x", buf[i]); > + } > + printf("\n"); > + } > + #endif > + > + return req; > +} > + > #ifdef __linux__ > static int get_device_type(SCSIDiskState *s) > { > diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h > index cdaf0f8..881ed23 100644 > --- a/include/hw/scsi/scsi.h > +++ b/include/hw/scsi/scsi.h > @@ -249,6 +249,9 @@ SCSIRequest *scsi_req_alloc(const SCSIReqOps *reqop= s, SCSIDevice *d, > uint32_t tag, uint32_t lun, void *hba_priv= ate); > SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, uint32_t lun, > uint8_t *buf, void *hba_private); > +SCSIRequest *scsi_new_request_from_bridge(SCSIDevice *d, uint32_t tag, > + uint32_t lun, uint8_t *buf, > + void *hba_private); > int32_t scsi_req_enqueue(SCSIRequest *req); > void scsi_req_free(SCSIRequest *req); > SCSIRequest *scsi_req_ref(SCSIRequest *req); >=20 Again, I would merge it with the latter patch where the function is actually used. Cheers, Hannes --=20 Dr. Hannes Reinecke zSeries & Storage hare@suse.de +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg GF: J. Hawn, J. Guild, F. Imend=F6rffer, HRB 16746 (AG N=FCrnberg)