On 3/29/2016 4:18 PM, Paolo Bonzini wrote: > > > On 29/03/2016 12:47, Jitendra Kolhe wrote: >>> Indeed. It is correct for the main system RAM, but hot-plugged RAM >>> would also have a zero-based section.offset_within_region. You need to >>> add memory_region_get_ram_addr(section.mr), just like the call to >>> balloon_page adds memory_region_get_ram_ptr(section.mr). >>> >>> Paolo >> >> I am only interested in the offset from memory region base. >> Would below guest PA to host offset work, as we do in >> address_space_translate_internal()? >> (Guest pa - section.offset_within_address_space + >> section.offset_within_region) > > Yes, that would work. But I'm not sure why you're not interested in the > ram_addr_t. >
You are right, I was wrongly calculating offsets for hot-plugged RAMblocks. I will have to use qemu_ram_block_from_host() to get ram_addr_t to get correct offsets in the bitmap. > Paolo >