[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 08/18] vdpa: move backend_cap to vhost_vdpa_shared
From: |
Eugenio Pérez |
Subject: |
[RFC PATCH 08/18] vdpa: move backend_cap to vhost_vdpa_shared |
Date: |
Thu, 19 Oct 2023 16:34:45 +0200 |
Next patches will register the vhost_vdpa memory listener while the VM
is migrating at the destination, so we can map the memory to the device
before stopping the VM at the source. The main goal is to reduce the
downtime.
However, the destination QEMU is unaware of which vhost_vdpa device will
register its memory_listener. If the source guest has CVQ enabled, it
will be the CVQ device. Otherwise, it will be the first one.
Move the backend_cap member to VhostVDPAShared so all vhost_vdpa can use
it, rather than always in the first / last vhost_vdpa.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
include/hw/virtio/vhost-vdpa.h | 3 +++
hw/virtio/vhost-vdpa.c | 8 +++++---
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
index 05219bbcf7..11ac14085a 100644
--- a/include/hw/virtio/vhost-vdpa.h
+++ b/include/hw/virtio/vhost-vdpa.h
@@ -38,6 +38,9 @@ typedef struct vhost_vdpa_shared {
/* IOVA mapping used by the Shadow Virtqueue */
VhostIOVATree *iova_tree;
+ /* Copy of backend features */
+ uint64_t backend_cap;
+
bool iotlb_batch_begin_sent;
/* Vdpa must send shadow addresses as IOTLB key for data queues, not GPA */
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 3da5a19a9e..124323de43 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -160,7 +160,7 @@ static void vhost_vdpa_listener_begin_batch(struct
vhost_vdpa *v)
static void vhost_vdpa_iotlb_batch_begin_once(struct vhost_vdpa *v)
{
- if (v->dev->backend_cap & (0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH) &&
+ if (v->shared->backend_cap & (0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH) &&
!v->shared->iotlb_batch_begin_sent) {
vhost_vdpa_listener_begin_batch(v);
}
@@ -171,11 +171,10 @@ static void vhost_vdpa_iotlb_batch_begin_once(struct
vhost_vdpa *v)
static void vhost_vdpa_listener_commit(MemoryListener *listener)
{
struct vhost_vdpa *v = container_of(listener, struct vhost_vdpa, listener);
- struct vhost_dev *dev = v->dev;
struct vhost_msg_v2 msg = {};
int fd = v->shared->device_fd;
- if (!(dev->backend_cap & (0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH))) {
+ if (!(v->shared->backend_cap & (0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH))) {
return;
}
@@ -833,6 +832,8 @@ static int vhost_vdpa_set_features(struct vhost_dev *dev,
static int vhost_vdpa_set_backend_cap(struct vhost_dev *dev)
{
+ struct vhost_vdpa *v = dev->opaque;
+
uint64_t features;
uint64_t f = 0x1ULL << VHOST_BACKEND_F_IOTLB_MSG_V2 |
0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH |
@@ -854,6 +855,7 @@ static int vhost_vdpa_set_backend_cap(struct vhost_dev *dev)
}
dev->backend_cap = features;
+ v->shared->backend_cap = features;
return 0;
}
--
2.39.3
- [RFC PATCH 04/18] vdpa: move shadow_data to vhost_vdpa_shared, (continued)
- [RFC PATCH 04/18] vdpa: move shadow_data to vhost_vdpa_shared, Eugenio Pérez, 2023/10/19
- [RFC PATCH 01/18] vdpa: add VhostVDPAShared, Eugenio Pérez, 2023/10/19
- [RFC PATCH 02/18] vdpa: move iova tree to the shared struct, Eugenio Pérez, 2023/10/19
- [RFC PATCH 03/18] vdpa: move iova_range to vhost_vdpa_shared, Eugenio Pérez, 2023/10/19
- [RFC PATCH 05/18] vdpa: use vdpa shared for tracing, Eugenio Pérez, 2023/10/19
- [RFC PATCH 07/18] vdpa: move iotlb_batch_begin_sent to vhost_vdpa_shared, Eugenio Pérez, 2023/10/19
- [RFC PATCH 06/18] vdpa: move file descriptor to vhost_vdpa_shared, Eugenio Pérez, 2023/10/19
- [RFC PATCH 09/18] vdpa: remove msg type of vhost_vdpa, Eugenio Pérez, 2023/10/19
- [RFC PATCH 10/18] vdpa: move iommu_list to vhost_vdpa_shared, Eugenio Pérez, 2023/10/19
- [RFC PATCH 11/18] vdpa: use VhostVDPAShared in vdpa_dma_map and unmap, Eugenio Pérez, 2023/10/19
- [RFC PATCH 08/18] vdpa: move backend_cap to vhost_vdpa_shared,
Eugenio Pérez <=
- [RFC PATCH 13/18] vdpa: move memory listener to vhost_vdpa_shared, Eugenio Pérez, 2023/10/19
- [RFC PATCH 14/18] vdpa: do not set virtio status bits if unneeded, Eugenio Pérez, 2023/10/19
- [RFC PATCH 16/18] vdpa: add vhost_vdpa_net_load_setup NetClient callback, Eugenio Pérez, 2023/10/19
- [RFC PATCH 15/18] vdpa: add vhost_vdpa_load_setup, Eugenio Pérez, 2023/10/19
- [RFC PATCH 12/18] vdpa: use dev_shared in vdpa_iommu, Eugenio Pérez, 2023/10/19
- [RFC PATCH 17/18] vdpa: use shadow_data instead of first device v->shadow_vqs_enabled, Eugenio Pérez, 2023/10/19
- [RFC PATCH 18/18] virtio_net: register incremental migration handlers, Eugenio Pérez, 2023/10/19