All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yajun Wu <yajunw@nvidia.com>
To: <qemu-devel@nongnu.org>, <mst@redhat.com>, <yajunw@nvidia.com>,
	<parav@nvidia.com>
Subject: [PATCH v3 1/2] vhost: Change the sequence of device start
Date: Mon, 17 Oct 2022 14:44:51 +0800	[thread overview]
Message-ID: <20221017064452.1226514-2-yajunw@nvidia.com> (raw)
In-Reply-To: <20221017064452.1226514-1-yajunw@nvidia.com>

This patch is part of adding vhost-user vhost_dev_start support. The
motivation is to improve backend configuration speed and reduce live
migration VM downtime.

Moving the device start routines after finishing all the necessary device
and VQ configuration, further aligning to the virtio specification for
"device initialization sequence".

Following patch will add vhost-user vhost_dev_start support.

Signed-off-by: Yajun Wu <yajunw@nvidia.com>
Acked-by: Parav Pandit <parav@nvidia.com>

---
 hw/block/vhost-user-blk.c | 18 +++++++++++-------
 hw/net/vhost_net.c        | 12 ++++++------
 2 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index 84902dde17..f4deb8cd5d 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -164,13 +164,6 @@ static int vhost_user_blk_start(VirtIODevice *vdev, Error **errp)
         goto err_guest_notifiers;
     }
 
-    ret = vhost_dev_start(&s->dev, vdev);
-    if (ret < 0) {
-        error_setg_errno(errp, -ret, "Error starting vhost");
-        goto err_guest_notifiers;
-    }
-    s->started_vu = true;
-
     /* guest_notifier_mask/pending not used yet, so just unmask
      * everything here. virtio-pci will do the right thing by
      * enabling/disabling irqfd.
@@ -179,9 +172,20 @@ static int vhost_user_blk_start(VirtIODevice *vdev, Error **errp)
         vhost_virtqueue_mask(&s->dev, vdev, i, false);
     }
 
+    s->dev.vq_index_end = s->dev.nvqs;
+    ret = vhost_dev_start(&s->dev, vdev);
+    if (ret < 0) {
+        error_setg_errno(errp, -ret, "Error starting vhost");
+        goto err_guest_notifiers;
+    }
+    s->started_vu = true;
+
     return ret;
 
 err_guest_notifiers:
+    for (i = 0; i < s->dev.nvqs; i++) {
+        vhost_virtqueue_mask(&s->dev, vdev, i, true);
+    }
     k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false);
 err_host_notifiers:
     vhost_dev_disable_notifiers(&s->dev, vdev);
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index d28f8b974b..d6924f5e57 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -387,21 +387,21 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
         } else {
             peer = qemu_get_peer(ncs, n->max_queue_pairs);
         }
-        r = vhost_net_start_one(get_vhost_net(peer), dev);
-
-        if (r < 0) {
-            goto err_start;
-        }
 
         if (peer->vring_enable) {
             /* restore vring enable state */
             r = vhost_set_vring_enable(peer, peer->vring_enable);
 
             if (r < 0) {
-                vhost_net_stop_one(get_vhost_net(peer), dev);
                 goto err_start;
             }
         }
+
+        r = vhost_net_start_one(get_vhost_net(peer), dev);
+        if (r < 0) {
+            vhost_net_stop_one(get_vhost_net(peer), dev);
+            goto err_start;
+        }
     }
 
     return 0;
-- 
2.27.0



  reply	other threads:[~2022-10-17  7:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-29  2:25 [PATCH 0/2] vhost-user: Support vhost_dev_start Yajun Wu
2022-06-29  2:25 ` [PATCH 1/2] vhost: Change the sequence of device start Yajun Wu
2022-06-29  2:25 ` [PATCH 2/2] vhost-user: Support vhost_dev_start Yajun Wu
2022-07-12 10:54 ` [PATCH v2 0/2] " Yajun Wu
2022-07-12 10:55   ` [PATCH v2 1/2] vhost: Change the sequence of device start Yajun Wu
2022-07-12 10:55   ` [PATCH v2 2/2] vhost-user: Support vhost_dev_start Yajun Wu
2022-07-26 14:56   ` [PATCH v2 0/2] " Michael S. Tsirkin
2022-09-05  4:58     ` Yajun Wu
2022-10-12 10:10       ` Yajun Wu
2022-10-17  6:44 ` [PATCH v3 " Yajun Wu
2022-10-17  6:44   ` Yajun Wu [this message]
2022-11-05 16:43     ` [PATCH v3 1/2] vhost: Change the sequence of device start Michael S. Tsirkin
2022-10-17  6:44   ` [PATCH v3 2/2] vhost-user: Support vhost_dev_start Yajun Wu
2022-11-04  7:11   ` [PATCH v3 0/2] " Michael S. Tsirkin
2022-11-04  7:58     ` Michael S. Tsirkin
2022-11-07  4:08 ` [PATCH v4 " Yajun Wu
2022-11-07  4:08   ` [PATCH v4 1/2] vhost: Change the sequence of device start Yajun Wu
2022-11-07  4:08   ` [PATCH v4 2/2] vhost-user: Support vhost_dev_start Yajun Wu

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=20221017064452.1226514-2-yajunw@nvidia.com \
    --to=yajunw@nvidia.com \
    --cc=mst@redhat.com \
    --cc=parav@nvidia.com \
    --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 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.