Skip to content

Commit

Permalink
memory: make memory_listener_unregister idempotent
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bonzini authored and mstsirkin committed Feb 17, 2017
1 parent 79c0f39 commit 1d8280c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions memory.c
Expand Up @@ -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)
Expand Down

0 comments on commit 1d8280c

Please sign in to comment.