diff options
author | zhanghailiang <zhang.zhanghailiang@huawei.com> | 2016-01-15 11:37:41 +0800 |
---|---|---|
committer | Amit Shah <amit.shah@redhat.com> | 2016-02-05 19:09:50 +0530 |
commit | 4c4bad486186fed9631b4ceb7c06d24e9fa65e6f (patch) | |
tree | ede89d7bff21abcfc43213b42ec891258aeb464d /include/exec/ram_addr.h | |
parent | d38ea87ac54af64ef611de434d07c12dc0399216 (diff) | |
download | qemu-4c4bad486186fed9631b4ceb7c06d24e9fa65e6f.zip |
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 <zhang.zhanghailiang@huawei.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Amit Shah <amit.shah@redhat.com>
Message-Id: <1452829066-9764-2-git-send-email-zhang.zhanghailiang@huawei.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Diffstat (limited to 'include/exec/ram_addr.h')
-rw-r--r-- | include/exec/ram_addr.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index ef1489da77..606e277092 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; } |