Commit 74900277f2 for qemu.org

commit 74900277f2aa01f0b685cf31588024bb89811f14
Author: Alexandr Moshkov <dtalexundeer@yandex-team.ru>
Date:   Mon Aug 3 12:28:51 2026 +0500

    vhost-user-blk: make inflight-migration prop mutable on running vm

    The inflight-migration property currently can only be set before the
    device is realized. This makes it impossible to disable inflight
    migration at runtime without restarting the VM.

    Make the property mutable, but only while the VM is running. Blocking
    changes when the VM is not running ensures that the value at stop time
    reliably reflects the intent set on a live VM, which allows
    vhost_user_blk_stop() to use skip_drain unconditionally based on the
    property value without inspecting migration runstate.

    Signed-off-by: Alexandr Moshkov <dtalexundeer@yandex-team.ru>
    Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
    Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
    Message-ID: <20260803072853.2920007-5-dtalexundeer@yandex-team.ru>

diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index c3e3c37f8c..501de30796 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -629,6 +629,8 @@ static const VMStateDescription vmstate_vhost_user_blk = {
     }
 };

+static PropertyInfo vhost_user_blk_inflight_migration_prop;
+
 static const Property vhost_user_blk_properties[] = {
     DEFINE_PROP_CHR("chardev", VHostUserBlk, chardev),
     DEFINE_PROP_UINT16("num-queues", VHostUserBlk, num_queues,
@@ -644,8 +646,9 @@ static const Property vhost_user_blk_properties[] = {
                       VIRTIO_BLK_F_WRITE_ZEROES, true),
     DEFINE_PROP_BOOL("skip-get-vring-base-on-force-shutdown", VHostUserBlk,
                      skip_get_vring_base_on_force_shutdown, false),
-    DEFINE_PROP_BOOL("inflight-migration", VHostUserBlk,
-                     inflight_migration, false),
+    DEFINE_PROP("inflight-migration", VHostUserBlk, inflight_migration,
+                vhost_user_blk_inflight_migration_prop, bool,
+                .set_default = true, .defval.u = false),
 };

 static void vhost_user_blk_class_init(ObjectClass *klass, const void *data)
@@ -675,8 +678,29 @@ static const TypeInfo vhost_user_blk_info = {
     .class_init = vhost_user_blk_class_init,
 };

+static void vhost_user_blk_set_inflight_migration(Object *obj, Visitor *v,
+                                                  const char *name,
+                                                  void *opaque, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+
+    if (dev->realized && !runstate_is_running()) {
+        error_setg(errp, "Property '%s' cannot be changed "
+                         "while VM is not running", name);
+        return;
+    }
+
+    qdev_prop_bool.set(obj, v, name, opaque, errp);
+}
+
+
 static void virtio_register_types(void)
 {
+    vhost_user_blk_inflight_migration_prop = qdev_prop_bool;
+    vhost_user_blk_inflight_migration_prop.realized_set_allowed = true;
+    vhost_user_blk_inflight_migration_prop.set =
+        vhost_user_blk_set_inflight_migration;
+
     type_register_static(&vhost_user_blk_info);
 }