1
The following changes since commit afc9fcde55296b83f659de9da3cdf044812a6eeb:
1
The following changes since commit 741e1a618b126e664f7b723e6fe1b7ace511caf7:
2
2
3
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2021-10-20 06:10:51 -0700)
3
Merge remote-tracking branch 'remotes/stefanberger/tags/pull-tpm-2018-09-07-1' into staging (2018-09-24 18:12:54 +0100)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
https://gitlab.com/stefanha/qemu.git tags/block-pull-request
7
git://github.com/codyprime/qemu-kvm-jtc.git tags/block-pull-request
8
8
9
for you to fetch changes up to 4b2b3d2653f255ef4259a7689af1956536565901:
9
for you to fetch changes up to 637fa44ab80c6b317adf1d117494325a95daad60:
10
10
11
coroutine: resize pool periodically instead of limiting size (2021-10-21 18:40:07 +0100)
11
curl: Make sslverify=off disable host as well as peer verification. (2018-09-24 23:46:05 -0400)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Pull request
14
RBD and Curl patches
15
16
Performance optimization when guest applications submit a lot of parallel I/O.
17
This has also been found to improve clang SafeStack performance.
18
19
----------------------------------------------------------------
15
----------------------------------------------------------------
20
16
21
Stefan Hajnoczi (1):
17
Jeff Cody (4):
22
coroutine: resize pool periodically instead of limiting size
18
block/rbd: pull out qemu_rbd_convert_options
19
block/rbd: Attempt to parse legacy filenames
20
block/rbd: add iotest for rbd legacy keyvalue filename parsing
21
block/rbd: add deprecation documentation for filename keyvalue pairs
23
22
24
include/qemu/coroutine-pool-timer.h | 36 ++++++++++++++++
23
Richard W.M. Jones (1):
25
include/qemu/coroutine.h | 7 ++++
24
curl: Make sslverify=off disable host as well as peer verification.
26
iothread.c | 6 +++
25
27
util/coroutine-pool-timer.c | 35 ++++++++++++++++
26
block/curl.c | 2 +
28
util/main-loop.c | 5 +++
27
block/rbd.c | 90 ++++++++++++++++++++++++++++++++------
29
util/qemu-coroutine.c | 64 ++++++++++++++++-------------
28
qemu-deprecated.texi | 15 +++++++
30
util/meson.build | 1 +
29
tests/qemu-iotests/231 | 62 ++++++++++++++++++++++++++
31
7 files changed, 125 insertions(+), 29 deletions(-)
30
tests/qemu-iotests/231.out | 9 ++++
32
create mode 100644 include/qemu/coroutine-pool-timer.h
31
tests/qemu-iotests/group | 1 +
33
create mode 100644 util/coroutine-pool-timer.c
32
6 files changed, 165 insertions(+), 14 deletions(-)
33
create mode 100755 tests/qemu-iotests/231
34
create mode 100644 tests/qemu-iotests/231.out
34
35
35
--
36
--
36
2.31.1
37
2.17.1
37
38
38
39
39
diff view generated by jsdifflib
New patch
1
Code movement to pull the conversion from Qdict to BlockdevOptionsRbd
2
into a helper function.
1
3
4
Reviewed-by: Eric Blake <eblake@redhat.com>
5
Reviewed-by: John Snow <jsnow@redhat.com>
6
Signed-off-by: Jeff Cody <jcody@redhat.com>
7
Message-id: 5b49a980f2cde6610ab1df41bb0277d00b5db893.1536704901.git.jcody@redhat.com
8
Signed-off-by: Jeff Cody <jcody@redhat.com>
9
---
10
block/rbd.c | 36 ++++++++++++++++++++++++------------
11
1 file changed, 24 insertions(+), 12 deletions(-)
12
13
diff --git a/block/rbd.c b/block/rbd.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/block/rbd.c
16
+++ b/block/rbd.c
17
@@ -XXX,XX +XXX,XX @@ failed_opts:
18
return r;
19
}
20
21
+static int qemu_rbd_convert_options(QDict *options, BlockdevOptionsRbd **opts,
22
+ Error **errp)
23
+{
24
+ Visitor *v;
25
+ Error *local_err = NULL;
26
+
27
+ /* Convert the remaining options into a QAPI object */
28
+ v = qobject_input_visitor_new_flat_confused(options, errp);
29
+ if (!v) {
30
+ return -EINVAL;
31
+ }
32
+
33
+ visit_type_BlockdevOptionsRbd(v, NULL, opts, &local_err);
34
+ visit_free(v);
35
+
36
+ if (local_err) {
37
+ error_propagate(errp, local_err);
38
+ return -EINVAL;
39
+ }
40
+
41
+ return 0;
42
+}
43
+
44
static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
45
Error **errp)
46
{
47
BDRVRBDState *s = bs->opaque;
48
BlockdevOptionsRbd *opts = NULL;
49
- Visitor *v;
50
const QDictEntry *e;
51
Error *local_err = NULL;
52
char *keypairs, *secretid;
53
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
54
qdict_del(options, "password-secret");
55
}
56
57
- /* Convert the remaining options into a QAPI object */
58
- v = qobject_input_visitor_new_flat_confused(options, errp);
59
- if (!v) {
60
- r = -EINVAL;
61
- goto out;
62
- }
63
-
64
- visit_type_BlockdevOptionsRbd(v, NULL, &opts, &local_err);
65
- visit_free(v);
66
-
67
+ r = qemu_rbd_convert_options(options, &opts, &local_err);
68
if (local_err) {
69
error_propagate(errp, local_err);
70
- r = -EINVAL;
71
goto out;
72
}
73
74
--
75
2.17.1
76
77
diff view generated by jsdifflib
New patch
1
When we converted rbd to get rid of the older key/value-centric
2
encoding format, we broke compatibility with image files with backing
3
file strings encoded in the old format.
1
4
5
This leaves a bit of an ugly conundrum, and a hacky solution.
6
7
If the initial attempt to parse the "proper" options fails, it assumes
8
that we may have an older key/value encoded filename. Fall back to
9
attempting to parse the filename, and extract the required options from
10
it. If that fails, pass along the original error message.
11
12
We do not support mixed modern usage alongside legacy keyvalue pair
13
usage.
14
15
A deprecation warning has been added, although care should be taken
16
when actually deprecating since the impact is not limited to
17
commandline or qapi usage, but also opening existing images.
18
19
Reviewed-by: Eric Blake <eblake@redhat.com>
20
Signed-off-by: Jeff Cody <jcody@redhat.com>
21
Message-id: 15b332e5432ad069441f7275a46080f465d789a0.1536704901.git.jcody@redhat.com
22
Signed-off-by: Jeff Cody <jcody@redhat.com>
23
---
24
block/rbd.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++--
25
1 file changed, 52 insertions(+), 2 deletions(-)
26
27
diff --git a/block/rbd.c b/block/rbd.c
28
index XXXXXXX..XXXXXXX 100644
29
--- a/block/rbd.c
30
+++ b/block/rbd.c
31
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_convert_options(QDict *options, BlockdevOptionsRbd **opts,
32
return 0;
33
}
34
35
+static int qemu_rbd_attempt_legacy_options(QDict *options,
36
+ BlockdevOptionsRbd **opts,
37
+ char **keypairs)
38
+{
39
+ char *filename;
40
+ int r;
41
+
42
+ filename = g_strdup(qdict_get_try_str(options, "filename"));
43
+ if (!filename) {
44
+ return -EINVAL;
45
+ }
46
+ qdict_del(options, "filename");
47
+
48
+ qemu_rbd_parse_filename(filename, options, NULL);
49
+
50
+ /* keypairs freed by caller */
51
+ *keypairs = g_strdup(qdict_get_try_str(options, "=keyvalue-pairs"));
52
+ if (*keypairs) {
53
+ qdict_del(options, "=keyvalue-pairs");
54
+ }
55
+
56
+ r = qemu_rbd_convert_options(options, opts, NULL);
57
+
58
+ g_free(filename);
59
+ return r;
60
+}
61
+
62
static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
63
Error **errp)
64
{
65
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
66
67
r = qemu_rbd_convert_options(options, &opts, &local_err);
68
if (local_err) {
69
- error_propagate(errp, local_err);
70
- goto out;
71
+ /* If keypairs are present, that means some options are present in
72
+ * the modern option format. Don't attempt to parse legacy option
73
+ * formats, as we won't support mixed usage. */
74
+ if (keypairs) {
75
+ error_propagate(errp, local_err);
76
+ goto out;
77
+ }
78
+
79
+ /* If the initial attempt to convert and process the options failed,
80
+ * we may be attempting to open an image file that has the rbd options
81
+ * specified in the older format consisting of all key/value pairs
82
+ * encoded in the filename. Go ahead and attempt to parse the
83
+ * filename, and see if we can pull out the required options. */
84
+ r = qemu_rbd_attempt_legacy_options(options, &opts, &keypairs);
85
+ if (r < 0) {
86
+ /* Propagate the original error, not the legacy parsing fallback
87
+ * error, as the latter was just a best-effort attempt. */
88
+ error_propagate(errp, local_err);
89
+ goto out;
90
+ }
91
+ /* Take care whenever deciding to actually deprecate; once this ability
92
+ * is removed, we will not be able to open any images with legacy-styled
93
+ * backing image strings. */
94
+ error_report("RBD options encoded in the filename as keyvalue pairs "
95
+ "is deprecated");
96
}
97
98
/* Remove the processed options from the QDict (the visitor processes
99
--
100
2.17.1
101
102
diff view generated by jsdifflib
1
It was reported that enabling SafeStack reduces IOPS significantly
1
This is a small test that will check for the ability to parse
2
(>25%) with the following fio benchmark on virtio-blk using a NVMe host
2
both legacy and modern options for rbd.
3
block device:
4
3
5
# fio --rw=randrw --bs=4k --iodepth=64 --runtime=1m --direct=1 \
4
The way the test is set up is for failure to occur, but without
6
    --filename=/dev/vdb --name=job1 --ioengine=libaio --thread \
5
having to wait to timeout on a non-existent rbd server. The error
7
    --group_reporting --numjobs=16 --time_based \
6
messages in the success path show that the arguments were parsed.
8
--output=/tmp/fio_result
9
7
10
Serge Guelton and I found that SafeStack is not really at fault, it just
8
The failure behavior prior to the patch series that has this test, is
11
increases the cost of coroutine creation. This fio workload exhausts the
9
qemu-img complaining about mandatory options (e.g. 'pool') not being
12
coroutine pool and coroutine creation becomes a bottleneck. Previous
10
provided.
13
work by Honghao Wang also pointed to excessive coroutine creation.
14
11
15
Creating new coroutines is expensive due to allocating new stacks with
12
Reviewed-by: Eric Blake <eblake@redhat.com>
16
mmap(2) and mprotect(2). Currently there are thread-local and global
13
Signed-off-by: Jeff Cody <jcody@redhat.com>
17
pools that recycle old Coroutine objects and their stacks but the
14
Message-id: f830580e339b974a83ed4870d11adcdc17f49a47.1536704901.git.jcody@redhat.com
18
hardcoded size limit of 64 for thread-local pools and 128 for the global
15
Signed-off-by: Jeff Cody <jcody@redhat.com>
19
pool is insufficient for the fio benchmark shown above.
16
---
17
tests/qemu-iotests/231 | 62 ++++++++++++++++++++++++++++++++++++++
18
tests/qemu-iotests/231.out | 9 ++++++
19
tests/qemu-iotests/group | 1 +
20
3 files changed, 72 insertions(+)
21
create mode 100755 tests/qemu-iotests/231
22
create mode 100644 tests/qemu-iotests/231.out
20
23
21
This patch changes the coroutine pool algorithm to a simple thread-local
24
diff --git a/tests/qemu-iotests/231 b/tests/qemu-iotests/231
22
pool without a maximum size limit. Threads periodically shrink the pool
25
new file mode 100755
23
down to a size sufficient for the maximum observed number of coroutines.
26
index XXXXXXX..XXXXXXX
24
27
--- /dev/null
25
The global pool is removed by this patch. It can help to hide the fact
28
+++ b/tests/qemu-iotests/231
26
that local pools are easily exhausted, but it's doesn't fix the root
29
@@ -XXX,XX +XXX,XX @@
27
cause. I don't think there is a need for a global pool because QEMU's
30
+#!/bin/bash
28
threads are long-lived, so let's keep things simple.
31
+#
29
32
+# Test legacy and modern option parsing for rbd/ceph. This will not
30
Performance of the above fio benchmark is as follows:
33
+# actually connect to a ceph server, but rather looks for the appropriate
31
34
+# error message that indicates we parsed the options correctly.
32
Before After
35
+#
33
IOPS 60k 97k
36
+# Copyright (C) 2018 Red Hat, Inc.
34
37
+#
35
Memory usage varies over time as needed by the workload:
38
+# This program is free software; you can redistribute it and/or modify
36
39
+# it under the terms of the GNU General Public License as published by
37
VSZ (KB) RSS (KB)
40
+# the Free Software Foundation; either version 2 of the License, or
38
Before fio 4705248 843128
41
+# (at your option) any later version.
39
During fio 5747668 (+ ~100 MB) 849280
42
+#
40
After fio 4694996 (- ~100 MB) 845184
43
+# This program is distributed in the hope that it will be useful,
41
44
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
42
This confirms that coroutines are indeed being freed when no longer
45
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43
needed.
46
+# GNU General Public License for more details.
44
47
+#
45
Thanks to Serge Guelton for working on identifying the bottleneck with
48
+# You should have received a copy of the GNU General Public License
46
me!
49
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
47
50
+#
48
Reported-by: Tingting Mao <timao@redhat.com>
51
+
49
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
52
+# creator
50
Message-id: 20210913153524.1190696-1-stefanha@redhat.com
53
+owner=jcody@redhat.com
51
Cc: Serge Guelton <sguelton@redhat.com>
54
+
52
Cc: Honghao Wang <wanghonghao@bytedance.com>
55
+seq=`basename $0`
53
Cc: Paolo Bonzini <pbonzini@redhat.com>
56
+echo "QA output created by $seq"
54
Cc: Daniele Buono <dbuono@linux.vnet.ibm.com>
57
+
55
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
58
+here=`pwd`
56
59
+status=1    # failure is the default!
57
[Moved atexit notifier to coroutine_delete() after GitLab CI reported a
60
+
58
memory leak in tests/unit/test-aio-multithread because the Coroutine
61
+_cleanup()
59
object was created in the main thread but runs in an IOThread (where
62
+{
60
it's also deleted).
63
+ rm "${BOGUS_CONF}"
61
--Stefan]
64
+}
62
---
65
+trap "_cleanup; exit \$status" 0 1 2 3 15
63
include/qemu/coroutine-pool-timer.h | 36 ++++++++++++++++
66
+
64
include/qemu/coroutine.h | 7 ++++
67
+# get standard environment, filters and checks
65
iothread.c | 6 +++
68
+. ./common.rc
66
util/coroutine-pool-timer.c | 35 ++++++++++++++++
69
+. ./common.filter
67
util/main-loop.c | 5 +++
70
+
68
util/qemu-coroutine.c | 64 ++++++++++++++++-------------
71
+_supported_fmt generic
69
util/meson.build | 1 +
72
+_supported_proto rbd
70
7 files changed, 125 insertions(+), 29 deletions(-)
73
+_supported_os Linux
71
create mode 100644 include/qemu/coroutine-pool-timer.h
74
+
72
create mode 100644 util/coroutine-pool-timer.c
75
+BOGUS_CONF=${TEST_DIR}/ceph-$$.conf
73
76
+touch "${BOGUS_CONF}"
74
diff --git a/include/qemu/coroutine-pool-timer.h b/include/qemu/coroutine-pool-timer.h
77
+
78
+_filter_conf()
79
+{
80
+ sed -e "s#$BOGUS_CONF#BOGUS_CONF#g"
81
+}
82
+
83
+# We expect this to fail, with no monitor ip provided and a null conf file. Just want it
84
+# to fail in the right way.
85
+$QEMU_IMG info "json:{'file.driver':'rbd','file.filename':'rbd:rbd/bogus:conf=${BOGUS_CONF}'}" 2>&1 | _filter_conf
86
+$QEMU_IMG info "json:{'file.driver':'rbd','file.pool':'rbd','file.image':'bogus','file.conf':'${BOGUS_CONF}'}" 2>&1 | _filter_conf
87
+
88
+# success, all done
89
+echo "*** done"
90
+rm -f $seq.full
91
+status=0
92
diff --git a/tests/qemu-iotests/231.out b/tests/qemu-iotests/231.out
75
new file mode 100644
93
new file mode 100644
76
index XXXXXXX..XXXXXXX
94
index XXXXXXX..XXXXXXX
77
--- /dev/null
95
--- /dev/null
78
+++ b/include/qemu/coroutine-pool-timer.h
96
+++ b/tests/qemu-iotests/231.out
79
@@ -XXX,XX +XXX,XX @@
97
@@ -XXX,XX +XXX,XX @@
80
+/*
98
+QA output created by 231
81
+ * QEMU coroutine pool timer
99
+qemu-img: RBD options encoded in the filename as keyvalue pairs is deprecated. Future versions may cease to parse these options in the future.
82
+ *
100
+unable to get monitor info from DNS SRV with service name: ceph-mon
83
+ * Copyright (c) 2021 Red Hat, Inc.
101
+no monitors specified to connect to.
84
+ *
102
+qemu-img: Could not open 'json:{'file.driver':'rbd','file.filename':'rbd:rbd/bogus:conf=BOGUS_CONF'}': error connecting: No such file or directory
85
+ * SPDX-License-Identifier: LGPL-2.1-or-later
103
+unable to get monitor info from DNS SRV with service name: ceph-mon
86
+ *
104
+no monitors specified to connect to.
87
+ * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
105
+qemu-img: Could not open 'json:{'file.driver':'rbd','file.pool':'rbd','file.image':'bogus','file.conf':'BOGUS_CONF'}': error connecting: No such file or directory
88
+ * See the COPYING.LIB file in the top-level directory.
106
+*** done
89
+ *
107
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
90
+ */
91
+#ifndef COROUTINE_POOL_TIMER_H
92
+#define COROUTINE_POOL_TIMER_H
93
+
94
+#include "qemu/osdep.h"
95
+#include "block/aio.h"
96
+
97
+/**
98
+ * A timer that periodically resizes this thread's coroutine pool, freeing
99
+ * memory if there are too many unused coroutines.
100
+ *
101
+ * Threads that make heavy use of coroutines should use this. Failure to resize
102
+ * the coroutine pool can lead to large amounts of memory sitting idle and
103
+ * never being used after the first time.
104
+ */
105
+typedef struct {
106
+ QEMUTimer *timer;
107
+} CoroutinePoolTimer;
108
+
109
+/* Call this before the thread runs the AioContext */
110
+void coroutine_pool_timer_init(CoroutinePoolTimer *pt, AioContext *ctx);
111
+
112
+/* Call this before the AioContext from the init function is destroyed */
113
+void coroutine_pool_timer_cleanup(CoroutinePoolTimer *pt);
114
+
115
+#endif /* COROUTINE_POOL_TIMER_H */
116
diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h
117
index XXXXXXX..XXXXXXX 100644
108
index XXXXXXX..XXXXXXX 100644
118
--- a/include/qemu/coroutine.h
109
--- a/tests/qemu-iotests/group
119
+++ b/include/qemu/coroutine.h
110
+++ b/tests/qemu-iotests/group
120
@@ -XXX,XX +XXX,XX @@ bool qemu_in_coroutine(void);
121
*/
122
bool qemu_coroutine_entered(Coroutine *co);
123
124
+/**
125
+ * Optionally call this function periodically to shrink the thread-local pool
126
+ * down. Spiky workloads can create many coroutines and then never reach that
127
+ * level again. Shrinking the pool reclaims memory in this case.
128
+ */
129
+void qemu_coroutine_pool_periodic_resize(void);
130
+
131
/**
132
* Provides a mutex that can be used to synchronise coroutines
133
*/
134
diff --git a/iothread.c b/iothread.c
135
index XXXXXXX..XXXXXXX 100644
136
--- a/iothread.c
137
+++ b/iothread.c
138
@@ -XXX,XX +XXX,XX @@
111
@@ -XXX,XX +XXX,XX @@
139
#include "qemu/error-report.h"
112
226 auto quick
140
#include "qemu/rcu.h"
113
227 auto quick
141
#include "qemu/main-loop.h"
114
229 auto quick
142
+#include "qemu/coroutine-pool-timer.h"
115
+231 auto quick
143
144
typedef ObjectClass IOThreadClass;
145
146
@@ -XXX,XX +XXX,XX @@ DECLARE_CLASS_CHECKERS(IOThreadClass, IOTHREAD,
147
static void *iothread_run(void *opaque)
148
{
149
IOThread *iothread = opaque;
150
+ CoroutinePoolTimer co_pool_timer;
151
152
rcu_register_thread();
153
/*
154
@@ -XXX,XX +XXX,XX @@ static void *iothread_run(void *opaque)
155
iothread->thread_id = qemu_get_thread_id();
156
qemu_sem_post(&iothread->init_done_sem);
157
158
+ coroutine_pool_timer_init(&co_pool_timer, iothread->ctx);
159
+
160
while (iothread->running) {
161
/*
162
* Note: from functional-wise the g_main_loop_run() below can
163
@@ -XXX,XX +XXX,XX @@ static void *iothread_run(void *opaque)
164
}
165
}
166
167
+ coroutine_pool_timer_cleanup(&co_pool_timer);
168
+
169
g_main_context_pop_thread_default(iothread->worker_context);
170
rcu_unregister_thread();
171
return NULL;
172
diff --git a/util/coroutine-pool-timer.c b/util/coroutine-pool-timer.c
173
new file mode 100644
174
index XXXXXXX..XXXXXXX
175
--- /dev/null
176
+++ b/util/coroutine-pool-timer.c
177
@@ -XXX,XX +XXX,XX @@
178
+/*
179
+ * QEMU coroutine pool timer
180
+ *
181
+ * Copyright (c) 2021 Red Hat, Inc.
182
+ *
183
+ * SPDX-License-Identifier: LGPL-2.1-or-later
184
+ *
185
+ * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
186
+ * See the COPYING.LIB file in the top-level directory.
187
+ *
188
+ */
189
+#include "qemu/coroutine-pool-timer.h"
190
+
191
+static void coroutine_pool_timer_cb(void *opaque)
192
+{
193
+ CoroutinePoolTimer *pt = opaque;
194
+ int64_t expiry_time_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME) +
195
+ 15 * NANOSECONDS_PER_SECOND;
196
+
197
+ qemu_coroutine_pool_periodic_resize();
198
+ timer_mod(pt->timer, expiry_time_ns);
199
+}
200
+
201
+void coroutine_pool_timer_init(CoroutinePoolTimer *pt, AioContext *ctx)
202
+{
203
+ pt->timer = aio_timer_new(ctx, QEMU_CLOCK_REALTIME, SCALE_NS,
204
+ coroutine_pool_timer_cb, pt);
205
+ coroutine_pool_timer_cb(pt);
206
+}
207
+
208
+void coroutine_pool_timer_cleanup(CoroutinePoolTimer *pt)
209
+{
210
+ timer_free(pt->timer);
211
+ pt->timer = NULL;
212
+}
213
diff --git a/util/main-loop.c b/util/main-loop.c
214
index XXXXXXX..XXXXXXX 100644
215
--- a/util/main-loop.c
216
+++ b/util/main-loop.c
217
@@ -XXX,XX +XXX,XX @@
218
#include "qemu/error-report.h"
219
#include "qemu/queue.h"
220
#include "qemu/compiler.h"
221
+#include "qemu/coroutine-pool-timer.h"
222
223
#ifndef _WIN32
224
#include <sys/wait.h>
225
@@ -XXX,XX +XXX,XX @@ static int qemu_signal_init(Error **errp)
226
227
static AioContext *qemu_aio_context;
228
static QEMUBH *qemu_notify_bh;
229
+static CoroutinePoolTimer main_loop_co_pool_timer;
230
231
static void notify_event_cb(void *opaque)
232
{
233
@@ -XXX,XX +XXX,XX @@ int qemu_init_main_loop(Error **errp)
234
g_source_set_name(src, "io-handler");
235
g_source_attach(src, NULL);
236
g_source_unref(src);
237
+
238
+ coroutine_pool_timer_init(&main_loop_co_pool_timer, qemu_aio_context);
239
+
240
return 0;
241
}
242
243
diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c
244
index XXXXXXX..XXXXXXX 100644
245
--- a/util/qemu-coroutine.c
246
+++ b/util/qemu-coroutine.c
247
@@ -XXX,XX +XXX,XX @@
248
#include "block/aio.h"
249
250
enum {
251
- POOL_BATCH_SIZE = 64,
252
+ /*
253
+ * qemu_coroutine_pool_periodic_resize() keeps at least this many
254
+ * coroutines around.
255
+ */
256
+ ALLOC_POOL_MIN = 64,
257
};
258
259
+
260
/** Free list to speed up creation */
261
-static QSLIST_HEAD(, Coroutine) release_pool = QSLIST_HEAD_INITIALIZER(pool);
262
-static unsigned int release_pool_size;
263
static __thread QSLIST_HEAD(, Coroutine) alloc_pool = QSLIST_HEAD_INITIALIZER(pool);
264
static __thread unsigned int alloc_pool_size;
265
+static __thread unsigned int num_coroutines;
266
+static __thread unsigned int max_coroutines_this_slice;
267
static __thread Notifier coroutine_pool_cleanup_notifier;
268
269
static void coroutine_pool_cleanup(Notifier *n, void *value)
270
@@ -XXX,XX +XXX,XX @@ Coroutine *qemu_coroutine_create(CoroutineEntry *entry, void *opaque)
271
272
if (CONFIG_COROUTINE_POOL) {
273
co = QSLIST_FIRST(&alloc_pool);
274
- if (!co) {
275
- if (release_pool_size > POOL_BATCH_SIZE) {
276
- /* Slow path; a good place to register the destructor, too. */
277
- if (!coroutine_pool_cleanup_notifier.notify) {
278
- coroutine_pool_cleanup_notifier.notify = coroutine_pool_cleanup;
279
- qemu_thread_atexit_add(&coroutine_pool_cleanup_notifier);
280
- }
281
-
282
- /* This is not exact; there could be a little skew between
283
- * release_pool_size and the actual size of release_pool. But
284
- * it is just a heuristic, it does not need to be perfect.
285
- */
286
- alloc_pool_size = qatomic_xchg(&release_pool_size, 0);
287
- QSLIST_MOVE_ATOMIC(&alloc_pool, &release_pool);
288
- co = QSLIST_FIRST(&alloc_pool);
289
- }
290
- }
291
if (co) {
292
QSLIST_REMOVE_HEAD(&alloc_pool, pool_next);
293
alloc_pool_size--;
294
}
295
+
296
+ num_coroutines++;
297
+ if (num_coroutines > max_coroutines_this_slice) {
298
+ max_coroutines_this_slice = num_coroutines;
299
+ }
300
}
301
302
if (!co) {
303
@@ -XXX,XX +XXX,XX @@ static void coroutine_delete(Coroutine *co)
304
co->caller = NULL;
305
306
if (CONFIG_COROUTINE_POOL) {
307
- if (release_pool_size < POOL_BATCH_SIZE * 2) {
308
- QSLIST_INSERT_HEAD_ATOMIC(&release_pool, co, pool_next);
309
- qatomic_inc(&release_pool_size);
310
- return;
311
- }
312
- if (alloc_pool_size < POOL_BATCH_SIZE) {
313
- QSLIST_INSERT_HEAD(&alloc_pool, co, pool_next);
314
- alloc_pool_size++;
315
- return;
316
+ if (!coroutine_pool_cleanup_notifier.notify) {
317
+ coroutine_pool_cleanup_notifier.notify = coroutine_pool_cleanup;
318
+ qemu_thread_atexit_add(&coroutine_pool_cleanup_notifier);
319
}
320
+
321
+ num_coroutines--;
322
+ QSLIST_INSERT_HEAD(&alloc_pool, co, pool_next);
323
+ alloc_pool_size++;
324
+ return;
325
}
326
327
qemu_coroutine_delete(co);
328
}
329
330
+void qemu_coroutine_pool_periodic_resize(void)
331
+{
332
+ unsigned pool_size_target =
333
+ MAX(ALLOC_POOL_MIN, max_coroutines_this_slice) - num_coroutines;
334
+ max_coroutines_this_slice = num_coroutines;
335
+
336
+ while (alloc_pool_size > pool_size_target) {
337
+ Coroutine *co = QSLIST_FIRST(&alloc_pool);
338
+ QSLIST_REMOVE_HEAD(&alloc_pool, pool_next);
339
+ qemu_coroutine_delete(co);
340
+ alloc_pool_size--;
341
+ }
342
+}
343
+
344
void qemu_aio_coroutine_enter(AioContext *ctx, Coroutine *co)
345
{
346
QSIMPLEQ_HEAD(, Coroutine) pending = QSIMPLEQ_HEAD_INITIALIZER(pending);
347
diff --git a/util/meson.build b/util/meson.build
348
index XXXXXXX..XXXXXXX 100644
349
--- a/util/meson.build
350
+++ b/util/meson.build
351
@@ -XXX,XX +XXX,XX @@ if have_block
352
util_ss.add(files('buffer.c'))
353
util_ss.add(files('bufferiszero.c'))
354
util_ss.add(files('coroutine-@0@.c'.format(config_host['CONFIG_COROUTINE_BACKEND'])))
355
+ util_ss.add(files('coroutine-pool-timer.c'))
356
util_ss.add(files('hbitmap.c'))
357
util_ss.add(files('hexdump.c'))
358
util_ss.add(files('iova-tree.c'))
359
--
116
--
360
2.31.1
117
2.17.1
361
118
362
119
diff view generated by jsdifflib
New patch
1
Signed-off-by: Jeff Cody <jcody@redhat.com>
2
Message-id: 647f5b5ab7efd8bf567a504c832b1d2d6f719b23.1536704901.git.jcody@redhat.com
3
Signed-off-by: Jeff Cody <jcody@redhat.com>
4
---
5
qemu-deprecated.texi | 15 +++++++++++++++
6
1 file changed, 15 insertions(+)
1
7
8
diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi
9
index XXXXXXX..XXXXXXX 100644
10
--- a/qemu-deprecated.texi
11
+++ b/qemu-deprecated.texi
12
@@ -XXX,XX +XXX,XX @@ used instead.
13
In order to prevent QEMU from automatically opening an image's backing
14
chain, use ``"backing": null'' instead.
15
16
+@subsubsection rbd keyvalue pair encoded filenames: "" (since 3.1.0)
17
+
18
+Options for ``rbd'' should be specified according to its runtime options,
19
+like other block drivers. Legacy parsing of keyvalue pair encoded
20
+filenames is useful to open images with the old format for backing files;
21
+These image files should be updated to use the current format.
22
+
23
+Example of legacy encoding:
24
+
25
+@code{json:@{"file.driver":"rbd", "file.filename":"rbd:rbd/name"@}}
26
+
27
+The above, converted to the current supported format:
28
+
29
+@code{json:@{"file.driver":"rbd", "file.pool":"rbd", "file.image":"name"@}}
30
+
31
@subsection vio-spapr-device device options
32
33
@subsubsection "irq": "" (since 3.0.0)
34
--
35
2.17.1
36
37
diff view generated by jsdifflib
New patch
1
From: "Richard W.M. Jones" <rjones@redhat.com>
1
2
3
The sslverify setting is supposed to turn off all TLS certificate
4
checks in libcurl. However because of the way we use it, it only
5
turns off peer certificate authenticity checks
6
(CURLOPT_SSL_VERIFYPEER). This patch makes it also turn off the check
7
that the server name in the certificate is the same as the server
8
you're connecting to (CURLOPT_SSL_VERIFYHOST).
9
10
We can use Google's server at 8.8.8.8 which happens to have a bad TLS
11
certificate to demonstrate this:
12
13
$ ./qemu-img create -q -f qcow2 -b 'json: { "file.sslverify": "off", "file.driver": "https", "file.url": "https://8.8.8.8/foo" }' /var/tmp/file.qcow2
14
qemu-img: /var/tmp/file.qcow2: CURL: Error opening file: SSL: no alternative certificate subject name matches target host name '8.8.8.8'
15
Could not open backing image to determine size.
16
17
With this patch applied, qemu-img connects to the server regardless of
18
the bad certificate:
19
20
$ ./qemu-img create -q -f qcow2 -b 'json: { "file.sslverify": "off", "file.driver": "https", "file.url": "https://8.8.8.8/foo" }' /var/tmp/file.qcow2
21
qemu-img: /var/tmp/file.qcow2: CURL: Error opening file: The requested URL returned error: 404 Not Found
22
23
(The 404 error is expected because 8.8.8.8 is not actually serving a
24
file called "/foo".)
25
26
Of course the default (without sslverify=off) remains to always check
27
the certificate:
28
29
$ ./qemu-img create -q -f qcow2 -b 'json: { "file.driver": "https", "file.url": "https://8.8.8.8/foo" }' /var/tmp/file.qcow2
30
qemu-img: /var/tmp/file.qcow2: CURL: Error opening file: SSL: no alternative certificate subject name matches target host name '8.8.8.8'
31
Could not open backing image to determine size.
32
33
Further information about the two settings is available here:
34
35
https://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYPEER.html
36
https://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYHOST.html
37
38
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
39
Message-id: 20180914095622.19698-1-rjones@redhat.com
40
Signed-off-by: Jeff Cody <jcody@redhat.com>
41
---
42
block/curl.c | 2 ++
43
1 file changed, 2 insertions(+)
44
45
diff --git a/block/curl.c b/block/curl.c
46
index XXXXXXX..XXXXXXX 100644
47
--- a/block/curl.c
48
+++ b/block/curl.c
49
@@ -XXX,XX +XXX,XX @@ static int curl_init_state(BDRVCURLState *s, CURLState *state)
50
curl_easy_setopt(state->curl, CURLOPT_URL, s->url);
51
curl_easy_setopt(state->curl, CURLOPT_SSL_VERIFYPEER,
52
(long) s->sslverify);
53
+ curl_easy_setopt(state->curl, CURLOPT_SSL_VERIFYHOST,
54
+ s->sslverify ? 2L : 0L);
55
if (s->cookie) {
56
curl_easy_setopt(state->curl, CURLOPT_COOKIE, s->cookie);
57
}
58
--
59
2.17.1
60
61
diff view generated by jsdifflib