From patchwork Mon May 9 12:47:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 9046411 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 26E39BF29F for ; Mon, 9 May 2016 12:52:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 75CFE200DB for ; Mon, 9 May 2016 12:52:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9981D200C1 for ; Mon, 9 May 2016 12:52:12 +0000 (UTC) Received: from localhost ([::1]:41164 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azkfT-00061F-V5 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 09 May 2016 08:52:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azkbS-00057F-0O for qemu-devel@nongnu.org; Mon, 09 May 2016 08:48:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1azkbQ-0004ip-NG for qemu-devel@nongnu.org; Mon, 09 May 2016 08:48:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56250) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azkbQ-0004iP-FO for qemu-devel@nongnu.org; Mon, 09 May 2016 08:48:00 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0CE589B0EB; Mon, 9 May 2016 12:48:00 +0000 (UTC) Received: from localhost (ovpn-112-46.ams2.redhat.com [10.36.112.46]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u49ClwU6001801; Mon, 9 May 2016 08:47:59 -0400 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Mon, 9 May 2016 13:47:40 +0100 Message-Id: <1462798061-30382-8-git-send-email-stefanha@redhat.com> In-Reply-To: <1462798061-30382-1-git-send-email-stefanha@redhat.com> References: <1462798061-30382-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 09 May 2016 12:48:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RESEND PATCH v3 7/8] libqos: drop duplicated virtio_scsi.h definitions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marc.mari.barcelo@gmail.com, Paolo Bonzini , jsnow@redhat.com, Stefan Hajnoczi Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Stefan Hajnoczi --- 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 625bd6d..8b8f5f3 100644 --- a/tests/virtio-scsi-test.c +++ b/tests/virtio-scsi-test.c @@ -19,11 +19,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 @@ -35,24 +35,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; @@ -101,11 +83,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; @@ -114,7 +96,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 */ @@ -139,7 +121,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)); @@ -154,10 +137,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; @@ -240,10 +223,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 "