[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v3 80/81] vhost: Change the sequence of device start
From: |
Michael S. Tsirkin |
Subject: |
[PULL v3 80/81] vhost: Change the sequence of device start |
Date: |
Sat, 5 Nov 2022 13:19:20 -0400 |
From: Yajun Wu <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>
Message-Id: <20221017064452.1226514-2-yajunw@nvidia.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/block/vhost-user-blk.c | 18 +++++++++++-------
hw/net/vhost_net.c | 11 +++++------
2 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index 13bf5cc47a..28409c90f7 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -168,13 +168,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.
@@ -183,9 +176,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 53b2fac4f6..feda448878 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -389,21 +389,20 @@ 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) {
+ goto err_start;
+ }
}
return 0;
--
MST
- [PULL v3 37/81] virtio-pci: support queue enable, (continued)
- [PULL v3 37/81] virtio-pci: support queue enable, Michael S. Tsirkin, 2022/11/05
- [PULL v3 40/81] vhost-net: vhost-kernel: introduce vhost_net_virtqueue_reset(), Michael S. Tsirkin, 2022/11/05
- [PULL v3 46/81] virtio-net: enable vq reset feature, Michael S. Tsirkin, 2022/11/05
- [PULL v3 45/81] vhost: vhost-kernel: enable vq reset feature, Michael S. Tsirkin, 2022/11/05
- [PULL v3 54/81] acpi: add get_dev_aml_func() helper, Michael S. Tsirkin, 2022/11/05
- [PULL v3 52/81] tests: acpi: update expected DSDT after ISA bridge is moved directly under PCI host bridge, Michael S. Tsirkin, 2022/11/05
- [PULL v3 63/81] hw/i386/pc.c: CXL Fixed Memory Window should not reserve e820 in bios, Michael S. Tsirkin, 2022/11/05
- [PULL v3 66/81] hw/i386/acpi-build: Resolve north rather than south bridges, Michael S. Tsirkin, 2022/11/05
- [PULL v3 70/81] tests: acpi: q35: update expected blobs *.hmat-noinitiators expected HMAT:, Michael S. Tsirkin, 2022/11/05
- [PULL v3 76/81] intel-iommu: don't warn guest errors when getting rid2pasid entry, Michael S. Tsirkin, 2022/11/05
- [PULL v3 80/81] vhost: Change the sequence of device start,
Michael S. Tsirkin <=
- [PULL v3 41/81] vhost-net: vhost-kernel: introduce vhost_net_virtqueue_restart(), Michael S. Tsirkin, 2022/11/05
- [PULL v3 50/81] tests: acpi: whitelist DSDT before generating PCI-ISA bridge AML automatically, Michael S. Tsirkin, 2022/11/05
- [PULL v3 42/81] virtio-net: introduce flush_or_purge_queued_packets(), Michael S. Tsirkin, 2022/11/05
- [PULL v3 56/81] tests: acpi: update expected blobs, Michael S. Tsirkin, 2022/11/05
- [PULL v3 57/81] tests: acpi: pc/q35 whitelist DSDT before \_GPE cleanup, Michael S. Tsirkin, 2022/11/05
- [PULL v3 28/81] hw/cxl/cdat: CXL CDAT Data Object Exchange implementation, Michael S. Tsirkin, 2022/11/05
- [PULL v3 72/81] hw/arm/virt: Enable HMAT on arm virt machine, Michael S. Tsirkin, 2022/11/05