[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 33/86] vhost: Change the sequence of device start
From: |
Michael S. Tsirkin |
Subject: |
[PULL 33/86] vhost: Change the sequence of device start |
Date: |
Mon, 31 Oct 2022 08:52:18 -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 | 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;
--
MST
- [PULL 21/86] bios-tables-test: add test for number of cores > 255, (continued)
- [PULL 21/86] bios-tables-test: add test for number of cores > 255, Michael S. Tsirkin, 2022/10/31
- [PULL 23/86] tests/acpi: virt: allow acpi MADT and FADT changes, Michael S. Tsirkin, 2022/10/31
- [PULL 27/86] hw/pci: PCIe Data Object Exchange emulation, Michael S. Tsirkin, 2022/10/31
- [PULL 25/86] acpi: arm/virt: madt: bump to revision 4 accordingly to ACPI 6.0 Errata A, Michael S. Tsirkin, 2022/10/31
- [PULL 29/86] hw/cxl/cdat: CXL CDAT Data Object Exchange implementation, Michael S. Tsirkin, 2022/10/31
- [PULL 22/86] tests/acpi: update tables for new core count test, Michael S. Tsirkin, 2022/10/31
- [PULL 18/86] hw/smbios: add core_count2 to smbios table type 4, Michael S. Tsirkin, 2022/10/31
- [PULL 30/86] hw/mem/cxl-type3: Add CXL CDAT Data Object Exchange, Michael S. Tsirkin, 2022/10/31
- [PULL 24/86] acpi: fadt: support revision 6.0 of the ACPI specification, Michael S. Tsirkin, 2022/10/31
- [PULL 32/86] tests/qtest/cxl-test: Remove temporary directories after testing, Michael S. Tsirkin, 2022/10/31
- [PULL 33/86] vhost: Change the sequence of device start,
Michael S. Tsirkin <=
- [PULL 19/86] bios-tables-test: teach test to use smbios 3.0 tables, Michael S. Tsirkin, 2022/10/31
- [PULL 26/86] tests/acpi: virt: update ACPI MADT and FADT binaries, Michael S. Tsirkin, 2022/10/31
- [PULL 31/86] hw/pci-bridge/cxl-upstream: Add a CDAT table access DOE, Michael S. Tsirkin, 2022/10/31
- [PULL 35/86] hw/virtio/virtio-iommu-pci: Enforce the device is plugged on the root bus, Michael S. Tsirkin, 2022/10/31
- [PULL 36/86] virtio: re-order vm_running and use_started checks, Michael S. Tsirkin, 2022/10/31
- [PULL 37/86] virtio: introduce __virtio_queue_reset(), Michael S. Tsirkin, 2022/10/31
- [PULL 38/86] virtio: introduce virtio_queue_reset(), Michael S. Tsirkin, 2022/10/31
- [PULL 28/86] hw/mem/cxl-type3: Add MSIX support, Michael S. Tsirkin, 2022/10/31
- [PULL 34/86] vhost-user: Support vhost_dev_start, Michael S. Tsirkin, 2022/10/31
- [PULL 39/86] virtio: introduce virtio_queue_enable(), Michael S. Tsirkin, 2022/10/31