summaryrefslogtreecommitdiff
path: root/rust
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>2026-03-05 00:22:47 +0300
committerFabiano Rosas <farosas@suse.de>2026-04-23 12:14:43 -0300
commitef2045832ea414faa719d75a64bb20583c88353f (patch)
treef31552348ed9fdb4a33a1f317ac55c3b7b227472 /rust
parenta6dba4bb233f642a913278103833c566e7dea575 (diff)
downloadqemu-ef2045832ea414faa719d75a64bb20583c88353f.tar.gz
qemu-ef2045832ea414faa719d75a64bb20583c88353f.zip
migration: make .post_save() a void function
All other handlers now have _errp() variants. Should we go this way for .post_save()? Actually it's rather strange, when the vmstate do successful preparations in .pre_save(), then successfully save all sections and subsections, end then fail when all the state is successfully transferred to the target. Happily, we have only three .post_save() realizations, all always successful. Let's make this a rule. Also note, that we call .post_save() in two places, and handle its (theoretical) failure inconsistently. Fix that too. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Reviewed-by: Peter Xu <peterx@redhat.com> Reviewed-by: Zhao Liu <zhao1.liu@intel.com> #rust Link: https://lore.kernel.org/qemu-devel/20260304212303.667141-4-vsementsov@yandex-team.ru Signed-off-by: Fabiano Rosas <farosas@suse.de>
Diffstat (limited to 'rust')
-rw-r--r--rust/migration/src/migratable.rs6
-rw-r--r--rust/migration/src/vmstate.rs12
2 files changed, 9 insertions, 9 deletions
diff --git a/rust/migration/src/migratable.rs b/rust/migration/src/migratable.rs
index 7748aac2f2..b9e5e1fc15 100644
--- a/rust/migration/src/migratable.rs
+++ b/rust/migration/src/migratable.rs
@@ -406,10 +406,8 @@ impl<T: ToMigrationStateShared> Migratable<T> {
Ok(())
}
- fn post_save(&self) -> Result<(), InvalidError> {
- let state = unsafe { Box::from_raw(self.migration_state.replace(ptr::null_mut())) };
- drop(state);
- Ok(())
+ fn post_save(&self) {
+ let _ = unsafe { Box::from_raw(self.migration_state.replace(ptr::null_mut())) };
}
fn pre_load(&self) -> Result<(), InvalidError> {
diff --git a/rust/migration/src/vmstate.rs b/rust/migration/src/vmstate.rs
index edc7c70265..f34a36f680 100644
--- a/rust/migration/src/vmstate.rs
+++ b/rust/migration/src/vmstate.rs
@@ -492,6 +492,11 @@ unsafe extern "C" fn vmstate_no_version_cb<
into_neg_errno(result)
}
+unsafe extern "C" fn vmstate_post_save_cb<T, F: for<'a> FnCall<(&'a T,), ()>>(opaque: *mut c_void) {
+ // SAFETY: the function is used in T's implementation of VMState.
+ F::call((unsafe { &*(opaque.cast::<T>()) },));
+}
+
unsafe extern "C" fn vmstate_post_load_cb<
T,
F: for<'a> FnCall<(&'a T, u8), Result<(), impl Into<Errno>>>,
@@ -597,12 +602,9 @@ impl<T> VMStateDescriptionBuilder<T> {
}
#[must_use]
- pub const fn post_save<F: for<'a> FnCall<(&'a T,), Result<(), impl Into<Errno>>>>(
- mut self,
- _f: &F,
- ) -> Self {
+ pub const fn post_save<F: for<'a> FnCall<(&'a T,), ()>>(mut self, _f: &F) -> Self {
self.0.post_save = if F::IS_SOME {
- Some(vmstate_no_version_cb::<T, F>)
+ Some(vmstate_post_save_cb::<T, F>)
} else {
None
};