Patchwork [v2,09/41] arch_init: introduce helper function to find ram block with id string

login
register
mail settings
Submitter Isaku Yamahata
Date June 4, 2012, 9:57 a.m.
Message ID <a7edf334215badbdfdbc8b5d17148d0d73f38f29.1338802192.git.yamahata@valinux.co.jp>
Download mbox | patch
Permalink /patch/162712/
State New
Headers show

Comments

Isaku Yamahata - June 4, 2012, 9:57 a.m.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 arch_init.c |   13 +++++++++++++
 arch_init.h |    1 +
 2 files changed, 14 insertions(+), 0 deletions(-)

Patch

diff --git a/arch_init.c b/arch_init.c
index bb0cd52..9981abe 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -397,6 +397,19 @@  int ram_save_live(QEMUFile *f, int stage, void *opaque)
     return (stage == 2) && (expected_time <= migrate_max_downtime());
 }
 
+RAMBlock *ram_find_block(const char *id, uint8_t len)
+{
+    RAMBlock *block;
+
+    QLIST_FOREACH(block, &ram_list.blocks, next) {
+        if (!strncmp(id, block->idstr, len)) {
+            return block;
+        }
+    }
+
+    return NULL;
+}
+
 void *ram_load_host_from_stream_offset(QEMUFile *f,
                                        ram_addr_t offset,
                                        int flags,
diff --git a/arch_init.h b/arch_init.h
index 507f110..7f5c77a 100644
--- a/arch_init.h
+++ b/arch_init.h
@@ -41,6 +41,7 @@  int xen_available(void);
 
 #if defined(NEED_CPU_H) && !defined(CONFIG_USER_ONLY)
 int ram_save_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset);
+RAMBlock *ram_find_block(const char *id, uint8_t len);
 void *ram_load_host_from_stream_offset(QEMUFile *f,
                                        ram_addr_t offset,
                                        int flags,