From nobody Tue Feb 10 11:13:11 2026 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507672610373689.0316191400403; Tue, 10 Oct 2017 14:56:50 -0700 (PDT) Received: from localhost ([::1]:37353 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e22Vk-0001zH-Hg for importer@patchew.org; Tue, 10 Oct 2017 17:56:24 -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) 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) 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 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) Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 @@ =20 #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" =20 #include =20 @@ -163,90 +164,11 @@ static void vus_gsrc_new(VusDev *vdev_scsi, int fd, G= IOCondition cond, (gpointer)(uintptr_t)id); } =20 -/* from libiscsi's scsi-lowlevel.h ** - * - * nb. We can't directly include scsi-lowlevel.h due to a namespace confli= ct: - * 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 =3D 0x00, - SCSI_SENSE_RECOVERED_ERROR =3D 0x01, - SCSI_SENSE_NOT_READY =3D 0x02, - SCSI_SENSE_MEDIUM_ERROR =3D 0x03, - SCSI_SENSE_HARDWARE_ERROR =3D 0x04, - SCSI_SENSE_ILLEGAL_REQUEST =3D 0x05, - SCSI_SENSE_UNIT_ATTENTION =3D 0x06, - SCSI_SENSE_DATA_PROTECTION =3D 0x07, - SCSI_SENSE_BLANK_CHECK =3D 0x08, - SCSI_SENSE_VENDOR_SPECIFIC =3D 0x09, - SCSI_SENSE_COPY_ABORTED =3D 0x0a, - SCSI_SENSE_COMMAND_ABORTED =3D 0x0b, - SCSI_SENSE_OBSOLETE_ERROR_CODE =3D 0x0c, - SCSI_SENSE_OVERFLOW_COMMAND =3D 0x0d, - SCSI_SENSE_MISCOMPARE =3D 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 =3D 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 **/ =20 +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 =3D SCSI_XFER_NONE; } else if (out_len) { - dir =3D SCSI_XFER_TO_DEV; + dir =3D SCSI_XFER_WRITE; for (i =3D 0; i < out_len; i++) { len +=3D out[i].iov_len; } } else { - dir =3D SCSI_XFER_FROM_DEV; + dir =3D SCSI_XFER_READ; for (i =3D 0; i < in_len; i++) { len +=3D in[i].iov_len; } @@ -378,10 +300,10 @@ static int handle_cmd_sync(struct iscsi_context *ctx, =20 task =3D scsi_task_new(cdb_len, req->cdb, dir, len); =20 - if (dir =3D=3D SCSI_XFER_TO_DEV) { + if (dir =3D=3D SCSI_XFER_WRITE) { task->iovector_out.iov =3D (struct scsi_iovec *)out; task->iovector_out.niov =3D out_len; - } else if (dir =3D=3D SCSI_XFER_FROM_DEV) { + } else if (dir =3D=3D SCSI_XFER_READ) { task->iovector_in.iov =3D (struct scsi_iovec *)in; task->iovector_in.niov =3D in_len; } --=20 2.15.0.rc0.40.gaefcc5f6f