All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 04/20] scsi-block, scsi-generic: implement parse_cdb
Date: Tue, 19 Aug 2014 12:42:47 +0200	[thread overview]
Message-ID: <1408444983-21464-5-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1408444983-21464-1-git-send-email-pbonzini@redhat.com>

The callback lets the bus provide the direction and transfer count
for passthrough commands, enabling passthrough of vendor-specific
commands.

Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/scsi/scsi-bus.c     |  3 +--
 hw/scsi/scsi-disk.c    | 14 ++++++++++++++
 hw/scsi/scsi-generic.c |  7 +++++++
 include/hw/scsi/scsi.h |  1 +
 4 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index d97d18a..6f4462b 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -9,7 +9,6 @@
 
 static char *scsibus_get_dev_path(DeviceState *dev);
 static char *scsibus_get_fw_dev_path(DeviceState *dev);
-static int scsi_req_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf);
 static void scsi_req_dequeue(SCSIRequest *req);
 static uint8_t *scsi_target_alloc_buf(SCSIRequest *req, size_t len);
 static void scsi_target_free_buf(SCSIRequest *req);
@@ -1210,7 +1209,7 @@ static uint64_t scsi_cmd_lba(SCSICommand *cmd)
     return lba;
 }
 
-static int scsi_req_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf)
+int scsi_req_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf)
 {
     int rc;
 
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 81b7276..d55521d 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -2564,6 +2564,19 @@ static SCSIRequest *scsi_block_new_request(SCSIDevice *d, uint32_t tag,
                               hba_private);
     }
 }
+
+static int scsi_block_parse_cdb(SCSIDevice *d, SCSICommand *cmd,
+                                  uint8_t *buf, void *hba_private)
+{
+    SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, d);
+
+    if (scsi_block_is_passthrough(s, buf)) {
+        return scsi_bus_parse_cdb(&s->qdev, cmd, buf, hba_private);
+    } else {
+        return scsi_req_parse_cdb(&s->qdev, cmd, buf);
+    }
+}
+
 #endif
 
 #define DEFINE_SCSI_DISK_PROPERTIES()                                \
@@ -2672,6 +2685,7 @@ static void scsi_block_class_initfn(ObjectClass *klass, void *data)
     sc->init         = scsi_block_initfn;
     sc->destroy      = scsi_destroy;
     sc->alloc_req    = scsi_block_new_request;
+    sc->parse_cdb    = scsi_block_parse_cdb;
     dc->fw_name = "disk";
     dc->desc = "SCSI block device passthrough";
     dc->reset = scsi_disk_reset;
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index 3733d2c..0b2ff90 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -490,6 +490,12 @@ static Property scsi_generic_properties[] = {
     DEFINE_PROP_END_OF_LIST(),
 };
 
+static int scsi_generic_parse_cdb(SCSIDevice *dev, SCSICommand *cmd,
+                                  uint8_t *buf, void *hba_private)
+{
+    return scsi_bus_parse_cdb(dev, cmd, buf, hba_private);
+}
+
 static void scsi_generic_class_initfn(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
@@ -498,6 +504,7 @@ static void scsi_generic_class_initfn(ObjectClass *klass, void *data)
     sc->init         = scsi_generic_initfn;
     sc->destroy      = scsi_destroy;
     sc->alloc_req    = scsi_new_request;
+    sc->parse_cdb    = scsi_generic_parse_cdb;
     dc->fw_name = "disk";
     dc->desc = "pass through generic scsi device (/dev/sg*)";
     dc->reset = scsi_generic_reset;
diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h
index 4a0b860..a7a28e6 100644
--- a/include/hw/scsi/scsi.h
+++ b/include/hw/scsi/scsi.h
@@ -250,6 +250,7 @@ void scsi_req_unref(SCSIRequest *req);
 
 int scsi_bus_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf,
                        void *hba_private);
+int scsi_req_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf);
 void scsi_req_build_sense(SCSIRequest *req, SCSISense sense);
 void scsi_req_print(SCSIRequest *req);
 void scsi_req_continue(SCSIRequest *req);
-- 
1.8.3.1

  parent reply	other threads:[~2014-08-19 10:43 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-19 10:42 [Qemu-devel] [PULL 00/20] SCSI and memory changes for 2014-08-18 Paolo Bonzini
2014-08-19 10:42 ` [Qemu-devel] [PULL 01/20] scsi-bus: prepare scsi_req_new for introduction of parse_cdb Paolo Bonzini
2014-08-19 10:42 ` [Qemu-devel] [PULL 02/20] scsi-bus: introduce parse_cdb in SCSIDeviceClass and SCSIBusInfo Paolo Bonzini
2014-08-19 10:42 ` [Qemu-devel] [PULL 03/20] scsi-block: extract scsi_block_is_passthrough Paolo Bonzini
2014-08-19 10:42 ` Paolo Bonzini [this message]
2014-08-19 10:42 ` [Qemu-devel] [PULL 05/20] virtio-scsi: implement parse_cdb Paolo Bonzini
2014-08-19 10:42 ` [Qemu-devel] [PULL 06/20] qom: object: delete properties before calling instance_finalize Paolo Bonzini
2014-08-19 10:42 ` [Qemu-devel] [PULL 07/20] qom: object: move unparenting to the child property's release callback Paolo Bonzini
2014-08-19 10:42 ` [Qemu-devel] [PULL 08/20] sysbus: remove unused function sysbus_del_io Paolo Bonzini
2014-08-19 10:42 ` [Qemu-devel] [PULL 09/20] vga: do not dynamically allocate chain4_alias Paolo Bonzini
2014-08-19 10:42 ` [Qemu-devel] [PULL 10/20] nic: do not destroy memory regions in cleanup functions Paolo Bonzini
2014-08-19 10:42 ` [Qemu-devel] [PULL 11/20] ioport: split deletion and destruction Paolo Bonzini
2014-08-19 10:42 ` [Qemu-devel] [PULL 12/20] memory: convert memory_region_destroy to object_unparent Paolo Bonzini
2014-08-19 10:42 ` [Qemu-devel] [PULL 13/20] memory: remove memory_region_destroy Paolo Bonzini
2014-08-19 10:42 ` [Qemu-devel] [PULL 14/20] tpm_tis: remove instance_finalize callback Paolo Bonzini
2014-08-19 10:42 ` [Qemu-devel] [PULL 15/20] loader: Abstract away ref to memory region names Paolo Bonzini
2014-08-19 10:42 ` [Qemu-devel] [PULL 16/20] exec: " Paolo Bonzini
2014-08-19 10:43 ` [Qemu-devel] [PULL 17/20] memory: constify memory_region_name Paolo Bonzini
2014-08-19 10:43 ` [Qemu-devel] [PULL 18/20] memory: Use memory_region_name for name access Paolo Bonzini
2014-08-19 10:43 ` [Qemu-devel] [PULL 19/20] memory: Use canonical path component as the name Paolo Bonzini
2014-08-19 18:51   ` Peter Maydell
2014-08-20  5:01     ` Peter Crosthwaite
2014-08-19 19:01   ` Peter Maydell
2014-08-20  5:04     ` Peter Crosthwaite
2014-08-20  7:50       ` Peter Maydell
2014-08-20  8:16         ` Paolo Bonzini
2014-08-19 10:43 ` [Qemu-devel] [PULL 20/20] mtree: remove write-only field Paolo Bonzini
2014-08-19 14:09 ` [Qemu-devel] [PULL 00/20] SCSI and memory changes for 2014-08-18 Peter Maydell

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=1408444983-21464-5-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.