From e3dd74934f2d2c8c67083995928ff68e8c1d0030 Mon Sep 17 00:00:00 2001 From: "Dr. David Alan Gilbert" Date: Thu, 5 Nov 2015 18:10:33 +0000 Subject: qemu_ram_block_by_name Add a function to find a RAMBlock by name; use it in two of the places that already open code that loop; we've got another use later in postcopy. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- exec.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'exec.c') diff --git a/exec.c b/exec.c index 53d3848..36886ee 100644 --- a/exec.c +++ b/exec.c @@ -1946,6 +1946,26 @@ found: return block; } +/* + * Finds the named RAMBlock + * + * name: The name of RAMBlock to find + * + * Returns: RAMBlock (or NULL if not found) + */ +RAMBlock *qemu_ram_block_by_name(const char *name) +{ + RAMBlock *block; + + QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { + if (!strcmp(name, block->idstr)) { + return block; + } + } + + return NULL; +} + /* Some of the softmmu routines need to translate from a host pointer (typically a TLB entry) back to a ram offset. */ MemoryRegion *qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr) -- cgit v1.1