qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PULL 37/57] virtio-s390: introduce virtio_s390_device_plug


From: Michael S. Tsirkin
Subject: [Qemu-devel] [PULL 37/57] virtio-s390: introduce virtio_s390_device_plugged()
Date: Sun, 31 May 2015 20:36:39 +0200

From: Jason Wang <address@hidden>

This patch introduce a virtio-s390 specific device_plugged() function
and doing the number of virtqueue validation inside.

Cc: Alexander Graf <address@hidden>
Cc: Richard Henderson <address@hidden>
Signed-off-by: Jason Wang <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]