All of lore.kernel.org
 help / color / mirror / Atom feed
From: elohimes@gmail.com
To: mst@redhat.com, groug@kaod.org, dgilbert@redhat.com
Cc: Xie Yongji <xieyongji@baidu.com>, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 1/5] virtio: Set "start_on_kick" on virtio_set_features()
Date: Wed, 29 May 2019 15:09:51 +0800	[thread overview]
Message-ID: <20190529070955.25565-2-xieyongji@baidu.com> (raw)
In-Reply-To: <20190529070955.25565-1-xieyongji@baidu.com>

From: Xie Yongji <xieyongji@baidu.com>

The guest feature is not set correctly on virtio_reset() and
virtio_init(). So we should not use it to set "start_on_kick" at that
point. This patch set "start_on_kick" on virtio_set_features() instead.

Signed-off-by: Xie Yongji <xieyongji@baidu.com>
---
 hw/virtio/virtio.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 4805727b53..fc8fca81ad 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1214,8 +1214,7 @@ void virtio_reset(void *opaque)
         k->reset(vdev);
     }
 
-    vdev->start_on_kick = (virtio_host_has_feature(vdev, VIRTIO_F_VERSION_1) &&
-                          !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1));
+    vdev->start_on_kick = false;
     vdev->started = false;
     vdev->broken = false;
     vdev->guest_features = 0;
@@ -2069,14 +2068,21 @@ int virtio_set_features(VirtIODevice *vdev, uint64_t val)
         return -EINVAL;
     }
     ret = virtio_set_features_nocheck(vdev, val);
-    if (!ret && virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) {
-        /* VIRTIO_RING_F_EVENT_IDX changes the size of the caches.  */
-        int i;
-        for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
-            if (vdev->vq[i].vring.num != 0) {
-                virtio_init_region_cache(vdev, i);
+    if (!ret) {
+        if (virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) {
+            /* VIRTIO_RING_F_EVENT_IDX changes the size of the caches.  */
+            int i;
+            for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
+                if (vdev->vq[i].vring.num != 0) {
+                    virtio_init_region_cache(vdev, i);
+                }
             }
         }
+
+        if (virtio_host_has_feature(vdev, VIRTIO_F_VERSION_1) &&
+            !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
+            vdev->start_on_kick = true;
+        }
     }
     return ret;
 }
@@ -2331,8 +2337,7 @@ void virtio_init(VirtIODevice *vdev, const char *name,
             g_malloc0(sizeof(*vdev->vector_queues) * nvectors);
     }
 
-    vdev->start_on_kick = (virtio_host_has_feature(vdev, VIRTIO_F_VERSION_1) &&
-                          !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1));
+    vdev->start_on_kick = false;
     vdev->started = false;
     vdev->device_id = device_id;
     vdev->status = 0;
-- 
2.17.1



  reply	other threads:[~2019-05-29  7:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-29  7:09 [Qemu-devel] [PATCH 0/5] virtio: fix some issues of "started" and "start_on_kick" flag elohimes
2019-05-29  7:09 ` elohimes [this message]
2019-06-03 16:53   ` [Qemu-devel] [PATCH 1/5] virtio: Set "start_on_kick" on virtio_set_features() Greg Kurz
2019-06-04  1:41     ` Yongji Xie
2019-05-29  7:09 ` [Qemu-devel] [PATCH 2/5] virtio: Migrate the "start_on_kick" flag elohimes
2019-06-03 20:16   ` Greg Kurz
2019-06-03 21:03     ` Michael S. Tsirkin
2019-06-03 21:25       ` Greg Kurz
2019-06-03 21:51         ` Michael S. Tsirkin
2019-06-04  2:15     ` Yongji Xie
2019-05-29  7:09 ` [Qemu-devel] [PATCH 3/5] virtio: Make sure we get correct state of device on handle_aio_output() elohimes
2019-05-29  7:09 ` [Qemu-devel] [PATCH 4/5] virtio: Don't change "started" flag on virtio_vmstate_change() elohimes
2019-05-29  7:09 ` [Qemu-devel] [PATCH 5/5] virtio: add "use-started" property elohimes
2019-06-03 20:49   ` Greg Kurz
2019-06-04  2:37     ` Yongji Xie

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=20190529070955.25565-2-xieyongji@baidu.com \
    --to=elohimes@gmail.com \
    --cc=dgilbert@redhat.com \
    --cc=groug@kaod.org \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=xieyongji@baidu.com \
    /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.