Patchwork [v4,14/18] virtio-scsi: process control queue requests

login
register
mail settings
Submitter Hu Tao
Date Feb. 24, 2012, 7:54 a.m.
Message ID <20120224075437.GA6937@localhost.localdomain>
Download mbox | patch
Permalink /patch/142761/
State New
Headers show

Comments

Hu Tao - Feb. 24, 2012, 7:54 a.m.
On Wed, Feb 22, 2012 at 03:33:52PM +0100, Paolo Bonzini wrote:
> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/virtio-scsi.c |  134 ++++++++++++++++++++++++++++++++++++++++++++++++++---
>  1 files changed, 126 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c
> index f4eb8c7..380073a 100644
> --- a/hw/virtio-scsi.c
> +++ b/hw/virtio-scsi.c
> @@ -134,6 +134,7 @@ typedef struct {
>      VirtQueue *cmd_vq;
>      uint32_t sense_size;
>      uint32_t cdb_size;
> +    int resetting;
>  } VirtIOSCSI;
>  
>  typedef struct VirtIOSCSIReq {
> @@ -236,15 +237,104 @@ static VirtIOSCSIReq *virtio_scsi_pop_req(VirtIOSCSI *s, VirtQueue *vq)
>      return req;
>  }
>  
> -static void virtio_scsi_fail_ctrl_req(VirtIOSCSIReq *req)
> +static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req)
>  {
> -    if (req->req.tmf->type == VIRTIO_SCSI_T_TMF) {
> -        req->resp.tmf->response = VIRTIO_SCSI_S_FAILURE;
> -    } else {
> -        req->resp.an->response = VIRTIO_SCSI_S_FAILURE;
> +    SCSIDevice *d = virtio_scsi_device_find(s, req->req.cmd->lun);

should be req->req.tmf->lun here and elsewhere in this function?
Paolo Bonzini - Feb. 24, 2012, 8:56 a.m.
On 02/24/2012 08:54 AM, Hu Tao wrote:
> should be req->req.tmf->lun here and elsewhere in this function?

Yes, good catch!

Paolo
Paolo Bonzini - Feb. 24, 2012, 1:58 p.m.
On 02/24/2012 08:54 AM, Hu Tao wrote:
> diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c
> index 380073a..1f3b851 100644
> --- a/hw/virtio-scsi.c
> +++ b/hw/virtio-scsi.c
> @@ -239,7 +239,7 @@ static VirtIOSCSIReq *virtio_scsi_pop_req(VirtIOSCSI *s, VirtQueue *vq)
>  
>  static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req)
>  {
> -    SCSIDevice *d = virtio_scsi_device_find(s, req->req.cmd->lun);
> +    SCSIDevice *d = virtio_scsi_device_find(s, req->req.tmf->lun);
>      SCSIRequest *r, *next;
>      DeviceState *qdev;
>      int target;
> @@ -253,11 +253,11 @@ static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req)
>          if (!d) {
>              goto fail;
>          }
> -        if (d->lun != virtio_scsi_get_lun(req->req.cmd->lun)) {
> +        if (d->lun != virtio_scsi_get_lun(req->req.tmf->lun)) {
>              goto incorrect_lun;
>          }
>          QTAILQ_FOREACH_SAFE(r, &d->requests, next, next) {
> -            if (r->tag == req->req.cmd->tag) {
> +            if (r->tag == req->req.tmf->tag) {
>                  break;
>              }
>          }
> @@ -277,7 +277,7 @@ static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req)
>          if (!d) {
>              goto fail;
>          }
> -        if (d->lun != virtio_scsi_get_lun(req->req.cmd->lun)) {
> +        if (d->lun != virtio_scsi_get_lun(req->req.tmf->lun)) {
>              goto incorrect_lun;
>          }
>          s->resetting++;
> @@ -291,7 +291,7 @@ static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req)
>          if (!d) {
>              goto fail;
>          }
> -        if (d->lun != virtio_scsi_get_lun(req->req.cmd->lun)) {
> +        if (d->lun != virtio_scsi_get_lun(req->req.tmf->lun)) {
>              goto incorrect_lun;
>          }
>          QTAILQ_FOREACH_SAFE(r, &d->requests, next, next) {
> @@ -310,7 +310,7 @@ static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req)
>          break;
>  
>      case VIRTIO_SCSI_T_TMF_I_T_NEXUS_RESET:
> -        target = req->req.cmd->lun[1];
> +        target = req->req.tmf->lun[1];
>          s->resetting++;
>          QTAILQ_FOREACH(qdev, &s->bus.qbus.children, sibling) {
>               d = DO_UPCAST(SCSIDevice, qdev, qdev);

This is now fixed on github.

Paolo

Patch

diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c
index 380073a..1f3b851 100644
--- a/hw/virtio-scsi.c
+++ b/hw/virtio-scsi.c
@@ -239,7 +239,7 @@  static VirtIOSCSIReq *virtio_scsi_pop_req(VirtIOSCSI *s, VirtQueue *vq)
 
 static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req)
 {
-    SCSIDevice *d = virtio_scsi_device_find(s, req->req.cmd->lun);
+    SCSIDevice *d = virtio_scsi_device_find(s, req->req.tmf->lun);
     SCSIRequest *r, *next;
     DeviceState *qdev;
     int target;
@@ -253,11 +253,11 @@  static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req)
         if (!d) {
             goto fail;
         }
-        if (d->lun != virtio_scsi_get_lun(req->req.cmd->lun)) {
+        if (d->lun != virtio_scsi_get_lun(req->req.tmf->lun)) {
             goto incorrect_lun;
         }
         QTAILQ_FOREACH_SAFE(r, &d->requests, next, next) {
-            if (r->tag == req->req.cmd->tag) {
+            if (r->tag == req->req.tmf->tag) {
                 break;
             }
         }
@@ -277,7 +277,7 @@  static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req)
         if (!d) {
             goto fail;
         }
-        if (d->lun != virtio_scsi_get_lun(req->req.cmd->lun)) {
+        if (d->lun != virtio_scsi_get_lun(req->req.tmf->lun)) {
             goto incorrect_lun;
         }
         s->resetting++;
@@ -291,7 +291,7 @@  static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req)
         if (!d) {
             goto fail;
         }
-        if (d->lun != virtio_scsi_get_lun(req->req.cmd->lun)) {
+        if (d->lun != virtio_scsi_get_lun(req->req.tmf->lun)) {
             goto incorrect_lun;
         }
         QTAILQ_FOREACH_SAFE(r, &d->requests, next, next) {
@@ -310,7 +310,7 @@  static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req)
         break;
 
     case VIRTIO_SCSI_T_TMF_I_T_NEXUS_RESET:
-        target = req->req.cmd->lun[1];
+        target = req->req.tmf->lun[1];
         s->resetting++;
         QTAILQ_FOREACH(qdev, &s->bus.qbus.children, sibling) {
              d = DO_UPCAST(SCSIDevice, qdev, qdev);