From 4c4bad486186fed9631b4ceb7c06d24e9fa65e6f Mon Sep 17 00:00:00 2001 From: zhanghailiang Date: Fri, 15 Jan 2016 11:37:41 +0800 Subject: ram: Split host_from_stream_offset() into two helper functions Split host_from_stream_offset() into two parts: One is to get ram block, which the block idstr may be get from migration stream, the other is to get hva (host) address from block and the offset. Besides, we will do the check working in a new helper offset_in_ramblock(). Signed-off-by: zhanghailiang Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Amit Shah Message-Id: <1452829066-9764-2-git-send-email-zhang.zhanghailiang@huawei.com> Signed-off-by: Amit Shah --- include/exec/ram_addr.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index ef1489d..606e277 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -38,10 +38,14 @@ struct RAMBlock { int fd; }; +static inline bool offset_in_ramblock(RAMBlock *b, ram_addr_t offset) +{ + return (b && b->host && offset < b->used_length) ? true : false; +} + static inline void *ramblock_ptr(RAMBlock *block, ram_addr_t offset) { - assert(offset < block->used_length); - assert(block->host); + assert(offset_in_ramblock(block, offset)); return (char *)block->host + offset; } -- cgit v1.1 From 89a02a9f7bb6a371a42d9b26b76f4c9590548a03 Mon Sep 17 00:00:00 2001 From: zhanghailiang Date: Fri, 15 Jan 2016 11:37:42 +0800 Subject: migration: rename 'file' in MigrationState to 'to_dst_file' Rename the 'file' member of MigrationState to 'to_dst_file' to be consistent with to_src_file, from_src_file and from_dst_file. Signed-off-by: zhanghailiang Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Amit Shah Message-Id: <1452829066-9764-3-git-send-email-zhang.zhanghailiang@huawei.com> Signed-off-by: Amit Shah --- include/migration/migration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/migration/migration.h b/include/migration/migration.h index 0fc1ffa..74684ad 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -133,7 +133,7 @@ struct MigrationState size_t xfer_limit; QemuThread thread; QEMUBH *cleanup_bh; - QEMUFile *file; + QEMUFile *to_dst_file; int parameters[MIGRATION_PARAMETER__MAX]; int state; -- cgit v1.1