]> git.proxmox.com Git - mirror_qemu.git/commitdiff
virtio-ccw: fix ring sizing
authorMichael S. Tsirkin <mst@redhat.com>
Thu, 12 Jan 2017 21:26:22 +0000 (23:26 +0200)
committerCornelia Huck <cornelia.huck@de.ibm.com>
Fri, 20 Jan 2017 09:02:02 +0000 (10:02 +0100)
Current code seems to assume ring size is
always decreased but this is not required by spec:
what spec says is just that size can not exceed
the maximum. Fix it up.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <1484256243-1982-1-git-send-email-mst@redhat.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
hw/s390x/virtio-ccw.c
hw/virtio/virtio.c
include/hw/virtio/virtio.h

index 07650683f703f05825125c6d71bb7753f9fec729..63c46373fbb458bbed6dd39ab31102e4fb7b6986 100644 (file)
@@ -149,7 +149,7 @@ static int virtio_ccw_set_vqs(SubchDev *sch, VqInfoBlock *info,
     } else {
         if (info) {
             /* virtio-1 allows changing the ring size. */
-            if (virtio_queue_get_num(vdev, index) < num) {
+            if (virtio_queue_get_max_num(vdev, index) < num) {
                 /* Fail if we exceed the maximum number. */
                 return -EINVAL;
             }
index aa4f38f50a4d9c1368f3471cb466e15d6d9612a7..94d7dbae6c58fee050b0078b5b0d143c9a996ac6 100644 (file)
@@ -1262,6 +1262,11 @@ int virtio_queue_get_num(VirtIODevice *vdev, int n)
     return vdev->vq[n].vring.num;
 }
 
+int virtio_queue_get_max_num(VirtIODevice *vdev, int n)
+{
+    return vdev->vq[n].vring.num_default;
+}
+
 int virtio_get_num_queues(VirtIODevice *vdev)
 {
     int i;
index e5541c61f770b1a668f0f2483f026f7a84b92c80..6523bacd2f6ff30c644f0e131c87b32302b6e92e 100644 (file)
@@ -228,6 +228,7 @@ void virtio_queue_set_addr(VirtIODevice *vdev, int n, hwaddr addr);
 hwaddr virtio_queue_get_addr(VirtIODevice *vdev, int n);
 void virtio_queue_set_num(VirtIODevice *vdev, int n, int num);
 int virtio_queue_get_num(VirtIODevice *vdev, int n);
+int virtio_queue_get_max_num(VirtIODevice *vdev, int n);
 int virtio_get_num_queues(VirtIODevice *vdev);
 void virtio_queue_set_rings(VirtIODevice *vdev, int n, hwaddr desc,
                             hwaddr avail, hwaddr used);