From patchwork Tue Oct 27 08:48:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 536484 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0B142141352 for ; Tue, 27 Oct 2015 19:48:49 +1100 (AEDT) Received: from localhost ([::1]:58165 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zqzvy-0005Qj-Na for incoming@patchwork.ozlabs.org; Tue, 27 Oct 2015 04:48:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35406) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZqzvO-0004FX-1z for qemu-devel@nongnu.org; Tue, 27 Oct 2015 04:48:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZqzvN-0003bq-6k for qemu-devel@nongnu.org; Tue, 27 Oct 2015 04:48:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50280) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZqzvN-0003bm-1W for qemu-devel@nongnu.org; Tue, 27 Oct 2015 04:48:09 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id B3E5F461D6 for ; Tue, 27 Oct 2015 08:48:08 +0000 (UTC) Received: from redhat.com (ovpn-116-58.ams2.redhat.com [10.36.116.58]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t9R8m6dn016096; Tue, 27 Oct 2015 04:48:07 -0400 Date: Tue, 27 Oct 2015 10:48:06 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1445935663-31971-6-git-send-email-mst@redhat.com> References: <1445935663-31971-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1445935663-31971-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Igor Mammedov , Paolo Bonzini Subject: [Qemu-devel] [PATCH 5/6] virtio-scsi: convert to virtqueue_map X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Note: virtqueue_map already validates input so virtio-scsi does not have to. Signed-off-by: Michael S. Tsirkin Reviewed-by: Igor Mammedov --- hw/scsi/virtio-scsi.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 1c33f14..33bd25a 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -207,20 +207,8 @@ static void *virtio_scsi_load_request(QEMUFile *f, SCSIRequest *sreq) assert(n < vs->conf.num_queues); req = virtio_scsi_init_req(s, vs->cmd_vqs[n]); qemu_get_buffer(f, (unsigned char *)&req->elem, sizeof(req->elem)); - /* TODO: add a way for SCSIBusInfo's load_request to fail, - * and fail migration instead of asserting here. - * When we do, we might be able to re-enable NDEBUG below. - */ -#ifdef NDEBUG -#error building with NDEBUG is not supported -#endif - assert(req->elem.in_num <= ARRAY_SIZE(req->elem.in_sg)); - assert(req->elem.out_num <= ARRAY_SIZE(req->elem.out_sg)); - - virtqueue_map_sg(req->elem.in_sg, req->elem.in_addr, - req->elem.in_num, 1); - virtqueue_map_sg(req->elem.out_sg, req->elem.out_addr, - req->elem.out_num, 0); + + virtqueue_map(&req->elem); if (virtio_scsi_parse_req(req, sizeof(VirtIOSCSICmdReq) + vs->cdb_size, sizeof(VirtIOSCSICmdResp) + vs->sense_size) < 0) {