qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: peter.maydell@linaro.org
Cc: borntraeger@de.ibm.com, agraf@suse.de, jfrei@linux.vnet.ibm.com,
	qemu-devel@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
	Cornelia Huck <cornelia.huck@de.ibm.com>
Subject: [Qemu-devel] [PULL 12/12] virtio-ccw: fix ring sizing
Date: Tue, 17 Jan 2017 09:56:45 +0100	[thread overview]
Message-ID: <20170117085645.4267-13-cornelia.huck@de.ibm.com> (raw)
In-Reply-To: <20170117085645.4267-1-cornelia.huck@de.ibm.com>

From: "Michael S. Tsirkin" <mst@redhat.com>

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      | 2 +-
 hw/virtio/virtio.c         | 5 +++++
 include/hw/virtio/virtio.h | 1 +
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 07650683f7..63c46373fb 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -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;
             }
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index aa4f38f50a..94d7dbae6c 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -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;
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index e5541c61f7..6523bacd2f 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -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);
-- 
2.11.0

  parent reply	other threads:[~2017-01-17  8:57 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-17  8:56 [Qemu-devel] [PULL 00/12] s390x update Cornelia Huck
2017-01-17  8:56 ` [Qemu-devel] [PULL 01/12] s390x: remove double compat statement Cornelia Huck
2017-01-17  8:56 ` [Qemu-devel] [PULL 02/12] s390x: add compat machine for 2.9 Cornelia Huck
2017-01-17  8:56 ` [Qemu-devel] [PULL 03/12] s390x/kvm: use kvm_gsi_routing_enabled in flic Cornelia Huck
2017-01-17  8:56 ` [Qemu-devel] [PULL 04/12] s390x/pci: make S390PCIIOMMU inherit Object Cornelia Huck
2017-01-17  8:56 ` [Qemu-devel] [PULL 05/12] s390x/pci: dynamically allocate iommu Cornelia Huck
2017-01-17  8:56 ` [Qemu-devel] [PULL 06/12] s390x/pci: change the device array to a list Cornelia Huck
2017-01-17  8:56 ` [Qemu-devel] [PULL 07/12] s390x/pci: optimize calling s390_get_phb() Cornelia Huck
2017-01-17  8:56 ` [Qemu-devel] [PULL 08/12] s390x/pci: PCI multibus bridge handling Cornelia Huck
2017-01-17  8:56 ` [Qemu-devel] [PULL 09/12] s390x/pci: use hashtable to look up zpci via fh Cornelia Huck
2017-01-17  8:56 ` [Qemu-devel] [PULL 10/12] s390x/pci: handle PCIBridge bus number Cornelia Huck
2017-01-17  8:56 ` [Qemu-devel] [PULL 11/12] s390x/pci: merge msix init functions Cornelia Huck
2017-01-17  8:56 ` Cornelia Huck [this message]
2017-01-19 18:32 ` [Qemu-devel] [PULL 00/12] s390x update Peter Maydell
2017-01-20  9:21   ` Cornelia Huck
2017-01-20  9:52     ` Thomas Huth
2017-01-20  9:58       ` Thomas Huth
2017-01-20 10:00       ` Cornelia Huck
2017-01-20 10:04         ` Thomas Huth
2017-01-20 10:11           ` Cornelia Huck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170117085645.4267-13-cornelia.huck@de.ibm.com \
    --to=cornelia.huck@de.ibm.com \
    --cc=agraf@suse.de \
    --cc=borntraeger@de.ibm.com \
    --cc=jfrei@linux.vnet.ibm.com \
    --cc=mst@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).