qemu-cr16/rust
Paolo Bonzini 44a9d1b86c rust: migration: add high-level migration wrappers
Instead of dealing with pre/post callbacks, allow devices to
implement a snapshot/restore mechanism; this has two main
advantages:

- it can be easily implemented via procedural macros

- there can be generic implementations to deal with various
  kinds of interior-mutable containers, from BqlRefCell to Mutex,
  so that C code does not see Rust concepts such as Mutex<>.

Using it is easy; you can implement the snapshot/restore trait
ToMigrationState and declare your state like:

     regs: Migratable<Mutex<MyDeviceRegisters>>

Migratable<> allows dereferencing to the underlying object with
no run-time cost.

Note that Migratable<> actually does not accept ToMigrationState,
only the similar ToMigrationStateShared trait that the user will mostly
not care about.  This is required by the fact that pre/post callbacks
take a &self, and ensures that the argument is a Mutex or BqlRefCell
(including an array or Arc<> thereof).

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-14 11:04:02 +02:00
..
bindings/src rust: split "hwcore" crate 2025-09-17 19:00:57 +02:00
bits rust: re-export qemu_macros internal helper in "bits" 2025-09-17 19:00:57 +02:00
bql rust: move VMState from bql to migration 2025-10-14 11:04:00 +02:00
chardev rust: use glib-sys 2025-10-03 15:14:48 +02:00
common rust/common/uninit: Fix Clippy's complaints about lifetime 2025-09-22 17:17:18 +02:00
hw rust: hpet: fix fw_cfg handling 2025-10-14 11:03:43 +02:00
migration rust: migration: add high-level migration wrappers 2025-10-14 11:04:02 +02:00
qemu-macros rust: bits: disable double_parens check 2025-10-14 01:44:41 +02:00
qom rust: use glib-sys 2025-10-03 15:14:48 +02:00
system rust: use glib-sys 2025-10-03 15:14:48 +02:00
tests rust: re-export qemu macros from common/qom/hwcore 2025-09-17 19:00:58 +02:00
trace tracetool/syslog: add Rust support 2025-10-01 11:22:07 -04:00
util rust: use glib-sys 2025-10-03 15:14:48 +02:00
.gitignore
Cargo.lock rust: move VMState from bql to migration 2025-10-14 11:04:00 +02:00
Cargo.toml rust: use glib-sys 2025-10-03 15:14:48 +02:00
Kconfig rust: add PL011 device model 2024-11-05 14:18:15 +01:00
meson.build rust: move VMState from bql to migration 2025-10-14 11:04:00 +02:00
rustfmt.toml rust: add crate to expose bindings and interfaces 2024-10-11 12:32:17 +02:00