qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PULL 07/20] libqos: drop duplicated virtio_scsi.h definitions
Date: Mon, 20 Jun 2016 15:05:18 +0100	[thread overview]
Message-ID: <1466431531-17806-8-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1466431531-17806-1-git-send-email-stefanha@redhat.com>

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1462798061-30382-8-git-send-email-stefanha@redhat.com
---
 tests/virtio-scsi-test.c | 45 +++++++++++++++------------------------------
 1 file changed, 15 insertions(+), 30 deletions(-)

diff --git a/tests/virtio-scsi-test.c b/tests/virtio-scsi-test.c
index 26bb0e3..be0f760 100644
--- a/tests/virtio-scsi-test.c
+++ b/tests/virtio-scsi-test.c
@@ -18,11 +18,11 @@
 #include "libqos/malloc-pc.h"
 #include "libqos/malloc-generic.h"
 #include "standard-headers/linux/virtio_ids.h"
+#include "standard-headers/linux/virtio_scsi.h"
 
 #define PCI_SLOT                0x02
 #define PCI_FN                  0x00
 #define QVIRTIO_SCSI_TIMEOUT_US (1 * 1000 * 1000)
-#define CDB_SIZE 32
 
 #define MAX_NUM_QUEUES 64
 
@@ -34,24 +34,6 @@ typedef struct {
     QVirtQueue *vq[MAX_NUM_QUEUES + 2];
 } QVirtIOSCSI;
 
-typedef struct {
-    uint8_t lun[8];
-    int64_t tag;
-    uint8_t task_attr;
-    uint8_t prio;
-    uint8_t crn;
-    uint8_t cdb[CDB_SIZE];
-} QEMU_PACKED QVirtIOSCSICmdReq;
-
-typedef struct {
-    uint32_t sense_len;
-    uint32_t resid;
-    uint16_t status_qualifier;
-    uint8_t status;
-    uint8_t response;
-    uint8_t sense[96];
-} QEMU_PACKED QVirtIOSCSICmdResp;
-
 static void qvirtio_scsi_start(const char *extra_opts)
 {
     char *cmdline;
@@ -100,11 +82,11 @@ static uint8_t virtio_scsi_do_command(QVirtIOSCSI *vs, const uint8_t *cdb,
                                       const uint8_t *data_in,
                                       size_t data_in_len,
                                       uint8_t *data_out, size_t data_out_len,
-                                      QVirtIOSCSICmdResp *resp_out)
+                                      struct virtio_scsi_cmd_resp *resp_out)
 {
     QVirtQueue *vq;
-    QVirtIOSCSICmdReq req = { { 0 } };
-    QVirtIOSCSICmdResp resp = { .response = 0xff, .status = 0xff };
+    struct virtio_scsi_cmd_req req = { { 0 } };
+    struct virtio_scsi_cmd_resp resp = { .response = 0xff, .status = 0xff };
     uint64_t req_addr, resp_addr, data_in_addr = 0, data_out_addr = 0;
     uint8_t response;
     uint32_t free_head;
@@ -113,7 +95,7 @@ static uint8_t virtio_scsi_do_command(QVirtIOSCSI *vs, const uint8_t *cdb,
 
     req.lun[0] = 1; /* Select LUN */
     req.lun[1] = 1; /* Select target 1 */
-    memcpy(req.cdb, cdb, CDB_SIZE);
+    memcpy(req.cdb, cdb, VIRTIO_SCSI_CDB_SIZE);
 
     /* XXX: Fix endian if any multi-byte field in req/resp is used */
 
@@ -138,7 +120,8 @@ static uint8_t virtio_scsi_do_command(QVirtIOSCSI *vs, const uint8_t *cdb,
     qvirtqueue_kick(&qvirtio_pci, vs->dev, vq, free_head);
     qvirtio_wait_queue_isr(&qvirtio_pci, vs->dev, vq, QVIRTIO_SCSI_TIMEOUT_US);
 
-    response = readb(resp_addr + offsetof(QVirtIOSCSICmdResp, response));
+    response = readb(resp_addr +
+                     offsetof(struct virtio_scsi_cmd_resp, response));
 
     if (resp_out) {
         memread(resp_addr, resp_out, sizeof(*resp_out));
@@ -153,10 +136,10 @@ static uint8_t virtio_scsi_do_command(QVirtIOSCSI *vs, const uint8_t *cdb,
 
 static QVirtIOSCSI *qvirtio_scsi_pci_init(int slot)
 {
-    const uint8_t test_unit_ready_cdb[CDB_SIZE] = {};
+    const uint8_t test_unit_ready_cdb[VIRTIO_SCSI_CDB_SIZE] = {};
     QVirtIOSCSI *vs;
     QVirtioPCIDevice *dev;
-    QVirtIOSCSICmdResp resp;
+    struct virtio_scsi_cmd_resp resp;
     void *addr;
     int i;
 
@@ -239,10 +222,12 @@ static void test_unaligned_write_same(void)
     QVirtIOSCSI *vs;
     uint8_t buf1[512] = { 0 };
     uint8_t buf2[512] = { 1 };
-    const uint8_t write_same_cdb_1[CDB_SIZE] = { 0x41, 0x00, 0x00, 0x00, 0x00,
-                                               0x01, 0x00, 0x00, 0x02, 0x00 };
-    const uint8_t write_same_cdb_2[CDB_SIZE] = { 0x41, 0x00, 0x00, 0x00, 0x00,
-                                               0x01, 0x00, 0x33, 0x00, 0x00 };
+    const uint8_t write_same_cdb_1[VIRTIO_SCSI_CDB_SIZE] = {
+        0x41, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00
+    };
+    const uint8_t write_same_cdb_2[VIRTIO_SCSI_CDB_SIZE] = {
+        0x41, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x33, 0x00, 0x00
+    };
 
     qvirtio_scsi_start("-drive file=blkdebug::null-co://,if=none,id=dr1"
                        ",format=raw,file.align=4k "
-- 
2.5.5

  parent reply	other threads:[~2016-06-20 14:06 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-20 14:05 [Qemu-devel] [PULL 00/20] Block patches Stefan Hajnoczi
2016-06-20 14:05 ` [Qemu-devel] [PULL 01/20] libqos: use virtio_ids.h for device ID definitions Stefan Hajnoczi
2016-06-20 14:05 ` [Qemu-devel] [PULL 02/20] libqos: drop duplicated PCI vendor ID definition Stefan Hajnoczi
2016-06-20 14:05 ` [Qemu-devel] [PULL 03/20] libqos: drop duplicated virtio_config.h definitions Stefan Hajnoczi
2016-06-20 14:05 ` [Qemu-devel] [PULL 04/20] libqos: drop duplicated virtio_ring.h bit definitions Stefan Hajnoczi
2016-06-20 14:05 ` [Qemu-devel] [PULL 05/20] libqos: drop duplicated virtio_vring.h structs Stefan Hajnoczi
2016-06-20 14:05 ` [Qemu-devel] [PULL 06/20] libqos: drop duplicated virtio_blk.h definitions Stefan Hajnoczi
2016-06-20 14:05 ` Stefan Hajnoczi [this message]
2016-06-20 14:05 ` [Qemu-devel] [PULL 08/20] libqos: drop duplicated virtio_pci.h definitions Stefan Hajnoczi
2016-06-20 14:05 ` [Qemu-devel] [PULL 09/20] libqos: add qvirtqueue_cleanup() Stefan Hajnoczi
2016-06-20 14:05 ` [Qemu-devel] [PULL 10/20] block: fixed BdrvTrackedRequest filling in bdrv_co_discard Stefan Hajnoczi
2016-06-20 14:05 ` [Qemu-devel] [PULL 11/20] block: fix race in bdrv_co_discard with drive-mirror Stefan Hajnoczi
2016-06-20 14:05 ` [Qemu-devel] [PULL 12/20] block: process before_write_notifiers in bdrv_co_discard Stefan Hajnoczi
2016-06-20 14:05 ` [Qemu-devel] [PULL 13/20] blockjob: move iostatus reset out of block_job_enter() Stefan Hajnoczi
2016-06-20 14:05 ` [Qemu-devel] [PULL 14/20] blockjob: rename block_job_is_paused() Stefan Hajnoczi
2016-06-20 14:05 ` [Qemu-devel] [PULL 15/20] blockjob: add pause points Stefan Hajnoczi
2016-06-20 14:05 ` [Qemu-devel] [PULL 16/20] blockjob: add block_job_get_aio_context() Stefan Hajnoczi
2016-06-20 14:05 ` [Qemu-devel] [PULL 17/20] block: use safe iteration over AioContext notifiers Stefan Hajnoczi
2016-06-20 14:05 ` [Qemu-devel] [PULL 18/20] blockjob: add AioContext attached callback Stefan Hajnoczi
2016-06-20 14:05 ` [Qemu-devel] [PULL 19/20] mirror: follow AioContext change gracefully Stefan Hajnoczi
2016-06-20 14:05 ` [Qemu-devel] [PULL 20/20] backup: " Stefan Hajnoczi
2016-06-20 17:08 ` [Qemu-devel] [PULL 00/20] Block patches 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=1466431531-17806-8-git-send-email-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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 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).