On Mon, Apr 17, 2017 at 06:55:40PM +0800, jack.chen wrote: > Thanks,from the path you have list to me,it can be well explained,but > according to the source code,in the end of > kvm_init,kvm_memory_listener and kvm_io_listener were registered by > memory_listener_register(),and in the end of > memory_listener_register(),listener_add_address_space() was called for > each address_space,so the listener->region_add was executed then.I do > not know what mistake I have made,can you explain it to me ?? thank > you very much!
Firstly, there are two address spaces for each system: AddressSpace address_space_io; AddressSpace address_space_memory; The one you mentioned (kvm_io_listener) should be the listener for address_space_io, not address_space_memory, while for RAM, it's located on address_space_memory space. Secondly, when calling memory_listener_register() in kvm_init(), region_add() is actually not called, since FOR_EACH_FLAT_RANGE() in listener_add_address_space() is actually looping nothing since at that time the address_space_memory may not ever been rendered at all (rendering should be triggered by memory_region_transaction_commit() -> address_space_update_topology()). Thanks, -- Peter Xu