All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dima Stepanov <dimastep@yandex-team.ru>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, lvivier@redhat.com, thuth@redhat.com,
	qemu-block@nongnu.org, mst@redhat.com, stefanha@gmail.com,
	jasowang@redhat.com, dgilbert@redhat.com, mreitz@redhat.com,
	fengli@smartx.com, yc-core@yandex-team.ru, pbonzini@redhat.com,
	raphael.norwitz@nutanix.com
Subject: [PATCH v5 2/7] vhost: check queue state in the vhost_dev_set_log routine
Date: Fri, 11 Sep 2020 11:39:44 +0300	[thread overview]
Message-ID: <6232946d5af09e9775076645909964a6539b8ab5.1599813294.git.dimastep@yandex-team.ru> (raw)
In-Reply-To: <cover.1599813294.git.dimastep@yandex-team.ru>
In-Reply-To: <cover.1599813294.git.dimastep@yandex-team.ru>

If the vhost-user-blk daemon provides only one virtqueue, but device was
added with several queues, then QEMU will send more VHOST-USER command
than expected by daemon side. The vhost_virtqueue_start() routine
handles such case by checking the return value from the
virtio_queue_get_desc_addr() function call. Add the same check to the
vhost_dev_set_log() routine.

Signed-off-by: Dima Stepanov <dimastep@yandex-team.ru>
Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
---
 hw/virtio/vhost.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index ffef7ab..a08b7d8 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -825,12 +825,24 @@ static int vhost_dev_set_features(struct vhost_dev *dev,
 static int vhost_dev_set_log(struct vhost_dev *dev, bool enable_log)
 {
     int r, i, idx;
+    hwaddr addr;
+
     r = vhost_dev_set_features(dev, enable_log);
     if (r < 0) {
         goto err_features;
     }
     for (i = 0; i < dev->nvqs; ++i) {
         idx = dev->vhost_ops->vhost_get_vq_index(dev, dev->vq_index + i);
+        addr = virtio_queue_get_desc_addr(dev->vdev, idx);
+        if (!addr) {
+            /*
+             * The queue might not be ready for start. If this
+             * is the case there is no reason to continue the process.
+             * The similar logic is used by the vhost_virtqueue_start()
+             * routine.
+             */
+            continue;
+        }
         r = vhost_virtqueue_set_addr(dev, dev->vqs + i, idx,
                                      enable_log);
         if (r < 0) {
-- 
2.7.4



  parent reply	other threads:[~2020-09-11  8:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-11  8:39 [PATCH v5 0/7] vhost-user-blk: fix the migration issue and enhance qtests Dima Stepanov
2020-09-11  8:39 ` [PATCH v5 1/7] vhost: recheck dev state in the vhost_migration_log routine Dima Stepanov
2020-09-11  8:39 ` Dima Stepanov [this message]
2020-09-11  8:39 ` [PATCH v5 3/7] tests/qtest/vhost-user-test: prepare the tests for adding new dev class Dima Stepanov
2020-09-11  8:39 ` [PATCH v5 4/7] tests/qtest/libqos/virtio-blk: add support for vhost-user-blk Dima Stepanov
2020-09-15  1:23   ` Raphael Norwitz
2020-09-16 22:13     ` Dima Stepanov
2020-09-21 23:04       ` Raphael Norwitz
2020-09-22  0:54         ` Dima Stepanov
2020-09-11  8:39 ` [PATCH v5 5/7] tests/qtest/vhost-user-test: add support for the vhost-user-blk device Dima Stepanov
2020-09-11  8:39 ` [PATCH v5 6/7] tests/qtest/vhost-user-test: add migrate_reconnect test Dima Stepanov
2020-09-11  8:39 ` [PATCH v5 7/7] tests/qtest/vhost-user-test: enable the reconnect tests Dima Stepanov
2020-09-24 11:26 ` [PATCH v5 0/7] vhost-user-blk: fix the migration issue and enhance qtests Michael S. Tsirkin
2020-09-27  6:48   ` Dima Stepanov
2020-09-29  7:13     ` Michael S. Tsirkin
2020-09-29  9:48       ` Dima Stepanov
2020-10-07 13:52         ` Dima Stepanov

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=6232946d5af09e9775076645909964a6539b8ab5.1599813294.git.dimastep@yandex-team.ru \
    --to=dimastep@yandex-team.ru \
    --cc=dgilbert@redhat.com \
    --cc=fengli@smartx.com \
    --cc=jasowang@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=raphael.norwitz@nutanix.com \
    --cc=stefanha@gmail.com \
    --cc=thuth@redhat.com \
    --cc=yc-core@yandex-team.ru \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.