Skip to contentSkip to conversation

vhost: block migration if backend does not log memory

PATCH New Michael S. Tsirkin 1 participant 1 message Jun 18, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost: block migration if backend does not log memory

vhost user does not support LOG_ALL feature bit. Generally, we should not try to set this bit without checking that backend can support it first.

Detect and block migration.

Cc Antonios Motakis <[email protected]>
Cc Nikolay Nikolaev <[email protected]>
---
 include/hw/virtio/vhost.h |  1 +
 hw/virtio/vhost.c         | 11 +++++++++++
 2 files changed, 12 insertions(+)
include/hw/virtio/vhost.h +1 -0
index 33028ec..d5593d1 100644
@@ -45,6 +45,7 @@ struct vhost_dev {
     bool log_enabled;
     vhost_log_chunk_t *log;
     unsigned long long log_size;
+    Error *migration_blocker;
     bool force;
     bool memory_changed;
     hwaddr mem_changed_start_addr;
hw/virtio/vhost.c +11 -0
index 3f4e35f..f63941d 100644
@@ -856,6 +856,13 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
         .eventfd_del = vhost_eventfd_del,
         .priority = 10
     };
+    if (!(hdev->features & (0x1 << VHOST_F_LOG_ALL))) {
+        error_setg(&hdev->migration_blocker,
+                   "Migration disabled: vhost lacks VHOST_F_LOG_ALL feature.");
+        migrate_add_blocker(hdev->migration_blocker);
+    } else {
+        hdev->migration_blocker = NULL;
+    }
     hdev->mem = g_malloc0(offsetof(struct vhost_memory, regions));
     hdev->n_mem_sections = 0;
     hdev->mem_sections = NULL;
@@ -884,6 +891,10 @@ void vhost_dev_cleanup(struct vhost_dev *hdev)
         vhost_virtqueue_cleanup(hdev->vqs + i);
     }
     memory_listener_unregister(&hdev->memory_listener);
+    if (hdev->migration_blocker) {
+        migrate_del_blocker(hdev->migration_blocker);
+        error_free(hdev->migration_blocker);
+    }
     g_free(hdev->mem);
     g_free(hdev->mem_sections);
     hdev->vhost_ops->vhost_backend_cleanup(hdev);
Signature · 1 line
MST