mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
block: use safe iteration over AioContext notifiers
It's possible that an AioContext notifier user was close to finishing when .detach_aio_context() or .attached_aio_context() is called. In that case they may call bdrv_remove_aio_context_notifier() during the callback. Use safe iteration to avoid crashing when the notifier list is modified during iteration. We must not only handle the case where the current aio notifier is removed during a callback but also the one where any other aio notifier is removed. The next patch adds an AioContext notifier for block jobs and they really could be terminating just as .detach_aio_context() is invoked. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Message-id: 1466096189-6477-6-git-send-email-stefanha@redhat.com
This commit is contained in:
parent
9f6bc648c4
commit
e8a095dadb
2 changed files with 38 additions and 10 deletions
|
@ -361,6 +361,7 @@ typedef struct BdrvAioNotifier {
|
|||
void (*detach_aio_context)(void *opaque);
|
||||
|
||||
void *opaque;
|
||||
bool deleted;
|
||||
|
||||
QLIST_ENTRY(BdrvAioNotifier) list;
|
||||
} BdrvAioNotifier;
|
||||
|
@ -427,6 +428,7 @@ struct BlockDriverState {
|
|||
* BDS may register themselves in this list to be notified of changes
|
||||
* regarding this BDS's context */
|
||||
QLIST_HEAD(, BdrvAioNotifier) aio_notifiers;
|
||||
bool walking_aio_notifiers; /* to make removal during iteration safe */
|
||||
|
||||
char filename[PATH_MAX];
|
||||
char backing_file[PATH_MAX]; /* if non zero, the image is a diff of
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue