On 6/12/2025 4:27 PM, Chenyi Qiang wrote:
> Update ReplayRamDiscard() function to return the result and unify the
> ReplayRamPopulate() and ReplayRamDiscard() to ReplayRamDiscardState() at
> the same time due to their identical definitions. This unification
> simplifies related structures, such as VirtIOMEMReplayData, which makes
> it cleaner.
>
> Reviewed-by: David Hildenbrand <da...@redhat.com>
> Reviewed-by: Pankaj Gupta <pankaj.gu...@amd.com>
> Reviewed-by: Xiaoyao Li <xiaoyao...@intel.com>
> Signed-off-by: Chenyi Qiang <chenyi.qi...@intel.com>
> ---
> Changes in v7:
> - Add Reviewed-by from Xiaoyao and Pankaj.
>
> Changes in v6:
> - Add Reviewed-by from David
> - Add a documentation comment for the prototype change
>
> Changes in v5:
> - Rename ReplayRamStateChange to ReplayRamDiscardState (David)
> - return data->fn(s, data->opaque) instead of 0 in
> virtio_mem_rdm_replay_discarded_cb(). (Alexey)
>
> Changes in v4:
> - Modify the commit message. We won't use Replay() operation when
> doing the attribute change like v3.
> ---
> hw/virtio/virtio-mem.c | 21 +++++++-------
> include/system/memory.h | 64 ++++++++++++++++++++++++++++++-----------
> migration/ram.c | 5 ++--
> system/memory.c | 12 ++++----
> 4 files changed, 66 insertions(+), 36 deletions(-)
>
To fix the build error with --enable-docs configuration, Add the below fixup
======
>From 41bf404651b180f886bd174d36ae62be2b0da61f Mon Sep 17 00:00:00 2001
From: Chenyi Qiang <chenyi.qi...@intel.com>
Date: Thu, 19 Jun 2025 10:49:46 +0800
Subject: [PATCH] fixup! memory: Unify the definiton of ReplayRamPopulate() and
ReplayRamDiscard()
Signed-off-by: Chenyi Qiang <chenyi.qi...@intel.com>
---
include/system/memory.h | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/include/system/memory.h b/include/system/memory.h
index eb2618e1b4..46248d4a52 100644
--- a/include/system/memory.h
+++ b/include/system/memory.h
@@ -577,7 +577,7 @@ static inline void
ram_discard_listener_init(RamDiscardListener *rdl,
}
/**
- * ReplayRamDiscardState:
+ * typedef ReplayRamDiscardState:
*
* The callback handler for #RamDiscardManagerClass.replay_populated/
* #RamDiscardManagerClass.replay_discarded to invoke on populated/discarded
@@ -741,6 +741,11 @@ bool ram_discard_manager_is_populated(const
RamDiscardManager *rdm,
* A wrapper to call the #RamDiscardManagerClass.replay_populated callback
* of the #RamDiscardManager.
*
+ * @rdm: the #RamDiscardManager
+ * @section: the #MemoryRegionSection
+ * @replay_fn: the #ReplayRamDiscardState callback
+ * @opaque: pointer to forward to the callback
+ *
* Returns 0 on success, or a negative error if any notification failed.
*/
int ram_discard_manager_replay_populated(const RamDiscardManager *rdm,
@@ -754,6 +759,11 @@ int ram_discard_manager_replay_populated(const
RamDiscardManager *rdm,
* A wrapper to call the #RamDiscardManagerClass.replay_discarded callback
* of the #RamDiscardManager.
*
+ * @rdm: the #RamDiscardManager
+ * @section: the #MemoryRegionSection
+ * @replay_fn: the #ReplayRamDiscardState callback
+ * @opaque: pointer to forward to the callback
+ *
* Returns 0 on success, or a negative error if any notification failed.
*/
int ram_discard_manager_replay_discarded(const RamDiscardManager *rdm,
--
2.43.5