From patchwork Wed Jul 18 15:07:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 171727 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C8CFB2C009E for ; Thu, 19 Jul 2012 01:50:36 +1000 (EST) Received: from localhost ([::1]:35896 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrVsR-0006zW-80 for incoming@patchwork.ozlabs.org; Wed, 18 Jul 2012 11:09:23 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrVrt-0005tn-3e for qemu-devel@nongnu.org; Wed, 18 Jul 2012 11:08:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SrVrr-0000np-IY for qemu-devel@nongnu.org; Wed, 18 Jul 2012 11:08:48 -0400 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:48097) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrVrr-0000na-Ae for qemu-devel@nongnu.org; Wed, 18 Jul 2012 11:08:47 -0400 Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 18 Jul 2012 16:08:46 +0100 Received: from d06nrmr1806.portsmouth.uk.ibm.com (9.149.39.193) by e06smtp17.uk.ibm.com (192.168.101.147) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 18 Jul 2012 16:08:44 +0100 Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6IF8ivq2904108 for ; Wed, 18 Jul 2012 16:08:44 +0100 Received: from d06av03.portsmouth.uk.ibm.com (localhost.localdomain [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q6IF8hZW003785 for ; Wed, 18 Jul 2012 09:08:43 -0600 Received: from localhost (sig-9-145-185-169.de.ibm.com [9.145.185.169]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q6IF8hKm003775; Wed, 18 Jul 2012 09:08:43 -0600 From: Stefan Hajnoczi To: Date: Wed, 18 Jul 2012 16:07:50 +0100 Message-Id: <1342624074-24650-24-git-send-email-stefanha@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1342624074-24650-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1342624074-24650-1-git-send-email-stefanha@linux.vnet.ibm.com> x-cbid: 12071815-0542-0000-0000-00000280015F X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 195.75.94.113 Cc: Kevin Wolf , Anthony Liguori , Stefan Hajnoczi , kvm@vger.kernel.org, "Michael S. Tsirkin" , Khoa Huynh , Paolo Bonzini , Asias He Subject: [Qemu-devel] [RFC v9 23/27] virtio-blk: Stub out SCSI commands 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 Signed-off-by: Stefan Hajnoczi --- hw/virtio-blk.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index 51807b5..8734029 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -215,14 +215,8 @@ static void process_request(IOQueue *ioq, struct iovec iov[], unsigned int out_n /* TODO Linux sets the barrier bit even when not advertised! */ uint32_t type = outhdr->type & ~VIRTIO_BLK_T_BARRIER; - - if (unlikely(type & ~(VIRTIO_BLK_T_OUT | VIRTIO_BLK_T_FLUSH))) { - fprintf(stderr, "virtio-blk unsupported request type %#x\n", outhdr->type); - exit(1); - } - struct iocb *iocb; - switch (type & (VIRTIO_BLK_T_OUT | VIRTIO_BLK_T_FLUSH)) { + switch (type & (VIRTIO_BLK_T_OUT | VIRTIO_BLK_T_SCSI_CMD | VIRTIO_BLK_T_FLUSH)) { case VIRTIO_BLK_T_IN: if (unlikely(out_num != 1)) { fprintf(stderr, "virtio-blk invalid read request\n"); @@ -239,6 +233,21 @@ static void process_request(IOQueue *ioq, struct iovec iov[], unsigned int out_n iocb = ioq_rdwr(ioq, false, &iov[1], out_num - 1, outhdr->sector * 512UL); /* TODO is it always 512? */ break; + case VIRTIO_BLK_T_SCSI_CMD: + if (unlikely(in_num == 0)) { + fprintf(stderr, "virtio-blk invalid SCSI command request\n"); + exit(1); + } + + /* TODO support SCSI commands */ + { + VirtIOBlock *s = container_of(ioq, VirtIOBlock, ioqueue); + inhdr->status = VIRTIO_BLK_S_UNSUPP; + vring_push(&s->vring, head, sizeof *inhdr); + virtio_blk_notify_guest(s); + } + return; + case VIRTIO_BLK_T_FLUSH: if (unlikely(in_num != 1 || out_num != 1)) { fprintf(stderr, "virtio-blk invalid flush request\n"); @@ -256,7 +265,7 @@ static void process_request(IOQueue *ioq, struct iovec iov[], unsigned int out_n return; default: - fprintf(stderr, "virtio-blk multiple request type bits set\n"); + fprintf(stderr, "virtio-blk unsupported request type %#x\n", outhdr->type); exit(1); }