[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 21/22] vdpa: Add device migration blocker
From: |
Eugenio Pérez |
Subject: |
[PATCH 21/22] vdpa: Add device migration blocker |
Date: |
Fri, 8 Jul 2022 12:50:12 +0200 |
The device may need to add migration blockers. For example, if vdpa
device uses features not compatible with migration.
Add the possibility here.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
include/hw/virtio/vhost-vdpa.h | 1 +
hw/virtio/vhost-vdpa.c | 14 ++++++++++++++
2 files changed, 15 insertions(+)
diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
index 1111d85643..d10a89303e 100644
--- a/include/hw/virtio/vhost-vdpa.h
+++ b/include/hw/virtio/vhost-vdpa.h
@@ -35,6 +35,7 @@ typedef struct vhost_vdpa {
bool shadow_vqs_enabled;
/* IOVA mapping used by the Shadow Virtqueue */
VhostIOVATree *iova_tree;
+ Error *migration_blocker;
GPtrArray *shadow_vqs;
const VhostShadowVirtqueueOps *shadow_vq_ops;
void *shadow_vq_ops_opaque;
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index c1162daecc..764a81b57f 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -20,6 +20,7 @@
#include "hw/virtio/vhost-shadow-virtqueue.h"
#include "hw/virtio/vhost-vdpa.h"
#include "exec/address-spaces.h"
+#include "migration/blocker.h"
#include "qemu/cutils.h"
#include "qemu/main-loop.h"
#include "cpu.h"
@@ -1016,6 +1017,13 @@ static bool vhost_vdpa_svqs_start(struct vhost_dev *dev)
return true;
}
+ if (v->migration_blocker) {
+ int r = migrate_add_blocker(v->migration_blocker, &err);
+ if (unlikely(r < 0)) {
+ goto err_migration_blocker;
+ }
+ }
+
for (i = 0; i < v->shadow_vqs->len; ++i) {
VirtQueue *vq = virtio_get_queue(dev->vdev, dev->vq_index + i);
VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
@@ -1057,6 +1065,9 @@ err_svq_setup:
vhost_svq_stop(svq);
}
+err_migration_blocker:
+ error_reportf_err(err, "Cannot setup SVQ %u: ", i);
+
return false;
}
@@ -1073,6 +1084,9 @@ static void vhost_vdpa_svqs_stop(struct vhost_dev *dev)
vhost_vdpa_svq_unmap_rings(dev, svq);
}
+ if (v->migration_blocker) {
+ migrate_del_blocker(v->migration_blocker);
+ }
}
static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started)
--
2.31.1
- [PATCH 09/22] vhost: Add opaque member to SVQElement, (continued)
- [PATCH 09/22] vhost: Add opaque member to SVQElement, Eugenio Pérez, 2022/07/08
- [PATCH 12/22] vhost: Add vhost_svq_inject, Eugenio Pérez, 2022/07/08
- [PATCH 13/22] vhost: add vhost_svq_poll, Eugenio Pérez, 2022/07/08
- [PATCH 16/22] vhost: add detach SVQ operation, Eugenio Pérez, 2022/07/08
- [PATCH 18/22] vdpa: manual forward CVQ buffers, Eugenio Pérez, 2022/07/08
- [PATCH 15/22] vhost: Add svq avail_handler callback, Eugenio Pérez, 2022/07/08
- [PATCH 17/22] vdpa: Export vhost_vdpa_dma_map and unmap calls, Eugenio Pérez, 2022/07/08
- [PATCH 19/22] vdpa: Buffer CVQ support on shadow virtqueue, Eugenio Pérez, 2022/07/08
- [PATCH 20/22] vdpa: Extract get features part from vhost_vdpa_get_max_queue_pairs, Eugenio Pérez, 2022/07/08
- [PATCH 14/22] vhost: Add custom used buffer callback, Eugenio Pérez, 2022/07/08
- [PATCH 21/22] vdpa: Add device migration blocker,
Eugenio Pérez <=
- [PATCH 22/22] vdpa: Add x-svq to NetdevVhostVDPAOptions, Eugenio Pérez, 2022/07/08