mirror of https://gitee.com/openkylin/qemu.git
memory: make memory_listener_unregister idempotent
Make it easy to unregister a MemoryListener without tracking whether it had been registered before. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
79c0f397fe
commit
1d8280c18f
5
memory.c
5
memory.c
|
@ -2371,8 +2371,13 @@ void memory_listener_register(MemoryListener *listener, AddressSpace *as)
|
|||
|
||||
void memory_listener_unregister(MemoryListener *listener)
|
||||
{
|
||||
if (!listener->address_space) {
|
||||
return;
|
||||
}
|
||||
|
||||
QTAILQ_REMOVE(&memory_listeners, listener, link);
|
||||
QTAILQ_REMOVE(&listener->address_space->listeners, listener, link_as);
|
||||
listener->address_space = NULL;
|
||||
}
|
||||
|
||||
void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name)
|
||||
|
|
Loading…
Reference in New Issue