From patchwork Tue Oct 10 21:35:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 9998029 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 00D8460230 for ; Tue, 10 Oct 2017 21:56:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E880C287CA for ; Tue, 10 Oct 2017 21:56:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD2F1287D4; Tue, 10 Oct 2017 21:56:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 5DBC7287CA for ; Tue, 10 Oct 2017 21:56:06 +0000 (UTC) Received: from localhost ([::1]:37338 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e22VR-00014o-NL for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 Oct 2017 17:56:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39378) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e22E3-0003nu-3z for qemu-devel@nongnu.org; Tue, 10 Oct 2017 17:38:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e22Dy-0002eg-73 for qemu-devel@nongnu.org; Tue, 10 Oct 2017 17:38:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55250) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e22Dx-0002eK-U4 for qemu-devel@nongnu.org; Tue, 10 Oct 2017 17:38:02 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E8B345F2979; Tue, 10 Oct 2017 21:38:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E8B345F2979 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com Received: from localhost (unknown [10.36.112.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 049D468891; Tue, 10 Oct 2017 21:37:52 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Tue, 10 Oct 2017 23:35:00 +0200 Message-Id: <20171010213506.22989-22-marcandre.lureau@redhat.com> In-Reply-To: <20171010213506.22989-1-marcandre.lureau@redhat.com> References: <20171010213506.22989-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 10 Oct 2017 21:38:01 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 21/27] vhost-user-scsi: don't copy iscsi/scsi-lowlevel.h 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: pbonzini@redhat.com, felipe@nutanix.com, changpeng.liu@intel.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , f4bug@amsat.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP There is no need to include hw/virtio/virtio-scsi.h, then the conflict with SCSI_XFER enum goes away. Signed-off-by: Marc-André Lureau Reviewed-by: Philippe Mathieu-Daudé --- contrib/vhost-user-scsi/vhost-user-scsi.c | 96 +++---------------------------- 1 file changed, 9 insertions(+), 87 deletions(-) diff --git a/contrib/vhost-user-scsi/vhost-user-scsi.c b/contrib/vhost-user-scsi/vhost-user-scsi.c index c7f9d82142..cfac1ce1fe 100644 --- a/contrib/vhost-user-scsi/vhost-user-scsi.c +++ b/contrib/vhost-user-scsi/vhost-user-scsi.c @@ -12,8 +12,9 @@ #include "qemu/osdep.h" #include "contrib/libvhost-user/libvhost-user.h" -#include "hw/virtio/virtio-scsi.h" +#include "standard-headers/linux/virtio_scsi.h" #include "iscsi/iscsi.h" +#include "iscsi/scsi-lowlevel.h" #include @@ -163,90 +164,11 @@ static void vus_gsrc_new(VusDev *vdev_scsi, int fd, GIOCondition cond, (gpointer)(uintptr_t)id); } -/* from libiscsi's scsi-lowlevel.h ** - * - * nb. We can't directly include scsi-lowlevel.h due to a namespace conflict: - * QEMU's scsi.h also defines "SCSI_XFER_NONE". - */ - -#define SCSI_CDB_MAX_SIZE 16 - -struct scsi_iovector { - struct scsi_iovec *iov; - int niov; - int nalloc; - size_t offset; - int consumed; -}; - -struct scsi_allocated_memory { - struct scsi_allocated_memory *next; - char buf[0]; -}; - -struct scsi_data { - int size; - unsigned char *data; -}; - -enum scsi_sense_key { - SCSI_SENSE_NO_SENSE = 0x00, - SCSI_SENSE_RECOVERED_ERROR = 0x01, - SCSI_SENSE_NOT_READY = 0x02, - SCSI_SENSE_MEDIUM_ERROR = 0x03, - SCSI_SENSE_HARDWARE_ERROR = 0x04, - SCSI_SENSE_ILLEGAL_REQUEST = 0x05, - SCSI_SENSE_UNIT_ATTENTION = 0x06, - SCSI_SENSE_DATA_PROTECTION = 0x07, - SCSI_SENSE_BLANK_CHECK = 0x08, - SCSI_SENSE_VENDOR_SPECIFIC = 0x09, - SCSI_SENSE_COPY_ABORTED = 0x0a, - SCSI_SENSE_COMMAND_ABORTED = 0x0b, - SCSI_SENSE_OBSOLETE_ERROR_CODE = 0x0c, - SCSI_SENSE_OVERFLOW_COMMAND = 0x0d, - SCSI_SENSE_MISCOMPARE = 0x0e -}; - -struct scsi_sense { - unsigned char error_type; - enum scsi_sense_key key; - int ascq; - unsigned sense_specific:1; - unsigned ill_param_in_cdb:1; - unsigned bit_pointer_valid:1; - unsigned char bit_pointer; - uint16_t field_pointer; -}; - -enum scsi_residual { - SCSI_RESIDUAL_NO_RESIDUAL = 0, - SCSI_RESIDUAL_UNDERFLOW, - SCSI_RESIDUAL_OVERFLOW -}; - -struct scsi_task { - int status; - int cdb_size; - int xfer_dir; - int expxferlen; - unsigned char cdb[SCSI_CDB_MAX_SIZE]; - enum scsi_residual residual_status; - size_t residual; - struct scsi_sense sense; - struct scsi_data datain; - struct scsi_allocated_memory *mem; - void *ptr; - - uint32_t itt; - uint32_t cmdsn; - uint32_t lun; - - struct scsi_iovector iovector_in; - struct scsi_iovector iovector_out; -}; - /** libiscsi integration **/ +typedef struct virtio_scsi_cmd_req VirtIOSCSICmdReq; +typedef struct virtio_scsi_cmd_resp VirtIOSCSICmdResp; + static int vus_iscsi_add_lun(VusIscsiLun *lun, char *iscsi_uri) { struct iscsi_url *iscsi_url; @@ -365,12 +287,12 @@ static int handle_cmd_sync(struct iscsi_context *ctx, if (!out_len && !in_len) { dir = SCSI_XFER_NONE; } else if (out_len) { - dir = SCSI_XFER_TO_DEV; + dir = SCSI_XFER_WRITE; for (i = 0; i < out_len; i++) { len += out[i].iov_len; } } else { - dir = SCSI_XFER_FROM_DEV; + dir = SCSI_XFER_READ; for (i = 0; i < in_len; i++) { len += in[i].iov_len; } @@ -378,10 +300,10 @@ static int handle_cmd_sync(struct iscsi_context *ctx, task = scsi_task_new(cdb_len, req->cdb, dir, len); - if (dir == SCSI_XFER_TO_DEV) { + if (dir == SCSI_XFER_WRITE) { task->iovector_out.iov = (struct scsi_iovec *)out; task->iovector_out.niov = out_len; - } else if (dir == SCSI_XFER_FROM_DEV) { + } else if (dir == SCSI_XFER_READ) { task->iovector_in.iov = (struct scsi_iovec *)in; task->iovector_in.niov = in_len; }