1 | The following changes since commit c416eecea5f3aea863ab8fda5a36a24157b8f704: | 1 | The following changes since commit 887cba855bb6ff4775256f7968409281350b568c: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2018-05-15 17:02:00 +0100) | 3 | configure: Fix cross-building for RISCV host (v5) (2023-07-11 17:56:09 +0100) |
4 | 4 | ||
5 | are available in the git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | git://github.com/codyprime/qemu-kvm-jtc.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 c82be42cc803b36fd7aed5dceec68312c7056fd5: | 9 | for you to fetch changes up to 75dcb4d790bbe5327169fd72b185960ca58e2fa6: |
10 | 10 | ||
11 | nfs: Remove processed options from QDict (2018-05-16 13:37:47 -0400) | 11 | virtio-blk: fix host notifier issues during dataplane start/stop (2023-07-12 15:20:32 -0400) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Block patches | 14 | Pull request |
15 | |||
15 | ---------------------------------------------------------------- | 16 | ---------------------------------------------------------------- |
16 | 17 | ||
17 | Kevin Wolf (2): | 18 | Stefan Hajnoczi (1): |
18 | nfs: Fix error path in nfs_options_qdict_to_qapi() | 19 | virtio-blk: fix host notifier issues during dataplane start/stop |
19 | nfs: Remove processed options from QDict | ||
20 | 20 | ||
21 | Stefan Hajnoczi (2): | 21 | hw/block/dataplane/virtio-blk.c | 67 +++++++++++++++++++-------------- |
22 | qemu-iotests: reduce chance of races in 185 | 22 | 1 file changed, 38 insertions(+), 29 deletions(-) |
23 | blockjob: do not cancel timer in resume | ||
24 | |||
25 | block/nfs.c | 8 ++++++++ | ||
26 | blockjob.c | 22 +++++++++++++++------- | ||
27 | tests/qemu-iotests/185 | 17 +++++++++++++---- | ||
28 | tests/qemu-iotests/185.out | 12 +++++------- | ||
29 | 4 files changed, 41 insertions(+), 18 deletions(-) | ||
30 | 23 | ||
31 | -- | 24 | -- |
32 | 2.13.6 | 25 | 2.40.1 |
33 | |||
34 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Stefan Hajnoczi <stefanha@redhat.com> | ||
2 | 1 | ||
3 | Commit 8565c3ab537e78f3e69977ec2c609dc9417a806e ("qemu-iotests: fix | ||
4 | 185") identified a race condition in a sub-test. | ||
5 | |||
6 | Similar issues also affect the other sub-tests. If disk I/O completes | ||
7 | quickly, it races with the QMP 'quit' command. This causes spurious | ||
8 | test failures because QMP events are emitted in an unpredictable order. | ||
9 | |||
10 | This test relies on QEMU internals and there is no QMP API for getting | ||
11 | deterministic behavior needed to make this test 100% reliable. At the | ||
12 | same time, the test is useful and it would be a shame to remove it. | ||
13 | |||
14 | Add sleep 0.5 to reduce the chance of races. This is not a real fix but | ||
15 | appears to reduce spurious failures in practice. | ||
16 | |||
17 | Cc: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
18 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
19 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
20 | Message-id: 20180508135436.30140-2-stefanha@redhat.com | ||
21 | Reviewed-by: Jeff Cody <jcody@redhat.com> | ||
22 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
23 | --- | ||
24 | tests/qemu-iotests/185 | 12 ++++++++++++ | ||
25 | 1 file changed, 12 insertions(+) | ||
26 | |||
27 | diff --git a/tests/qemu-iotests/185 b/tests/qemu-iotests/185 | ||
28 | index XXXXXXX..XXXXXXX 100755 | ||
29 | --- a/tests/qemu-iotests/185 | ||
30 | +++ b/tests/qemu-iotests/185 | ||
31 | @@ -XXX,XX +XXX,XX @@ _send_qemu_cmd $h \ | ||
32 | 'speed': 65536 } }" \ | ||
33 | "return" | ||
34 | |||
35 | +# If we don't sleep here 'quit' command races with disk I/O | ||
36 | +sleep 0.5 | ||
37 | + | ||
38 | _send_qemu_cmd $h "{ 'execute': 'quit' }" "return" | ||
39 | wait=1 _cleanup_qemu | ||
40 | |||
41 | @@ -XXX,XX +XXX,XX @@ _send_qemu_cmd $h \ | ||
42 | 'speed': 65536 } }" \ | ||
43 | "return" | ||
44 | |||
45 | +# If we don't sleep here 'quit' command races with disk I/O | ||
46 | +sleep 0.5 | ||
47 | + | ||
48 | _send_qemu_cmd $h "{ 'execute': 'quit' }" "return" | ||
49 | wait=1 _cleanup_qemu | ||
50 | |||
51 | @@ -XXX,XX +XXX,XX @@ _send_qemu_cmd $h \ | ||
52 | 'speed': 65536 } }" \ | ||
53 | "return" | ||
54 | |||
55 | +# If we don't sleep here 'quit' command races with disk I/O | ||
56 | +sleep 0.5 | ||
57 | + | ||
58 | _send_qemu_cmd $h "{ 'execute': 'quit' }" "return" | ||
59 | wait=1 _cleanup_qemu | ||
60 | |||
61 | @@ -XXX,XX +XXX,XX @@ _send_qemu_cmd $h \ | ||
62 | 'speed': 65536 } }" \ | ||
63 | "return" | ||
64 | |||
65 | +# If we don't sleep here 'quit' command races with disk I/O | ||
66 | +sleep 0.5 | ||
67 | + | ||
68 | _send_qemu_cmd $h "{ 'execute': 'quit' }" "return" | ||
69 | wait=1 _cleanup_qemu | ||
70 | |||
71 | -- | ||
72 | 2.13.6 | ||
73 | |||
74 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Stefan Hajnoczi <stefanha@redhat.com> | ||
2 | 1 | ||
3 | Currently the timer is cancelled and the block job is entered by | ||
4 | block_job_resume(). This behavior causes drain to run extra blockjob | ||
5 | iterations when the job was sleeping due to the ratelimit. | ||
6 | |||
7 | This patch leaves the job asleep when block_job_resume() is called. | ||
8 | Jobs can still be forcibly woken up using block_job_enter(), which is | ||
9 | used to cancel jobs. | ||
10 | |||
11 | After this patch drain no longer runs extra blockjob iterations. This | ||
12 | is the expected behavior that qemu-iotests 185 used to rely on. We | ||
13 | temporarily changed the 185 test output to make it pass for the QEMU | ||
14 | 2.12 release but now it's time to address this issue. | ||
15 | |||
16 | Cc: QingFeng Hao <haoqf@linux.vnet.ibm.com> | ||
17 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
18 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
19 | Reviewed-by: QingFeng Hao <haoqf@linux.vnet.ibm.com> | ||
20 | Message-id: 20180508135436.30140-3-stefanha@redhat.com | ||
21 | Reviewed-by: Jeff Cody <jcody@redhat.com> | ||
22 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
23 | --- | ||
24 | blockjob.c | 22 +++++++++++++++------- | ||
25 | tests/qemu-iotests/185 | 5 +---- | ||
26 | tests/qemu-iotests/185.out | 12 +++++------- | ||
27 | 3 files changed, 21 insertions(+), 18 deletions(-) | ||
28 | |||
29 | diff --git a/blockjob.c b/blockjob.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/blockjob.c | ||
32 | +++ b/blockjob.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static void block_job_txn_del_job(BlockJob *job) | ||
34 | } | ||
35 | } | ||
36 | |||
37 | +/* Assumes the block_job_mutex is held */ | ||
38 | +static bool block_job_timer_pending(BlockJob *job) | ||
39 | +{ | ||
40 | + return timer_pending(&job->sleep_timer); | ||
41 | +} | ||
42 | + | ||
43 | +/* Assumes the block_job_mutex is held */ | ||
44 | +static bool block_job_timer_not_pending(BlockJob *job) | ||
45 | +{ | ||
46 | + return !block_job_timer_pending(job); | ||
47 | +} | ||
48 | + | ||
49 | static void block_job_pause(BlockJob *job) | ||
50 | { | ||
51 | job->pause_count++; | ||
52 | @@ -XXX,XX +XXX,XX @@ static void block_job_resume(BlockJob *job) | ||
53 | if (job->pause_count) { | ||
54 | return; | ||
55 | } | ||
56 | - block_job_enter(job); | ||
57 | + | ||
58 | + /* kick only if no timer is pending */ | ||
59 | + block_job_enter_cond(job, block_job_timer_not_pending); | ||
60 | } | ||
61 | |||
62 | void block_job_ref(BlockJob *job) | ||
63 | @@ -XXX,XX +XXX,XX @@ static void block_job_completed_txn_success(BlockJob *job) | ||
64 | } | ||
65 | } | ||
66 | |||
67 | -/* Assumes the block_job_mutex is held */ | ||
68 | -static bool block_job_timer_pending(BlockJob *job) | ||
69 | -{ | ||
70 | - return timer_pending(&job->sleep_timer); | ||
71 | -} | ||
72 | - | ||
73 | void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp) | ||
74 | { | ||
75 | int64_t old_speed = job->speed; | ||
76 | diff --git a/tests/qemu-iotests/185 b/tests/qemu-iotests/185 | ||
77 | index XXXXXXX..XXXXXXX 100755 | ||
78 | --- a/tests/qemu-iotests/185 | ||
79 | +++ b/tests/qemu-iotests/185 | ||
80 | @@ -XXX,XX +XXX,XX @@ echo | ||
81 | # command to be received (after receiving the command, the rest runs | ||
82 | # synchronously, so jobs can arbitrarily continue or complete). | ||
83 | # | ||
84 | -# Jobs present while QEMU is terminating iterate once more due to | ||
85 | -# bdrv_drain_all(). | ||
86 | -# | ||
87 | # The buffer size for commit and streaming is 512k (waiting for 8 seconds after | ||
88 | # the first request), for active commit and mirror it's large enough to cover | ||
89 | # the full 4M, and for backup it's the qcow2 cluster size, which we know is | ||
90 | # 64k. As all of these are at least as large as the speed, we are sure that the | ||
91 | -# offset advances exactly twice before qemu exits. | ||
92 | +# offset advances exactly once before qemu exits. | ||
93 | |||
94 | _send_qemu_cmd $h \ | ||
95 | "{ 'execute': 'block-commit', | ||
96 | diff --git a/tests/qemu-iotests/185.out b/tests/qemu-iotests/185.out | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/tests/qemu-iotests/185.out | ||
99 | +++ b/tests/qemu-iotests/185.out | ||
100 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 backing_file=TEST_DIR/t.q | ||
101 | {"return": {}} | ||
102 | {"return": {}} | ||
103 | {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} | ||
104 | -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 67108864, "offset": 1048576, "speed": 65536, "type": "commit"}} | ||
105 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 67108864, "offset": 524288, "speed": 65536, "type": "commit"}} | ||
106 | |||
107 | === Start active commit job and exit qemu === | ||
108 | |||
109 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 backing_file=TEST_DIR/t.q | ||
110 | {"return": {}} | ||
111 | {"return": {}} | ||
112 | {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} | ||
113 | -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "commit"}} | ||
114 | -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "commit"}} | ||
115 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "commit"}} | ||
116 | |||
117 | === Start mirror job and exit qemu === | ||
118 | |||
119 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 size=67108864 cluster_size=65536 l | ||
120 | {"return": {}} | ||
121 | {"return": {}} | ||
122 | {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} | ||
123 | -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "mirror"}} | ||
124 | -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "mirror"}} | ||
125 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "mirror"}} | ||
126 | |||
127 | === Start backup job and exit qemu === | ||
128 | |||
129 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 size=67108864 cluster_size=65536 l | ||
130 | {"return": {}} | ||
131 | {"return": {}} | ||
132 | {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} | ||
133 | -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 67108864, "offset": 131072, "speed": 65536, "type": "backup"}} | ||
134 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 67108864, "offset": 65536, "speed": 65536, "type": "backup"}} | ||
135 | |||
136 | === Start streaming job and exit qemu === | ||
137 | |||
138 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 size=67108864 cluster_size=65536 l | ||
139 | {"return": {}} | ||
140 | {"return": {}} | ||
141 | {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} | ||
142 | -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 67108864, "offset": 1048576, "speed": 65536, "type": "stream"}} | ||
143 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 67108864, "offset": 524288, "speed": 65536, "type": "stream"}} | ||
144 | No errors were found on the image. | ||
145 | *** done | ||
146 | -- | ||
147 | 2.13.6 | ||
148 | |||
149 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Kevin Wolf <kwolf@redhat.com> | ||
2 | 1 | ||
3 | Don't throw away local_err, but propagate it to errp. | ||
4 | |||
5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
6 | Message-id: 20180516161034.27440-1-kwolf@redhat.com | ||
7 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
8 | Reviewed-by: Jeff Cody <jcody@redhat.com> | ||
9 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
10 | --- | ||
11 | block/nfs.c | 1 + | ||
12 | 1 file changed, 1 insertion(+) | ||
13 | |||
14 | diff --git a/block/nfs.c b/block/nfs.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/block/nfs.c | ||
17 | +++ b/block/nfs.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static BlockdevOptionsNfs *nfs_options_qdict_to_qapi(QDict *options, | ||
19 | qobject_unref(crumpled); | ||
20 | |||
21 | if (local_err) { | ||
22 | + error_propagate(errp, local_err); | ||
23 | return NULL; | ||
24 | } | ||
25 | |||
26 | -- | ||
27 | 2.13.6 | ||
28 | |||
29 | diff view generated by jsdifflib |
1 | From: Kevin Wolf <kwolf@redhat.com> | 1 | The main loop thread can consume 100% CPU when using --device |
---|---|---|---|
2 | virtio-blk-pci,iothread=<iothread>. ppoll() constantly returns but | ||
3 | reading virtqueue host notifiers fails with EAGAIN. The file descriptors | ||
4 | are stale and remain registered with the AioContext because of bugs in | ||
5 | the virtio-blk dataplane start/stop code. | ||
2 | 6 | ||
3 | Commit c22a03454 QAPIfied option parsing in the NFS block driver, but | 7 | The problem is that the dataplane start/stop code involves drain |
4 | forgot to remove all the options we processed. Therefore, we get an | 8 | operations, which call virtio_blk_drained_begin() and |
5 | error in bdrv_open_inherit(), which thinks the remaining options are | 9 | virtio_blk_drained_end() at points where the host notifier is not |
6 | invalid. Trying to open an NFS image will result in an error like this: | 10 | operational: |
11 | - In virtio_blk_data_plane_start(), blk_set_aio_context() drains after | ||
12 | vblk->dataplane_started has been set to true but the host notifier has | ||
13 | not been attached yet. | ||
14 | - In virtio_blk_data_plane_stop(), blk_drain() and blk_set_aio_context() | ||
15 | drain after the host notifier has already been detached but with | ||
16 | vblk->dataplane_started still set to true. | ||
7 | 17 | ||
8 | Block protocol 'nfs' doesn't support the option 'server.host' | 18 | I would like to simplify ->ioeventfd_start/stop() to avoid interactions |
19 | with drain entirely, but couldn't find a way to do that. Instead, this | ||
20 | patch accepts the fragile nature of the code and reorders it so that | ||
21 | vblk->dataplane_started is false during drain operations. This way the | ||
22 | virtio_blk_drained_begin() and virtio_blk_drained_end() calls don't | ||
23 | touch the host notifier. The result is that | ||
24 | virtio_blk_data_plane_start() and virtio_blk_data_plane_stop() have | ||
25 | complete control over the host notifier and stale file descriptors are | ||
26 | no longer left in the AioContext. | ||
9 | 27 | ||
10 | Remove all options from the QDict to make the NFS driver work again. | 28 | This patch fixes the 100% CPU consumption in the main loop thread and |
29 | correctly moves host notifier processing to the IOThread. | ||
11 | 30 | ||
12 | Cc: qemu-stable@nongnu.org | 31 | Fixes: 1665d9326fd2 ("virtio-blk: implement BlockDevOps->drained_begin()") |
13 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 32 | Reported-by: Lukáš Doktor <ldoktor@redhat.com> |
14 | Message-id: 20180516160816.26259-1-kwolf@redhat.com | 33 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
15 | Reviewed-by: Eric Blake <eblake@redhat.com> | 34 | Tested-by: Lukas Doktor <ldoktor@redhat.com> |
16 | Reviewed-by: Jeff Cody <jcody@redhat.com> | 35 | Message-id: 20230704151527.193586-1-stefanha@redhat.com |
17 | Signed-off-by: Jeff Cody <jcody@redhat.com> | 36 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
18 | --- | 37 | --- |
19 | block/nfs.c | 7 +++++++ | 38 | hw/block/dataplane/virtio-blk.c | 67 +++++++++++++++++++-------------- |
20 | 1 file changed, 7 insertions(+) | 39 | 1 file changed, 38 insertions(+), 29 deletions(-) |
21 | 40 | ||
22 | diff --git a/block/nfs.c b/block/nfs.c | 41 | diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c |
23 | index XXXXXXX..XXXXXXX 100644 | 42 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/block/nfs.c | 43 | --- a/hw/block/dataplane/virtio-blk.c |
25 | +++ b/block/nfs.c | 44 | +++ b/hw/block/dataplane/virtio-blk.c |
26 | @@ -XXX,XX +XXX,XX @@ static BlockdevOptionsNfs *nfs_options_qdict_to_qapi(QDict *options, | 45 | @@ -XXX,XX +XXX,XX @@ int virtio_blk_data_plane_start(VirtIODevice *vdev) |
27 | BlockdevOptionsNfs *opts = NULL; | 46 | |
28 | QObject *crumpled = NULL; | 47 | memory_region_transaction_commit(); |
29 | Visitor *v; | 48 | |
30 | + const QDictEntry *e; | 49 | - /* |
31 | Error *local_err = NULL; | 50 | - * These fields are visible to the IOThread so we rely on implicit barriers |
32 | 51 | - * in aio_context_acquire() on the write side and aio_notify_accept() on | |
33 | crumpled = qdict_crumple(options, errp); | 52 | - * the read side. |
34 | @@ -XXX,XX +XXX,XX @@ static BlockdevOptionsNfs *nfs_options_qdict_to_qapi(QDict *options, | 53 | - */ |
35 | return NULL; | 54 | - s->starting = false; |
55 | - vblk->dataplane_started = true; | ||
56 | trace_virtio_blk_data_plane_start(s); | ||
57 | |||
58 | old_context = blk_get_aio_context(s->conf->conf.blk); | ||
59 | @@ -XXX,XX +XXX,XX @@ int virtio_blk_data_plane_start(VirtIODevice *vdev) | ||
60 | event_notifier_set(virtio_queue_get_host_notifier(vq)); | ||
36 | } | 61 | } |
37 | 62 | ||
38 | + /* Remove the processed options from the QDict (the visitor processes | 63 | + /* |
39 | + * _all_ options in the QDict) */ | 64 | + * These fields must be visible to the IOThread when it processes the |
40 | + while ((e = qdict_first(options))) { | 65 | + * virtqueue, otherwise it will think dataplane has not started yet. |
41 | + qdict_del(options, e->key); | 66 | + * |
67 | + * Make sure ->dataplane_started is false when blk_set_aio_context() is | ||
68 | + * called above so that draining does not cause the host notifier to be | ||
69 | + * detached/attached prematurely. | ||
70 | + */ | ||
71 | + s->starting = false; | ||
72 | + vblk->dataplane_started = true; | ||
73 | + smp_wmb(); /* paired with aio_notify_accept() on the read side */ | ||
74 | + | ||
75 | /* Get this show started by hooking up our callbacks */ | ||
76 | if (!blk_in_drain(s->conf->conf.blk)) { | ||
77 | aio_context_acquire(s->ctx); | ||
78 | @@ -XXX,XX +XXX,XX @@ int virtio_blk_data_plane_start(VirtIODevice *vdev) | ||
79 | fail_guest_notifiers: | ||
80 | vblk->dataplane_disabled = true; | ||
81 | s->starting = false; | ||
82 | - vblk->dataplane_started = true; | ||
83 | return -ENOSYS; | ||
84 | } | ||
85 | |||
86 | @@ -XXX,XX +XXX,XX @@ void virtio_blk_data_plane_stop(VirtIODevice *vdev) | ||
87 | aio_wait_bh_oneshot(s->ctx, virtio_blk_data_plane_stop_bh, s); | ||
88 | } | ||
89 | |||
90 | + /* | ||
91 | + * Batch all the host notifiers in a single transaction to avoid | ||
92 | + * quadratic time complexity in address_space_update_ioeventfds(). | ||
93 | + */ | ||
94 | + memory_region_transaction_begin(); | ||
95 | + | ||
96 | + for (i = 0; i < nvqs; i++) { | ||
97 | + virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false); | ||
42 | + } | 98 | + } |
43 | + | 99 | + |
44 | return opts; | 100 | + /* |
101 | + * The transaction expects the ioeventfds to be open when it | ||
102 | + * commits. Do it now, before the cleanup loop. | ||
103 | + */ | ||
104 | + memory_region_transaction_commit(); | ||
105 | + | ||
106 | + for (i = 0; i < nvqs; i++) { | ||
107 | + virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), i); | ||
108 | + } | ||
109 | + | ||
110 | + /* | ||
111 | + * Set ->dataplane_started to false before draining so that host notifiers | ||
112 | + * are not detached/attached anymore. | ||
113 | + */ | ||
114 | + vblk->dataplane_started = false; | ||
115 | + | ||
116 | aio_context_acquire(s->ctx); | ||
117 | |||
118 | /* Wait for virtio_blk_dma_restart_bh() and in flight I/O to complete */ | ||
119 | @@ -XXX,XX +XXX,XX @@ void virtio_blk_data_plane_stop(VirtIODevice *vdev) | ||
120 | |||
121 | aio_context_release(s->ctx); | ||
122 | |||
123 | - /* | ||
124 | - * Batch all the host notifiers in a single transaction to avoid | ||
125 | - * quadratic time complexity in address_space_update_ioeventfds(). | ||
126 | - */ | ||
127 | - memory_region_transaction_begin(); | ||
128 | - | ||
129 | - for (i = 0; i < nvqs; i++) { | ||
130 | - virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false); | ||
131 | - } | ||
132 | - | ||
133 | - /* | ||
134 | - * The transaction expects the ioeventfds to be open when it | ||
135 | - * commits. Do it now, before the cleanup loop. | ||
136 | - */ | ||
137 | - memory_region_transaction_commit(); | ||
138 | - | ||
139 | - for (i = 0; i < nvqs; i++) { | ||
140 | - virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), i); | ||
141 | - } | ||
142 | - | ||
143 | qemu_bh_cancel(s->bh); | ||
144 | notify_guest_bh(s); /* final chance to notify guest */ | ||
145 | |||
146 | /* Clean up guest notifier (irq) */ | ||
147 | k->set_guest_notifiers(qbus->parent, nvqs, false); | ||
148 | |||
149 | - vblk->dataplane_started = false; | ||
150 | s->stopping = false; | ||
45 | } | 151 | } |
46 | |||
47 | -- | 152 | -- |
48 | 2.13.6 | 153 | 2.40.1 |
49 | 154 | ||
50 | 155 | diff view generated by jsdifflib |