1 | The following changes since commit d147f7e815f97cb477e223586bcb80c316ae10ea: | 1 | The following changes since commit 9c125d17e9402c232c46610802e5931b3639d77b: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2017-10-03 16:27:24 +0100) | 3 | Merge tag 'pull-tcg-20220420' of https://gitlab.com/rth7680/qemu into staging (2022-04-20 16:43:11 -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 d45c83328feab2e4083991693160f0a417cfd9b0: |
10 | 10 | ||
11 | aio: fix assert when remove poll during destroy (2017-10-03 14:36:19 -0400) | 11 | virtiofsd: Add docs/helper for killpriv_v2/no_killpriv_v2 option (2022-04-21 12:05:15 +0200) |
12 | |||
13 | ---------------------------------------------------------------- | ||
14 | Pull request | ||
15 | |||
16 | Small contrib/vhost-user-blk, contrib/vhost-user-scsi, and tools/virtiofsd | ||
17 | improvements. | ||
12 | 18 | ||
13 | ---------------------------------------------------------------- | 19 | ---------------------------------------------------------------- |
14 | 20 | ||
15 | ---------------------------------------------------------------- | 21 | Liu Yiding (1): |
22 | virtiofsd: Add docs/helper for killpriv_v2/no_killpriv_v2 option | ||
16 | 23 | ||
17 | Peter Xu (4): | 24 | Sakshi Kaushik (1): |
18 | qom: provide root container for internal objs | 25 | Implements Backend Program conventions for vhost-user-scsi |
19 | iothread: provide helpers for internal use | ||
20 | iothread: export iothread_stop() | ||
21 | iothread: delay the context release to finalize | ||
22 | 26 | ||
23 | Stefan Hajnoczi (1): | 27 | Stefan Hajnoczi (1): |
24 | aio: fix assert when remove poll during destroy | 28 | contrib/vhost-user-blk: add missing GOptionEntry NULL terminator |
25 | 29 | ||
26 | include/qom/object.h | 11 +++++++++++ | 30 | docs/tools/virtiofsd.rst | 5 ++ |
27 | include/sysemu/iothread.h | 9 +++++++++ | 31 | contrib/vhost-user-blk/vhost-user-blk.c | 3 +- |
28 | iothread.c | 46 ++++++++++++++++++++++++++++++++++++---------- | 32 | contrib/vhost-user-scsi/vhost-user-scsi.c | 77 +++++++++++++++-------- |
29 | qom/object.c | 11 +++++++++++ | 33 | tools/virtiofsd/helper.c | 3 + |
30 | util/aio-posix.c | 9 ++++++++- | 34 | 4 files changed, 62 insertions(+), 26 deletions(-) |
31 | 5 files changed, 75 insertions(+), 11 deletions(-) | ||
32 | 35 | ||
33 | -- | 36 | -- |
34 | 2.13.6 | 37 | 2.35.1 |
35 | |||
36 | diff view generated by jsdifflib |
1 | From: Peter Xu <peterx@redhat.com> | 1 | From: Sakshi Kaushik <sakshikaushik717@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | We have object_get_objects_root() to keep user created objects, however | 3 | Signed-off-by: Sakshi Kaushik <sakshikaushik717@gmail.com> |
4 | no place for objects that will be used internally. Create such a | 4 | Message-id: 20220406162410.8536-1-sakshikaushik717@gmail.com |
5 | container for internal objects. | ||
6 | 5 | ||
7 | CC: Andreas Färber <afaerber@suse.de> | 6 | [Name the iSCSI URL long option --iscsi-uri instead of --iscsi_uri for |
8 | CC: Markus Armbruster <armbru@redhat.com> | 7 | consistency, fix --fd which was rejected due to an outdated |
9 | CC: Paolo Bonzini <pbonzini@redhat.com> | 8 | --socket-path check, and add missing entries[] terminator. |
10 | Suggested-by: Daniel P. Berrange <berrange@redhat.com> | 9 | --Stefan] |
11 | Signed-off-by: Peter Xu <peterx@redhat.com> | 10 | |
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> | 11 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
15 | --- | 12 | --- |
16 | include/qom/object.h | 11 +++++++++++ | 13 | contrib/vhost-user-scsi/vhost-user-scsi.c | 77 +++++++++++++++-------- |
17 | qom/object.c | 11 +++++++++++ | 14 | 1 file changed, 52 insertions(+), 25 deletions(-) |
18 | 2 files changed, 22 insertions(+) | ||
19 | 15 | ||
20 | diff --git a/include/qom/object.h b/include/qom/object.h | 16 | diff --git a/contrib/vhost-user-scsi/vhost-user-scsi.c b/contrib/vhost-user-scsi/vhost-user-scsi.c |
21 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/qom/object.h | 18 | --- a/contrib/vhost-user-scsi/vhost-user-scsi.c |
23 | +++ b/include/qom/object.h | 19 | +++ b/contrib/vhost-user-scsi/vhost-user-scsi.c |
24 | @@ -XXX,XX +XXX,XX @@ Object *object_get_root(void); | 20 | @@ -XXX,XX +XXX,XX @@ fail: |
25 | Object *object_get_objects_root(void); | 21 | |
26 | 22 | /** vhost-user-scsi **/ | |
27 | /** | 23 | |
28 | + * object_get_internal_root: | 24 | +static int opt_fdnum = -1; |
29 | + * | 25 | +static char *opt_socket_path; |
30 | + * Get the container object that holds internally used object | 26 | +static gboolean opt_print_caps; |
31 | + * instances. Any object which is put into this container must not be | 27 | +static char *iscsi_uri; |
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 | + | 28 | + |
38 | +/** | 29 | +static GOptionEntry entries[] = { |
39 | * object_get_canonical_path_component: | 30 | + { "print-capabilities", 'c', 0, G_OPTION_ARG_NONE, &opt_print_caps, |
40 | * | 31 | + "Print capabilities", NULL }, |
41 | * Returns: The final component in the object's canonical path. The canonical | 32 | + { "fd", 'f', 0, G_OPTION_ARG_INT, &opt_fdnum, |
42 | diff --git a/qom/object.c b/qom/object.c | 33 | + "Use inherited fd socket", "FDNUM" }, |
43 | index XXXXXXX..XXXXXXX 100644 | 34 | + { "iscsi-uri", 'i', 0, G_OPTION_ARG_FILENAME, &iscsi_uri, |
44 | --- a/qom/object.c | 35 | + "iSCSI URI to connect to", "FDNUM" }, |
45 | +++ b/qom/object.c | 36 | + { "socket-path", 's', 0, G_OPTION_ARG_FILENAME, &opt_socket_path, |
46 | @@ -XXX,XX +XXX,XX @@ Object *object_get_objects_root(void) | 37 | + "Use UNIX socket path", "PATH" }, |
47 | return container_get(object_get_root(), "/objects"); | 38 | + { NULL, } |
48 | } | 39 | +}; |
49 | |||
50 | +Object *object_get_internal_root(void) | ||
51 | +{ | ||
52 | + static Object *internal_root; | ||
53 | + | 40 | + |
54 | + if (!internal_root) { | 41 | int main(int argc, char **argv) |
55 | + internal_root = object_new("container"); | 42 | { |
43 | VusDev *vdev_scsi = NULL; | ||
44 | - char *unix_fn = NULL; | ||
45 | - char *iscsi_uri = NULL; | ||
46 | - int lsock = -1, csock = -1, opt, err = EXIT_SUCCESS; | ||
47 | + int lsock = -1, csock = -1, err = EXIT_SUCCESS; | ||
48 | |||
49 | - while ((opt = getopt(argc, argv, "u:i:")) != -1) { | ||
50 | - switch (opt) { | ||
51 | - case 'h': | ||
52 | - goto help; | ||
53 | - case 'u': | ||
54 | - unix_fn = g_strdup(optarg); | ||
55 | - break; | ||
56 | - case 'i': | ||
57 | - iscsi_uri = g_strdup(optarg); | ||
58 | - break; | ||
59 | - default: | ||
60 | - goto help; | ||
61 | - } | ||
62 | + GError *error = NULL; | ||
63 | + GOptionContext *context; | ||
64 | + | ||
65 | + context = g_option_context_new(NULL); | ||
66 | + g_option_context_add_main_entries(context, entries, NULL); | ||
67 | + if (!g_option_context_parse(context, &argc, &argv, &error)) { | ||
68 | + g_printerr("Option parsing failed: %s\n", error->message); | ||
69 | + exit(EXIT_FAILURE); | ||
56 | + } | 70 | + } |
57 | + | 71 | + |
58 | + return internal_root; | 72 | + if (opt_print_caps) { |
59 | +} | 73 | + g_print("{\n"); |
74 | + g_print(" \"type\": \"scsi\"\n"); | ||
75 | + g_print("}\n"); | ||
76 | + goto out; | ||
77 | } | ||
78 | - if (!unix_fn || !iscsi_uri) { | ||
60 | + | 79 | + |
61 | static void object_get_child_property(Object *obj, Visitor *v, | 80 | + if (!iscsi_uri) { |
62 | const char *name, void *opaque, | 81 | goto help; |
63 | Error **errp) | 82 | } |
83 | |||
84 | - lsock = unix_sock_new(unix_fn); | ||
85 | - if (lsock < 0) { | ||
86 | - goto err; | ||
87 | + if (opt_socket_path) { | ||
88 | + lsock = unix_sock_new(opt_socket_path); | ||
89 | + if (lsock < 0) { | ||
90 | + exit(EXIT_FAILURE); | ||
91 | + } | ||
92 | + } else if (opt_fdnum < 0) { | ||
93 | + g_print("%s\n", g_option_context_get_help(context, true, NULL)); | ||
94 | + exit(EXIT_FAILURE); | ||
95 | + } else { | ||
96 | + lsock = opt_fdnum; | ||
97 | } | ||
98 | |||
99 | csock = accept(lsock, NULL, NULL); | ||
100 | @@ -XXX,XX +XXX,XX @@ out: | ||
101 | if (vdev_scsi) { | ||
102 | g_main_loop_unref(vdev_scsi->loop); | ||
103 | g_free(vdev_scsi); | ||
104 | - unlink(unix_fn); | ||
105 | + unlink(opt_socket_path); | ||
106 | } | ||
107 | if (csock >= 0) { | ||
108 | close(csock); | ||
109 | @@ -XXX,XX +XXX,XX @@ out: | ||
110 | if (lsock >= 0) { | ||
111 | close(lsock); | ||
112 | } | ||
113 | - g_free(unix_fn); | ||
114 | + g_free(opt_socket_path); | ||
115 | g_free(iscsi_uri); | ||
116 | |||
117 | return err; | ||
118 | @@ -XXX,XX +XXX,XX @@ err: | ||
119 | goto out; | ||
120 | |||
121 | help: | ||
122 | - fprintf(stderr, "Usage: %s [ -u unix_sock_path -i iscsi_uri ] | [ -h ]\n", | ||
123 | + fprintf(stderr, "Usage: %s [ -s socket-path -i iscsi-uri -f fd -p print-capabilities ] | [ -h ]\n", | ||
124 | argv[0]); | ||
125 | - fprintf(stderr, " -u path to unix socket\n"); | ||
126 | - fprintf(stderr, " -i iscsi uri for lun 0\n"); | ||
127 | + fprintf(stderr, " -s, --socket-path=SOCKET_PATH path to unix socket\n"); | ||
128 | + fprintf(stderr, " -i, --iscsi-uri=ISCSI_URI iscsi uri for lun 0\n"); | ||
129 | + fprintf(stderr, " -f, --fd=FILE_DESCRIPTOR file-descriptor\n"); | ||
130 | + fprintf(stderr, " -p, --print-capabilities=PRINT_CAPABILITIES denotes print-capabilities\n"); | ||
131 | fprintf(stderr, " -h print help and quit\n"); | ||
132 | |||
133 | goto err; | ||
64 | -- | 134 | -- |
65 | 2.13.6 | 135 | 2.35.1 |
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 | After iothread is enabled internally inside QEMU with GMainContext, we | 1 | The GLib documentation says "a NULL-terminated array of GOptionEntrys" |
---|---|---|---|
2 | may encounter this warning when destroying the iothread: | 2 | so we'd better make sure there is a terminator that lets |
3 | 3 | g_option_context_add_main_entries() know when the end of the array has | |
4 | (qemu-system-x86_64:19925): GLib-CRITICAL **: g_source_remove_poll: | 4 | been reached. |
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 | 5 | ||
15 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 6 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
16 | Reviewed-by: Fam Zheng <famz@redhat.com> | 7 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> |
17 | Signed-off-by: Peter Xu <peterx@redhat.com> | 8 | Message-id: 20220411150057.3009667-1-stefanha@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> | 9 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
22 | --- | 10 | --- |
23 | util/aio-posix.c | 9 ++++++++- | 11 | contrib/vhost-user-blk/vhost-user-blk.c | 3 ++- |
24 | 1 file changed, 8 insertions(+), 1 deletion(-) | 12 | 1 file changed, 2 insertions(+), 1 deletion(-) |
25 | 13 | ||
26 | diff --git a/util/aio-posix.c b/util/aio-posix.c | 14 | diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c |
27 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/util/aio-posix.c | 16 | --- a/contrib/vhost-user-blk/vhost-user-blk.c |
29 | +++ b/util/aio-posix.c | 17 | +++ b/contrib/vhost-user-blk/vhost-user-blk.c |
30 | @@ -XXX,XX +XXX,XX @@ void aio_set_fd_handler(AioContext *ctx, | 18 | @@ -XXX,XX +XXX,XX @@ static GOptionEntry entries[] = { |
31 | return; | 19 | {"blk-file", 'b', 0, G_OPTION_ARG_FILENAME, &opt_blk_file, |
32 | } | 20 | "block device or file path", "PATH"}, |
33 | 21 | { "read-only", 'r', 0, G_OPTION_ARG_NONE, &opt_read_only, | |
34 | - g_source_remove_poll(&ctx->source, &node->pfd); | 22 | - "Enable read-only", NULL } |
35 | + /* If the GSource is in the process of being destroyed then | 23 | + "Enable read-only", NULL }, |
36 | + * g_source_remove_poll() causes an assertion failure. Skip | 24 | + { NULL, }, |
37 | + * removal in that case, because glib cleans up its state during | 25 | }; |
38 | + * destruction anyway. | 26 | |
39 | + */ | 27 | int main(int argc, char **argv) |
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 | -- | 28 | -- |
47 | 2.13.6 | 29 | 2.35.1 |
48 | |||
49 | diff view generated by jsdifflib |
1 | From: Peter Xu <peterx@redhat.com> | 1 | From: Liu Yiding <liuyd.fnst@fujitsu.com> |
---|---|---|---|
2 | 2 | ||
3 | So that internal iothread users can explicitly stop one iothread without | 3 | virtiofsd has introduced killpriv_v2/no_killpriv_v2 for a while. Add |
4 | destroying it. | 4 | description of it to docs/helper. |
5 | 5 | ||
6 | Since at it, fix iothread_stop() to allow it to be called multiple | 6 | Signed-off-by: Liu Yiding <liuyd.fnst@fujitsu.com> |
7 | times. Before this patch we may call iothread_stop() more than once on | 7 | Message-Id: <20220421095151.2231099-1-liuyd.fnst@fujitsu.com> |
8 | single iothread, while that may not be correct since qemu_thread_join() | ||
9 | is not allowed to run twice. From manual of pthread_join(): | ||
10 | 8 | ||
11 | Joining with a thread that has previously been joined results in | 9 | [Small documentation fixes: s/as client supports/as the client supports/ |
12 | undefined behavior. | 10 | and s/. /. /. |
11 | --Stefan] | ||
13 | 12 | ||
14 | Reviewed-by: Fam Zheng <famz@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> | 13 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
19 | --- | 14 | --- |
20 | include/sysemu/iothread.h | 1 + | 15 | docs/tools/virtiofsd.rst | 5 +++++ |
21 | iothread.c | 24 ++++++++++++++++-------- | 16 | tools/virtiofsd/helper.c | 3 +++ |
22 | 2 files changed, 17 insertions(+), 8 deletions(-) | 17 | 2 files changed, 8 insertions(+) |
23 | 18 | ||
24 | diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h | 19 | diff --git a/docs/tools/virtiofsd.rst b/docs/tools/virtiofsd.rst |
25 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/sysemu/iothread.h | 21 | --- a/docs/tools/virtiofsd.rst |
27 | +++ b/include/sysemu/iothread.h | 22 | +++ b/docs/tools/virtiofsd.rst |
28 | @@ -XXX,XX +XXX,XX @@ GMainContext *iothread_get_g_main_context(IOThread *iothread); | 23 | @@ -XXX,XX +XXX,XX @@ Options |
29 | * "query-iothreads". | 24 | label. Server will try to set that label on newly created file |
30 | */ | 25 | atomically wherever possible. |
31 | IOThread *iothread_create(const char *id, Error **errp); | 26 | |
32 | +void iothread_stop(IOThread *iothread); | 27 | + * killpriv_v2|no_killpriv_v2 - |
33 | void iothread_destroy(IOThread *iothread); | 28 | + Enable/disable ``FUSE_HANDLE_KILLPRIV_V2`` support. KILLPRIV_V2 is enabled |
34 | 29 | + by default as long as the client supports it. Enabling this option helps | |
35 | #endif /* IOTHREAD_H */ | 30 | + with performance in write path. |
36 | diff --git a/iothread.c b/iothread.c | 31 | + |
32 | .. option:: --socket-path=PATH | ||
33 | |||
34 | Listen on vhost-user UNIX domain socket at PATH. | ||
35 | diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | 36 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/iothread.c | 37 | --- a/tools/virtiofsd/helper.c |
39 | +++ b/iothread.c | 38 | +++ b/tools/virtiofsd/helper.c |
40 | @@ -XXX,XX +XXX,XX @@ static void *iothread_run(void *opaque) | 39 | @@ -XXX,XX +XXX,XX @@ void fuse_cmdline_help(void) |
41 | return NULL; | 40 | " -o announce_submounts Announce sub-mount points to the guest\n" |
41 | " -o posix_acl/no_posix_acl Enable/Disable posix_acl. (default: disabled)\n" | ||
42 | " -o security_label/no_security_label Enable/Disable security label. (default: disabled)\n" | ||
43 | + " -o killpriv_v2/no_killpriv_v2\n" | ||
44 | + " Enable/Disable FUSE_HANDLE_KILLPRIV_V2.\n" | ||
45 | + " (default: enabled as long as client supports it)\n" | ||
46 | ); | ||
42 | } | 47 | } |
43 | 48 | ||
44 | -static int iothread_stop(Object *object, void *opaque) | ||
45 | +void iothread_stop(IOThread *iothread) | ||
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 | { | ||
77 | IOThread *iothread = IOTHREAD(obj); | ||
78 | |||
79 | - iothread_stop(obj, NULL); | ||
80 | + iothread_stop(iothread); | ||
81 | qemu_cond_destroy(&iothread->init_done_cond); | ||
82 | qemu_mutex_destroy(&iothread->init_done_lock); | ||
83 | if (!iothread->ctx) { | ||
84 | @@ -XXX,XX +XXX,XX @@ void iothread_stop_all(void) | ||
85 | aio_context_release(ctx); | ||
86 | } | ||
87 | |||
88 | - object_child_foreach(container, iothread_stop, NULL); | ||
89 | + object_child_foreach(container, iothread_stop_iter, NULL); | ||
90 | } | ||
91 | |||
92 | static gpointer iothread_g_main_context_init(gpointer opaque) | ||
93 | -- | 49 | -- |
94 | 2.13.6 | 50 | 2.35.1 |
95 | |||
96 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Peter Xu <peterx@redhat.com> | ||
2 | 1 | ||
3 | When gcontext is used with iothread, the context will be destroyed | ||
4 | during iothread_stop(). That's not good since sometimes we would like | ||
5 | to keep the resources until iothread is destroyed, but we may want to | ||
6 | stop the thread before that point. | ||
7 | |||
8 | Delay the destruction of gcontext to iothread finalize. Then we can do: | ||
9 | |||
10 | iothread_stop(thread); | ||
11 | some_cleanup_on_resources(); | ||
12 | iothread_destroy(thread); | ||
13 | |||
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> | ||
24 | --- | ||
25 | iothread.c | 6 ++++-- | ||
26 | 1 file changed, 4 insertions(+), 2 deletions(-) | ||
27 | |||
28 | diff --git a/iothread.c b/iothread.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/iothread.c | ||
31 | +++ b/iothread.c | ||
32 | @@ -XXX,XX +XXX,XX @@ static void *iothread_run(void *opaque) | ||
33 | g_main_loop_unref(loop); | ||
34 | |||
35 | g_main_context_pop_thread_default(iothread->worker_context); | ||
36 | - g_main_context_unref(iothread->worker_context); | ||
37 | - iothread->worker_context = NULL; | ||
38 | } | ||
39 | } | ||
40 | |||
41 | @@ -XXX,XX +XXX,XX @@ static void iothread_instance_finalize(Object *obj) | ||
42 | IOThread *iothread = IOTHREAD(obj); | ||
43 | |||
44 | iothread_stop(iothread); | ||
45 | + if (iothread->worker_context) { | ||
46 | + g_main_context_unref(iothread->worker_context); | ||
47 | + iothread->worker_context = NULL; | ||
48 | + } | ||
49 | qemu_cond_destroy(&iothread->init_done_cond); | ||
50 | qemu_mutex_destroy(&iothread->init_done_lock); | ||
51 | if (!iothread->ctx) { | ||
52 | -- | ||
53 | 2.13.6 | ||
54 | |||
55 | diff view generated by jsdifflib |