1 | The following changes since commit d147f7e815f97cb477e223586bcb80c316ae10ea: | 1 | The following changes since commit ca61fa4b803e5d0abaf6f1ceb690f23bb78a4def: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2017-10-03 16:27:24 +0100) | 3 | Merge remote-tracking branch 'remotes/quic/tags/pull-hex-20211006' into staging (2021-10-06 12:11:14 -0700) |
4 | 4 | ||
5 | are available in the git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | git://github.com/stefanha/qemu.git tags/block-pull-request | 7 | https://gitlab.com/stefanha/qemu.git tags/block-pull-request |
8 | 8 | ||
9 | for you to fetch changes up to f708a5e71cba0d784e307334c07ade5f56f827ab: | 9 | for you to fetch changes up to 1cc7eada97914f090125e588497986f6f7900514: |
10 | 10 | ||
11 | aio: fix assert when remove poll during destroy (2017-10-03 14:36:19 -0400) | 11 | iothread: use IOThreadParamInfo in iothread_[set|get]_param() (2021-10-07 15:29:50 +0100) |
12 | |||
13 | ---------------------------------------------------------------- | ||
14 | Pull request | ||
12 | 15 | ||
13 | ---------------------------------------------------------------- | 16 | ---------------------------------------------------------------- |
14 | 17 | ||
15 | ---------------------------------------------------------------- | 18 | Stefano Garzarella (2): |
19 | iothread: rename PollParamInfo to IOThreadParamInfo | ||
20 | iothread: use IOThreadParamInfo in iothread_[set|get]_param() | ||
16 | 21 | ||
17 | Peter Xu (4): | 22 | iothread.c | 28 +++++++++++++++------------- |
18 | qom: provide root container for internal objs | 23 | 1 file changed, 15 insertions(+), 13 deletions(-) |
19 | iothread: provide helpers for internal use | ||
20 | iothread: export iothread_stop() | ||
21 | iothread: delay the context release to finalize | ||
22 | |||
23 | Stefan Hajnoczi (1): | ||
24 | aio: fix assert when remove poll during destroy | ||
25 | |||
26 | include/qom/object.h | 11 +++++++++++ | ||
27 | include/sysemu/iothread.h | 9 +++++++++ | ||
28 | iothread.c | 46 ++++++++++++++++++++++++++++++++++++---------- | ||
29 | qom/object.c | 11 +++++++++++ | ||
30 | util/aio-posix.c | 9 ++++++++- | ||
31 | 5 files changed, 75 insertions(+), 11 deletions(-) | ||
32 | 24 | ||
33 | -- | 25 | -- |
34 | 2.13.6 | 26 | 2.31.1 |
35 | 27 | ||
36 | 28 | ||
29 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Peter Xu <peterx@redhat.com> | ||
2 | 1 | ||
3 | We have object_get_objects_root() to keep user created objects, however | ||
4 | no place for objects that will be used internally. Create such a | ||
5 | container for internal objects. | ||
6 | |||
7 | CC: Andreas Färber <afaerber@suse.de> | ||
8 | CC: Markus Armbruster <armbru@redhat.com> | ||
9 | CC: Paolo Bonzini <pbonzini@redhat.com> | ||
10 | Suggested-by: Daniel P. Berrange <berrange@redhat.com> | ||
11 | Signed-off-by: Peter Xu <peterx@redhat.com> | ||
12 | Reviewed-by: Fam Zheng <famz@redhat.com> | ||
13 | Message-id: 20170928025958.1420-2-peterx@redhat.com | ||
14 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
15 | --- | ||
16 | include/qom/object.h | 11 +++++++++++ | ||
17 | qom/object.c | 11 +++++++++++ | ||
18 | 2 files changed, 22 insertions(+) | ||
19 | |||
20 | diff --git a/include/qom/object.h b/include/qom/object.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/include/qom/object.h | ||
23 | +++ b/include/qom/object.h | ||
24 | @@ -XXX,XX +XXX,XX @@ Object *object_get_root(void); | ||
25 | Object *object_get_objects_root(void); | ||
26 | |||
27 | /** | ||
28 | + * object_get_internal_root: | ||
29 | + * | ||
30 | + * Get the container object that holds internally used object | ||
31 | + * instances. Any object which is put into this container must not be | ||
32 | + * user visible, and it will not be exposed in the QOM tree. | ||
33 | + * | ||
34 | + * Returns: the internal object container | ||
35 | + */ | ||
36 | +Object *object_get_internal_root(void); | ||
37 | + | ||
38 | +/** | ||
39 | * object_get_canonical_path_component: | ||
40 | * | ||
41 | * Returns: The final component in the object's canonical path. The canonical | ||
42 | diff --git a/qom/object.c b/qom/object.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/qom/object.c | ||
45 | +++ b/qom/object.c | ||
46 | @@ -XXX,XX +XXX,XX @@ Object *object_get_objects_root(void) | ||
47 | return container_get(object_get_root(), "/objects"); | ||
48 | } | ||
49 | |||
50 | +Object *object_get_internal_root(void) | ||
51 | +{ | ||
52 | + static Object *internal_root; | ||
53 | + | ||
54 | + if (!internal_root) { | ||
55 | + internal_root = object_new("container"); | ||
56 | + } | ||
57 | + | ||
58 | + return internal_root; | ||
59 | +} | ||
60 | + | ||
61 | static void object_get_child_property(Object *obj, Visitor *v, | ||
62 | const char *name, void *opaque, | ||
63 | Error **errp) | ||
64 | -- | ||
65 | 2.13.6 | ||
66 | |||
67 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Peter Xu <peterx@redhat.com> | ||
2 | 1 | ||
3 | IOThread is a general framework that contains IO loop environment and a | ||
4 | real thread behind. It's also good to be used internally inside qemu. | ||
5 | Provide some helpers for it to create iothreads to be used internally. | ||
6 | |||
7 | Put all the internal used iothreads into the internal object container. | ||
8 | |||
9 | Reviewed-by: Fam Zheng <famz@redhat.com> | ||
10 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
11 | Signed-off-by: Peter Xu <peterx@redhat.com> | ||
12 | Message-id: 20170928025958.1420-3-peterx@redhat.com | ||
13 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
14 | --- | ||
15 | include/sysemu/iothread.h | 8 ++++++++ | ||
16 | iothread.c | 16 ++++++++++++++++ | ||
17 | 2 files changed, 24 insertions(+) | ||
18 | |||
19 | diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/include/sysemu/iothread.h | ||
22 | +++ b/include/sysemu/iothread.h | ||
23 | @@ -XXX,XX +XXX,XX @@ AioContext *iothread_get_aio_context(IOThread *iothread); | ||
24 | void iothread_stop_all(void); | ||
25 | GMainContext *iothread_get_g_main_context(IOThread *iothread); | ||
26 | |||
27 | +/* | ||
28 | + * Helpers used to allocate iothreads for internal use. These | ||
29 | + * iothreads will not be seen by monitor clients when query using | ||
30 | + * "query-iothreads". | ||
31 | + */ | ||
32 | +IOThread *iothread_create(const char *id, Error **errp); | ||
33 | +void iothread_destroy(IOThread *iothread); | ||
34 | + | ||
35 | #endif /* IOTHREAD_H */ | ||
36 | diff --git a/iothread.c b/iothread.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/iothread.c | ||
39 | +++ b/iothread.c | ||
40 | @@ -XXX,XX +XXX,XX @@ GMainContext *iothread_get_g_main_context(IOThread *iothread) | ||
41 | |||
42 | return iothread->worker_context; | ||
43 | } | ||
44 | + | ||
45 | +IOThread *iothread_create(const char *id, Error **errp) | ||
46 | +{ | ||
47 | + Object *obj; | ||
48 | + | ||
49 | + obj = object_new_with_props(TYPE_IOTHREAD, | ||
50 | + object_get_internal_root(), | ||
51 | + id, errp, NULL); | ||
52 | + | ||
53 | + return IOTHREAD(obj); | ||
54 | +} | ||
55 | + | ||
56 | +void iothread_destroy(IOThread *iothread) | ||
57 | +{ | ||
58 | + object_unparent(OBJECT(iothread)); | ||
59 | +} | ||
60 | -- | ||
61 | 2.13.6 | ||
62 | |||
63 | diff view generated by jsdifflib |
1 | From: Peter Xu <peterx@redhat.com> | 1 | From: Stefano Garzarella <sgarzare@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | When gcontext is used with iothread, the context will be destroyed | 3 | Commit 1793ad0247 ("iothread: add aio-max-batch parameter") added |
4 | during iothread_stop(). That's not good since sometimes we would like | 4 | a new parameter (aio-max-batch) to IOThread and used PollParamInfo |
5 | to keep the resources until iothread is destroyed, but we may want to | 5 | structure to handle it. |
6 | stop the thread before that point. | ||
7 | 6 | ||
8 | Delay the destruction of gcontext to iothread finalize. Then we can do: | 7 | Since it is not a parameter of the polling mechanism, we rename the |
8 | structure to a more generic IOThreadParamInfo. | ||
9 | 9 | ||
10 | iothread_stop(thread); | 10 | Suggested-by: Kevin Wolf <kwolf@redhat.com> |
11 | some_cleanup_on_resources(); | 11 | Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> |
12 | iothread_destroy(thread); | 12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
13 | 13 | Message-id: 20210727145936.147032-2-sgarzare@redhat.com | |
14 | We may need this patch if we want to run chardev IOs in iothreads and | ||
15 | hopefully clean them up correctly. For more specific information, | ||
16 | please see 2b316774f6 ("qemu-char: do not operate on sources from | ||
17 | finalize callbacks"). | ||
18 | |||
19 | Reviewed-by: Fam Zheng <famz@redhat.com> | ||
20 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
21 | Signed-off-by: Peter Xu <peterx@redhat.com> | ||
22 | Message-id: 20170928025958.1420-5-peterx@redhat.com | ||
23 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 14 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
24 | --- | 15 | --- |
25 | iothread.c | 6 ++++-- | 16 | iothread.c | 14 +++++++------- |
26 | 1 file changed, 4 insertions(+), 2 deletions(-) | 17 | 1 file changed, 7 insertions(+), 7 deletions(-) |
27 | 18 | ||
28 | diff --git a/iothread.c b/iothread.c | 19 | diff --git a/iothread.c b/iothread.c |
29 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/iothread.c | 21 | --- a/iothread.c |
31 | +++ b/iothread.c | 22 | +++ b/iothread.c |
32 | @@ -XXX,XX +XXX,XX @@ static void *iothread_run(void *opaque) | 23 | @@ -XXX,XX +XXX,XX @@ static void iothread_complete(UserCreatable *obj, Error **errp) |
33 | g_main_loop_unref(loop); | 24 | typedef struct { |
34 | 25 | const char *name; | |
35 | g_main_context_pop_thread_default(iothread->worker_context); | 26 | ptrdiff_t offset; /* field's byte offset in IOThread struct */ |
36 | - g_main_context_unref(iothread->worker_context); | 27 | -} PollParamInfo; |
37 | - iothread->worker_context = NULL; | 28 | +} IOThreadParamInfo; |
38 | } | 29 | |
39 | } | 30 | -static PollParamInfo poll_max_ns_info = { |
40 | 31 | +static IOThreadParamInfo poll_max_ns_info = { | |
41 | @@ -XXX,XX +XXX,XX @@ static void iothread_instance_finalize(Object *obj) | 32 | "poll-max-ns", offsetof(IOThread, poll_max_ns), |
33 | }; | ||
34 | -static PollParamInfo poll_grow_info = { | ||
35 | +static IOThreadParamInfo poll_grow_info = { | ||
36 | "poll-grow", offsetof(IOThread, poll_grow), | ||
37 | }; | ||
38 | -static PollParamInfo poll_shrink_info = { | ||
39 | +static IOThreadParamInfo poll_shrink_info = { | ||
40 | "poll-shrink", offsetof(IOThread, poll_shrink), | ||
41 | }; | ||
42 | -static PollParamInfo aio_max_batch_info = { | ||
43 | +static IOThreadParamInfo aio_max_batch_info = { | ||
44 | "aio-max-batch", offsetof(IOThread, aio_max_batch), | ||
45 | }; | ||
46 | |||
47 | @@ -XXX,XX +XXX,XX @@ static void iothread_get_param(Object *obj, Visitor *v, | ||
48 | const char *name, void *opaque, Error **errp) | ||
49 | { | ||
42 | IOThread *iothread = IOTHREAD(obj); | 50 | IOThread *iothread = IOTHREAD(obj); |
43 | 51 | - PollParamInfo *info = opaque; | |
44 | iothread_stop(iothread); | 52 | + IOThreadParamInfo *info = opaque; |
45 | + if (iothread->worker_context) { | 53 | int64_t *field = (void *)iothread + info->offset; |
46 | + g_main_context_unref(iothread->worker_context); | 54 | |
47 | + iothread->worker_context = NULL; | 55 | visit_type_int64(v, name, field, errp); |
48 | + } | 56 | @@ -XXX,XX +XXX,XX @@ static bool iothread_set_param(Object *obj, Visitor *v, |
49 | qemu_cond_destroy(&iothread->init_done_cond); | 57 | const char *name, void *opaque, Error **errp) |
50 | qemu_mutex_destroy(&iothread->init_done_lock); | 58 | { |
51 | if (!iothread->ctx) { | 59 | IOThread *iothread = IOTHREAD(obj); |
60 | - PollParamInfo *info = opaque; | ||
61 | + IOThreadParamInfo *info = opaque; | ||
62 | int64_t *field = (void *)iothread + info->offset; | ||
63 | int64_t value; | ||
64 | |||
52 | -- | 65 | -- |
53 | 2.13.6 | 66 | 2.31.1 |
54 | 67 | ||
55 | 68 | diff view generated by jsdifflib |
1 | From: Peter Xu <peterx@redhat.com> | 1 | From: Stefano Garzarella <sgarzare@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | So that internal iothread users can explicitly stop one iothread without | 3 | Commit 0445409d74 ("iothread: generalize |
4 | destroying it. | 4 | iothread_set_param/iothread_get_param") moved common code to set and |
5 | get IOThread parameters in two new functions. | ||
5 | 6 | ||
6 | Since at it, fix iothread_stop() to allow it to be called multiple | 7 | These functions are called inside callbacks, so we don't need to use an |
7 | times. Before this patch we may call iothread_stop() more than once on | 8 | opaque pointer. Let's replace `void *opaque` parameter with |
8 | single iothread, while that may not be correct since qemu_thread_join() | 9 | `IOThreadParamInfo *info`. |
9 | is not allowed to run twice. From manual of pthread_join(): | ||
10 | 10 | ||
11 | Joining with a thread that has previously been joined results in | 11 | Suggested-by: Kevin Wolf <kwolf@redhat.com> |
12 | undefined behavior. | 12 | Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> |
13 | 13 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | |
14 | Reviewed-by: Fam Zheng <famz@redhat.com> | 14 | Message-id: 20210727145936.147032-3-sgarzare@redhat.com |
15 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
16 | Signed-off-by: Peter Xu <peterx@redhat.com> | ||
17 | Message-id: 20170928025958.1420-4-peterx@redhat.com | ||
18 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 15 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
19 | --- | 16 | --- |
20 | include/sysemu/iothread.h | 1 + | 17 | iothread.c | 18 ++++++++++-------- |
21 | iothread.c | 24 ++++++++++++++++-------- | 18 | 1 file changed, 10 insertions(+), 8 deletions(-) |
22 | 2 files changed, 17 insertions(+), 8 deletions(-) | ||
23 | 19 | ||
24 | diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/include/sysemu/iothread.h | ||
27 | +++ b/include/sysemu/iothread.h | ||
28 | @@ -XXX,XX +XXX,XX @@ GMainContext *iothread_get_g_main_context(IOThread *iothread); | ||
29 | * "query-iothreads". | ||
30 | */ | ||
31 | IOThread *iothread_create(const char *id, Error **errp); | ||
32 | +void iothread_stop(IOThread *iothread); | ||
33 | void iothread_destroy(IOThread *iothread); | ||
34 | |||
35 | #endif /* IOTHREAD_H */ | ||
36 | diff --git a/iothread.c b/iothread.c | 20 | diff --git a/iothread.c b/iothread.c |
37 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/iothread.c | 22 | --- a/iothread.c |
39 | +++ b/iothread.c | 23 | +++ b/iothread.c |
40 | @@ -XXX,XX +XXX,XX @@ static void *iothread_run(void *opaque) | 24 | @@ -XXX,XX +XXX,XX @@ static IOThreadParamInfo aio_max_batch_info = { |
41 | return NULL; | 25 | }; |
42 | } | 26 | |
43 | 27 | static void iothread_get_param(Object *obj, Visitor *v, | |
44 | -static int iothread_stop(Object *object, void *opaque) | 28 | - const char *name, void *opaque, Error **errp) |
45 | +void iothread_stop(IOThread *iothread) | 29 | + const char *name, IOThreadParamInfo *info, Error **errp) |
46 | { | ||
47 | - IOThread *iothread; | ||
48 | - | ||
49 | - iothread = (IOThread *)object_dynamic_cast(object, TYPE_IOTHREAD); | ||
50 | - if (!iothread || !iothread->ctx || iothread->stopping) { | ||
51 | - return 0; | ||
52 | + if (!iothread->ctx || iothread->stopping) { | ||
53 | + return; | ||
54 | } | ||
55 | iothread->stopping = true; | ||
56 | aio_notify(iothread->ctx); | ||
57 | @@ -XXX,XX +XXX,XX @@ static int iothread_stop(Object *object, void *opaque) | ||
58 | g_main_loop_quit(iothread->main_loop); | ||
59 | } | ||
60 | qemu_thread_join(&iothread->thread); | ||
61 | +} | ||
62 | + | ||
63 | +static int iothread_stop_iter(Object *object, void *opaque) | ||
64 | +{ | ||
65 | + IOThread *iothread; | ||
66 | + | ||
67 | + iothread = (IOThread *)object_dynamic_cast(object, TYPE_IOTHREAD); | ||
68 | + if (!iothread) { | ||
69 | + return 0; | ||
70 | + } | ||
71 | + iothread_stop(iothread); | ||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | @@ -XXX,XX +XXX,XX @@ static void iothread_instance_finalize(Object *obj) | ||
76 | { | 30 | { |
77 | IOThread *iothread = IOTHREAD(obj); | 31 | IOThread *iothread = IOTHREAD(obj); |
78 | 32 | - IOThreadParamInfo *info = opaque; | |
79 | - iothread_stop(obj, NULL); | 33 | int64_t *field = (void *)iothread + info->offset; |
80 | + iothread_stop(iothread); | 34 | |
81 | qemu_cond_destroy(&iothread->init_done_cond); | 35 | visit_type_int64(v, name, field, errp); |
82 | qemu_mutex_destroy(&iothread->init_done_lock); | 36 | } |
83 | if (!iothread->ctx) { | 37 | |
84 | @@ -XXX,XX +XXX,XX @@ void iothread_stop_all(void) | 38 | static bool iothread_set_param(Object *obj, Visitor *v, |
85 | aio_context_release(ctx); | 39 | - const char *name, void *opaque, Error **errp) |
40 | + const char *name, IOThreadParamInfo *info, Error **errp) | ||
41 | { | ||
42 | IOThread *iothread = IOTHREAD(obj); | ||
43 | - IOThreadParamInfo *info = opaque; | ||
44 | int64_t *field = (void *)iothread + info->offset; | ||
45 | int64_t value; | ||
46 | |||
47 | @@ -XXX,XX +XXX,XX @@ static bool iothread_set_param(Object *obj, Visitor *v, | ||
48 | static void iothread_get_poll_param(Object *obj, Visitor *v, | ||
49 | const char *name, void *opaque, Error **errp) | ||
50 | { | ||
51 | + IOThreadParamInfo *info = opaque; | ||
52 | |||
53 | - iothread_get_param(obj, v, name, opaque, errp); | ||
54 | + iothread_get_param(obj, v, name, info, errp); | ||
55 | } | ||
56 | |||
57 | static void iothread_set_poll_param(Object *obj, Visitor *v, | ||
58 | const char *name, void *opaque, Error **errp) | ||
59 | { | ||
60 | IOThread *iothread = IOTHREAD(obj); | ||
61 | + IOThreadParamInfo *info = opaque; | ||
62 | |||
63 | - if (!iothread_set_param(obj, v, name, opaque, errp)) { | ||
64 | + if (!iothread_set_param(obj, v, name, info, errp)) { | ||
65 | return; | ||
86 | } | 66 | } |
87 | 67 | ||
88 | - object_child_foreach(container, iothread_stop, NULL); | 68 | @@ -XXX,XX +XXX,XX @@ static void iothread_set_poll_param(Object *obj, Visitor *v, |
89 | + object_child_foreach(container, iothread_stop_iter, NULL); | 69 | static void iothread_get_aio_param(Object *obj, Visitor *v, |
70 | const char *name, void *opaque, Error **errp) | ||
71 | { | ||
72 | + IOThreadParamInfo *info = opaque; | ||
73 | |||
74 | - iothread_get_param(obj, v, name, opaque, errp); | ||
75 | + iothread_get_param(obj, v, name, info, errp); | ||
90 | } | 76 | } |
91 | 77 | ||
92 | static gpointer iothread_g_main_context_init(gpointer opaque) | 78 | static void iothread_set_aio_param(Object *obj, Visitor *v, |
79 | const char *name, void *opaque, Error **errp) | ||
80 | { | ||
81 | IOThread *iothread = IOTHREAD(obj); | ||
82 | + IOThreadParamInfo *info = opaque; | ||
83 | |||
84 | - if (!iothread_set_param(obj, v, name, opaque, errp)) { | ||
85 | + if (!iothread_set_param(obj, v, name, info, errp)) { | ||
86 | return; | ||
87 | } | ||
88 | |||
93 | -- | 89 | -- |
94 | 2.13.6 | 90 | 2.31.1 |
95 | 91 | ||
96 | 92 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | After iothread is enabled internally inside QEMU with GMainContext, we | ||
2 | may encounter this warning when destroying the iothread: | ||
3 | 1 | ||
4 | (qemu-system-x86_64:19925): GLib-CRITICAL **: g_source_remove_poll: | ||
5 | assertion '!SOURCE_DESTROYED (source)' failed | ||
6 | |||
7 | The problem is that g_source_remove_poll() does not allow to remove one | ||
8 | source from array if the source is detached from its owner | ||
9 | context. (peterx: which IMHO does not make much sense) | ||
10 | |||
11 | Fix it on QEMU side by avoid calling g_source_remove_poll() if we know | ||
12 | the object is during destruction, and we won't leak anything after all | ||
13 | since the array will be gone soon cleanly even with that fd. | ||
14 | |||
15 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
16 | Reviewed-by: Fam Zheng <famz@redhat.com> | ||
17 | Signed-off-by: Peter Xu <peterx@redhat.com> | ||
18 | Message-id: 20170928025958.1420-6-peterx@redhat.com | ||
19 | [peterx: write the commit message] | ||
20 | Signed-off-by: Peter Xu <peterx@redhat.com> | ||
21 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
22 | --- | ||
23 | util/aio-posix.c | 9 ++++++++- | ||
24 | 1 file changed, 8 insertions(+), 1 deletion(-) | ||
25 | |||
26 | diff --git a/util/aio-posix.c b/util/aio-posix.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/util/aio-posix.c | ||
29 | +++ b/util/aio-posix.c | ||
30 | @@ -XXX,XX +XXX,XX @@ void aio_set_fd_handler(AioContext *ctx, | ||
31 | return; | ||
32 | } | ||
33 | |||
34 | - g_source_remove_poll(&ctx->source, &node->pfd); | ||
35 | + /* If the GSource is in the process of being destroyed then | ||
36 | + * g_source_remove_poll() causes an assertion failure. Skip | ||
37 | + * removal in that case, because glib cleans up its state during | ||
38 | + * destruction anyway. | ||
39 | + */ | ||
40 | + if (!g_source_is_destroyed(&ctx->source)) { | ||
41 | + g_source_remove_poll(&ctx->source, &node->pfd); | ||
42 | + } | ||
43 | |||
44 | /* If the lock is held, just mark the node as deleted */ | ||
45 | if (qemu_lockcnt_count(&ctx->list_lock)) { | ||
46 | -- | ||
47 | 2.13.6 | ||
48 | |||
49 | diff view generated by jsdifflib |