Subject: [PATCH 09/46] rdma: introduce qemu_ram_foreach_block()

From: Nigel Croxon <[email-masked]>
Date: Thu, 14 Nov 2013 22:52:45 +0100

RH-Author: Nigel Croxon <[email-masked]>
Message-id: <[email-masked]>
Patchwork-id: 55693
O-Subject: [RHEL7.0 PATCH 09/42] rdma: introduce qemu_ram_foreach_block()
Bugzilla: 1011720
RH-Acked-by: Orit Wasserman <[email-masked]>
RH-Acked-by: Amit Shah <[email-masked]>
RH-Acked-by: Paolo Bonzini <[email-masked]>

Bugzilla: 1011720
https://bugzilla.redhat.com/show_bug.cgi?id=1011720

>From commit ID:
commit bd2fa51fcdba3408f308df1b08fae04053ecdee5
Author: Michael R. Hines <[email-masked]>
Date:   Tue Jun 25 21:35:34 2013 -0400

    rdma: introduce qemu_ram_foreach_block()

    This is used during RDMA initialization in order to
    transmit a description of all the RAM blocks to the
    peer for later dynamic chunk registration purposes.

    Reviewed-by: Juan Quintela <[email-masked]>
    Reviewed-by: Paolo Bonzini <[email-masked]>
    Reviewed-by: Chegu Vinod <[email-masked]>
    Tested-by: Chegu Vinod <[email-masked]>
    Tested-by: Michael R. Hines <[email-masked]>
    Signed-off-by: Michael R. Hines <[email-masked]>
    Signed-off-by: Juan Quintela <[email-masked]>
---
 exec.c                    |    9 +++++++++
 include/exec/cpu-common.h |    5 +++++
 2 files changed, 14 insertions(+), 0 deletions(-)

Signed-off-by: Michal Novotny <[email-masked]>
---
 exec.c                    | 9 +++++++++
 include/exec/cpu-common.h | 5 +++++
 2 files changed, 14 insertions(+)

diff --git a/exec.c b/exec.c
index cb11571..64af205 100644
--- a/exec.c
+++ b/exec.c
@@ -2644,3 +2644,12 @@ bool cpu_physical_memory_is_io(hwaddr phys_addr)
              memory_region_is_romd(section->mr));
 }
 #endif
+
+void qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque)
+{
+    RAMBlock *block;
+
+    QTAILQ_FOREACH(block, &ram_list.blocks, next) {
+        func(block->host, block->offset, block->length, opaque);
+    }
+}
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index 2e5f11f..2900fd6 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -119,6 +119,11 @@ extern struct MemoryRegion io_mem_rom;
 extern struct MemoryRegion io_mem_unassigned;
 extern struct MemoryRegion io_mem_notdirty;
 
+typedef void (RAMBlockIterFunc)(void *host_addr,
+    ram_addr_t offset, ram_addr_t length, void *opaque);
+
+void qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque);
+
 #endif
 
 #endif /* !CPU_COMMON_H */
-- 
1.7.11.7