1 | The following changes since commit 0ab4537f08e09b13788db67efd760592fb7db769: | 1 | The following changes since commit 9c125d17e9402c232c46610802e5931b3639d77b: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/stefanberger/tags/pull-tpm-2018-03-07-1' into staging (2018-03-08 12:56:39 +0000) | 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 4486e89c219c0d1b9bd8dfa0b1dd5b0d51ff2268: | 9 | for you to fetch changes up to d45c83328feab2e4083991693160f0a417cfd9b0: |
10 | 10 | ||
11 | vl: introduce vm_shutdown() (2018-03-08 17:38:51 +0000) | 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 | Deepa Srinivasan (1): | 24 | Sakshi Kaushik (1): |
18 | block: Fix qemu crash when using scsi-block | 25 | Implements Backend Program conventions for vhost-user-scsi |
19 | 26 | ||
20 | Fam Zheng (1): | 27 | Stefan Hajnoczi (1): |
21 | README: Fix typo 'git-publish' | 28 | contrib/vhost-user-blk: add missing GOptionEntry NULL terminator |
22 | 29 | ||
23 | Sergio Lopez (1): | 30 | docs/tools/virtiofsd.rst | 5 ++ |
24 | virtio-blk: dataplane: Don't batch notifications if EVENT_IDX is | 31 | contrib/vhost-user-blk/vhost-user-blk.c | 3 +- |
25 | present | 32 | contrib/vhost-user-scsi/vhost-user-scsi.c | 77 +++++++++++++++-------- |
26 | 33 | tools/virtiofsd/helper.c | 3 + | |
27 | Stefan Hajnoczi (4): | 34 | 4 files changed, 62 insertions(+), 26 deletions(-) |
28 | block: add aio_wait_bh_oneshot() | ||
29 | virtio-blk: fix race between .ioeventfd_stop() and vq handler | ||
30 | virtio-scsi: fix race between .ioeventfd_stop() and vq handler | ||
31 | vl: introduce vm_shutdown() | ||
32 | |||
33 | include/block/aio-wait.h | 13 +++++++++++ | ||
34 | include/sysemu/iothread.h | 1 - | ||
35 | include/sysemu/sysemu.h | 1 + | ||
36 | block/block-backend.c | 51 ++++++++++++++++++++--------------------- | ||
37 | cpus.c | 16 ++++++++++--- | ||
38 | hw/block/dataplane/virtio-blk.c | 39 +++++++++++++++++++++++-------- | ||
39 | hw/scsi/virtio-scsi-dataplane.c | 9 ++++---- | ||
40 | iothread.c | 31 ------------------------- | ||
41 | util/aio-wait.c | 31 +++++++++++++++++++++++++ | ||
42 | vl.c | 13 +++-------- | ||
43 | README | 2 +- | ||
44 | 11 files changed, 122 insertions(+), 85 deletions(-) | ||
45 | 35 | ||
46 | -- | 36 | -- |
47 | 2.14.3 | 37 | 2.35.1 |
48 | |||
49 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Deepa Srinivasan <deepa.srinivasan@oracle.com> | ||
2 | 1 | ||
3 | Starting qemu with the following arguments causes qemu to segfault: | ||
4 | ... -device lsi,id=lsi0 -drive file=iscsi:<...>,format=raw,if=none,node-name= | ||
5 | iscsi1 -device scsi-block,bus=lsi0.0,id=<...>,drive=iscsi1 | ||
6 | |||
7 | This patch fixes blk_aio_ioctl() so it does not pass stack addresses to | ||
8 | blk_aio_ioctl_entry() which may be invoked after blk_aio_ioctl() returns. More | ||
9 | details about the bug follow. | ||
10 | |||
11 | blk_aio_ioctl() invokes blk_aio_prwv() with blk_aio_ioctl_entry as the | ||
12 | coroutine parameter. blk_aio_prwv() ultimately calls aio_co_enter(). | ||
13 | |||
14 | When blk_aio_ioctl() is executed from within a coroutine context (e.g. | ||
15 | iscsi_bh_cb()), aio_co_enter() adds the coroutine (blk_aio_ioctl_entry) to | ||
16 | the current coroutine's wakeup queue. blk_aio_ioctl() then returns. | ||
17 | |||
18 | When blk_aio_ioctl_entry() executes later, it accesses an invalid pointer: | ||
19 | .... | ||
20 | BlkRwCo *rwco = &acb->rwco; | ||
21 | |||
22 | rwco->ret = blk_co_ioctl(rwco->blk, rwco->offset, | ||
23 | rwco->qiov->iov[0].iov_base); <--- qiov is | ||
24 | invalid here | ||
25 | ... | ||
26 | |||
27 | In the case when blk_aio_ioctl() is called from a non-coroutine context, | ||
28 | blk_aio_ioctl_entry() executes immediately. But if bdrv_co_ioctl() calls | ||
29 | qemu_coroutine_yield(), blk_aio_ioctl() will return. When the coroutine | ||
30 | execution is complete, control returns to blk_aio_ioctl_entry() after the call | ||
31 | to blk_co_ioctl(). There is no invalid reference after this point, but the | ||
32 | function is still holding on to invalid pointers. | ||
33 | |||
34 | The fix is to change blk_aio_prwv() to accept a void pointer for the IO buffer | ||
35 | rather than a QEMUIOVector. blk_aio_prwv() passes this through in BlkRwCo and the | ||
36 | coroutine function casts it to QEMUIOVector or uses the void pointer directly. | ||
37 | |||
38 | Signed-off-by: Deepa Srinivasan <deepa.srinivasan@oracle.com> | ||
39 | Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | ||
40 | Reviewed-by: Mark Kanda <mark.kanda@oracle.com> | ||
41 | Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> | ||
42 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
43 | --- | ||
44 | block/block-backend.c | 51 +++++++++++++++++++++++++-------------------------- | ||
45 | 1 file changed, 25 insertions(+), 26 deletions(-) | ||
46 | |||
47 | diff --git a/block/block-backend.c b/block/block-backend.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/block/block-backend.c | ||
50 | +++ b/block/block-backend.c | ||
51 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset, | ||
52 | typedef struct BlkRwCo { | ||
53 | BlockBackend *blk; | ||
54 | int64_t offset; | ||
55 | - QEMUIOVector *qiov; | ||
56 | + void *iobuf; | ||
57 | int ret; | ||
58 | BdrvRequestFlags flags; | ||
59 | } BlkRwCo; | ||
60 | @@ -XXX,XX +XXX,XX @@ typedef struct BlkRwCo { | ||
61 | static void blk_read_entry(void *opaque) | ||
62 | { | ||
63 | BlkRwCo *rwco = opaque; | ||
64 | + QEMUIOVector *qiov = rwco->iobuf; | ||
65 | |||
66 | - rwco->ret = blk_co_preadv(rwco->blk, rwco->offset, rwco->qiov->size, | ||
67 | - rwco->qiov, rwco->flags); | ||
68 | + rwco->ret = blk_co_preadv(rwco->blk, rwco->offset, qiov->size, | ||
69 | + qiov, rwco->flags); | ||
70 | } | ||
71 | |||
72 | static void blk_write_entry(void *opaque) | ||
73 | { | ||
74 | BlkRwCo *rwco = opaque; | ||
75 | + QEMUIOVector *qiov = rwco->iobuf; | ||
76 | |||
77 | - rwco->ret = blk_co_pwritev(rwco->blk, rwco->offset, rwco->qiov->size, | ||
78 | - rwco->qiov, rwco->flags); | ||
79 | + rwco->ret = blk_co_pwritev(rwco->blk, rwco->offset, qiov->size, | ||
80 | + qiov, rwco->flags); | ||
81 | } | ||
82 | |||
83 | static int blk_prw(BlockBackend *blk, int64_t offset, uint8_t *buf, | ||
84 | @@ -XXX,XX +XXX,XX @@ static int blk_prw(BlockBackend *blk, int64_t offset, uint8_t *buf, | ||
85 | rwco = (BlkRwCo) { | ||
86 | .blk = blk, | ||
87 | .offset = offset, | ||
88 | - .qiov = &qiov, | ||
89 | + .iobuf = &qiov, | ||
90 | .flags = flags, | ||
91 | .ret = NOT_DONE, | ||
92 | }; | ||
93 | @@ -XXX,XX +XXX,XX @@ static void blk_aio_complete_bh(void *opaque) | ||
94 | } | ||
95 | |||
96 | static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, int64_t offset, int bytes, | ||
97 | - QEMUIOVector *qiov, CoroutineEntry co_entry, | ||
98 | + void *iobuf, CoroutineEntry co_entry, | ||
99 | BdrvRequestFlags flags, | ||
100 | BlockCompletionFunc *cb, void *opaque) | ||
101 | { | ||
102 | @@ -XXX,XX +XXX,XX @@ static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, int64_t offset, int bytes, | ||
103 | acb->rwco = (BlkRwCo) { | ||
104 | .blk = blk, | ||
105 | .offset = offset, | ||
106 | - .qiov = qiov, | ||
107 | + .iobuf = iobuf, | ||
108 | .flags = flags, | ||
109 | .ret = NOT_DONE, | ||
110 | }; | ||
111 | @@ -XXX,XX +XXX,XX @@ static void blk_aio_read_entry(void *opaque) | ||
112 | { | ||
113 | BlkAioEmAIOCB *acb = opaque; | ||
114 | BlkRwCo *rwco = &acb->rwco; | ||
115 | + QEMUIOVector *qiov = rwco->iobuf; | ||
116 | |||
117 | - assert(rwco->qiov->size == acb->bytes); | ||
118 | + assert(qiov->size == acb->bytes); | ||
119 | rwco->ret = blk_co_preadv(rwco->blk, rwco->offset, acb->bytes, | ||
120 | - rwco->qiov, rwco->flags); | ||
121 | + qiov, rwco->flags); | ||
122 | blk_aio_complete(acb); | ||
123 | } | ||
124 | |||
125 | @@ -XXX,XX +XXX,XX @@ static void blk_aio_write_entry(void *opaque) | ||
126 | { | ||
127 | BlkAioEmAIOCB *acb = opaque; | ||
128 | BlkRwCo *rwco = &acb->rwco; | ||
129 | + QEMUIOVector *qiov = rwco->iobuf; | ||
130 | |||
131 | - assert(!rwco->qiov || rwco->qiov->size == acb->bytes); | ||
132 | + assert(!qiov || qiov->size == acb->bytes); | ||
133 | rwco->ret = blk_co_pwritev(rwco->blk, rwco->offset, acb->bytes, | ||
134 | - rwco->qiov, rwco->flags); | ||
135 | + qiov, rwco->flags); | ||
136 | blk_aio_complete(acb); | ||
137 | } | ||
138 | |||
139 | @@ -XXX,XX +XXX,XX @@ int blk_co_ioctl(BlockBackend *blk, unsigned long int req, void *buf) | ||
140 | static void blk_ioctl_entry(void *opaque) | ||
141 | { | ||
142 | BlkRwCo *rwco = opaque; | ||
143 | + QEMUIOVector *qiov = rwco->iobuf; | ||
144 | + | ||
145 | rwco->ret = blk_co_ioctl(rwco->blk, rwco->offset, | ||
146 | - rwco->qiov->iov[0].iov_base); | ||
147 | + qiov->iov[0].iov_base); | ||
148 | } | ||
149 | |||
150 | int blk_ioctl(BlockBackend *blk, unsigned long int req, void *buf) | ||
151 | @@ -XXX,XX +XXX,XX @@ static void blk_aio_ioctl_entry(void *opaque) | ||
152 | BlkAioEmAIOCB *acb = opaque; | ||
153 | BlkRwCo *rwco = &acb->rwco; | ||
154 | |||
155 | - rwco->ret = blk_co_ioctl(rwco->blk, rwco->offset, | ||
156 | - rwco->qiov->iov[0].iov_base); | ||
157 | + rwco->ret = blk_co_ioctl(rwco->blk, rwco->offset, rwco->iobuf); | ||
158 | + | ||
159 | blk_aio_complete(acb); | ||
160 | } | ||
161 | |||
162 | BlockAIOCB *blk_aio_ioctl(BlockBackend *blk, unsigned long int req, void *buf, | ||
163 | BlockCompletionFunc *cb, void *opaque) | ||
164 | { | ||
165 | - QEMUIOVector qiov; | ||
166 | - struct iovec iov; | ||
167 | - | ||
168 | - iov = (struct iovec) { | ||
169 | - .iov_base = buf, | ||
170 | - .iov_len = 0, | ||
171 | - }; | ||
172 | - qemu_iovec_init_external(&qiov, &iov, 1); | ||
173 | - | ||
174 | - return blk_aio_prwv(blk, req, 0, &qiov, blk_aio_ioctl_entry, 0, cb, opaque); | ||
175 | + return blk_aio_prwv(blk, req, 0, buf, blk_aio_ioctl_entry, 0, cb, opaque); | ||
176 | } | ||
177 | |||
178 | int blk_co_pdiscard(BlockBackend *blk, int64_t offset, int bytes) | ||
179 | @@ -XXX,XX +XXX,XX @@ int blk_truncate(BlockBackend *blk, int64_t offset, PreallocMode prealloc, | ||
180 | static void blk_pdiscard_entry(void *opaque) | ||
181 | { | ||
182 | BlkRwCo *rwco = opaque; | ||
183 | - rwco->ret = blk_co_pdiscard(rwco->blk, rwco->offset, rwco->qiov->size); | ||
184 | + QEMUIOVector *qiov = rwco->iobuf; | ||
185 | + | ||
186 | + rwco->ret = blk_co_pdiscard(rwco->blk, rwco->offset, qiov->size); | ||
187 | } | ||
188 | |||
189 | int blk_pdiscard(BlockBackend *blk, int64_t offset, int bytes) | ||
190 | -- | ||
191 | 2.14.3 | ||
192 | |||
193 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Fam Zheng <famz@redhat.com> | ||
2 | 1 | ||
3 | Reported-by: Alberto Garcia <berto@igalia.com> | ||
4 | Signed-off-by: Fam Zheng <famz@redhat.com> | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Message-id: 20180306024328.19195-1-famz@redhat.com | ||
7 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
8 | --- | ||
9 | README | 2 +- | ||
10 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
11 | |||
12 | diff --git a/README b/README | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/README | ||
15 | +++ b/README | ||
16 | @@ -XXX,XX +XXX,XX @@ The QEMU website is also maintained under source control. | ||
17 | git clone git://git.qemu.org/qemu-web.git | ||
18 | https://www.qemu.org/2017/02/04/the-new-qemu-website-is-up/ | ||
19 | |||
20 | -A 'git-profile' utility was created to make above process less | ||
21 | +A 'git-publish' utility was created to make above process less | ||
22 | cumbersome, and is highly recommended for making regular contributions, | ||
23 | or even just for sending consecutive patch series revisions. It also | ||
24 | requires a working 'git send-email' setup, and by default doesn't | ||
25 | -- | ||
26 | 2.14.3 | ||
27 | |||
28 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sergio Lopez <slp@redhat.com> | ||
2 | 1 | ||
3 | Commit 5b2ffbe4d99843fd8305c573a100047a8c962327 ("virtio-blk: dataplane: | ||
4 | notify guest as a batch") deferred guest notification to a BH in order | ||
5 | batch notifications, with purpose of avoiding flooding the guest with | ||
6 | interruptions. | ||
7 | |||
8 | This optimization came with a cost. The average latency perceived in the | ||
9 | guest is increased by a few microseconds, but also when multiple IO | ||
10 | operations finish at the same time, the guest won't be notified until | ||
11 | all completions from each operation has been run. On the contrary, | ||
12 | virtio-scsi issues the notification at the end of each completion. | ||
13 | |||
14 | On the other hand, nowadays we have the EVENT_IDX feature that allows a | ||
15 | better coordination between QEMU and the Guest OS to avoid sending | ||
16 | unnecessary interruptions. | ||
17 | |||
18 | With this change, virtio-blk/dataplane only batches notifications if the | ||
19 | EVENT_IDX feature is not present. | ||
20 | |||
21 | Some numbers obtained with fio (ioengine=sync, iodepth=1, direct=1): | ||
22 | - Test specs: | ||
23 | * fio-3.4 (ioengine=sync, iodepth=1, direct=1) | ||
24 | * qemu master | ||
25 | * virtio-blk with a dedicated iothread (default poll-max-ns) | ||
26 | * backend: null_blk nr_devices=1 irqmode=2 completion_nsec=280000 | ||
27 | * 8 vCPUs pinned to isolated physical cores | ||
28 | * Emulator and iothread also pinned to separate isolated cores | ||
29 | * variance between runs < 1% | ||
30 | |||
31 | - Not patched | ||
32 | * numjobs=1: lat_avg=327.32 irqs=29998 | ||
33 | * numjobs=4: lat_avg=337.89 irqs=29073 | ||
34 | * numjobs=8: lat_avg=342.98 irqs=28643 | ||
35 | |||
36 | - Patched: | ||
37 | * numjobs=1: lat_avg=323.92 irqs=30262 | ||
38 | * numjobs=4: lat_avg=332.65 irqs=29520 | ||
39 | * numjobs=8: lat_avg=335.54 irqs=29323 | ||
40 | |||
41 | Signed-off-by: Sergio Lopez <slp@redhat.com> | ||
42 | Message-id: 20180307114459.26636-1-slp@redhat.com | ||
43 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
44 | --- | ||
45 | hw/block/dataplane/virtio-blk.c | 15 +++++++++++++-- | ||
46 | 1 file changed, 13 insertions(+), 2 deletions(-) | ||
47 | |||
48 | diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/hw/block/dataplane/virtio-blk.c | ||
51 | +++ b/hw/block/dataplane/virtio-blk.c | ||
52 | @@ -XXX,XX +XXX,XX @@ struct VirtIOBlockDataPlane { | ||
53 | VirtIODevice *vdev; | ||
54 | QEMUBH *bh; /* bh for guest notification */ | ||
55 | unsigned long *batch_notify_vqs; | ||
56 | + bool batch_notifications; | ||
57 | |||
58 | /* Note that these EventNotifiers are assigned by value. This is | ||
59 | * fine as long as you do not call event_notifier_cleanup on them | ||
60 | @@ -XXX,XX +XXX,XX @@ struct VirtIOBlockDataPlane { | ||
61 | /* Raise an interrupt to signal guest, if necessary */ | ||
62 | void virtio_blk_data_plane_notify(VirtIOBlockDataPlane *s, VirtQueue *vq) | ||
63 | { | ||
64 | - set_bit(virtio_get_queue_index(vq), s->batch_notify_vqs); | ||
65 | - qemu_bh_schedule(s->bh); | ||
66 | + if (s->batch_notifications) { | ||
67 | + set_bit(virtio_get_queue_index(vq), s->batch_notify_vqs); | ||
68 | + qemu_bh_schedule(s->bh); | ||
69 | + } else { | ||
70 | + virtio_notify_irqfd(s->vdev, vq); | ||
71 | + } | ||
72 | } | ||
73 | |||
74 | static void notify_guest_bh(void *opaque) | ||
75 | @@ -XXX,XX +XXX,XX @@ int virtio_blk_data_plane_start(VirtIODevice *vdev) | ||
76 | |||
77 | s->starting = true; | ||
78 | |||
79 | + if (!virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { | ||
80 | + s->batch_notifications = true; | ||
81 | + } else { | ||
82 | + s->batch_notifications = false; | ||
83 | + } | ||
84 | + | ||
85 | /* Set up guest notifier (irq) */ | ||
86 | r = k->set_guest_notifiers(qbus->parent, nvqs, true); | ||
87 | if (r != 0) { | ||
88 | -- | ||
89 | 2.14.3 | ||
90 | |||
91 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Sometimes it's necessary for the main loop thread to run a BH in an | ||
2 | IOThread and wait for its completion. This primitive is useful during | ||
3 | startup/shutdown to synchronize and avoid race conditions. | ||
4 | 1 | ||
5 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
6 | Reviewed-by: Fam Zheng <famz@redhat.com> | ||
7 | Acked-by: Paolo Bonzini <pbonzini@redhat.com> | ||
8 | Message-id: 20180307144205.20619-2-stefanha@redhat.com | ||
9 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
10 | --- | ||
11 | include/block/aio-wait.h | 13 +++++++++++++ | ||
12 | util/aio-wait.c | 31 +++++++++++++++++++++++++++++++ | ||
13 | 2 files changed, 44 insertions(+) | ||
14 | |||
15 | diff --git a/include/block/aio-wait.h b/include/block/aio-wait.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/include/block/aio-wait.h | ||
18 | +++ b/include/block/aio-wait.h | ||
19 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
20 | */ | ||
21 | void aio_wait_kick(AioWait *wait); | ||
22 | |||
23 | +/** | ||
24 | + * aio_wait_bh_oneshot: | ||
25 | + * @ctx: the aio context | ||
26 | + * @cb: the BH callback function | ||
27 | + * @opaque: user data for the BH callback function | ||
28 | + * | ||
29 | + * Run a BH in @ctx and wait for it to complete. | ||
30 | + * | ||
31 | + * Must be called from the main loop thread with @ctx acquired exactly once. | ||
32 | + * Note that main loop event processing may occur. | ||
33 | + */ | ||
34 | +void aio_wait_bh_oneshot(AioContext *ctx, QEMUBHFunc *cb, void *opaque); | ||
35 | + | ||
36 | #endif /* QEMU_AIO_WAIT */ | ||
37 | diff --git a/util/aio-wait.c b/util/aio-wait.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/util/aio-wait.c | ||
40 | +++ b/util/aio-wait.c | ||
41 | @@ -XXX,XX +XXX,XX @@ void aio_wait_kick(AioWait *wait) | ||
42 | aio_bh_schedule_oneshot(qemu_get_aio_context(), dummy_bh_cb, NULL); | ||
43 | } | ||
44 | } | ||
45 | + | ||
46 | +typedef struct { | ||
47 | + AioWait wait; | ||
48 | + bool done; | ||
49 | + QEMUBHFunc *cb; | ||
50 | + void *opaque; | ||
51 | +} AioWaitBHData; | ||
52 | + | ||
53 | +/* Context: BH in IOThread */ | ||
54 | +static void aio_wait_bh(void *opaque) | ||
55 | +{ | ||
56 | + AioWaitBHData *data = opaque; | ||
57 | + | ||
58 | + data->cb(data->opaque); | ||
59 | + | ||
60 | + data->done = true; | ||
61 | + aio_wait_kick(&data->wait); | ||
62 | +} | ||
63 | + | ||
64 | +void aio_wait_bh_oneshot(AioContext *ctx, QEMUBHFunc *cb, void *opaque) | ||
65 | +{ | ||
66 | + AioWaitBHData data = { | ||
67 | + .cb = cb, | ||
68 | + .opaque = opaque, | ||
69 | + }; | ||
70 | + | ||
71 | + assert(qemu_get_current_aio_context() == qemu_get_aio_context()); | ||
72 | + | ||
73 | + aio_bh_schedule_oneshot(ctx, aio_wait_bh, &data); | ||
74 | + AIO_WAIT_WHILE(&data.wait, ctx, !data.done); | ||
75 | +} | ||
76 | -- | ||
77 | 2.14.3 | ||
78 | |||
79 | diff view generated by jsdifflib |
1 | Commit 00d09fdbbae5f7864ce754913efc84c12fdf9f1a ("vl: pause vcpus before | 1 | From: Sakshi Kaushik <sakshikaushik717@gmail.com> |
---|---|---|---|
2 | stopping iothreads") and commit dce8921b2baaf95974af8176406881872067adfa | ||
3 | ("iothread: Stop threads before main() quits") tried to work around the | ||
4 | fact that emulation was still active during termination by stopping | ||
5 | iothreads. They suffer from race conditions: | ||
6 | 1. virtio_scsi_handle_cmd_vq() racing with iothread_stop_all() hits the | ||
7 | virtio_scsi_ctx_check() assertion failure because the BDS AioContext | ||
8 | has been modified by iothread_stop_all(). | ||
9 | 2. Guest vq kick racing with main loop termination leaves a readable | ||
10 | ioeventfd that is handled by the next aio_poll() when external | ||
11 | clients are enabled again, resulting in unwanted emulation activity. | ||
12 | 2 | ||
13 | This patch obsoletes those commits by fully disabling emulation activity | 3 | Signed-off-by: Sakshi Kaushik <sakshikaushik717@gmail.com> |
14 | when vcpus are stopped. | 4 | Message-id: 20220406162410.8536-1-sakshikaushik717@gmail.com |
15 | 5 | ||
16 | Use the new vm_shutdown() function instead of pause_all_vcpus() so that | 6 | [Name the iSCSI URL long option --iscsi-uri instead of --iscsi_uri for |
17 | vm change state handlers are invoked too. Virtio devices will now stop | 7 | consistency, fix --fd which was rejected due to an outdated |
18 | their ioeventfds, preventing further emulation activity after vm_stop(). | 8 | --socket-path check, and add missing entries[] terminator. |
9 | --Stefan] | ||
19 | 10 | ||
20 | Note that vm_stop(RUN_STATE_SHUTDOWN) cannot be used because it emits a | ||
21 | QMP STOP event that may affect existing clients. | ||
22 | |||
23 | It is no longer necessary to call replay_disable_events() directly since | ||
24 | vm_shutdown() does so already. | ||
25 | |||
26 | Drop iothread_stop_all() since it is no longer used. | ||
27 | |||
28 | Cc: Fam Zheng <famz@redhat.com> | ||
29 | Cc: Kevin Wolf <kwolf@redhat.com> | ||
30 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
31 | Reviewed-by: Fam Zheng <famz@redhat.com> | ||
32 | Acked-by: Paolo Bonzini <pbonzini@redhat.com> | ||
33 | Message-id: 20180307144205.20619-5-stefanha@redhat.com | ||
34 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 11 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
35 | --- | 12 | --- |
36 | include/sysemu/iothread.h | 1 - | 13 | contrib/vhost-user-scsi/vhost-user-scsi.c | 77 +++++++++++++++-------- |
37 | include/sysemu/sysemu.h | 1 + | 14 | 1 file changed, 52 insertions(+), 25 deletions(-) |
38 | cpus.c | 16 +++++++++++++--- | ||
39 | iothread.c | 31 ------------------------------- | ||
40 | vl.c | 13 +++---------- | ||
41 | 5 files changed, 17 insertions(+), 45 deletions(-) | ||
42 | 15 | ||
43 | diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h | 16 | diff --git a/contrib/vhost-user-scsi/vhost-user-scsi.c b/contrib/vhost-user-scsi/vhost-user-scsi.c |
44 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
45 | --- a/include/sysemu/iothread.h | 18 | --- a/contrib/vhost-user-scsi/vhost-user-scsi.c |
46 | +++ b/include/sysemu/iothread.h | 19 | +++ b/contrib/vhost-user-scsi/vhost-user-scsi.c |
47 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 20 | @@ -XXX,XX +XXX,XX @@ fail: |
48 | char *iothread_get_id(IOThread *iothread); | 21 | |
49 | IOThread *iothread_by_id(const char *id); | 22 | /** vhost-user-scsi **/ |
50 | AioContext *iothread_get_aio_context(IOThread *iothread); | 23 | |
51 | -void iothread_stop_all(void); | 24 | +static int opt_fdnum = -1; |
52 | GMainContext *iothread_get_g_main_context(IOThread *iothread); | 25 | +static char *opt_socket_path; |
53 | 26 | +static gboolean opt_print_caps; | |
54 | /* | 27 | +static char *iscsi_uri; |
55 | diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h | 28 | + |
56 | index XXXXXXX..XXXXXXX 100644 | 29 | +static GOptionEntry entries[] = { |
57 | --- a/include/sysemu/sysemu.h | 30 | + { "print-capabilities", 'c', 0, G_OPTION_ARG_NONE, &opt_print_caps, |
58 | +++ b/include/sysemu/sysemu.h | 31 | + "Print capabilities", NULL }, |
59 | @@ -XXX,XX +XXX,XX @@ void vm_start(void); | 32 | + { "fd", 'f', 0, G_OPTION_ARG_INT, &opt_fdnum, |
60 | int vm_prepare_start(void); | 33 | + "Use inherited fd socket", "FDNUM" }, |
61 | int vm_stop(RunState state); | 34 | + { "iscsi-uri", 'i', 0, G_OPTION_ARG_FILENAME, &iscsi_uri, |
62 | int vm_stop_force_state(RunState state); | 35 | + "iSCSI URI to connect to", "FDNUM" }, |
63 | +int vm_shutdown(void); | 36 | + { "socket-path", 's', 0, G_OPTION_ARG_FILENAME, &opt_socket_path, |
64 | 37 | + "Use UNIX socket path", "PATH" }, | |
65 | typedef enum WakeupReason { | 38 | + { NULL, } |
66 | /* Always keep QEMU_WAKEUP_REASON_NONE = 0 */ | 39 | +}; |
67 | diff --git a/cpus.c b/cpus.c | 40 | + |
68 | index XXXXXXX..XXXXXXX 100644 | 41 | int main(int argc, char **argv) |
69 | --- a/cpus.c | 42 | { |
70 | +++ b/cpus.c | 43 | VusDev *vdev_scsi = NULL; |
71 | @@ -XXX,XX +XXX,XX @@ void cpu_synchronize_all_pre_loadvm(void) | 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); | ||
70 | + } | ||
71 | + | ||
72 | + if (opt_print_caps) { | ||
73 | + g_print("{\n"); | ||
74 | + g_print(" \"type\": \"scsi\"\n"); | ||
75 | + g_print("}\n"); | ||
76 | + goto out; | ||
72 | } | 77 | } |
73 | } | 78 | - if (!unix_fn || !iscsi_uri) { |
74 | 79 | + | |
75 | -static int do_vm_stop(RunState state) | 80 | + if (!iscsi_uri) { |
76 | +static int do_vm_stop(RunState state, bool send_stop) | 81 | goto help; |
77 | { | 82 | } |
78 | int ret = 0; | 83 | |
79 | 84 | - lsock = unix_sock_new(unix_fn); | |
80 | @@ -XXX,XX +XXX,XX @@ static int do_vm_stop(RunState state) | 85 | - if (lsock < 0) { |
81 | pause_all_vcpus(); | 86 | - goto err; |
82 | runstate_set(state); | 87 | + if (opt_socket_path) { |
83 | vm_state_notify(0, state); | 88 | + lsock = unix_sock_new(opt_socket_path); |
84 | - qapi_event_send_stop(&error_abort); | 89 | + if (lsock < 0) { |
85 | + if (send_stop) { | 90 | + exit(EXIT_FAILURE); |
86 | + qapi_event_send_stop(&error_abort); | ||
87 | + } | 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; | ||
88 | } | 97 | } |
89 | 98 | ||
90 | bdrv_drain_all(); | 99 | csock = accept(lsock, NULL, NULL); |
91 | @@ -XXX,XX +XXX,XX @@ static int do_vm_stop(RunState state) | 100 | @@ -XXX,XX +XXX,XX @@ out: |
92 | return ret; | 101 | if (vdev_scsi) { |
93 | } | 102 | g_main_loop_unref(vdev_scsi->loop); |
94 | 103 | g_free(vdev_scsi); | |
95 | +/* Special vm_stop() variant for terminating the process. Historically clients | 104 | - unlink(unix_fn); |
96 | + * did not expect a QMP STOP event and so we need to retain compatibility. | 105 | + unlink(opt_socket_path); |
97 | + */ | ||
98 | +int vm_shutdown(void) | ||
99 | +{ | ||
100 | + return do_vm_stop(RUN_STATE_SHUTDOWN, false); | ||
101 | +} | ||
102 | + | ||
103 | static bool cpu_can_run(CPUState *cpu) | ||
104 | { | ||
105 | if (cpu->stop) { | ||
106 | @@ -XXX,XX +XXX,XX @@ int vm_stop(RunState state) | ||
107 | return 0; | ||
108 | } | 106 | } |
109 | 107 | if (csock >= 0) { | |
110 | - return do_vm_stop(state); | 108 | close(csock); |
111 | + return do_vm_stop(state, true); | 109 | @@ -XXX,XX +XXX,XX @@ out: |
112 | } | 110 | if (lsock >= 0) { |
113 | 111 | close(lsock); | |
114 | /** | 112 | } |
115 | diff --git a/iothread.c b/iothread.c | 113 | - g_free(unix_fn); |
116 | index XXXXXXX..XXXXXXX 100644 | 114 | + g_free(opt_socket_path); |
117 | --- a/iothread.c | 115 | g_free(iscsi_uri); |
118 | +++ b/iothread.c | 116 | |
119 | @@ -XXX,XX +XXX,XX @@ void iothread_stop(IOThread *iothread) | 117 | return err; |
120 | qemu_thread_join(&iothread->thread); | 118 | @@ -XXX,XX +XXX,XX @@ err: |
121 | } | 119 | goto out; |
122 | 120 | ||
123 | -static int iothread_stop_iter(Object *object, void *opaque) | 121 | help: |
124 | -{ | 122 | - fprintf(stderr, "Usage: %s [ -u unix_sock_path -i iscsi_uri ] | [ -h ]\n", |
125 | - IOThread *iothread; | 123 | + fprintf(stderr, "Usage: %s [ -s socket-path -i iscsi-uri -f fd -p print-capabilities ] | [ -h ]\n", |
126 | - | 124 | argv[0]); |
127 | - iothread = (IOThread *)object_dynamic_cast(object, TYPE_IOTHREAD); | 125 | - fprintf(stderr, " -u path to unix socket\n"); |
128 | - if (!iothread) { | 126 | - fprintf(stderr, " -i iscsi uri for lun 0\n"); |
129 | - return 0; | 127 | + fprintf(stderr, " -s, --socket-path=SOCKET_PATH path to unix socket\n"); |
130 | - } | 128 | + fprintf(stderr, " -i, --iscsi-uri=ISCSI_URI iscsi uri for lun 0\n"); |
131 | - iothread_stop(iothread); | 129 | + fprintf(stderr, " -f, --fd=FILE_DESCRIPTOR file-descriptor\n"); |
132 | - return 0; | 130 | + fprintf(stderr, " -p, --print-capabilities=PRINT_CAPABILITIES denotes print-capabilities\n"); |
133 | -} | 131 | fprintf(stderr, " -h print help and quit\n"); |
134 | - | 132 | |
135 | static void iothread_instance_init(Object *obj) | 133 | goto err; |
136 | { | ||
137 | IOThread *iothread = IOTHREAD(obj); | ||
138 | @@ -XXX,XX +XXX,XX @@ IOThreadInfoList *qmp_query_iothreads(Error **errp) | ||
139 | return head; | ||
140 | } | ||
141 | |||
142 | -void iothread_stop_all(void) | ||
143 | -{ | ||
144 | - Object *container = object_get_objects_root(); | ||
145 | - BlockDriverState *bs; | ||
146 | - BdrvNextIterator it; | ||
147 | - | ||
148 | - for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { | ||
149 | - AioContext *ctx = bdrv_get_aio_context(bs); | ||
150 | - if (ctx == qemu_get_aio_context()) { | ||
151 | - continue; | ||
152 | - } | ||
153 | - aio_context_acquire(ctx); | ||
154 | - bdrv_set_aio_context(bs, qemu_get_aio_context()); | ||
155 | - aio_context_release(ctx); | ||
156 | - } | ||
157 | - | ||
158 | - object_child_foreach(container, iothread_stop_iter, NULL); | ||
159 | -} | ||
160 | - | ||
161 | static gpointer iothread_g_main_context_init(gpointer opaque) | ||
162 | { | ||
163 | AioContext *ctx; | ||
164 | diff --git a/vl.c b/vl.c | ||
165 | index XXXXXXX..XXXXXXX 100644 | ||
166 | --- a/vl.c | ||
167 | +++ b/vl.c | ||
168 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv, char **envp) | ||
169 | os_setup_post(); | ||
170 | |||
171 | main_loop(); | ||
172 | - replay_disable_events(); | ||
173 | |||
174 | - /* The ordering of the following is delicate. Stop vcpus to prevent new | ||
175 | - * I/O requests being queued by the guest. Then stop IOThreads (this | ||
176 | - * includes a drain operation and completes all request processing). At | ||
177 | - * this point emulated devices are still associated with their IOThreads | ||
178 | - * (if any) but no longer have any work to do. Only then can we close | ||
179 | - * block devices safely because we know there is no more I/O coming. | ||
180 | - */ | ||
181 | - pause_all_vcpus(); | ||
182 | - iothread_stop_all(); | ||
183 | + /* No more vcpu or device emulation activity beyond this point */ | ||
184 | + vm_shutdown(); | ||
185 | + | ||
186 | bdrv_close_all(); | ||
187 | |||
188 | res_free(); | ||
189 | -- | 134 | -- |
190 | 2.14.3 | 135 | 2.35.1 |
191 | |||
192 | diff view generated by jsdifflib |
1 | If the main loop thread invokes .ioeventfd_stop() just as the vq handler | 1 | The GLib documentation says "a NULL-terminated array of GOptionEntrys" |
---|---|---|---|
2 | function begins in the IOThread then the handler may lose the race for | 2 | so we'd better make sure there is a terminator that lets |
3 | the AioContext lock. By the time the vq handler is able to acquire the | 3 | g_option_context_add_main_entries() know when the end of the array has |
4 | AioContext lock the ioeventfd has already been removed and the handler | 4 | been reached. |
5 | isn't supposed to run anymore! | ||
6 | |||
7 | Use the new aio_wait_bh_oneshot() function to perform ioeventfd removal | ||
8 | from within the IOThread. This way no races with the vq handler are | ||
9 | possible. | ||
10 | 5 | ||
11 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 6 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
12 | Reviewed-by: Fam Zheng <famz@redhat.com> | 7 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> |
13 | Acked-by: Paolo Bonzini <pbonzini@redhat.com> | 8 | Message-id: 20220411150057.3009667-1-stefanha@redhat.com |
14 | Message-id: 20180307144205.20619-4-stefanha@redhat.com | ||
15 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 9 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
16 | --- | 10 | --- |
17 | hw/scsi/virtio-scsi-dataplane.c | 9 +++++---- | 11 | contrib/vhost-user-blk/vhost-user-blk.c | 3 ++- |
18 | 1 file changed, 5 insertions(+), 4 deletions(-) | 12 | 1 file changed, 2 insertions(+), 1 deletion(-) |
19 | 13 | ||
20 | diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c | 14 | diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c |
21 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/scsi/virtio-scsi-dataplane.c | 16 | --- a/contrib/vhost-user-blk/vhost-user-blk.c |
23 | +++ b/hw/scsi/virtio-scsi-dataplane.c | 17 | +++ b/contrib/vhost-user-blk/vhost-user-blk.c |
24 | @@ -XXX,XX +XXX,XX @@ static int virtio_scsi_vring_init(VirtIOSCSI *s, VirtQueue *vq, int n, | 18 | @@ -XXX,XX +XXX,XX @@ static GOptionEntry entries[] = { |
25 | return 0; | 19 | {"blk-file", 'b', 0, G_OPTION_ARG_FILENAME, &opt_blk_file, |
26 | } | 20 | "block device or file path", "PATH"}, |
27 | 21 | { "read-only", 'r', 0, G_OPTION_ARG_NONE, &opt_read_only, | |
28 | -/* assumes s->ctx held */ | 22 | - "Enable read-only", NULL } |
29 | -static void virtio_scsi_clear_aio(VirtIOSCSI *s) | 23 | + "Enable read-only", NULL }, |
30 | +/* Context: BH in IOThread */ | 24 | + { NULL, }, |
31 | +static void virtio_scsi_dataplane_stop_bh(void *opaque) | 25 | }; |
32 | { | 26 | |
33 | + VirtIOSCSI *s = opaque; | 27 | int main(int argc, char **argv) |
34 | VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s); | ||
35 | int i; | ||
36 | |||
37 | @@ -XXX,XX +XXX,XX @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev) | ||
38 | return 0; | ||
39 | |||
40 | fail_vrings: | ||
41 | - virtio_scsi_clear_aio(s); | ||
42 | + aio_wait_bh_oneshot(s->ctx, virtio_scsi_dataplane_stop_bh, s); | ||
43 | aio_context_release(s->ctx); | ||
44 | for (i = 0; i < vs->conf.num_queues + 2; i++) { | ||
45 | virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false); | ||
46 | @@ -XXX,XX +XXX,XX @@ void virtio_scsi_dataplane_stop(VirtIODevice *vdev) | ||
47 | s->dataplane_stopping = true; | ||
48 | |||
49 | aio_context_acquire(s->ctx); | ||
50 | - virtio_scsi_clear_aio(s); | ||
51 | + aio_wait_bh_oneshot(s->ctx, virtio_scsi_dataplane_stop_bh, s); | ||
52 | aio_context_release(s->ctx); | ||
53 | |||
54 | blk_drain_all(); /* ensure there are no in-flight requests */ | ||
55 | -- | 28 | -- |
56 | 2.14.3 | 29 | 2.35.1 |
57 | |||
58 | diff view generated by jsdifflib |
1 | If the main loop thread invokes .ioeventfd_stop() just as the vq handler | 1 | From: Liu Yiding <liuyd.fnst@fujitsu.com> |
---|---|---|---|
2 | function begins in the IOThread then the handler may lose the race for | ||
3 | the AioContext lock. By the time the vq handler is able to acquire the | ||
4 | AioContext lock the ioeventfd has already been removed and the handler | ||
5 | isn't supposed to run anymore! | ||
6 | 2 | ||
7 | Use the new aio_wait_bh_oneshot() function to perform ioeventfd removal | 3 | virtiofsd has introduced killpriv_v2/no_killpriv_v2 for a while. Add |
8 | from within the IOThread. This way no races with the vq handler are | 4 | description of it to docs/helper. |
9 | possible. | 5 | |
6 | Signed-off-by: Liu Yiding <liuyd.fnst@fujitsu.com> | ||
7 | Message-Id: <20220421095151.2231099-1-liuyd.fnst@fujitsu.com> | ||
8 | |||
9 | [Small documentation fixes: s/as client supports/as the client supports/ | ||
10 | and s/. /. /. | ||
11 | --Stefan] | ||
10 | 12 | ||
11 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 13 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
12 | Reviewed-by: Fam Zheng <famz@redhat.com> | ||
13 | Acked-by: Paolo Bonzini <pbonzini@redhat.com> | ||
14 | Message-id: 20180307144205.20619-3-stefanha@redhat.com | ||
15 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
16 | --- | 14 | --- |
17 | hw/block/dataplane/virtio-blk.c | 24 +++++++++++++++++------- | 15 | docs/tools/virtiofsd.rst | 5 +++++ |
18 | 1 file changed, 17 insertions(+), 7 deletions(-) | 16 | tools/virtiofsd/helper.c | 3 +++ |
17 | 2 files changed, 8 insertions(+) | ||
19 | 18 | ||
20 | diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c | 19 | diff --git a/docs/tools/virtiofsd.rst b/docs/tools/virtiofsd.rst |
21 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/block/dataplane/virtio-blk.c | 21 | --- a/docs/tools/virtiofsd.rst |
23 | +++ b/hw/block/dataplane/virtio-blk.c | 22 | +++ b/docs/tools/virtiofsd.rst |
24 | @@ -XXX,XX +XXX,XX @@ int virtio_blk_data_plane_start(VirtIODevice *vdev) | 23 | @@ -XXX,XX +XXX,XX @@ Options |
25 | return -ENOSYS; | 24 | label. Server will try to set that label on newly created file |
25 | atomically wherever possible. | ||
26 | |||
27 | + * killpriv_v2|no_killpriv_v2 - | ||
28 | + Enable/disable ``FUSE_HANDLE_KILLPRIV_V2`` support. KILLPRIV_V2 is enabled | ||
29 | + by default as long as the client supports it. Enabling this option helps | ||
30 | + with performance in write path. | ||
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 | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/tools/virtiofsd/helper.c | ||
38 | +++ b/tools/virtiofsd/helper.c | ||
39 | @@ -XXX,XX +XXX,XX @@ void fuse_cmdline_help(void) | ||
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 | ); | ||
26 | } | 47 | } |
27 | 48 | ||
28 | +/* Stop notifications for new requests from guest. | ||
29 | + * | ||
30 | + * Context: BH in IOThread | ||
31 | + */ | ||
32 | +static void virtio_blk_data_plane_stop_bh(void *opaque) | ||
33 | +{ | ||
34 | + VirtIOBlockDataPlane *s = opaque; | ||
35 | + unsigned i; | ||
36 | + | ||
37 | + for (i = 0; i < s->conf->num_queues; i++) { | ||
38 | + VirtQueue *vq = virtio_get_queue(s->vdev, i); | ||
39 | + | ||
40 | + virtio_queue_aio_set_host_notifier_handler(vq, s->ctx, NULL); | ||
41 | + } | ||
42 | +} | ||
43 | + | ||
44 | /* Context: QEMU global mutex held */ | ||
45 | void virtio_blk_data_plane_stop(VirtIODevice *vdev) | ||
46 | { | ||
47 | @@ -XXX,XX +XXX,XX @@ void virtio_blk_data_plane_stop(VirtIODevice *vdev) | ||
48 | trace_virtio_blk_data_plane_stop(s); | ||
49 | |||
50 | aio_context_acquire(s->ctx); | ||
51 | - | ||
52 | - /* Stop notifications for new requests from guest */ | ||
53 | - for (i = 0; i < nvqs; i++) { | ||
54 | - VirtQueue *vq = virtio_get_queue(s->vdev, i); | ||
55 | - | ||
56 | - virtio_queue_aio_set_host_notifier_handler(vq, s->ctx, NULL); | ||
57 | - } | ||
58 | + aio_wait_bh_oneshot(s->ctx, virtio_blk_data_plane_stop_bh, s); | ||
59 | |||
60 | /* Drain and switch bs back to the QEMU main loop */ | ||
61 | blk_set_aio_context(s->conf->conf.blk, qemu_get_aio_context()); | ||
62 | -- | 49 | -- |
63 | 2.14.3 | 50 | 2.35.1 |
64 | |||
65 | diff view generated by jsdifflib |