On 2026/07/24 7:30, Connor Kite wrote:
Implements functionality to cleanup svqs on cleanup of isolation
regions.

Signed-off-by: Connor Kite <[email protected]>
---
  hw/virtio/vhost-user.c | 10 ++++++++++
  1 file changed, 10 insertions(+)

diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index e65f877f9a..bb4de78b95 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -1140,6 +1140,15 @@ static int vhost_user_set_mem_table_postcopy(struct 
vhost_dev *dev,
      return 0;
  }
+static void vhost_user_svq_cleanup(struct vhost_user *u)
+{
+    for (int i = 0; i < u->shadow_vqs->len; i++) {
+        vhost_svq_stop(g_ptr_array_index(u->shadow_vqs, i));
+    }
+
+    g_ptr_array_free(u->shadow_vqs, true);
+}
+
  /* TODO: Is there any notifier cleanup required here?*/
  static void cleanup_isolation_regions(struct vhost_dev *dev)
  {
@@ -1147,6 +1156,7 @@ static void cleanup_isolation_regions(struct vhost_dev 
*dev)
      if (u->iso_memory.base_addr) {
          vhost_iova_tree_delete(u->iso_iova_tree);
          u->iso_iova_tree = NULL;
+        vhost_user_svq_cleanup(u);

Memory-table refresh frees live SVQs permanently. init_isolation_regions() uses cleanup for refreshes, but cleanup frees shadow_vqs; they are created only once during backend initialization.

Regards,
Akihiko Odaki

          memset(&u->iso_memory, 0, sizeof(IsolationRegion));
          qemu_memfd_free((gpointer) u->iso_memory.base_addr, 
u->iso_memory.size,
                           u->iso_memory.iso_fd);



Reply via email to