From 75701d03ee168a02c1ad5659a1fdefc071f66b2b Mon Sep 17 00:00:00 2001 From: "Dr. David Alan Gilbert" Date: Sun, 18 Feb 2018 19:16:52 -0500 Subject: [PATCH] qemu_ram_foreach_block: pass up error value, and down the ramblock name check the return value of the function it calls and error if it's non-0 Fixup qemu_rdma_init_one_block that is the only current caller, and rdma_add_block the only function it calls using it. Pass the name of the ramblock to the function; helps in debugging. Backports commit e3807054e20fb3b94d18cb751c437ee2f43b6fac from qemu --- qemu/exec.c | 14 ++++++++++++-- qemu/include/exec/cpu-common.h | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/qemu/exec.c b/qemu/exec.c index 5c9418d3..81bf58a9 100644 --- a/qemu/exec.c +++ b/qemu/exec.c @@ -2861,12 +2861,22 @@ bool cpu_physical_memory_is_io(AddressSpace *as, hwaddr phys_addr) memory_region_is_romd(mr)); } -void qemu_ram_foreach_block(struct uc_struct *uc, RAMBlockIterFunc func, void *opaque) +int qemu_ram_foreach_block(struct uc_struct *uc, RAMBlockIterFunc func, void *opaque) { RAMBlock *block; + int ret = 0; + // Unicorn: commented out + //rcu_read_lock(); QLIST_FOREACH(block, &uc->ram_list.blocks, next) { - func(block->host, block->offset, block->used_length, opaque); + ret = func(block->idstr, block->host, block->offset, + block->used_length, opaque); + if (ret) { + break; + } } + // Unicorn: commented out + //rcu_read_unlock(); + return ret; } #endif diff --git a/qemu/include/exec/cpu-common.h b/qemu/include/exec/cpu-common.h index 4a066246..6ba425db 100644 --- a/qemu/include/exec/cpu-common.h +++ b/qemu/include/exec/cpu-common.h @@ -116,10 +116,10 @@ void cpu_flush_icache_range(AddressSpace *as, hwaddr start, int len); extern struct MemoryRegion io_mem_rom; extern struct MemoryRegion io_mem_notdirty; -typedef void (RAMBlockIterFunc)(void *host_addr, +typedef int (RAMBlockIterFunc)(const char *block_name, void *host_addr, ram_addr_t offset, ram_addr_t length, void *opaque); -void qemu_ram_foreach_block(struct uc_struct *uc, RAMBlockIterFunc func, void *opaque); +int qemu_ram_foreach_block(struct uc_struct *uc, RAMBlockIterFunc func, void *opaque); #endif