diff mbox series

[v1,1/4] migration/debug: Introduce foreach_migratable_block()

Message ID 1603720725-81206-2-git-send-email-zhengchuan@huawei.com
State New
Headers show
Series migration/debug: Add migration ram consistency check | expand

Commit Message

Zheng Chuan Oct. 26, 2020, 1:58 p.m. UTC
Signed-off-by: Chuan Zheng <zhengchuan@huawei.com>
---
 migration/ram.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/migration/ram.c b/migration/ram.c
index 433489d..aa39908 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -166,6 +166,22 @@  bool ramblock_is_ignored(RAMBlock *block)
 
 #undef RAMBLOCK_FOREACH
 
+static int foreach_migratable_block(RAMBlockIterFunc func, void *opaque)
+{
+    RAMBlock *block;
+    int ret = 0;
+
+    rcu_read_lock();
+    RAMBLOCK_FOREACH_MIGRATABLE(block) {
+        ret = func(block, opaque);
+        if (ret) {
+            break;
+        }
+    }
+    rcu_read_unlock();
+    return ret;
+}
+
 int foreach_not_ignored_block(RAMBlockIterFunc func, void *opaque)
 {
     RAMBlock *block;