[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 04/41] arch_init: refactor host_from_stream_offse
From: |
Isaku Yamahata |
Subject: |
[Qemu-devel] [PATCH v2 04/41] arch_init: refactor host_from_stream_offset() |
Date: |
Mon, 4 Jun 2012 18:57:06 +0900 |
Signed-off-by: Isaku Yamahata <address@hidden>
---
arch_init.c | 25 ++++++++++++++++++-------
arch_init.h | 7 +++++++
2 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/arch_init.c b/arch_init.c
index 2a53f58..36ece1d 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -374,21 +374,22 @@ int ram_save_live(QEMUFile *f, int stage, void *opaque)
return (stage == 2) && (expected_time <= migrate_max_downtime());
}
-static inline void *host_from_stream_offset(QEMUFile *f,
- ram_addr_t offset,
- int flags)
+void *ram_load_host_from_stream_offset(QEMUFile *f,
+ ram_addr_t offset,
+ int flags,
+ RAMBlock **last_blockp)
{
- static RAMBlock *block = NULL;
+ RAMBlock *block;
char id[256];
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!(*last_blockp)) {
fprintf(stderr, "Ack, bad migration stream!\n");
return NULL;
}
- return memory_region_get_ram_ptr(block->mr) + offset;
+ return memory_region_get_ram_ptr((*last_blockp)->mr) + offset;
}
len = qemu_get_byte(f);
@@ -396,14 +397,24 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QLIST_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id))) {
+ *last_blockp = block;
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
fprintf(stderr, "Can't find block %s!\n", id);
return NULL;
}
+static inline void *host_from_stream_offset(QEMUFile *f,
+ ram_addr_t offset,
+ int flags)
+{
+ static RAMBlock *block = NULL;
+ return ram_load_host_from_stream_offset(f, offset, flags, &block);
+}
+
int ram_load(QEMUFile *f, void *opaque, int version_id)
{
ram_addr_t addr;
diff --git a/arch_init.h b/arch_init.h
index 456637d..d84eac7 100644
--- a/arch_init.h
+++ b/arch_init.h
@@ -39,4 +39,11 @@ int xen_available(void);
#define RAM_SAVE_VERSION_ID 4 /* currently version 4 */
+#if defined(NEED_CPU_H) && !defined(CONFIG_USER_ONLY)
+void *ram_load_host_from_stream_offset(QEMUFile *f,
+ ram_addr_t offset,
+ int flags,
+ RAMBlock **last_blockp);
+#endif
+
#endif
--
1.7.1.1
- [Qemu-devel] [PATCH v2 00/41] postcopy live migration, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 16/41] savevm: qemu_pending_size() to return pending buffered size, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 04/41] arch_init: refactor host_from_stream_offset(),
Isaku Yamahata <=
- [Qemu-devel] [PATCH v2 06/41] arch_init: refactor ram_save_block(), Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 03/41] arch_init/ram_save: introduce constant for ram save version = 4, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 17/41] savevm, buffered_file: introduce method to drain buffer of buffered file, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 20/41] savevm/QEMUFileSocket: drop duplicated member fd, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 01/41] arch_init: export sort_ram_list() and ram_save_block(), Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 18/41] QEMUFile: add qemu_file_fd() for later use, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 24/41] migration: export migrate_fd_completed() and migrate_fd_cleanup(), Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 05/41] arch_init/ram_save_live: factor out RAM_SAVE_FLAG_MEM_SIZE case, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 31/41] configure: add CONFIG_POSTCOPY option, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 22/41] savevm/QEMUFile: introduce qemu_fopen_fd, Isaku Yamahata, 2012/06/04