Skip to content

Commit

Permalink
virtio-s390: introduce virtio_s390_device_plugged()
Browse files Browse the repository at this point in the history
This patch introduce a virtio-s390 specific device_plugged() function
and doing the number of virtqueue validation inside.

Cc: Alexander Graf <agraf@suse.de>
Cc: Richard Henderson <rth@twiddle.net>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
jasowang authored and mstsirkin committed May 31, 2015
1 parent 74c8529 commit d820331
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions hw/s390x/s390-virtio-bus.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit d820331

Please sign in to comment.