[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 13/14] vdpa: Expose VHOST_F_LOG_ALL on SVQ
From: |
Eugenio Pérez |
Subject: |
[PATCH v3 13/14] vdpa: Expose VHOST_F_LOG_ALL on SVQ |
Date: |
Wed, 2 Mar 2022 21:30:11 +0100 |
SVQ is able to log the dirty bits by itself, so let's use it to not
block migration.
Also, ignore set and clear of VHOST_F_LOG_ALL on set_features if SVQ is
enabled. Even if the device supports it, the reports would be nonsense
because SVQ memory is in the qemu region.
The log region is still allocated. Future changes might skip that, but
this series is already long enough.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
include/hw/virtio/vhost-vdpa.h | 1 +
hw/virtio/vhost-vdpa.c | 39 ++++++++++++++++++++++++++++++----
2 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
index ee8e939ad0..a29dbb3f53 100644
--- a/include/hw/virtio/vhost-vdpa.h
+++ b/include/hw/virtio/vhost-vdpa.h
@@ -30,6 +30,7 @@ typedef struct vhost_vdpa {
bool iotlb_batch_begin_sent;
MemoryListener listener;
struct vhost_vdpa_iova_range iova_range;
+ uint64_t acked_features;
bool shadow_vqs_enabled;
/* IOVA mapping used by the Shadow Virtqueue */
VhostIOVATree *iova_tree;
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 95cb72a2ee..5eefc5911a 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -373,6 +373,16 @@ static bool vhost_vdpa_one_time_request(struct vhost_dev
*dev)
return v->index != 0;
}
+static int vhost_vdpa_get_dev_features(struct vhost_dev *dev,
+ uint64_t *features)
+{
+ int ret;
+
+ ret = vhost_vdpa_call(dev, VHOST_GET_FEATURES, features);
+ trace_vhost_vdpa_get_features(dev, *features);
+ return ret;
+}
+
static int vhost_vdpa_init_svq(struct vhost_dev *hdev, struct vhost_vdpa *v,
Error **errp)
{
@@ -385,7 +395,7 @@ static int vhost_vdpa_init_svq(struct vhost_dev *hdev,
struct vhost_vdpa *v,
return 0;
}
- r = hdev->vhost_ops->vhost_get_features(hdev, &dev_features);
+ r = vhost_vdpa_get_dev_features(hdev, &dev_features);
if (r != 0) {
error_setg_errno(errp, -r, "Can't get vdpa device features");
return r;
@@ -609,12 +619,29 @@ static int vhost_vdpa_set_mem_table(struct vhost_dev *dev,
static int vhost_vdpa_set_features(struct vhost_dev *dev,
uint64_t features)
{
+ struct vhost_vdpa *v = dev->opaque;
int ret;
if (vhost_vdpa_one_time_request(dev)) {
return 0;
}
+ if (v->shadow_vqs_enabled) {
+ if ((v->acked_features ^ features) == BIT_ULL(VHOST_F_LOG_ALL)) {
+ /*
+ * QEMU is just trying to enable or disable logging. SVQ handles
+ * this sepparately, so no need to forward this.
+ */
+ v->acked_features = features;
+ return 0;
+ }
+
+ v->acked_features = features;
+
+ /* We must not ack _F_LOG if SVQ is enabled */
+ features &= ~BIT_ULL(VHOST_F_LOG_ALL);
+ }
+
trace_vhost_vdpa_set_features(dev, features);
ret = vhost_vdpa_call(dev, VHOST_SET_FEATURES, &features);
if (ret) {
@@ -1202,10 +1229,14 @@ static int vhost_vdpa_set_vring_call(struct vhost_dev
*dev,
static int vhost_vdpa_get_features(struct vhost_dev *dev,
uint64_t *features)
{
- int ret;
+ struct vhost_vdpa *v = dev->opaque;
+ int ret = vhost_vdpa_get_dev_features(dev, features);
+
+ if (ret == 0 && v->shadow_vqs_enabled) {
+ /* Add SVQ logging capabilities */
+ *features |= BIT_ULL(VHOST_F_LOG_ALL);
+ }
- ret = vhost_vdpa_call(dev, VHOST_GET_FEATURES, features);
- trace_vhost_vdpa_get_features(dev, *features);
return ret;
}
--
2.27.0
- [PATCH v3 03/14] vhost: Add Shadow VirtQueue call forwarding capabilities, (continued)
- [PATCH v3 03/14] vhost: Add Shadow VirtQueue call forwarding capabilities, Eugenio Pérez, 2022/03/02
- [PATCH v3 04/14] vhost: Add vhost_svq_valid_features to shadow vq, Eugenio Pérez, 2022/03/02
- [PATCH v3 05/14] virtio: Add vhost_svq_get_vring_addr, Eugenio Pérez, 2022/03/02
- [PATCH v3 06/14] vdpa: adapt vhost_ops callbacks to svq, Eugenio Pérez, 2022/03/02
- [PATCH v3 07/14] vhost: Shadow virtqueue buffers forwarding, Eugenio Pérez, 2022/03/02
- [PATCH v3 08/14] util: Add iova_tree_alloc_map, Eugenio Pérez, 2022/03/02
- [PATCH v3 09/14] vhost: Add VhostIOVATree, Eugenio Pérez, 2022/03/02
- [PATCH v3 10/14] vdpa: Add custom IOTLB translations to SVQ, Eugenio Pérez, 2022/03/02
- [PATCH v3 11/14] vdpa: Adapt vhost_vdpa_get_vring_base to SVQ, Eugenio Pérez, 2022/03/02
- [PATCH v3 12/14] vdpa: Never set log_base addr if SVQ is enabled, Eugenio Pérez, 2022/03/02
- [PATCH v3 13/14] vdpa: Expose VHOST_F_LOG_ALL on SVQ,
Eugenio Pérez <=
- [PATCH v3 14/14] vdpa: Add x-svq to NetdevVhostVDPAOptions, Eugenio Pérez, 2022/03/02
- Re: [PATCH v3 14/14] vdpa: Add x-svq to NetdevVhostVDPAOptions, Markus Armbruster, 2022/03/03
- Re: [PATCH v3 14/14] vdpa: Add x-svq to NetdevVhostVDPAOptions, Eugenio Perez Martin, 2022/03/03
- Re: [PATCH v3 14/14] vdpa: Add x-svq to NetdevVhostVDPAOptions, Markus Armbruster, 2022/03/03
- Re: [PATCH v3 14/14] vdpa: Add x-svq to NetdevVhostVDPAOptions, Eugenio Perez Martin, 2022/03/03
- Re: [PATCH v3 14/14] vdpa: Add x-svq to NetdevVhostVDPAOptions, Markus Armbruster, 2022/03/04
- Re: [PATCH v3 14/14] vdpa: Add x-svq to NetdevVhostVDPAOptions, Eugenio Perez Martin, 2022/03/04