]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
rust/migration: Add Sync implementation for Migratable<>
authorZhao Liu <zhao1.liu@intel.com>
Thu, 13 Nov 2025 05:19:16 +0000 (13:19 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Sat, 27 Dec 2025 09:11:10 +0000 (10:11 +0100)
It's common to define MemoryRegionOps<T> and VMStateDescription<T> as
static variables, and this requires T to implement Sync.

Migratable<T> is usually embedded in device state, so it's necessary to
implement Sync for Migratable<T>.

Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Link: https://lore.kernel.org/r/20251113051937.4017675-2-zhao1.liu@intel.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
rust/migration/src/migratable.rs

index ce60386750270ee390d364ea40a3761f1d9db13b..5700554f7eb418863ce28a4fcbad3ea20b48cb52 100644 (file)
@@ -340,6 +340,9 @@ pub struct Migratable<T: ToMigrationStateShared> {
     runtime_state: T,
 }
 
+// SAFETY: the migration_state asserts via `BqlCell` that the BQL is taken.
+unsafe impl<T: ToMigrationStateShared + Sync> Sync for Migratable<T> {}
+
 impl<T: ToMigrationStateShared> std::ops::Deref for Migratable<T> {
     type Target = T;