Anthony Liguori | d1e70c5 | 2010-03-09 13:16:14 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Notifier lists |
| 3 | * |
| 4 | * Copyright IBM, Corp. 2010 |
| 5 | * |
| 6 | * Authors: |
| 7 | * Anthony Liguori <aliguori@us.ibm.com> |
| 8 | * |
| 9 | * This work is licensed under the terms of the GNU GPL, version 2. See |
| 10 | * the COPYING file in the top-level directory. |
| 11 | * |
Paolo Bonzini | 6b620ca | 2012-01-13 17:44:23 +0100 | [diff] [blame] | 12 | * Contributions after 2012-01-13 are licensed under the terms of the |
| 13 | * GNU GPL, version 2 or (at your option) any later version. |
Anthony Liguori | d1e70c5 | 2010-03-09 13:16:14 -0600 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include "qemu-common.h" |
| 17 | #include "notify.h" |
| 18 | |
| 19 | void notifier_list_init(NotifierList *list) |
| 20 | { |
Paolo Bonzini | 3155252 | 2012-01-13 17:34:01 +0100 | [diff] [blame] | 21 | QLIST_INIT(&list->notifiers); |
Anthony Liguori | d1e70c5 | 2010-03-09 13:16:14 -0600 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | void notifier_list_add(NotifierList *list, Notifier *notifier) |
| 25 | { |
Paolo Bonzini | 3155252 | 2012-01-13 17:34:01 +0100 | [diff] [blame] | 26 | QLIST_INSERT_HEAD(&list->notifiers, notifier, node); |
Anthony Liguori | d1e70c5 | 2010-03-09 13:16:14 -0600 | [diff] [blame] | 27 | } |
| 28 | |
Paolo Bonzini | 3155252 | 2012-01-13 17:34:01 +0100 | [diff] [blame] | 29 | void notifier_remove(Notifier *notifier) |
Anthony Liguori | d1e70c5 | 2010-03-09 13:16:14 -0600 | [diff] [blame] | 30 | { |
Paolo Bonzini | 3155252 | 2012-01-13 17:34:01 +0100 | [diff] [blame] | 31 | QLIST_REMOVE(notifier, node); |
Anthony Liguori | d1e70c5 | 2010-03-09 13:16:14 -0600 | [diff] [blame] | 32 | } |
| 33 | |
Jan Kiszka | 9e8dd45 | 2011-06-20 14:06:26 +0200 | [diff] [blame] | 34 | void notifier_list_notify(NotifierList *list, void *data) |
Anthony Liguori | d1e70c5 | 2010-03-09 13:16:14 -0600 | [diff] [blame] | 35 | { |
| 36 | Notifier *notifier, *next; |
| 37 | |
Paolo Bonzini | 3155252 | 2012-01-13 17:34:01 +0100 | [diff] [blame] | 38 | QLIST_FOREACH_SAFE(notifier, &list->notifiers, node, next) { |
Jan Kiszka | 9e8dd45 | 2011-06-20 14:06:26 +0200 | [diff] [blame] | 39 | notifier->notify(notifier, data); |
Anthony Liguori | d1e70c5 | 2010-03-09 13:16:14 -0600 | [diff] [blame] | 40 | } |
| 41 | } |