diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2025-09-15 11:34:36 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2025-10-14 11:04:02 +0200 |
commit | 44a9d1b86c06ea955e4720ae5de8c130ff5719bc (patch) | |
tree | a972d98d55787e547d713c818765660abcbbccf5 /scripts/lib/kdoc/kdoc_output.py | |
parent | 4526418affcd536748a344bdba9a6913a5f7e135 (diff) | |
download | qemu-44a9d1b86c06ea955e4720ae5de8c130ff5719bc.zip qemu-44a9d1b86c06ea955e4720ae5de8c130ff5719bc.tar.gz qemu-44a9d1b86c06ea955e4720ae5de8c130ff5719bc.tar.bz2 |
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>
Diffstat (limited to 'scripts/lib/kdoc/kdoc_output.py')
0 files changed, 0 insertions, 0 deletions