1 | The following changes since commit 0280396a33c7210c4df5306afeab63411a41535a: | 1 | The following changes since commit e3debd5e7d0ce031356024878a0a18b9d109354a: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/stsquad/tags/pull-testing-gdbstub-150221-1' into staging (2021-02-15 10:13:13 +0000) | 3 | Merge tag 'pull-request-2023-03-24' of https://gitlab.com/thuth/qemu into staging (2023-03-24 16:08:46 +0000) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | git://repo.or.cz/qemu/kevin.git tags/for-upstream | 7 | https://repo.or.cz/qemu/kevin.git tags/for-upstream |
8 | 8 | ||
9 | for you to fetch changes up to b248e61652e20c3353af4b0ccb90f17d76f4db21: | 9 | for you to fetch changes up to d8fbf9aa85aed64450907580a1d70583f097e9df: |
10 | 10 | ||
11 | monitor/qmp: Stop processing requests when shutdown is requested (2021-02-15 15:10:14 +0100) | 11 | block/export: Fix graph locking in blk_get_geometry() call (2023-03-27 15:16:05 +0200) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Block layer patches: | 14 | Block layer patches |
15 | 15 | ||
16 | - qemu-storage-daemon: Enable object-add | 16 | - aio-posix: Fix race during epoll upgrade |
17 | - blockjob: Fix crash with IOthread when block commit after snapshot | 17 | - vhost-user-blk/VDUSE export: Fix a potential deadlock and an assertion |
18 | - monitor: Shutdown fixes | 18 | failure when the export runs in an iothread |
19 | - xen-block: fix reporting of discard feature | 19 | - NBD server: Push pending frames after sending reply to fix performance |
20 | - qcow2: Remove half-initialised image file after failed image creation | 20 | especially when used with TLS |
21 | - ahci: Fix DMA direction | ||
22 | - iotests fixes | ||
23 | 21 | ||
24 | ---------------------------------------------------------------- | 22 | ---------------------------------------------------------------- |
25 | Alexander Bulekov (1): | 23 | Florian Westphal (1): |
26 | hw/ide/ahci: map cmd_fis as DMA_DIRECTION_TO_DEVICE | 24 | nbd/server: push pending frames after sending reply |
27 | 25 | ||
28 | Kevin Wolf (3): | 26 | Kevin Wolf (1): |
29 | qemu-storage-daemon: Enable object-add | 27 | block/export: Fix graph locking in blk_get_geometry() call |
30 | monitor: Fix assertion failure on shutdown | ||
31 | monitor/qmp: Stop processing requests when shutdown is requested | ||
32 | 28 | ||
33 | Max Reitz (1): | 29 | Stefan Hajnoczi (2): |
34 | iotests: Consistent $IMGOPTS boundary matching | 30 | block/export: only acquire AioContext once for vhost_user_server_stop() |
31 | aio-posix: fix race between epoll upgrade and aio_set_fd_handler() | ||
35 | 32 | ||
36 | Maxim Levitsky (3): | 33 | include/block/block-io.h | 4 +++- |
37 | crypto: luks: Fix tiny memory leak | 34 | include/sysemu/block-backend-io.h | 5 ++++- |
38 | block: add bdrv_co_delete_file_noerr | 35 | block.c | 5 +++-- |
39 | block: qcow2: remove the created file on initialization error | 36 | block/block-backend.c | 7 +++++-- |
40 | 37 | block/export/virtio-blk-handler.c | 7 ++++--- | |
41 | Michael Qiu (1): | 38 | nbd/server.c | 3 +++ |
42 | blockjob: Fix crash with IOthread when block commit after snapshot | 39 | util/fdmon-epoll.c | 25 ++++++++++++++++++------- |
43 | 40 | util/vhost-user-server.c | 5 +---- | |
44 | Roger Pau Monné (1): | 41 | 8 files changed, 41 insertions(+), 20 deletions(-) |
45 | xen-block: fix reporting of discard feature | ||
46 | |||
47 | Thomas Huth (1): | ||
48 | tests/qemu-iotests: Remove test 259 from the "auto" group | ||
49 | |||
50 | include/block/block.h | 1 + | ||
51 | block.c | 22 ++++++++++++++++++++++ | ||
52 | block/crypto.c | 13 ++----------- | ||
53 | block/qcow2.c | 8 +++++--- | ||
54 | blockjob.c | 8 ++++++-- | ||
55 | hw/block/xen-block.c | 1 + | ||
56 | hw/ide/ahci.c | 12 ++++++------ | ||
57 | monitor/monitor.c | 25 +++++++++++++++---------- | ||
58 | monitor/qmp.c | 5 +++++ | ||
59 | storage-daemon/qemu-storage-daemon.c | 2 ++ | ||
60 | tests/qemu-iotests/259 | 2 +- | ||
61 | tests/qemu-iotests/common.rc | 4 +++- | ||
62 | 12 files changed, 69 insertions(+), 34 deletions(-) | ||
63 | |||
64 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | As we don't have a fully QAPIfied version of object-add yet and it still | ||
2 | has 'gen': false in the schema, it needs to be registered explicitly in | ||
3 | init_qmp_commands() to be available for users. | ||
4 | 1 | ||
5 | Fixes: 2af282ec51a27116d0402cab237b8970800f870c | ||
6 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
7 | Message-Id: <20210204072137.19663-1-kwolf@redhat.com> | ||
8 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
10 | --- | ||
11 | storage-daemon/qemu-storage-daemon.c | 2 ++ | ||
12 | 1 file changed, 2 insertions(+) | ||
13 | |||
14 | diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-storage-daemon.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/storage-daemon/qemu-storage-daemon.c | ||
17 | +++ b/storage-daemon/qemu-storage-daemon.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void init_qmp_commands(void) | ||
19 | qmp_init_marshal(&qmp_commands); | ||
20 | qmp_register_command(&qmp_commands, "query-qmp-schema", | ||
21 | qmp_query_qmp_schema, QCO_ALLOW_PRECONFIG); | ||
22 | + qmp_register_command(&qmp_commands, "object-add", qmp_object_add, | ||
23 | + QCO_NO_OPTIONS); | ||
24 | |||
25 | QTAILQ_INIT(&qmp_cap_negotiation_commands); | ||
26 | qmp_register_command(&qmp_cap_negotiation_commands, "qmp_capabilities", | ||
27 | -- | ||
28 | 2.29.2 | ||
29 | |||
30 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Max Reitz <mreitz@redhat.com> | ||
2 | 1 | ||
3 | To disallow certain refcount_bits values, some _unsupported_imgopts | ||
4 | invocations look like "refcount_bits=1[^0-9]", i.e. they match an | ||
5 | integer boundary with [^0-9]. This expression does not match the end of | ||
6 | the string, though, so it breaks down when refcount_bits is the last | ||
7 | option (which it tends to be after the rewrite of the check script in | ||
8 | Python). | ||
9 | |||
10 | Those invocations could use \b or \> instead, but those are not | ||
11 | portable. They could use something like \([^0-9]\|$\), but that would | ||
12 | be cumbersome. To make it simple and keep the existing invocations | ||
13 | working, just let _unsupported_imgopts match the regex against $IMGOPTS | ||
14 | plus a trailing space. | ||
15 | |||
16 | Suggested-by: Eric Blake <eblake@redhat.com> | ||
17 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
18 | Message-Id: <20210210095128.22732-1-mreitz@redhat.com> | ||
19 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
20 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
21 | --- | ||
22 | tests/qemu-iotests/common.rc | 4 +++- | ||
23 | 1 file changed, 3 insertions(+), 1 deletion(-) | ||
24 | |||
25 | diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/tests/qemu-iotests/common.rc | ||
28 | +++ b/tests/qemu-iotests/common.rc | ||
29 | @@ -XXX,XX +XXX,XX @@ _unsupported_imgopts() | ||
30 | { | ||
31 | for bad_opt | ||
32 | do | ||
33 | - if echo "$IMGOPTS" | grep -q 2>/dev/null "$bad_opt" | ||
34 | + # Add a space so tests can match for whitespace that marks the | ||
35 | + # end of an option (\b or \> are not portable) | ||
36 | + if echo "$IMGOPTS " | grep -q 2>/dev/null "$bad_opt" | ||
37 | then | ||
38 | _notrun "not suitable for image option: $bad_opt" | ||
39 | fi | ||
40 | -- | ||
41 | 2.29.2 | ||
42 | |||
43 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Michael Qiu <qiudayu@huayun.com> | ||
2 | 1 | ||
3 | Currently, if guest has workloads, IO thread will acquire aio_context | ||
4 | lock before do io_submit, it leads to segmentfault when do block commit | ||
5 | after snapshot. Just like below: | ||
6 | |||
7 | Program received signal SIGSEGV, Segmentation fault. | ||
8 | |||
9 | [Switching to Thread 0x7f7c7d91f700 (LWP 99907)] | ||
10 | 0x00005576d0f65aab in bdrv_mirror_top_pwritev at ../block/mirror.c:1437 | ||
11 | 1437 ../block/mirror.c: No such file or directory. | ||
12 | (gdb) p s->job | ||
13 | $17 = (MirrorBlockJob *) 0x0 | ||
14 | (gdb) p s->stop | ||
15 | $18 = false | ||
16 | |||
17 | Call trace of IO thread: | ||
18 | 0 0x00005576d0f65aab in bdrv_mirror_top_pwritev at ../block/mirror.c:1437 | ||
19 | 1 0x00005576d0f7f3ab in bdrv_driver_pwritev at ../block/io.c:1174 | ||
20 | 2 0x00005576d0f8139d in bdrv_aligned_pwritev at ../block/io.c:1988 | ||
21 | 3 0x00005576d0f81b65 in bdrv_co_pwritev_part at ../block/io.c:2156 | ||
22 | 4 0x00005576d0f8e6b7 in blk_do_pwritev_part at ../block/block-backend.c:1260 | ||
23 | 5 0x00005576d0f8e84d in blk_aio_write_entry at ../block/block-backend.c:1476 | ||
24 | ... | ||
25 | |||
26 | Switch to qemu main thread: | ||
27 | 0 0x00007f903be704ed in __lll_lock_wait at | ||
28 | /lib/../lib64/libpthread.so.0 | ||
29 | 1 0x00007f903be6bde6 in _L_lock_941 at /lib/../lib64/libpthread.so.0 | ||
30 | 2 0x00007f903be6bcdf in pthread_mutex_lock at | ||
31 | /lib/../lib64/libpthread.so.0 | ||
32 | 3 0x0000564b21456889 in qemu_mutex_lock_impl at | ||
33 | ../util/qemu-thread-posix.c:79 | ||
34 | 4 0x0000564b213af8a5 in block_job_add_bdrv at ../blockjob.c:224 | ||
35 | 5 0x0000564b213b00ad in block_job_create at ../blockjob.c:440 | ||
36 | 6 0x0000564b21357c0a in mirror_start_job at ../block/mirror.c:1622 | ||
37 | 7 0x0000564b2135a9af in commit_active_start at ../block/mirror.c:1867 | ||
38 | 8 0x0000564b2133d132 in qmp_block_commit at ../blockdev.c:2768 | ||
39 | 9 0x0000564b2141fef3 in qmp_marshal_block_commit at | ||
40 | qapi/qapi-commands-block-core.c:346 | ||
41 | 10 0x0000564b214503c9 in do_qmp_dispatch_bh at | ||
42 | ../qapi/qmp-dispatch.c:110 | ||
43 | 11 0x0000564b21451996 in aio_bh_poll at ../util/async.c:164 | ||
44 | 12 0x0000564b2146018e in aio_dispatch at ../util/aio-posix.c:381 | ||
45 | 13 0x0000564b2145187e in aio_ctx_dispatch at ../util/async.c:306 | ||
46 | 14 0x00007f9040239049 in g_main_context_dispatch at | ||
47 | /lib/../lib64/libglib-2.0.so.0 | ||
48 | 15 0x0000564b21447368 in main_loop_wait at ../util/main-loop.c:232 | ||
49 | 16 0x0000564b21447368 in main_loop_wait at ../util/main-loop.c:255 | ||
50 | 17 0x0000564b21447368 in main_loop_wait at ../util/main-loop.c:531 | ||
51 | 18 0x0000564b212304e1 in qemu_main_loop at ../softmmu/runstate.c:721 | ||
52 | 19 0x0000564b20f7975e in main at ../softmmu/main.c:50 | ||
53 | |||
54 | In IO thread when do bdrv_mirror_top_pwritev, the job is NULL, and stop field | ||
55 | is false, this means the MirrorBDSOpaque "s" object has not been initialized | ||
56 | yet, and this object is initialized by block_job_create(), but the initialize | ||
57 | process is stuck in acquiring the lock. | ||
58 | |||
59 | In this situation, IO thread come to bdrv_mirror_top_pwritev(),which means that | ||
60 | mirror-top node is already inserted into block graph, but its bs->opaque->job | ||
61 | is not initialized. | ||
62 | |||
63 | The root cause is that qemu main thread do release/acquire when hold the lock, | ||
64 | at the same time, IO thread get the lock after release stage, and the crash | ||
65 | occured. | ||
66 | |||
67 | Actually, in this situation, job->job.aio_context will not equal to | ||
68 | qemu_get_aio_context(), and will be the same as bs->aio_context, | ||
69 | thus, no need to release the lock, becasue bdrv_root_attach_child() | ||
70 | will not change the context. | ||
71 | |||
72 | This patch fix this issue. | ||
73 | |||
74 | Fixes: 132ada80 "block: Adjust AioContexts when attaching nodes" | ||
75 | |||
76 | Signed-off-by: Michael Qiu <qiudayu@huayun.com> | ||
77 | Message-Id: <20210203024059.52683-1-08005325@163.com> | ||
78 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
79 | --- | ||
80 | blockjob.c | 8 ++++++-- | ||
81 | 1 file changed, 6 insertions(+), 2 deletions(-) | ||
82 | |||
83 | diff --git a/blockjob.c b/blockjob.c | ||
84 | index XXXXXXX..XXXXXXX 100644 | ||
85 | --- a/blockjob.c | ||
86 | +++ b/blockjob.c | ||
87 | @@ -XXX,XX +XXX,XX @@ int block_job_add_bdrv(BlockJob *job, const char *name, BlockDriverState *bs, | ||
88 | uint64_t perm, uint64_t shared_perm, Error **errp) | ||
89 | { | ||
90 | BdrvChild *c; | ||
91 | + bool need_context_ops; | ||
92 | |||
93 | bdrv_ref(bs); | ||
94 | - if (job->job.aio_context != qemu_get_aio_context()) { | ||
95 | + | ||
96 | + need_context_ops = bdrv_get_aio_context(bs) != job->job.aio_context; | ||
97 | + | ||
98 | + if (need_context_ops && job->job.aio_context != qemu_get_aio_context()) { | ||
99 | aio_context_release(job->job.aio_context); | ||
100 | } | ||
101 | c = bdrv_root_attach_child(bs, name, &child_job, 0, | ||
102 | job->job.aio_context, perm, shared_perm, job, | ||
103 | errp); | ||
104 | - if (job->job.aio_context != qemu_get_aio_context()) { | ||
105 | + if (need_context_ops && job->job.aio_context != qemu_get_aio_context()) { | ||
106 | aio_context_acquire(job->job.aio_context); | ||
107 | } | ||
108 | if (c == NULL) { | ||
109 | -- | ||
110 | 2.29.2 | ||
111 | |||
112 | diff view generated by jsdifflib |
1 | From: Maxim Levitsky <mlevitsk@redhat.com> | 1 | From: Florian Westphal <fw@strlen.de> |
---|---|---|---|
2 | 2 | ||
3 | If the qcow initialization fails, we should remove the file if it was | 3 | qemu-nbd doesn't set TCP_NODELAY on the tcp socket. |
4 | already created, to avoid leaving stale files around. | ||
5 | 4 | ||
6 | We already do this for luks raw images. | 5 | Kernel waits for more data and avoids transmission of small packets. |
6 | Without TLS this is barely noticeable, but with TLS this really shows. | ||
7 | 7 | ||
8 | Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> | 8 | Booting a VM via qemu-nbd on localhost (with tls) takes more than |
9 | Reviewed-by: Alberto Garcia <berto@igalia.com> | 9 | 2 minutes on my system. tcpdump shows frequent wait periods, where no |
10 | Message-Id: <20201217170904.946013-4-mlevitsk@redhat.com> | 10 | packets get sent for a 40ms period. |
11 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 11 | |
12 | Add explicit (un)corking when processing (and responding to) requests. | ||
13 | "TCP_CORK, &zero" after earlier "CORK, &one" will flush pending data. | ||
14 | |||
15 | VM Boot time: | ||
16 | main: no tls: 23s, with tls: 2m45s | ||
17 | patched: no tls: 14s, with tls: 15s | ||
18 | |||
19 | VM Boot time, qemu-nbd via network (same lan): | ||
20 | main: no tls: 18s, with tls: 1m50s | ||
21 | patched: no tls: 17s, with tls: 18s | ||
22 | |||
23 | Future optimization: if we could detect if there is another pending | ||
24 | request we could defer the uncork operation because more data would be | ||
25 | appended. | ||
26 | |||
27 | Signed-off-by: Florian Westphal <fw@strlen.de> | ||
28 | Message-Id: <20230324104720.2498-1-fw@strlen.de> | ||
29 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
30 | Reviewed-by: Kevin Wolf <kwolf@redhat.com> | ||
12 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 31 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
13 | --- | 32 | --- |
14 | block/qcow2.c | 8 +++++--- | 33 | nbd/server.c | 3 +++ |
15 | 1 file changed, 5 insertions(+), 3 deletions(-) | 34 | 1 file changed, 3 insertions(+) |
16 | 35 | ||
17 | diff --git a/block/qcow2.c b/block/qcow2.c | 36 | diff --git a/nbd/server.c b/nbd/server.c |
18 | index XXXXXXX..XXXXXXX 100644 | 37 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/block/qcow2.c | 38 | --- a/nbd/server.c |
20 | +++ b/block/qcow2.c | 39 | +++ b/nbd/server.c |
21 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_co_create_opts(BlockDriver *drv, | 40 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn void nbd_trip(void *opaque) |
22 | 41 | goto disconnect; | |
23 | /* Create the qcow2 image (format layer) */ | 42 | } |
24 | ret = qcow2_co_create(create_options, errp); | 43 | |
25 | +finish: | 44 | + qio_channel_set_cork(client->ioc, true); |
45 | + | ||
26 | if (ret < 0) { | 46 | if (ret < 0) { |
27 | - goto finish; | 47 | /* It wasn't -EIO, so, according to nbd_co_receive_request() |
28 | + bdrv_co_delete_file_noerr(bs); | 48 | * semantics, we should return the error to the client. */ |
29 | + bdrv_co_delete_file_noerr(data_bs); | 49 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn void nbd_trip(void *opaque) |
30 | + } else { | 50 | goto disconnect; |
31 | + ret = 0; | ||
32 | } | 51 | } |
33 | 52 | ||
34 | - ret = 0; | 53 | + qio_channel_set_cork(client->ioc, false); |
35 | -finish: | 54 | done: |
36 | qobject_unref(qdict); | 55 | nbd_request_put(req); |
37 | bdrv_unref(bs); | 56 | nbd_client_put(client); |
38 | bdrv_unref(data_bs); | ||
39 | -- | 57 | -- |
40 | 2.29.2 | 58 | 2.39.2 |
41 | |||
42 | diff view generated by jsdifflib |
1 | From: Alexander Bulekov <alxndr@bu.edu> | 1 | From: Stefan Hajnoczi <stefanha@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | cmd_fis is mapped as DMA_DIRECTION_FROM_DEVICE, however, it is read | 3 | vhost_user_server_stop() uses AIO_WAIT_WHILE(). AIO_WAIT_WHILE() |
4 | from, and not written to anywhere. Fix the DMA_DIRECTION and mark | 4 | requires that AioContext is only acquired once. |
5 | cmd_fis as read-only in the code. | ||
6 | 5 | ||
7 | Signed-off-by: Alexander Bulekov <alxndr@bu.edu> | 6 | Since blk_exp_request_shutdown() already acquires the AioContext it |
8 | Message-Id: <20210119164051.89268-1-alxndr@bu.edu> | 7 | shouldn't be acquired again in vhost_user_server_stop(). |
8 | |||
9 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
10 | Message-Id: <20230323145853.1345527-1-stefanha@redhat.com> | ||
11 | Reviewed-by: Kevin Wolf <kwolf@redhat.com> | ||
9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 12 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
10 | --- | 13 | --- |
11 | hw/ide/ahci.c | 12 ++++++------ | 14 | util/vhost-user-server.c | 5 +---- |
12 | 1 file changed, 6 insertions(+), 6 deletions(-) | 15 | 1 file changed, 1 insertion(+), 4 deletions(-) |
13 | 16 | ||
14 | diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c | 17 | diff --git a/util/vhost-user-server.c b/util/vhost-user-server.c |
15 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/ide/ahci.c | 19 | --- a/util/vhost-user-server.c |
17 | +++ b/hw/ide/ahci.c | 20 | +++ b/util/vhost-user-server.c |
18 | @@ -XXX,XX +XXX,XX @@ static void ahci_reset_port(AHCIState *s, int port) | 21 | @@ -XXX,XX +XXX,XX @@ static void vu_accept(QIONetListener *listener, QIOChannelSocket *sioc, |
22 | aio_context_release(server->ctx); | ||
19 | } | 23 | } |
20 | 24 | ||
21 | /* Buffer pretty output based on a raw FIS structure. */ | 25 | +/* server->ctx acquired by caller */ |
22 | -static char *ahci_pretty_buffer_fis(uint8_t *fis, int cmd_len) | 26 | void vhost_user_server_stop(VuServer *server) |
23 | +static char *ahci_pretty_buffer_fis(const uint8_t *fis, int cmd_len) | ||
24 | { | 27 | { |
25 | int i; | 28 | - aio_context_acquire(server->ctx); |
26 | GString *s = g_string_new("FIS:"); | 29 | - |
27 | @@ -XXX,XX +XXX,XX @@ static void execute_ncq_command(NCQTransferState *ncq_tfs) | 30 | qemu_bh_delete(server->restart_listener_bh); |
28 | } | 31 | server->restart_listener_bh = NULL; |
29 | 32 | ||
30 | 33 | @@ -XXX,XX +XXX,XX @@ void vhost_user_server_stop(VuServer *server) | |
31 | -static void process_ncq_command(AHCIState *s, int port, uint8_t *cmd_fis, | 34 | AIO_WAIT_WHILE(server->ctx, server->co_trip); |
32 | +static void process_ncq_command(AHCIState *s, int port, const uint8_t *cmd_fis, | ||
33 | uint8_t slot) | ||
34 | { | ||
35 | AHCIDevice *ad = &s->dev[port]; | ||
36 | - NCQFrame *ncq_fis = (NCQFrame*)cmd_fis; | ||
37 | + const NCQFrame *ncq_fis = (NCQFrame *)cmd_fis; | ||
38 | uint8_t tag = ncq_fis->tag >> 3; | ||
39 | NCQTransferState *ncq_tfs = &ad->ncq_tfs[tag]; | ||
40 | size_t size; | ||
41 | @@ -XXX,XX +XXX,XX @@ static AHCICmdHdr *get_cmd_header(AHCIState *s, uint8_t port, uint8_t slot) | ||
42 | } | ||
43 | |||
44 | static void handle_reg_h2d_fis(AHCIState *s, int port, | ||
45 | - uint8_t slot, uint8_t *cmd_fis) | ||
46 | + uint8_t slot, const uint8_t *cmd_fis) | ||
47 | { | ||
48 | IDEState *ide_state = &s->dev[port].port.ifs[0]; | ||
49 | AHCICmdHdr *cmd = get_cmd_header(s, port, slot); | ||
50 | @@ -XXX,XX +XXX,XX @@ static int handle_cmd(AHCIState *s, int port, uint8_t slot) | ||
51 | tbl_addr = le64_to_cpu(cmd->tbl_addr); | ||
52 | cmd_len = 0x80; | ||
53 | cmd_fis = dma_memory_map(s->as, tbl_addr, &cmd_len, | ||
54 | - DMA_DIRECTION_FROM_DEVICE); | ||
55 | + DMA_DIRECTION_TO_DEVICE); | ||
56 | if (!cmd_fis) { | ||
57 | trace_handle_cmd_badfis(s, port); | ||
58 | return -1; | ||
59 | @@ -XXX,XX +XXX,XX @@ static int handle_cmd(AHCIState *s, int port, uint8_t slot) | ||
60 | } | 35 | } |
61 | 36 | ||
62 | out: | 37 | - aio_context_release(server->ctx); |
63 | - dma_memory_unmap(s->as, cmd_fis, cmd_len, DMA_DIRECTION_FROM_DEVICE, | 38 | - |
64 | + dma_memory_unmap(s->as, cmd_fis, cmd_len, DMA_DIRECTION_TO_DEVICE, | 39 | if (server->listener) { |
65 | cmd_len); | 40 | qio_net_listener_disconnect(server->listener); |
66 | 41 | object_unref(OBJECT(server->listener)); | |
67 | if (s->dev[port].port.ifs[0].status & (BUSY_STAT|DRQ_STAT)) { | ||
68 | -- | 42 | -- |
69 | 2.29.2 | 43 | 2.39.2 |
70 | |||
71 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Roger Pau Monne <roger.pau@citrix.com> | ||
2 | 1 | ||
3 | Linux blkfront expects both "discard-granularity" and | ||
4 | "discard-alignment" present on xenbus in order to properly enable the | ||
5 | feature, not exposing "discard-alignment" left some Linux blkfront | ||
6 | versions with a broken discard setup. This has also been addressed in | ||
7 | Linux with: | ||
8 | |||
9 | https://lore.kernel.org/lkml/20210118151528.81668-1-roger.pau@citrix.com/T/#u | ||
10 | |||
11 | Fix QEMU to report a "discard-alignment" of 0, in order for it to work | ||
12 | with older Linux frontends. | ||
13 | |||
14 | Reported-by: Arthur Borsboom <arthurborsboom@gmail.com> | ||
15 | Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> | ||
16 | Message-Id: <20210118153330.82324-1-roger.pau@citrix.com> | ||
17 | Reviewed-by: Paul Durrant <paul@xen.org> | ||
18 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
19 | --- | ||
20 | hw/block/xen-block.c | 1 + | ||
21 | 1 file changed, 1 insertion(+) | ||
22 | |||
23 | diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/hw/block/xen-block.c | ||
26 | +++ b/hw/block/xen-block.c | ||
27 | @@ -XXX,XX +XXX,XX @@ static void xen_block_realize(XenDevice *xendev, Error **errp) | ||
28 | xen_device_backend_printf(xendev, "feature-discard", "%u", 1); | ||
29 | xen_device_backend_printf(xendev, "discard-granularity", "%u", | ||
30 | conf->discard_granularity); | ||
31 | + xen_device_backend_printf(xendev, "discard-alignment", "%u", 0); | ||
32 | } | ||
33 | |||
34 | xen_device_backend_printf(xendev, "feature-flush-cache", "%u", 1); | ||
35 | -- | ||
36 | 2.29.2 | ||
37 | |||
38 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Thomas Huth <thuth@redhat.com> | ||
2 | 1 | ||
3 | Tests in the "auto" group should support qcow2 so that they can | ||
4 | be run during "make check-block". Test 259 only supports "raw", so | ||
5 | it currently always gets skipped when running "make check-block". | ||
6 | Let's skip this unnecessary step and remove it from the auto group. | ||
7 | |||
8 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
9 | Message-Id: <20210215103835.1129145-1-thuth@redhat.com> | ||
10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
11 | --- | ||
12 | tests/qemu-iotests/259 | 2 +- | ||
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
14 | |||
15 | diff --git a/tests/qemu-iotests/259 b/tests/qemu-iotests/259 | ||
16 | index XXXXXXX..XXXXXXX 100755 | ||
17 | --- a/tests/qemu-iotests/259 | ||
18 | +++ b/tests/qemu-iotests/259 | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #!/usr/bin/env bash | ||
21 | -# group: rw auto quick | ||
22 | +# group: rw quick | ||
23 | # | ||
24 | # Test generic image creation fallback (by using NBD) | ||
25 | # | ||
26 | -- | ||
27 | 2.29.2 | ||
28 | |||
29 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Maxim Levitsky <mlevitsk@redhat.com> | ||
2 | 1 | ||
3 | When the underlying block device doesn't support the | ||
4 | bdrv_co_delete_file interface, an 'Error' object was leaked. | ||
5 | |||
6 | Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
7 | Reviewed-by: Alberto Garcia <berto@igalia.com> | ||
8 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
9 | Message-Id: <20201217170904.946013-2-mlevitsk@redhat.com> | ||
10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
11 | --- | ||
12 | block/crypto.c | 2 ++ | ||
13 | 1 file changed, 2 insertions(+) | ||
14 | |||
15 | diff --git a/block/crypto.c b/block/crypto.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/block/crypto.c | ||
18 | +++ b/block/crypto.c | ||
19 | @@ -XXX,XX +XXX,XX @@ fail: | ||
20 | */ | ||
21 | if ((r_del < 0) && (r_del != -ENOTSUP)) { | ||
22 | error_report_err(local_delete_err); | ||
23 | + } else { | ||
24 | + error_free(local_delete_err); | ||
25 | } | ||
26 | } | ||
27 | |||
28 | -- | ||
29 | 2.29.2 | ||
30 | |||
31 | diff view generated by jsdifflib |
1 | Commit 357bda95 already tried to fix the order in monitor_cleanup() by | 1 | From: Stefan Hajnoczi <stefanha@redhat.com> |
---|---|---|---|
2 | moving shutdown of the dispatcher coroutine further to the start. | ||
3 | However, it didn't go far enough: | ||
4 | 2 | ||
5 | iothread_stop() makes sure that all pending work (bottom halves) in the | 3 | If another thread calls aio_set_fd_handler() while the IOThread event |
6 | AioContext of the monitor iothread is completed. iothread_destroy() | 4 | loop is upgrading from ppoll(2) to epoll(7) then we might miss new |
7 | depends on this and fails an assertion if there is still a pending BH. | 5 | AioHandlers. The epollfd will not monitor the new AioHandler's fd, |
6 | resulting in hangs. | ||
8 | 7 | ||
9 | While the dispatcher coroutine is running, it will try to resume the | 8 | Take the AioHandler list lock while upgrading to epoll. This prevents |
10 | monitor after taking a request out of the queue, which involves a BH. | 9 | AioHandlers from changing while epoll is being set up. If we cannot lock |
11 | The dispatcher is run until it terminates in the AIO_WAIT_WHILE() loop. | 10 | because we're in a nested event loop, then don't upgrade to epoll (it |
12 | However, adding new BHs between iothread_stop() and iothread_destroy() | 11 | will happen next time we're not in a nested call). |
13 | is forbidden. | ||
14 | 12 | ||
15 | Fix this by stopping the dispatcher first before shutting down the other | 13 | The downside to taking the lock is that the aio_set_fd_handler() thread |
16 | parts of the monitor. This means we can now receive requests that aren't | 14 | has to wait until the epoll upgrade is finished, which involves many |
17 | handled any more when QEMU is shutting down, but this is unlikely to be | 15 | epoll_ctl(2) system calls. However, this scenario is rare and I couldn't |
18 | a problem for QMP clients. | 16 | think of another solution that is still simple. |
19 | 17 | ||
20 | Fixes: 357bda9590784ff75803d52de43150d4107ed98e | 18 | Reported-by: Qing Wang <qinwang@redhat.com> |
21 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 19 | Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2090998 |
22 | Message-Id: <20210212172028.288825-2-kwolf@redhat.com> | 20 | Cc: Paolo Bonzini <pbonzini@redhat.com> |
23 | Tested-by: Markus Armbruster <armbru@redhat.com> | 21 | Cc: Fam Zheng <fam@euphon.net> |
24 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 22 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
23 | Message-Id: <20230323144859.1338495-1-stefanha@redhat.com> | ||
24 | Reviewed-by: Kevin Wolf <kwolf@redhat.com> | ||
25 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 25 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
26 | --- | 26 | --- |
27 | monitor/monitor.c | 25 +++++++++++++++---------- | 27 | util/fdmon-epoll.c | 25 ++++++++++++++++++------- |
28 | 1 file changed, 15 insertions(+), 10 deletions(-) | 28 | 1 file changed, 18 insertions(+), 7 deletions(-) |
29 | 29 | ||
30 | diff --git a/monitor/monitor.c b/monitor/monitor.c | 30 | diff --git a/util/fdmon-epoll.c b/util/fdmon-epoll.c |
31 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/monitor/monitor.c | 32 | --- a/util/fdmon-epoll.c |
33 | +++ b/monitor/monitor.c | 33 | +++ b/util/fdmon-epoll.c |
34 | @@ -XXX,XX +XXX,XX @@ void monitor_data_destroy(Monitor *mon) | 34 | @@ -XXX,XX +XXX,XX @@ static bool fdmon_epoll_try_enable(AioContext *ctx) |
35 | 35 | ||
36 | void monitor_cleanup(void) | 36 | bool fdmon_epoll_try_upgrade(AioContext *ctx, unsigned npfd) |
37 | { | 37 | { |
38 | - /* | 38 | + bool ok; |
39 | - * We need to explicitly stop the I/O thread (but not destroy it), | 39 | + |
40 | - * clean up the monitor resources, then destroy the I/O thread since | 40 | if (ctx->epollfd < 0) { |
41 | - * we need to unregister from chardev below in | 41 | return false; |
42 | - * monitor_data_destroy(), and chardev is not thread-safe yet | 42 | } |
43 | - */ | 43 | @@ -XXX,XX +XXX,XX @@ bool fdmon_epoll_try_upgrade(AioContext *ctx, unsigned npfd) |
44 | - if (mon_iothread) { | 44 | return false; |
45 | - iothread_stop(mon_iothread); | 45 | } |
46 | - } | 46 | |
47 | - | 47 | - if (npfd >= EPOLL_ENABLE_THRESHOLD) { |
48 | /* | 48 | - if (fdmon_epoll_try_enable(ctx)) { |
49 | * The dispatcher needs to stop before destroying the monitor and | 49 | - return true; |
50 | * the I/O thread. | 50 | - } else { |
51 | @@ -XXX,XX +XXX,XX @@ void monitor_cleanup(void) | 51 | - fdmon_epoll_disable(ctx); |
52 | * eventually terminates. qemu_aio_context is automatically | 52 | - } |
53 | * polled by calling AIO_WAIT_WHILE on it, but we must poll | 53 | + if (npfd < EPOLL_ENABLE_THRESHOLD) { |
54 | * iohandler_ctx manually. | 54 | + return false; |
55 | + * | ||
56 | + * Letting the iothread continue while shutting down the dispatcher | ||
57 | + * means that new requests may still be coming in. This is okay, | ||
58 | + * we'll just leave them in the queue without sending a response | ||
59 | + * and monitor_data_destroy() will free them. | ||
60 | */ | ||
61 | qmp_dispatcher_co_shutdown = true; | ||
62 | if (!qatomic_xchg(&qmp_dispatcher_co_busy, true)) { | ||
63 | @@ -XXX,XX +XXX,XX @@ void monitor_cleanup(void) | ||
64 | (aio_poll(iohandler_get_aio_context(), false), | ||
65 | qatomic_mb_read(&qmp_dispatcher_co_busy))); | ||
66 | |||
67 | + /* | ||
68 | + * We need to explicitly stop the I/O thread (but not destroy it), | ||
69 | + * clean up the monitor resources, then destroy the I/O thread since | ||
70 | + * we need to unregister from chardev below in | ||
71 | + * monitor_data_destroy(), and chardev is not thread-safe yet | ||
72 | + */ | ||
73 | + if (mon_iothread) { | ||
74 | + iothread_stop(mon_iothread); | ||
75 | + } | 55 | + } |
76 | + | 56 | + |
77 | /* Flush output buffers and destroy monitors */ | 57 | + /* The list must not change while we add fds to epoll */ |
78 | qemu_mutex_lock(&monitor_lock); | 58 | + if (!qemu_lockcnt_dec_if_lock(&ctx->list_lock)) { |
79 | monitor_destroyed = true; | 59 | + return false; |
60 | + } | ||
61 | + | ||
62 | + ok = fdmon_epoll_try_enable(ctx); | ||
63 | + | ||
64 | + qemu_lockcnt_inc_and_unlock(&ctx->list_lock); | ||
65 | + | ||
66 | + if (!ok) { | ||
67 | + fdmon_epoll_disable(ctx); | ||
68 | } | ||
69 | - return false; | ||
70 | + return ok; | ||
71 | } | ||
72 | |||
73 | void fdmon_epoll_setup(AioContext *ctx) | ||
80 | -- | 74 | -- |
81 | 2.29.2 | 75 | 2.39.2 |
82 | |||
83 | diff view generated by jsdifflib |
1 | From: Maxim Levitsky <mlevitsk@redhat.com> | 1 | blk_get_geometry() eventually calls bdrv_nb_sectors(), which is a |
---|---|---|---|
2 | co_wrapper_mixed_bdrv_rdlock. This means that when it is called from | ||
3 | coroutine context, it already assume to have the graph locked. | ||
2 | 4 | ||
3 | This function wraps bdrv_co_delete_file for the common case of removing a file, | 5 | However, virtio_blk_sect_range_ok() in block/export/virtio-blk-handler.c |
4 | which was just created by format driver, on an error condition. | 6 | (used by vhost-user-blk and VDUSE exports) runs in a coroutine, but |
7 | doesn't take the graph lock - blk_*() functions are generally expected | ||
8 | to do that internally. This causes an assertion failure when accessing | ||
9 | an export for the first time if it runs in an iothread. | ||
5 | 10 | ||
6 | It hides the -ENOTSUPP error, and reports all other errors otherwise. | 11 | This is an example of the crash: |
7 | 12 | ||
8 | Use it in luks driver | 13 | $ ./storage-daemon/qemu-storage-daemon --object iothread,id=th0 --blockdev file,filename=/home/kwolf/images/hd.img,node-name=disk --export vhost-user-blk,addr.type=unix,addr.path=/tmp/vhost.sock,node-name=disk,id=exp0,iothread=th0 |
14 | qemu-storage-daemon: ../block/graph-lock.c:268: void assert_bdrv_graph_readable(void): Assertion `qemu_in_main_thread() || reader_count()' failed. | ||
9 | 15 | ||
10 | Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> | 16 | (gdb) bt |
11 | Reviewed-by: Alberto Garcia <berto@igalia.com> | 17 | #0 0x00007ffff6eafe5c in __pthread_kill_implementation () from /lib64/libc.so.6 |
12 | Message-Id: <20201217170904.946013-3-mlevitsk@redhat.com> | 18 | #1 0x00007ffff6e5fa76 in raise () from /lib64/libc.so.6 |
13 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 19 | #2 0x00007ffff6e497fc in abort () from /lib64/libc.so.6 |
20 | #3 0x00007ffff6e4971b in __assert_fail_base.cold () from /lib64/libc.so.6 | ||
21 | #4 0x00007ffff6e58656 in __assert_fail () from /lib64/libc.so.6 | ||
22 | #5 0x00005555556337a3 in assert_bdrv_graph_readable () at ../block/graph-lock.c:268 | ||
23 | #6 0x00005555555fd5a2 in bdrv_co_nb_sectors (bs=0x5555564c5ef0) at ../block.c:5847 | ||
24 | #7 0x00005555555ee949 in bdrv_nb_sectors (bs=0x5555564c5ef0) at block/block-gen.c:256 | ||
25 | #8 0x00005555555fd6b9 in bdrv_get_geometry (bs=0x5555564c5ef0, nb_sectors_ptr=0x7fffef7fedd0) at ../block.c:5884 | ||
26 | #9 0x000055555562ad6d in blk_get_geometry (blk=0x5555564cb200, nb_sectors_ptr=0x7fffef7fedd0) at ../block/block-backend.c:1624 | ||
27 | #10 0x00005555555ddb74 in virtio_blk_sect_range_ok (blk=0x5555564cb200, block_size=512, sector=0, size=512) at ../block/export/virtio-blk-handler.c:44 | ||
28 | #11 0x00005555555dd80d in virtio_blk_process_req (handler=0x5555564cbb98, in_iov=0x7fffe8003830, out_iov=0x7fffe8003860, in_num=1, out_num=0) at ../block/export/virtio-blk-handler.c:189 | ||
29 | #12 0x00005555555dd546 in vu_blk_virtio_process_req (opaque=0x7fffe8003800) at ../block/export/vhost-user-blk-server.c:66 | ||
30 | #13 0x00005555557bf4a1 in coroutine_trampoline (i0=-402635264, i1=32767) at ../util/coroutine-ucontext.c:177 | ||
31 | #14 0x00007ffff6e75c20 in ?? () from /lib64/libc.so.6 | ||
32 | #15 0x00007fffefffa870 in ?? () | ||
33 | #16 0x0000000000000000 in ?? () | ||
34 | |||
35 | Fix this by creating a new blk_co_get_geometry() that takes the lock, | ||
36 | and changing blk_get_geometry() to be a co_wrapper_mixed around it. | ||
37 | |||
38 | To make the resulting code cleaner, virtio-blk-handler.c can directly | ||
39 | call the coroutine version now (though that wouldn't be necessary for | ||
40 | fixing the bug, taking the lock in blk_co_get_geometry() is what fixes | ||
41 | it). | ||
42 | |||
43 | Fixes: 8ab8140a04cf771d63e9754d6ba6c1e676bfe507 | ||
44 | Reported-by: Lukáš Doktor <ldoktor@redhat.com> | ||
45 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
46 | Message-Id: <20230327113959.60071-1-kwolf@redhat.com> | ||
47 | Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> | ||
14 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 48 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
15 | --- | 49 | --- |
16 | include/block/block.h | 1 + | 50 | include/block/block-io.h | 4 +++- |
17 | block.c | 22 ++++++++++++++++++++++ | 51 | include/sysemu/block-backend-io.h | 5 ++++- |
18 | block/crypto.c | 15 ++------------- | 52 | block.c | 5 +++-- |
19 | 3 files changed, 25 insertions(+), 13 deletions(-) | 53 | block/block-backend.c | 7 +++++-- |
54 | block/export/virtio-blk-handler.c | 7 ++++--- | ||
55 | 5 files changed, 19 insertions(+), 9 deletions(-) | ||
20 | 56 | ||
21 | diff --git a/include/block/block.h b/include/block/block.h | 57 | diff --git a/include/block/block-io.h b/include/block/block-io.h |
22 | index XXXXXXX..XXXXXXX 100644 | 58 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/include/block/block.h | 59 | --- a/include/block/block-io.h |
24 | +++ b/include/block/block.h | 60 | +++ b/include/block/block-io.h |
25 | @@ -XXX,XX +XXX,XX @@ int bdrv_freeze_backing_chain(BlockDriverState *bs, BlockDriverState *base, | 61 | @@ -XXX,XX +XXX,XX @@ int64_t co_wrapper bdrv_get_allocated_file_size(BlockDriverState *bs); |
26 | Error **errp); | 62 | |
27 | void bdrv_unfreeze_backing_chain(BlockDriverState *bs, BlockDriverState *base); | 63 | BlockMeasureInfo *bdrv_measure(BlockDriver *drv, QemuOpts *opts, |
28 | int coroutine_fn bdrv_co_delete_file(BlockDriverState *bs, Error **errp); | 64 | BlockDriverState *in_bs, Error **errp); |
29 | +void coroutine_fn bdrv_co_delete_file_noerr(BlockDriverState *bs); | 65 | -void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr); |
30 | 66 | + | |
31 | 67 | +void coroutine_fn GRAPH_RDLOCK | |
32 | typedef struct BdrvCheckResult { | 68 | +bdrv_co_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr); |
69 | |||
70 | int coroutine_fn GRAPH_RDLOCK | ||
71 | bdrv_co_delete_file(BlockDriverState *bs, Error **errp); | ||
72 | diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backend-io.h | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/include/sysemu/block-backend-io.h | ||
75 | +++ b/include/sysemu/block-backend-io.h | ||
76 | @@ -XXX,XX +XXX,XX @@ void co_wrapper blk_eject(BlockBackend *blk, bool eject_flag); | ||
77 | int64_t coroutine_fn blk_co_getlength(BlockBackend *blk); | ||
78 | int64_t co_wrapper_mixed blk_getlength(BlockBackend *blk); | ||
79 | |||
80 | -void blk_get_geometry(BlockBackend *blk, uint64_t *nb_sectors_ptr); | ||
81 | +void coroutine_fn blk_co_get_geometry(BlockBackend *blk, | ||
82 | + uint64_t *nb_sectors_ptr); | ||
83 | +void co_wrapper_mixed blk_get_geometry(BlockBackend *blk, | ||
84 | + uint64_t *nb_sectors_ptr); | ||
85 | |||
86 | int64_t coroutine_fn blk_co_nb_sectors(BlockBackend *blk); | ||
87 | int64_t co_wrapper_mixed blk_nb_sectors(BlockBackend *blk); | ||
33 | diff --git a/block.c b/block.c | 88 | diff --git a/block.c b/block.c |
34 | index XXXXXXX..XXXXXXX 100644 | 89 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/block.c | 90 | --- a/block.c |
36 | +++ b/block.c | 91 | +++ b/block.c |
37 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_delete_file(BlockDriverState *bs, Error **errp) | 92 | @@ -XXX,XX +XXX,XX @@ int64_t coroutine_fn bdrv_co_getlength(BlockDriverState *bs) |
38 | return ret; | ||
39 | } | 93 | } |
40 | 94 | ||
41 | +void coroutine_fn bdrv_co_delete_file_noerr(BlockDriverState *bs) | 95 | /* return 0 as number of sectors if no device present or error */ |
42 | +{ | 96 | -void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr) |
43 | + Error *local_err = NULL; | 97 | +void coroutine_fn bdrv_co_get_geometry(BlockDriverState *bs, |
44 | + int ret; | 98 | + uint64_t *nb_sectors_ptr) |
99 | { | ||
100 | - int64_t nb_sectors = bdrv_nb_sectors(bs); | ||
101 | + int64_t nb_sectors = bdrv_co_nb_sectors(bs); | ||
102 | IO_CODE(); | ||
103 | |||
104 | *nb_sectors_ptr = nb_sectors < 0 ? 0 : nb_sectors; | ||
105 | diff --git a/block/block-backend.c b/block/block-backend.c | ||
106 | index XXXXXXX..XXXXXXX 100644 | ||
107 | --- a/block/block-backend.c | ||
108 | +++ b/block/block-backend.c | ||
109 | @@ -XXX,XX +XXX,XX @@ int64_t coroutine_fn blk_co_getlength(BlockBackend *blk) | ||
110 | return bdrv_co_getlength(blk_bs(blk)); | ||
111 | } | ||
112 | |||
113 | -void blk_get_geometry(BlockBackend *blk, uint64_t *nb_sectors_ptr) | ||
114 | +void coroutine_fn blk_co_get_geometry(BlockBackend *blk, | ||
115 | + uint64_t *nb_sectors_ptr) | ||
116 | { | ||
117 | IO_CODE(); | ||
118 | + GRAPH_RDLOCK_GUARD(); | ||
45 | + | 119 | + |
46 | + if (!bs) { | 120 | if (!blk_bs(blk)) { |
47 | + return; | 121 | *nb_sectors_ptr = 0; |
48 | + } | 122 | } else { |
49 | + | 123 | - bdrv_get_geometry(blk_bs(blk), nb_sectors_ptr); |
50 | + ret = bdrv_co_delete_file(bs, &local_err); | 124 | + bdrv_co_get_geometry(blk_bs(blk), nb_sectors_ptr); |
51 | + /* | 125 | } |
52 | + * ENOTSUP will happen if the block driver doesn't support | 126 | } |
53 | + * the 'bdrv_co_delete_file' interface. This is a predictable | 127 | |
54 | + * scenario and shouldn't be reported back to the user. | 128 | diff --git a/block/export/virtio-blk-handler.c b/block/export/virtio-blk-handler.c |
55 | + */ | ||
56 | + if (ret == -ENOTSUP) { | ||
57 | + error_free(local_err); | ||
58 | + } else if (ret < 0) { | ||
59 | + error_report_err(local_err); | ||
60 | + } | ||
61 | +} | ||
62 | + | ||
63 | /** | ||
64 | * Try to get @bs's logical and physical block size. | ||
65 | * On success, store them in @bsz struct and return 0. | ||
66 | diff --git a/block/crypto.c b/block/crypto.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | 129 | index XXXXXXX..XXXXXXX 100644 |
68 | --- a/block/crypto.c | 130 | --- a/block/export/virtio-blk-handler.c |
69 | +++ b/block/crypto.c | 131 | +++ b/block/export/virtio-blk-handler.c |
70 | @@ -XXX,XX +XXX,XX @@ fail: | 132 | @@ -XXX,XX +XXX,XX @@ struct virtio_blk_inhdr { |
71 | * If an error occurred, delete 'filename'. Even if the file existed | 133 | unsigned char status; |
72 | * beforehand, it has been truncated and corrupted in the process. | 134 | }; |
73 | */ | 135 | |
74 | - if (ret && bs) { | 136 | -static bool virtio_blk_sect_range_ok(BlockBackend *blk, uint32_t block_size, |
75 | - Error *local_delete_err = NULL; | 137 | - uint64_t sector, size_t size) |
76 | - int r_del = bdrv_co_delete_file(bs, &local_delete_err); | 138 | +static bool coroutine_fn |
77 | - /* | 139 | +virtio_blk_sect_range_ok(BlockBackend *blk, uint32_t block_size, |
78 | - * ENOTSUP will happen if the block driver doesn't support | 140 | + uint64_t sector, size_t size) |
79 | - * the 'bdrv_co_delete_file' interface. This is a predictable | 141 | { |
80 | - * scenario and shouldn't be reported back to the user. | 142 | uint64_t nb_sectors; |
81 | - */ | 143 | uint64_t total_sectors; |
82 | - if ((r_del < 0) && (r_del != -ENOTSUP)) { | 144 | @@ -XXX,XX +XXX,XX @@ static bool virtio_blk_sect_range_ok(BlockBackend *blk, uint32_t block_size, |
83 | - error_report_err(local_delete_err); | 145 | if ((sector << VIRTIO_BLK_SECTOR_BITS) % block_size) { |
84 | - } else { | 146 | return false; |
85 | - error_free(local_delete_err); | ||
86 | - } | ||
87 | + if (ret) { | ||
88 | + bdrv_co_delete_file_noerr(bs); | ||
89 | } | 147 | } |
90 | 148 | - blk_get_geometry(blk, &total_sectors); | |
91 | bdrv_unref(bs); | 149 | + blk_co_get_geometry(blk, &total_sectors); |
150 | if (sector > total_sectors || nb_sectors > total_sectors - sector) { | ||
151 | return false; | ||
152 | } | ||
92 | -- | 153 | -- |
93 | 2.29.2 | 154 | 2.39.2 |
94 | 155 | ||
95 | 156 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Before this patch, monitor_qmp_dispatcher_co() used to check whether | ||
2 | shutdown is requested only when it would have to wait for new requests. | ||
3 | If there were still some queued requests, it would try to execute all of | ||
4 | them before shutting down. | ||
5 | 1 | ||
6 | This can be surprising when the queued QMP commands take long or hang | ||
7 | because Ctrl-C may not actually exit QEMU as soon as possible. | ||
8 | |||
9 | Change monitor_qmp_dispatcher_co() so that it additionally checks | ||
10 | whether shutdown is request before it gets a new request from the queue. | ||
11 | |||
12 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
13 | Message-Id: <20210212172028.288825-3-kwolf@redhat.com> | ||
14 | Tested-by: Markus Armbruster <armbru@redhat.com> | ||
15 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | ||
16 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
17 | --- | ||
18 | monitor/qmp.c | 5 +++++ | ||
19 | 1 file changed, 5 insertions(+) | ||
20 | |||
21 | diff --git a/monitor/qmp.c b/monitor/qmp.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/monitor/qmp.c | ||
24 | +++ b/monitor/qmp.c | ||
25 | @@ -XXX,XX +XXX,XX @@ void coroutine_fn monitor_qmp_dispatcher_co(void *data) | ||
26 | */ | ||
27 | qatomic_mb_set(&qmp_dispatcher_co_busy, false); | ||
28 | |||
29 | + /* On shutdown, don't take any more requests from the queue */ | ||
30 | + if (qmp_dispatcher_co_shutdown) { | ||
31 | + return; | ||
32 | + } | ||
33 | + | ||
34 | while (!(req_obj = monitor_qmp_requests_pop_any_with_lock())) { | ||
35 | /* | ||
36 | * No more requests to process. Wait to be reentered from | ||
37 | -- | ||
38 | 2.29.2 | ||
39 | |||
40 | diff view generated by jsdifflib |