From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47791) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMEnd-0000Ik-B3 for qemu-devel@nongnu.org; Tue, 26 Aug 2014 07:20:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMEnX-0005WM-5b for qemu-devel@nongnu.org; Tue, 26 Aug 2014 07:20:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1784) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMEnW-0005W9-Uk for qemu-devel@nongnu.org; Tue, 26 Aug 2014 07:20:23 -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 (8.14.4/8.14.4) with ESMTP id s7QBKM4X009363 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 26 Aug 2014 07:20:22 -0400 Message-ID: <53FC6D73.8010401@redhat.com> Date: Tue, 26 Aug 2014 13:20:19 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1409034630-22226-1-git-send-email-famz@redhat.com> In-Reply-To: <1409034630-22226-1-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] virtio-scsi: Report error if num_queues is 0 or too large List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Il 26/08/2014 08:30, Fam Zheng ha scritto: > No cmd vq surprises guest (Linux panics in virtscsi_probe), too many > queues abort qemu (in the following virtio_add_queue). > > Signed-off-by: Fam Zheng > --- > hw/scsi/virtio-scsi.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c > index 2dd9255..86aba88 100644 > --- a/hw/scsi/virtio-scsi.c > +++ b/hw/scsi/virtio-scsi.c > @@ -699,6 +699,12 @@ void virtio_scsi_common_realize(DeviceState *dev, Error **errp, > virtio_init(vdev, "virtio-scsi", VIRTIO_ID_SCSI, > sizeof(VirtIOSCSIConfig)); > > + if (s->conf.num_queues <= 0 || s->conf.num_queues > VIRTIO_PCI_QUEUE_MAX) { > + error_setg(errp, "Invalid number of queues (= %" PRId32 "), " > + "must be a positive integer less than %d.", > + s->conf.num_queues, VIRTIO_PCI_QUEUE_MAX); > + return; > + } > s->cmd_vqs = g_malloc0(s->conf.num_queues * sizeof(VirtQueue *)); > s->sense_size = VIRTIO_SCSI_SENSE_SIZE; > s->cdb_size = VIRTIO_SCSI_CDB_SIZE; > Thanks, applying to scsi-next. Paolo