[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v4 75/83] vhost: Change the sequence of device start
From: |
Michael S. Tsirkin |
Subject: |
[PULL v4 75/83] vhost: Change the sequence of device start |
Date: |
Mon, 7 Nov 2022 17:53:49 -0500 |
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 v4 65/83] tests: acpi: q35: update expected blobs *.hmat-noinitiators expected HMAT:, (continued)
- [PULL v4 65/83] tests: acpi: q35: update expected blobs *.hmat-noinitiators expected HMAT:, Michael S. Tsirkin, 2022/11/07
- [PULL v4 66/83] tests: Add HMAT AArch64/virt empty table files, Michael S. Tsirkin, 2022/11/07
- [PULL v4 67/83] hw/arm/virt: Enable HMAT on arm virt machine, Michael S. Tsirkin, 2022/11/07
- [PULL v4 68/83] tests: acpi: aarch64/virt: add a test for hmat nodes with no initiators, Michael S. Tsirkin, 2022/11/07
- [PULL v4 69/83] tests: virt: Update expected *.acpihmatvirt tables, Michael S. Tsirkin, 2022/11/07
- [PULL v4 70/83] vfio: move implement of vfio_get_xlat_addr() to memory.c, Michael S. Tsirkin, 2022/11/07
- [PULL v4 71/83] intel-iommu: don't warn guest errors when getting rid2pasid entry, Michael S. Tsirkin, 2022/11/07
- [PULL v4 72/83] intel-iommu: drop VTDBus, Michael S. Tsirkin, 2022/11/07
- [PULL v4 73/83] intel-iommu: convert VTD_PE_GET_FPD_ERR() to be a function, Michael S. Tsirkin, 2022/11/07
- [PULL v4 74/83] intel-iommu: PASID support, Michael S. Tsirkin, 2022/11/07
- [PULL v4 75/83] vhost: Change the sequence of device start,
Michael S. Tsirkin <=
- [PULL v4 76/83] vhost-user: Support vhost_dev_start, Michael S. Tsirkin, 2022/11/07
- [PULL v4 77/83] hw/smbios: add core_count2 to smbios table type 4, Michael S. Tsirkin, 2022/11/07
- [PULL v4 78/83] bios-tables-test: teach test to use smbios 3.0 tables, Michael S. Tsirkin, 2022/11/07
- [PULL v4 79/83] tests/acpi: allow changes for core_count2 test, Michael S. Tsirkin, 2022/11/07
- [PULL v4 80/83] bios-tables-test: add test for number of cores > 255, Michael S. Tsirkin, 2022/11/07
- [PULL v4 81/83] tests/acpi: update tables for new core count test, Michael S. Tsirkin, 2022/11/07
- [PULL v4 82/83] hw/virtio: introduce virtio_device_should_start, Michael S. Tsirkin, 2022/11/07
- [PULL v4 83/83] checkpatch: better pattern for inline comments, Michael S. Tsirkin, 2022/11/07
- Re: [PULL v4 00/83] pci,pc,virtio: features, tests, fixes, cleanups, Michael S. Tsirkin, 2022/11/08