From patchwork Mon Jun 1 12:24:15 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: 478959 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 5BF8A140E41 for ; Mon, 1 Jun 2015 22:38:40 +1000 (AEST) Received: from localhost ([::1]:52017 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzOzG-0007WU-F9 for incoming@patchwork.ozlabs.org; Mon, 01 Jun 2015 08:38:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34565) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzOlV-0008Gh-O5 for qemu-devel@nongnu.org; Mon, 01 Jun 2015 08:24:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YzOlP-0007id-C7 for qemu-devel@nongnu.org; Mon, 01 Jun 2015 08:24:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41875) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzOlP-0007iY-7M for qemu-devel@nongnu.org; Mon, 01 Jun 2015 08:24:19 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id D7B643679C2; Mon, 1 Jun 2015 12:24:18 +0000 (UTC) Received: from redhat.com (ovpn-116-67.ams2.redhat.com [10.36.116.67]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t51COGqw018345; Mon, 1 Jun 2015 08:24:16 -0400 Date: Mon, 1 Jun 2015 14:24:15 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1433161230-29421-36-git-send-email-mst@redhat.com> References: <1433161230-29421-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1433161230-29421-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell , Jason Wang , Alexander Graf , Christian Borntraeger , Cornelia Huck , Richard Henderson Subject: [Qemu-devel] [PULL v2 35/60] virtio-ccw: validate the number of queues against bus limitation 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 From: Jason Wang Cc: Cornelia Huck Cc: Christian Borntraeger Cc: Richard Henderson Cc: Alexander Graf Signed-off-by: Jason Wang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/s390x/virtio-ccw.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index 60d60d6..ef90fed 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -1381,7 +1381,16 @@ static int virtio_ccw_load_config(DeviceState *d, QEMUFile *f) static void virtio_ccw_device_plugged(DeviceState *d, Error **errp) { VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); + VirtIODevice *vdev = virtio_bus_get_device(&dev->bus); SubchDev *sch = dev->sch; + int n = virtio_get_num_queues(vdev); + + if (virtio_get_num_queues(vdev) > VIRTIO_CCW_QUEUE_MAX) { + error_setg(errp, "The nubmer of virtqueues %d " + "exceeds ccw limit %d", n, + VIRTIO_CCW_QUEUE_MAX); + return; + } sch->id.cu_model = virtio_bus_get_vdev_id(&dev->bus);