qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] virtio-scsi: clean up virtio_scsi_parse_cdb
@ 2014-09-18 14:58 Paolo Bonzini
  2014-09-18 15:43 ` Laszlo Ersek
  0 siblings, 1 reply; 2+ messages in thread
From: Paolo Bonzini @ 2014-09-18 14:58 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laszlo Ersek

The command direction according to the guest-passed buffers
is already stored in the VirtIOSCSIReq.  We can use it instead
of computing it again from req->elem.

Cc: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/scsi/virtio-scsi.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index f0d21a3..6953cbe 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -430,13 +430,7 @@ static int virtio_scsi_parse_cdb(SCSIDevice *dev, SCSICommand *cmd,
      * host device passthrough.
      */
     cmd->xfer = req->qsgl.size;
-    if (cmd->xfer == 0) {
-        cmd->mode = SCSI_XFER_NONE;
-    } else if (iov_size(req->elem.in_sg, req->elem.in_num) > req->resp_size) {
-        cmd->mode = SCSI_XFER_FROM_DEV;
-    } else {
-        cmd->mode = SCSI_XFER_TO_DEV;
-    }
+    cmd->mode = req->mode;
     return 0;
 }
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] virtio-scsi: clean up virtio_scsi_parse_cdb
  2014-09-18 14:58 [Qemu-devel] [PATCH] virtio-scsi: clean up virtio_scsi_parse_cdb Paolo Bonzini
@ 2014-09-18 15:43 ` Laszlo Ersek
  0 siblings, 0 replies; 2+ messages in thread
From: Laszlo Ersek @ 2014-09-18 15:43 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel

On 09/18/14 16:58, Paolo Bonzini wrote:
> The command direction according to the guest-passed buffers
> is already stored in the VirtIOSCSIReq.  We can use it instead
> of computing it again from req->elem.
> 
> Cc: Laszlo Ersek <lersek@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/scsi/virtio-scsi.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
> index f0d21a3..6953cbe 100644
> --- a/hw/scsi/virtio-scsi.c
> +++ b/hw/scsi/virtio-scsi.c
> @@ -430,13 +430,7 @@ static int virtio_scsi_parse_cdb(SCSIDevice *dev, SCSICommand *cmd,
>       * host device passthrough.
>       */
>      cmd->xfer = req->qsgl.size;
> -    if (cmd->xfer == 0) {
> -        cmd->mode = SCSI_XFER_NONE;
> -    } else if (iov_size(req->elem.in_sg, req->elem.in_num) > req->resp_size) {
> -        cmd->mode = SCSI_XFER_FROM_DEV;
> -    } else {
> -        cmd->mode = SCSI_XFER_TO_DEV;
> -    }
> +    cmd->mode = req->mode;
>      return 0;
>  }
>  
> 

virtio_scsi_handle_cmd()                              [hw/scsi/virtio-scsi.c]
  virtio_scsi_parse_req()                             [hw/scsi/virtio-scsi.c]
    /* sets req->mode */
  scsi_req_new()                                      [hw/scsi/scsi-bus.c]
    scsi_block_parse_cdb() | scsi_generic_parse_cdb() [hw/scsi/scsi-disk.c | hw/scsi/scsi-generic.c]
      scsi_bus_parse_cdb()                            [hw/scsi/scsi-bus.c]
        virtio_scsi_parse_cdb()                       [hw/scsi/virtio-scsi.c]
          /* uses req->mode */

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-09-18 16:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-18 14:58 [Qemu-devel] [PATCH] virtio-scsi: clean up virtio_scsi_parse_cdb Paolo Bonzini
2014-09-18 15:43 ` Laszlo Ersek

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).