> @@ -95,14 +95,30 @@ static SCSIRequest *scsi_new_request(SCSIDevice *d, > uint32_t tag, > return req; > } > > +static SCSIRequest *scsi_new_request_iovec(SCSIDevice *d, uint32_t tag, > + uint32_t lun, struct iovec *iov, int iov_num) > +{ > + SCSIRequest *req; > + SCSIDiskReq *r; > + > + req = scsi_req_alloc(sizeof(SCSIDiskReq), d, tag, lun); > + r = DO_UPCAST(SCSIDiskReq, req, req); > + r->iov = iov; > + r->iov_num = iov_num; > + r->iov_buf = NULL; > + return req; > +}
While the amount of duplicated code here is rather small I still hate the duplication. The simplest step is to implement scsi_new_request on top of scsi_new_request_iovec by just allocation the iovec in scsi_new_request and passing it to scsi_new_request_iovec. The next patch on top would be to move the iovec allocation to the HBA driver and only stick to one interface.