From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzOlX-0008K5-6x for qemu-devel@nongnu.org; Mon, 01 Jun 2015 08:24:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YzOlW-0007ke-7p for qemu-devel@nongnu.org; Mon, 01 Jun 2015 08:24:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44083) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzOlW-0007kZ-3p for qemu-devel@nongnu.org; Mon, 01 Jun 2015 08:24:26 -0400 Date: Mon, 1 Jun 2015 14:24:22 +0200 From: "Michael S. Tsirkin" Message-ID: <1433161230-29421-38-git-send-email-mst@redhat.com> References: <1433161230-29421-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1433161230-29421-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL v2 37/60] virtio-s390: introduce virtio_s390_device_plugged() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Jason Wang , Alexander Graf , Richard Henderson From: Jason Wang This patch introduce a virtio-s390 specific device_plugged() function and doing the number of virtqueue validation inside. Cc: Alexander Graf Cc: Richard Henderson Signed-off-by: Jason Wang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/s390x/s390-virtio-bus.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c index 0748e30..8a6e27e 100644 --- a/hw/s390x/s390-virtio-bus.c +++ b/hw/s390x/s390-virtio-bus.c @@ -529,6 +529,19 @@ static void virtio_s390_notify(DeviceState *d, uint16_t vector) s390_virtio_irq(0, token); } +static void virtio_s390_device_plugged(DeviceState *d, Error **errp) +{ + VirtIOS390Device *dev = to_virtio_s390_device(d); + VirtIODevice *vdev = virtio_bus_get_device(&dev->bus); + int n = virtio_get_num_queues(vdev); + + if (n > VIRTIO_S390_QUEUE_MAX) { + error_setg(errp, "The nubmer of virtqueues %d " + "exceeds s390 limit %d", n, + VIRTIO_S390_QUEUE_MAX); + } +} + /**************** S390 Virtio Bus Device Descriptions *******************/ static void s390_virtio_net_class_init(ObjectClass *klass, void *data) @@ -722,6 +735,7 @@ static void virtio_s390_bus_class_init(ObjectClass *klass, void *data) BusClass *bus_class = BUS_CLASS(klass); bus_class->max_dev = 1; k->notify = virtio_s390_notify; + k->device_plugged = virtio_s390_device_plugged; } static const TypeInfo virtio_s390_bus_info = { -- MST