1
The following changes since commit 711c0418c8c1ce3a24346f058b001c4c5a2f0f81:
1
The following changes since commit 8cb41fda78c7ebde0dd248c6afe1d336efb0de50:
2
2
3
Merge remote-tracking branch 'remotes/philmd/tags/mips-20210702' into staging (2021-07-04 14:04:12 +0100)
3
Merge remote-tracking branch 'remotes/philmd/tags/machine-20211101' into staging (2021-11-02 05:53:45 -0400)
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
https://github.com/XanClic/qemu.git tags/pull-block-2021-11-02
8
8
9
for you to fetch changes up to 9f460c64e13897117f35ffb61f6f5e0102cabc70:
9
for you to fetch changes up to 7da9623cc078229caf07c290e16401ccdb9408d2:
10
10
11
block/io: Merge discard request alignments (2021-07-06 14:28:55 +0100)
11
block/vpc: Add a sanity check that fixed-size images have the right type (2021-11-02 12:47:51 +0100)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Pull request
14
Emanuele Giuseppe Esposito (1):
15
pylint: fix errors and warnings generated by tests/qemu-iotests/297
15
16
16
----------------------------------------------------------------
17
Eric Blake (1):
18
qemu-img: Consistent docs for convert -F
17
19
18
Akihiko Odaki (3):
20
Thomas Huth (1):
19
block/file-posix: Optimize for macOS
21
block/vpc: Add a sanity check that fixed-size images have the right
20
block: Add backend_defaults property
22
type
21
block/io: Merge discard request alignments
22
23
23
Stefan Hajnoczi (2):
24
Thomas Weißschuh (1):
24
util/async: add a human-readable name to BHs for debugging
25
vmdk: allow specification of tools version
25
util/async: print leaked BH name when AioContext finalizes
26
26
27
include/block/aio.h | 31 ++++++++++++++++++++++---
27
docs/tools/qemu-img.rst | 2 +-
28
include/hw/block/block.h | 3 +++
28
qapi/block-core.json | 3 +++
29
include/qemu/main-loop.h | 4 +++-
29
block/vmdk.c | 24 ++++++++++++++++++++----
30
block/file-posix.c | 27 ++++++++++++++++++++--
30
block/vpc.c | 3 ++-
31
block/io.c | 2 ++
31
qemu-img-cmds.hx | 2 +-
32
hw/block/block.c | 42 ++++++++++++++++++++++++++++++----
32
tests/qemu-iotests/129 | 18 +++++++++---------
33
tests/unit/ptimer-test-stubs.c | 2 +-
33
tests/qemu-iotests/310 | 16 ++++++++--------
34
util/async.c | 25 ++++++++++++++++----
34
tests/qemu-iotests/check | 11 ++++++-----
35
util/main-loop.c | 4 ++--
35
tests/qemu-iotests/iotests.py | 7 ++++---
36
tests/qemu-iotests/172.out | 38 ++++++++++++++++++++++++++++++
36
tests/qemu-iotests/tests/image-fleecing | 4 ++--
37
10 files changed, 161 insertions(+), 17 deletions(-)
37
10 files changed, 56 insertions(+), 34 deletions(-)
38
38
39
--
39
--
40
2.31.1
40
2.31.1
41
41
42
diff view generated by jsdifflib
Deleted patch
1
It can be difficult to debug issues with BHs in production environments.
2
Although BHs can usually be identified by looking up their ->cb()
3
function pointer, this requires debug information for the program. It is
4
also not possible to print human-readable diagnostics about BHs because
5
they have no identifier.
6
1
7
This patch adds a name to each BH. The name is not unique per instance
8
but differentiates between cb() functions, which is usually enough. It's
9
done by changing aio_bh_new() and friends to macros that stringify cb.
10
11
The next patch will use the name field when reporting leaked BHs.
12
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
15
Message-Id: <20210414200247.917496-2-stefanha@redhat.com>
16
---
17
include/block/aio.h | 31 ++++++++++++++++++++++++++++---
18
include/qemu/main-loop.h | 4 +++-
19
tests/unit/ptimer-test-stubs.c | 2 +-
20
util/async.c | 9 +++++++--
21
util/main-loop.c | 4 ++--
22
5 files changed, 41 insertions(+), 9 deletions(-)
23
24
diff --git a/include/block/aio.h b/include/block/aio.h
25
index XXXXXXX..XXXXXXX 100644
26
--- a/include/block/aio.h
27
+++ b/include/block/aio.h
28
@@ -XXX,XX +XXX,XX @@ void aio_context_acquire(AioContext *ctx);
29
/* Relinquish ownership of the AioContext. */
30
void aio_context_release(AioContext *ctx);
31
32
+/**
33
+ * aio_bh_schedule_oneshot_full: Allocate a new bottom half structure that will
34
+ * run only once and as soon as possible.
35
+ *
36
+ * @name: A human-readable identifier for debugging purposes.
37
+ */
38
+void aio_bh_schedule_oneshot_full(AioContext *ctx, QEMUBHFunc *cb, void *opaque,
39
+ const char *name);
40
+
41
/**
42
* aio_bh_schedule_oneshot: Allocate a new bottom half structure that will run
43
* only once and as soon as possible.
44
+ *
45
+ * A convenience wrapper for aio_bh_schedule_oneshot_full() that uses cb as the
46
+ * name string.
47
*/
48
-void aio_bh_schedule_oneshot(AioContext *ctx, QEMUBHFunc *cb, void *opaque);
49
+#define aio_bh_schedule_oneshot(ctx, cb, opaque) \
50
+ aio_bh_schedule_oneshot_full((ctx), (cb), (opaque), (stringify(cb)))
51
52
/**
53
- * aio_bh_new: Allocate a new bottom half structure.
54
+ * aio_bh_new_full: Allocate a new bottom half structure.
55
*
56
* Bottom halves are lightweight callbacks whose invocation is guaranteed
57
* to be wait-free, thread-safe and signal-safe. The #QEMUBH structure
58
* is opaque and must be allocated prior to its use.
59
+ *
60
+ * @name: A human-readable identifier for debugging purposes.
61
*/
62
-QEMUBH *aio_bh_new(AioContext *ctx, QEMUBHFunc *cb, void *opaque);
63
+QEMUBH *aio_bh_new_full(AioContext *ctx, QEMUBHFunc *cb, void *opaque,
64
+ const char *name);
65
+
66
+/**
67
+ * aio_bh_new: Allocate a new bottom half structure
68
+ *
69
+ * A convenience wrapper for aio_bh_new_full() that uses the cb as the name
70
+ * string.
71
+ */
72
+#define aio_bh_new(ctx, cb, opaque) \
73
+ aio_bh_new_full((ctx), (cb), (opaque), (stringify(cb)))
74
75
/**
76
* aio_notify: Force processing of pending events.
77
diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h
78
index XXXXXXX..XXXXXXX 100644
79
--- a/include/qemu/main-loop.h
80
+++ b/include/qemu/main-loop.h
81
@@ -XXX,XX +XXX,XX @@ void qemu_cond_timedwait_iothread(QemuCond *cond, int ms);
82
83
void qemu_fd_register(int fd);
84
85
-QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque);
86
+#define qemu_bh_new(cb, opaque) \
87
+ qemu_bh_new_full((cb), (opaque), (stringify(cb)))
88
+QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name);
89
void qemu_bh_schedule_idle(QEMUBH *bh);
90
91
enum {
92
diff --git a/tests/unit/ptimer-test-stubs.c b/tests/unit/ptimer-test-stubs.c
93
index XXXXXXX..XXXXXXX 100644
94
--- a/tests/unit/ptimer-test-stubs.c
95
+++ b/tests/unit/ptimer-test-stubs.c
96
@@ -XXX,XX +XXX,XX @@ int64_t qemu_clock_deadline_ns_all(QEMUClockType type, int attr_mask)
97
return deadline;
98
}
99
100
-QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque)
101
+QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name)
102
{
103
QEMUBH *bh = g_new(QEMUBH, 1);
104
105
diff --git a/util/async.c b/util/async.c
106
index XXXXXXX..XXXXXXX 100644
107
--- a/util/async.c
108
+++ b/util/async.c
109
@@ -XXX,XX +XXX,XX @@ enum {
110
111
struct QEMUBH {
112
AioContext *ctx;
113
+ const char *name;
114
QEMUBHFunc *cb;
115
void *opaque;
116
QSLIST_ENTRY(QEMUBH) next;
117
@@ -XXX,XX +XXX,XX @@ static QEMUBH *aio_bh_dequeue(BHList *head, unsigned *flags)
118
return bh;
119
}
120
121
-void aio_bh_schedule_oneshot(AioContext *ctx, QEMUBHFunc *cb, void *opaque)
122
+void aio_bh_schedule_oneshot_full(AioContext *ctx, QEMUBHFunc *cb,
123
+ void *opaque, const char *name)
124
{
125
QEMUBH *bh;
126
bh = g_new(QEMUBH, 1);
127
@@ -XXX,XX +XXX,XX @@ void aio_bh_schedule_oneshot(AioContext *ctx, QEMUBHFunc *cb, void *opaque)
128
.ctx = ctx,
129
.cb = cb,
130
.opaque = opaque,
131
+ .name = name,
132
};
133
aio_bh_enqueue(bh, BH_SCHEDULED | BH_ONESHOT);
134
}
135
136
-QEMUBH *aio_bh_new(AioContext *ctx, QEMUBHFunc *cb, void *opaque)
137
+QEMUBH *aio_bh_new_full(AioContext *ctx, QEMUBHFunc *cb, void *opaque,
138
+ const char *name)
139
{
140
QEMUBH *bh;
141
bh = g_new(QEMUBH, 1);
142
@@ -XXX,XX +XXX,XX @@ QEMUBH *aio_bh_new(AioContext *ctx, QEMUBHFunc *cb, void *opaque)
143
.ctx = ctx,
144
.cb = cb,
145
.opaque = opaque,
146
+ .name = name,
147
};
148
return bh;
149
}
150
diff --git a/util/main-loop.c b/util/main-loop.c
151
index XXXXXXX..XXXXXXX 100644
152
--- a/util/main-loop.c
153
+++ b/util/main-loop.c
154
@@ -XXX,XX +XXX,XX @@ void main_loop_wait(int nonblocking)
155
156
/* Functions to operate on the main QEMU AioContext. */
157
158
-QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque)
159
+QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name)
160
{
161
- return aio_bh_new(qemu_aio_context, cb, opaque);
162
+ return aio_bh_new_full(qemu_aio_context, cb, opaque, name);
163
}
164
165
/*
166
--
167
2.31.1
168
diff view generated by jsdifflib
1
From: Akihiko Odaki <akihiko.odaki@gmail.com>
1
From: Eric Blake <eblake@redhat.com>
2
2
3
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
3
Use consistent capitalization, and fix a missed line (we duplicate the
4
Message-id: 20210705130458.97642-3-akihiko.odaki@gmail.com
4
qemu-img synopses in too many places).
5
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
5
6
Fixes: 1899bf4737 (qemu-img: Add -F shorthand to convert)
7
Signed-off-by: Eric Blake <eblake@redhat.com>
8
Message-Id: <20210921142812.2631605-1-eblake@redhat.com>
9
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
10
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
6
---
11
---
7
block/io.c | 2 ++
12
docs/tools/qemu-img.rst | 2 +-
8
1 file changed, 2 insertions(+)
13
qemu-img-cmds.hx | 2 +-
14
2 files changed, 2 insertions(+), 2 deletions(-)
9
15
10
diff --git a/block/io.c b/block/io.c
16
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
11
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
12
--- a/block/io.c
18
--- a/docs/tools/qemu-img.rst
13
+++ b/block/io.c
19
+++ b/docs/tools/qemu-img.rst
14
@@ -XXX,XX +XXX,XX @@ void bdrv_parent_drained_begin_single(BdrvChild *c, bool poll)
20
@@ -XXX,XX +XXX,XX @@ Command description:
15
21
4
16
static void bdrv_merge_limits(BlockLimits *dst, const BlockLimits *src)
22
Error on reading data
17
{
23
18
+ dst->pdiscard_alignment = MAX(dst->pdiscard_alignment,
24
-.. option:: convert [--object OBJECTDEF] [--image-opts] [--target-image-opts] [--target-is-zero] [--bitmaps [--skip-broken-bitmaps]] [-U] [-C] [-c] [-p] [-q] [-n] [-f FMT] [-t CACHE] [-T SRC_CACHE] [-O OUTPUT_FMT] [-B BACKING_FILE [-F backing_fmt]] [-o OPTIONS] [-l SNAPSHOT_PARAM] [-S SPARSE_SIZE] [-r RATE_LIMIT] [-m NUM_COROUTINES] [-W] FILENAME [FILENAME2 [...]] OUTPUT_FILENAME
19
+ src->pdiscard_alignment);
25
+.. option:: convert [--object OBJECTDEF] [--image-opts] [--target-image-opts] [--target-is-zero] [--bitmaps [--skip-broken-bitmaps]] [-U] [-C] [-c] [-p] [-q] [-n] [-f FMT] [-t CACHE] [-T SRC_CACHE] [-O OUTPUT_FMT] [-B BACKING_FILE [-F BACKING_FMT]] [-o OPTIONS] [-l SNAPSHOT_PARAM] [-S SPARSE_SIZE] [-r RATE_LIMIT] [-m NUM_COROUTINES] [-W] FILENAME [FILENAME2 [...]] OUTPUT_FILENAME
20
dst->opt_transfer = MAX(dst->opt_transfer, src->opt_transfer);
26
21
dst->max_transfer = MIN_NON_ZERO(dst->max_transfer, src->max_transfer);
27
Convert the disk image *FILENAME* or a snapshot *SNAPSHOT_PARAM*
22
dst->max_hw_transfer = MIN_NON_ZERO(dst->max_hw_transfer,
28
to disk image *OUTPUT_FILENAME* using format *OUTPUT_FMT*. It can
29
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
30
index XXXXXXX..XXXXXXX 100644
31
--- a/qemu-img-cmds.hx
32
+++ b/qemu-img-cmds.hx
33
@@ -XXX,XX +XXX,XX @@ ERST
34
DEF("convert", img_convert,
35
"convert [--object objectdef] [--image-opts] [--target-image-opts] [--target-is-zero] [--bitmaps] [-U] [-C] [-c] [-p] [-q] [-n] [-f fmt] [-t cache] [-T src_cache] [-O output_fmt] [-B backing_file [-F backing_fmt]] [-o options] [-l snapshot_param] [-S sparse_size] [-r rate_limit] [-m num_coroutines] [-W] [--salvage] filename [filename2 [...]] output_filename")
36
SRST
37
-.. option:: convert [--object OBJECTDEF] [--image-opts] [--target-image-opts] [--target-is-zero] [--bitmaps] [-U] [-C] [-c] [-p] [-q] [-n] [-f FMT] [-t CACHE] [-T SRC_CACHE] [-O OUTPUT_FMT] [-B BACKING_FILE] [-o OPTIONS] [-l SNAPSHOT_PARAM] [-S SPARSE_SIZE] [-r RATE_LIMIT] [-m NUM_COROUTINES] [-W] [--salvage] FILENAME [FILENAME2 [...]] OUTPUT_FILENAME
38
+.. option:: convert [--object OBJECTDEF] [--image-opts] [--target-image-opts] [--target-is-zero] [--bitmaps] [-U] [-C] [-c] [-p] [-q] [-n] [-f FMT] [-t CACHE] [-T SRC_CACHE] [-O OUTPUT_FMT] [-B BACKING_FILE [-F BACKING_FMT]] [-o OPTIONS] [-l SNAPSHOT_PARAM] [-S SPARSE_SIZE] [-r RATE_LIMIT] [-m NUM_COROUTINES] [-W] [--salvage] FILENAME [FILENAME2 [...]] OUTPUT_FILENAME
39
ERST
40
41
DEF("create", img_create,
23
--
42
--
24
2.31.1
43
2.31.1
25
44
45
diff view generated by jsdifflib
1
From: Akihiko Odaki <akihiko.odaki@gmail.com>
1
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
2
2
3
This commit introduces "punch hole" operation and optimizes transfer
3
Test 297 in tests/qemu-iotests currently fails: pylint has
4
block size for macOS.
4
learned new things to check, or we simply missed them.
5
5
6
Thanks to Konstantin Nazarov for detailed analysis of a flaw in an
6
All fixes in this patch are related to additional spaces used
7
old version of this change:
7
or wrong indentation. No functional change intended.
8
https://gist.github.com/akihikodaki/87df4149e7ca87f18dc56807ec5a1bc5#gistcomment-3654667
9
8
10
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
9
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
11
Message-id: 20210705130458.97642-1-akihiko.odaki@gmail.com
10
Message-Id: <20211008062821.1010967-2-eesposit@redhat.com>
12
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
13
---
12
---
14
block/file-posix.c | 27 +++++++++++++++++++++++++--
13
tests/qemu-iotests/129 | 18 +++++++++---------
15
1 file changed, 25 insertions(+), 2 deletions(-)
14
tests/qemu-iotests/310 | 16 ++++++++--------
15
tests/qemu-iotests/check | 11 ++++++-----
16
tests/qemu-iotests/iotests.py | 7 ++++---
17
tests/qemu-iotests/tests/image-fleecing | 4 ++--
18
5 files changed, 29 insertions(+), 27 deletions(-)
16
19
17
diff --git a/block/file-posix.c b/block/file-posix.c
20
diff --git a/tests/qemu-iotests/129 b/tests/qemu-iotests/129
21
index XXXXXXX..XXXXXXX 100755
22
--- a/tests/qemu-iotests/129
23
+++ b/tests/qemu-iotests/129
24
@@ -XXX,XX +XXX,XX @@ class TestStopWithBlockJob(iotests.QMPTestCase):
25
self.do_test_stop("drive-backup", device="drive0",
26
target=self.target_img, format=iotests.imgfmt,
27
sync="full",
28
- x_perf={ 'max-chunk': 65536,
29
- 'max-workers': 8 })
30
+ x_perf={'max-chunk': 65536,
31
+ 'max-workers': 8})
32
33
def test_block_commit(self):
34
# Add overlay above the source node so that we actually use a
35
@@ -XXX,XX +XXX,XX @@ class TestStopWithBlockJob(iotests.QMPTestCase):
36
'1G')
37
38
result = self.vm.qmp('blockdev-add', **{
39
- 'node-name': 'overlay',
40
- 'driver': iotests.imgfmt,
41
- 'file': {
42
- 'driver': 'file',
43
- 'filename': self.overlay_img
44
- }
45
- })
46
+ 'node-name': 'overlay',
47
+ 'driver': iotests.imgfmt,
48
+ 'file': {
49
+ 'driver': 'file',
50
+ 'filename': self.overlay_img
51
+ }
52
+ })
53
self.assert_qmp(result, 'return', {})
54
55
result = self.vm.qmp('blockdev-snapshot',
56
diff --git a/tests/qemu-iotests/310 b/tests/qemu-iotests/310
57
index XXXXXXX..XXXXXXX 100755
58
--- a/tests/qemu-iotests/310
59
+++ b/tests/qemu-iotests/310
60
@@ -XXX,XX +XXX,XX @@ with iotests.FilePath('base.img') as base_img_path, \
61
assert qemu_io_silent(base_img_path, '-c', 'write -P 1 3M 1M') == 0
62
assert qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
63
'-F', iotests.imgfmt, mid_img_path) == 0
64
- assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 2M 1M') == 0
65
- assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 4M 1M') == 0
66
+ assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 2M 1M') == 0
67
+ assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 4M 1M') == 0
68
assert qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path,
69
'-F', iotests.imgfmt, top_img_path) == 0
70
- assert qemu_io_silent(top_img_path, '-c', 'write -P 2 1M 1M') == 0
71
+ assert qemu_io_silent(top_img_path, '-c', 'write -P 2 1M 1M') == 0
72
73
# 0 1 2 3 4
74
# top 2
75
@@ -XXX,XX +XXX,XX @@ with iotests.FilePath('base.img') as base_img_path, \
76
assert qemu_img('rebase', '-u', '-b', '', '-f', iotests.imgfmt,
77
top_img_path) == 0
78
79
- assert qemu_io_silent(top_img_path, '-c', 'read -P 0 0 1M') == 0
80
- assert qemu_io_silent(top_img_path, '-c', 'read -P 2 1M 1M') == 0
81
- assert qemu_io_silent(top_img_path, '-c', 'read -P 3 2M 1M') == 0
82
- assert qemu_io_silent(top_img_path, '-c', 'read -P 0 3M 1M') == 0
83
- assert qemu_io_silent(top_img_path, '-c', 'read -P 3 4M 1M') == 0
84
+ assert qemu_io_silent(top_img_path, '-c', 'read -P 0 0 1M') == 0
85
+ assert qemu_io_silent(top_img_path, '-c', 'read -P 2 1M 1M') == 0
86
+ assert qemu_io_silent(top_img_path, '-c', 'read -P 3 2M 1M') == 0
87
+ assert qemu_io_silent(top_img_path, '-c', 'read -P 0 3M 1M') == 0
88
+ assert qemu_io_silent(top_img_path, '-c', 'read -P 3 4M 1M') == 0
89
90
log('Done')
91
diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
92
index XXXXXXX..XXXXXXX 100755
93
--- a/tests/qemu-iotests/check
94
+++ b/tests/qemu-iotests/check
95
@@ -XXX,XX +XXX,XX @@ def make_argparser() -> argparse.ArgumentParser:
96
97
p.add_argument('-d', dest='debug', action='store_true', help='debug')
98
p.add_argument('-p', dest='print', action='store_true',
99
- help='redirects qemu\'s stdout and stderr to the test output')
100
+ help='redirects qemu\'s stdout and stderr to '
101
+ 'the test output')
102
p.add_argument('-gdb', action='store_true',
103
- help="start gdbserver with $GDB_OPTIONS options \
104
- ('localhost:12345' if $GDB_OPTIONS is empty)")
105
+ help="start gdbserver with $GDB_OPTIONS options "
106
+ "('localhost:12345' if $GDB_OPTIONS is empty)")
107
p.add_argument('-valgrind', action='store_true',
108
- help='use valgrind, sets VALGRIND_QEMU environment '
109
- 'variable')
110
+ help='use valgrind, sets VALGRIND_QEMU environment '
111
+ 'variable')
112
113
p.add_argument('-misalign', action='store_true',
114
help='misalign memory allocations')
115
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
18
index XXXXXXX..XXXXXXX 100644
116
index XXXXXXX..XXXXXXX 100644
19
--- a/block/file-posix.c
117
--- a/tests/qemu-iotests/iotests.py
20
+++ b/block/file-posix.c
118
+++ b/tests/qemu-iotests/iotests.py
21
@@ -XXX,XX +XXX,XX @@
119
@@ -XXX,XX +XXX,XX @@ def _post_shutdown(self) -> None:
22
#if defined(HAVE_HOST_BLOCK_DEVICE)
120
super()._post_shutdown()
23
#include <paths.h>
121
if not qemu_valgrind or not self._popen:
24
#include <sys/param.h>
122
return
25
+#include <sys/mount.h>
123
- valgrind_filename = f"{test_dir}/{self._popen.pid}.valgrind"
26
#include <IOKit/IOKitLib.h>
124
+ valgrind_filename = f"{test_dir}/{self._popen.pid}.valgrind"
27
#include <IOKit/IOBSD.h>
125
if self.exitcode() == 99:
28
#include <IOKit/storage/IOMediaBSDClient.h>
126
with open(valgrind_filename, encoding='utf-8') as f:
29
@@ -XXX,XX +XXX,XX @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp)
127
print(f.read())
30
return;
128
@@ -XXX,XX +XXX,XX @@ def write(self, arg=None):
31
}
129
32
130
class ReproducibleTestRunner(unittest.TextTestRunner):
33
+#if defined(__APPLE__) && (__MACH__)
131
def __init__(self, stream: Optional[TextIO] = None,
34
+ struct statfs buf;
132
- resultclass: Type[unittest.TestResult] = ReproducibleTestResult,
35
+
133
- **kwargs: Any) -> None:
36
+ if (!fstatfs(s->fd, &buf)) {
134
+ resultclass: Type[unittest.TestResult] =
37
+ bs->bl.opt_transfer = buf.f_iosize;
135
+ ReproducibleTestResult,
38
+ bs->bl.pdiscard_alignment = buf.f_bsize;
136
+ **kwargs: Any) -> None:
39
+ }
137
rstream = ReproducibleStreamWrapper(stream or sys.stdout)
40
+#endif
138
super().__init__(stream=rstream, # type: ignore
41
+
139
descriptions=True,
42
if (bs->sg || S_ISBLK(st.st_mode)) {
140
diff --git a/tests/qemu-iotests/tests/image-fleecing b/tests/qemu-iotests/tests/image-fleecing
43
int ret = hdev_get_max_hw_transfer(s->fd, &st);
141
index XXXXXXX..XXXXXXX 100755
44
142
--- a/tests/qemu-iotests/tests/image-fleecing
45
@@ -XXX,XX +XXX,XX @@ out:
143
+++ b/tests/qemu-iotests/tests/image-fleecing
46
}
144
@@ -XXX,XX +XXX,XX @@ def do_test(use_cbw, base_img_path, fleece_img_path, nbd_sock_path, vm):
47
}
145
48
146
nbd_uri = 'nbd+unix:///%s?socket=%s' % (tmp_node, nbd_sock_path)
49
+#if defined(CONFIG_FALLOCATE) || defined(BLKZEROOUT) || defined(BLKDISCARD)
147
log(vm.qmp('nbd-server-start',
50
static int translate_err(int err)
148
- {'addr': { 'type': 'unix',
51
{
149
- 'data': { 'path': nbd_sock_path } } }))
52
if (err == -ENODEV || err == -ENOSYS || err == -EOPNOTSUPP ||
150
+ {'addr': {'type': 'unix',
53
@@ -XXX,XX +XXX,XX @@ static int translate_err(int err)
151
+ 'data': {'path': nbd_sock_path}}}))
54
}
152
55
return err;
153
log(vm.qmp('nbd-server-add', device=tmp_node))
56
}
154
57
+#endif
58
59
#ifdef CONFIG_FALLOCATE
60
static int do_fallocate(int fd, int mode, off_t offset, off_t len)
61
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_discard(void *opaque)
62
}
63
} while (errno == EINTR);
64
65
- ret = -errno;
66
+ ret = translate_err(-errno);
67
#endif
68
} else {
69
#ifdef CONFIG_FALLOCATE_PUNCH_HOLE
70
ret = do_fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
71
aiocb->aio_offset, aiocb->aio_nbytes);
72
+ ret = translate_err(-errno);
73
+#elif defined(__APPLE__) && (__MACH__)
74
+ fpunchhole_t fpunchhole;
75
+ fpunchhole.fp_flags = 0;
76
+ fpunchhole.reserved = 0;
77
+ fpunchhole.fp_offset = aiocb->aio_offset;
78
+ fpunchhole.fp_length = aiocb->aio_nbytes;
79
+ if (fcntl(s->fd, F_PUNCHHOLE, &fpunchhole) == -1) {
80
+ ret = errno == ENODEV ? -ENOTSUP : -errno;
81
+ } else {
82
+ ret = 0;
83
+ }
84
#endif
85
}
86
87
- ret = translate_err(ret);
88
if (ret == -ENOTSUP) {
89
s->has_discard = false;
90
}
91
--
155
--
92
2.31.1
156
2.31.1
93
157
158
diff view generated by jsdifflib
1
From: Akihiko Odaki <akihiko.odaki@gmail.com>
1
From: Thomas Weißschuh <thomas.weissschuh.ext@zeiss.com>
2
2
3
backend_defaults property allow users to control if default block
3
VMDK files support an attribute that represents the version of the guest
4
properties should be decided with backend information.
4
tools that are installed on the disk.
5
This attribute is used by vSphere before a machine has been started to
6
determine if the VM has the guest tools installed.
7
This is important when configuring "Operating system customizations" in
8
vSphere, as it checks for the presence of the guest tools before
9
allowing those customizations.
10
Thus when the VM has not yet booted normally it would be impossible to
11
customize it, therefore preventing a customized first-boot.
5
12
6
If it is off, any backend information will be discarded, which is
13
The attribute should not hurt on disks that do not have the guest tools
7
suitable if you plan to perform live migration to a different disk backend.
14
installed and indeed the VMware tools also unconditionally add this
15
attribute.
16
(Defaulting to the value "2147483647", as is done in this patch)
8
17
9
If it is on, a block device may utilize backend information more
18
Signed-off-by: Thomas Weißschuh <thomas.weissschuh.ext@zeiss.com>
10
aggressively.
19
Message-Id: <20210913130419.13241-1-thomas.weissschuh.ext@zeiss.com>
20
[hreitz: Added missing '#' in block-core.json]
21
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
22
---
23
qapi/block-core.json | 3 +++
24
block/vmdk.c | 24 ++++++++++++++++++++----
25
2 files changed, 23 insertions(+), 4 deletions(-)
11
26
12
By default, it is auto, which uses backend information for block
27
diff --git a/qapi/block-core.json b/qapi/block-core.json
13
sizes and ignores the others, which is consistent with the older
14
versions.
15
16
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
17
Message-id: 20210705130458.97642-2-akihiko.odaki@gmail.com
18
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
19
---
20
include/hw/block/block.h | 3 +++
21
hw/block/block.c | 42 ++++++++++++++++++++++++++++++++++----
22
tests/qemu-iotests/172.out | 38 ++++++++++++++++++++++++++++++++++
23
3 files changed, 79 insertions(+), 4 deletions(-)
24
25
diff --git a/include/hw/block/block.h b/include/hw/block/block.h
26
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
27
--- a/include/hw/block/block.h
29
--- a/qapi/block-core.json
28
+++ b/include/hw/block/block.h
30
+++ b/qapi/block-core.json
29
@@ -XXX,XX +XXX,XX @@
31
@@ -XXX,XX +XXX,XX @@
30
32
# @adapter-type: The adapter type used to fill in the descriptor. Default: ide.
31
typedef struct BlockConf {
33
# @hwversion: Hardware version. The meaningful options are "4" or "6".
32
BlockBackend *blk;
34
# Default: "4".
33
+ OnOffAuto backend_defaults;
35
+# @toolsversion: VMware guest tools version.
34
uint32_t physical_block_size;
36
+# Default: "2147483647" (Since 6.2)
35
uint32_t logical_block_size;
37
# @zeroed-grain: Whether to enable zeroed-grain feature for sparse subformats.
36
uint32_t min_io_size;
38
# Default: false.
37
@@ -XXX,XX +XXX,XX @@ static inline unsigned int get_physical_block_exp(BlockConf *conf)
39
#
38
}
40
@@ -XXX,XX +XXX,XX @@
39
41
'*backing-file': 'str',
40
#define DEFINE_BLOCK_PROPERTIES_BASE(_state, _conf) \
42
'*adapter-type': 'BlockdevVmdkAdapterType',
41
+ DEFINE_PROP_ON_OFF_AUTO("backend_defaults", _state, \
43
'*hwversion': 'str',
42
+ _conf.backend_defaults, ON_OFF_AUTO_AUTO), \
44
+ '*toolsversion': 'str',
43
DEFINE_PROP_BLOCKSIZE("logical_block_size", _state, \
45
'*zeroed-grain': 'bool' } }
44
_conf.logical_block_size), \
46
45
DEFINE_PROP_BLOCKSIZE("physical_block_size", _state, \
47
46
diff --git a/hw/block/block.c b/hw/block/block.c
48
diff --git a/block/vmdk.c b/block/vmdk.c
47
index XXXXXXX..XXXXXXX 100644
49
index XXXXXXX..XXXXXXX 100644
48
--- a/hw/block/block.c
50
--- a/block/vmdk.c
49
+++ b/hw/block/block.c
51
+++ b/block/vmdk.c
50
@@ -XXX,XX +XXX,XX @@ bool blkconf_blocksizes(BlockConf *conf, Error **errp)
52
@@ -XXX,XX +XXX,XX @@
51
{
53
#define VMDK_ZEROED (-3)
52
BlockBackend *blk = conf->blk;
54
53
BlockSizes blocksizes;
55
#define BLOCK_OPT_ZEROED_GRAIN "zeroed_grain"
54
- int backend_ret;
56
+#define BLOCK_OPT_TOOLSVERSION "toolsversion"
55
+ BlockDriverState *bs;
57
56
+ bool use_blocksizes;
58
typedef struct {
57
+ bool use_bs;
59
uint32_t version;
58
+
60
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn vmdk_co_do_create(int64_t size,
59
+ switch (conf->backend_defaults) {
61
BlockdevVmdkAdapterType adapter_type,
60
+ case ON_OFF_AUTO_AUTO:
62
const char *backing_file,
61
+ use_blocksizes = !blk_probe_blocksizes(blk, &blocksizes);
63
const char *hw_version,
62
+ use_bs = false;
64
+ const char *toolsversion,
63
+ break;
65
bool compat6,
64
+
66
bool zeroed_grain,
65
+ case ON_OFF_AUTO_ON:
67
vmdk_create_extent_fn extent_fn,
66
+ use_blocksizes = !blk_probe_blocksizes(blk, &blocksizes);
68
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn vmdk_co_do_create(int64_t size,
67
+ bs = blk_bs(blk);
69
"ddb.geometry.cylinders = \"%" PRId64 "\"\n"
68
+ use_bs = bs;
70
"ddb.geometry.heads = \"%" PRIu32 "\"\n"
69
+ break;
71
"ddb.geometry.sectors = \"63\"\n"
70
+
72
- "ddb.adapterType = \"%s\"\n";
71
+ case ON_OFF_AUTO_OFF:
73
+ "ddb.adapterType = \"%s\"\n"
72
+ use_blocksizes = false;
74
+ "ddb.toolsVersion = \"%s\"\n";
73
+ use_bs = false;
75
74
+ break;
76
ext_desc_lines = g_string_new(NULL);
75
+
77
76
+ default:
78
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn vmdk_co_do_create(int64_t size,
77
+ abort();
79
if (!hw_version) {
80
hw_version = "4";
81
}
82
+ if (!toolsversion) {
83
+ toolsversion = "2147483647";
78
+ }
84
+ }
79
85
80
- backend_ret = blk_probe_blocksizes(blk, &blocksizes);
86
if (adapter_type != BLOCKDEV_VMDK_ADAPTER_TYPE_IDE) {
81
/* fill in detected values if they are not defined via qemu command line */
87
/* that's the number of heads with which vmware operates when
82
if (!conf->physical_block_size) {
88
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn vmdk_co_do_create(int64_t size,
83
- if (!backend_ret) {
89
size /
84
+ if (use_blocksizes) {
90
(int64_t)(63 * number_heads * BDRV_SECTOR_SIZE),
85
conf->physical_block_size = blocksizes.phys;
91
number_heads,
86
} else {
92
- BlockdevVmdkAdapterType_str(adapter_type));
87
conf->physical_block_size = BDRV_SECTOR_SIZE;
93
+ BlockdevVmdkAdapterType_str(adapter_type),
88
}
94
+ toolsversion);
89
}
95
desc_len = strlen(desc);
90
if (!conf->logical_block_size) {
96
/* the descriptor offset = 0x200 */
91
- if (!backend_ret) {
97
if (!split && !flat) {
92
+ if (use_blocksizes) {
98
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn vmdk_co_create_opts(BlockDriver *drv,
93
conf->logical_block_size = blocksizes.log;
99
BlockdevVmdkAdapterType adapter_type_enum;
94
} else {
100
char *backing_file = NULL;
95
conf->logical_block_size = BDRV_SECTOR_SIZE;
101
char *hw_version = NULL;
96
}
102
+ char *toolsversion = NULL;
97
}
103
char *fmt = NULL;
98
+ if (use_bs) {
104
BlockdevVmdkSubformat subformat;
99
+ if (!conf->opt_io_size) {
105
int ret = 0;
100
+ conf->opt_io_size = bs->bl.opt_transfer;
106
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn vmdk_co_create_opts(BlockDriver *drv,
101
+ }
107
adapter_type = qemu_opt_get_del(opts, BLOCK_OPT_ADAPTER_TYPE);
102
+ if (conf->discard_granularity == -1) {
108
backing_file = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FILE);
103
+ if (bs->bl.pdiscard_alignment) {
109
hw_version = qemu_opt_get_del(opts, BLOCK_OPT_HWVERSION);
104
+ conf->discard_granularity = bs->bl.pdiscard_alignment;
110
+ toolsversion = qemu_opt_get_del(opts, BLOCK_OPT_TOOLSVERSION);
105
+ } else if (bs->bl.request_alignment != 1) {
111
compat6 = qemu_opt_get_bool_del(opts, BLOCK_OPT_COMPAT6, false);
106
+ conf->discard_granularity = bs->bl.request_alignment;
112
if (strcmp(hw_version, "undefined") == 0) {
107
+ }
113
g_free(hw_version);
108
+ }
114
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn vmdk_co_create_opts(BlockDriver *drv,
109
+ }
115
.opts = opts,
110
116
};
111
if (conf->logical_block_size > conf->physical_block_size) {
117
ret = vmdk_co_do_create(total_size, subformat, adapter_type_enum,
112
error_setg(errp,
118
- backing_file, hw_version, compat6, zeroed_grain,
113
diff --git a/tests/qemu-iotests/172.out b/tests/qemu-iotests/172.out
119
- vmdk_co_create_opts_cb, &data, errp);
114
index XXXXXXX..XXXXXXX 100644
120
+ backing_file, hw_version, toolsversion, compat6,
115
--- a/tests/qemu-iotests/172.out
121
+ zeroed_grain, vmdk_co_create_opts_cb, &data, errp);
116
+++ b/tests/qemu-iotests/172.out
122
117
@@ -XXX,XX +XXX,XX @@ Testing:
123
exit:
118
dev: floppy, id ""
124
g_free(backing_fmt);
119
unit = 0 (0x0)
125
g_free(adapter_type);
120
drive = "floppy0"
126
g_free(backing_file);
121
+ backend_defaults = "auto"
127
g_free(hw_version);
122
logical_block_size = 512 (512 B)
128
+ g_free(toolsversion);
123
physical_block_size = 512 (512 B)
129
g_free(fmt);
124
min_io_size = 0 (0 B)
130
g_free(desc);
125
@@ -XXX,XX +XXX,XX @@ Testing: -fda TEST_DIR/t.qcow2
131
g_free(path);
126
dev: floppy, id ""
132
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn vmdk_co_create(BlockdevCreateOptions *create_options,
127
unit = 0 (0x0)
133
opts->adapter_type,
128
drive = "floppy0"
134
opts->backing_file,
129
+ backend_defaults = "auto"
135
opts->hwversion,
130
logical_block_size = 512 (512 B)
136
+ opts->toolsversion,
131
physical_block_size = 512 (512 B)
137
false,
132
min_io_size = 0 (0 B)
138
opts->zeroed_grain,
133
@@ -XXX,XX +XXX,XX @@ Testing: -fdb TEST_DIR/t.qcow2
139
vmdk_co_create_cb,
134
dev: floppy, id ""
140
@@ -XXX,XX +XXX,XX @@ static QemuOptsList vmdk_create_opts = {
135
unit = 1 (0x1)
141
.help = "VMDK hardware version",
136
drive = "floppy1"
142
.def_value_str = "undefined"
137
+ backend_defaults = "auto"
143
},
138
logical_block_size = 512 (512 B)
144
+ {
139
physical_block_size = 512 (512 B)
145
+ .name = BLOCK_OPT_TOOLSVERSION,
140
min_io_size = 0 (0 B)
146
+ .type = QEMU_OPT_STRING,
141
@@ -XXX,XX +XXX,XX @@ Testing: -fdb TEST_DIR/t.qcow2
147
+ .help = "VMware guest tools version",
142
dev: floppy, id ""
148
+ },
143
unit = 0 (0x0)
149
{
144
drive = "floppy0"
150
.name = BLOCK_OPT_SUBFMT,
145
+ backend_defaults = "auto"
151
.type = QEMU_OPT_STRING,
146
logical_block_size = 512 (512 B)
147
physical_block_size = 512 (512 B)
148
min_io_size = 0 (0 B)
149
@@ -XXX,XX +XXX,XX @@ Testing: -fda TEST_DIR/t.qcow2 -fdb TEST_DIR/t.qcow2.2
150
dev: floppy, id ""
151
unit = 1 (0x1)
152
drive = "floppy1"
153
+ backend_defaults = "auto"
154
logical_block_size = 512 (512 B)
155
physical_block_size = 512 (512 B)
156
min_io_size = 0 (0 B)
157
@@ -XXX,XX +XXX,XX @@ Testing: -fda TEST_DIR/t.qcow2 -fdb TEST_DIR/t.qcow2.2
158
dev: floppy, id ""
159
unit = 0 (0x0)
160
drive = "floppy0"
161
+ backend_defaults = "auto"
162
logical_block_size = 512 (512 B)
163
physical_block_size = 512 (512 B)
164
min_io_size = 0 (0 B)
165
@@ -XXX,XX +XXX,XX @@ Testing: -fdb
166
dev: floppy, id ""
167
unit = 1 (0x1)
168
drive = "floppy1"
169
+ backend_defaults = "auto"
170
logical_block_size = 512 (512 B)
171
physical_block_size = 512 (512 B)
172
min_io_size = 0 (0 B)
173
@@ -XXX,XX +XXX,XX @@ Testing: -fdb
174
dev: floppy, id ""
175
unit = 0 (0x0)
176
drive = "floppy0"
177
+ backend_defaults = "auto"
178
logical_block_size = 512 (512 B)
179
physical_block_size = 512 (512 B)
180
min_io_size = 0 (0 B)
181
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2
182
dev: floppy, id ""
183
unit = 0 (0x0)
184
drive = "floppy0"
185
+ backend_defaults = "auto"
186
logical_block_size = 512 (512 B)
187
physical_block_size = 512 (512 B)
188
min_io_size = 0 (0 B)
189
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2,index=1
190
dev: floppy, id ""
191
unit = 1 (0x1)
192
drive = "floppy1"
193
+ backend_defaults = "auto"
194
logical_block_size = 512 (512 B)
195
physical_block_size = 512 (512 B)
196
min_io_size = 0 (0 B)
197
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2,index=1
198
dev: floppy, id ""
199
unit = 0 (0x0)
200
drive = "floppy0"
201
+ backend_defaults = "auto"
202
logical_block_size = 512 (512 B)
203
physical_block_size = 512 (512 B)
204
min_io_size = 0 (0 B)
205
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=floppy,file=TEST_DIR/t
206
dev: floppy, id ""
207
unit = 1 (0x1)
208
drive = "floppy1"
209
+ backend_defaults = "auto"
210
logical_block_size = 512 (512 B)
211
physical_block_size = 512 (512 B)
212
min_io_size = 0 (0 B)
213
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=floppy,file=TEST_DIR/t
214
dev: floppy, id ""
215
unit = 0 (0x0)
216
drive = "floppy0"
217
+ backend_defaults = "auto"
218
logical_block_size = 512 (512 B)
219
physical_block_size = 512 (512 B)
220
min_io_size = 0 (0 B)
221
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0
222
dev: floppy, id ""
223
unit = 0 (0x0)
224
drive = "none0"
225
+ backend_defaults = "auto"
226
logical_block_size = 512 (512 B)
227
physical_block_size = 512 (512 B)
228
min_io_size = 0 (0 B)
229
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,unit=1
230
dev: floppy, id ""
231
unit = 1 (0x1)
232
drive = "none0"
233
+ backend_defaults = "auto"
234
logical_block_size = 512 (512 B)
235
physical_block_size = 512 (512 B)
236
min_io_size = 0 (0 B)
237
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qco
238
dev: floppy, id ""
239
unit = 1 (0x1)
240
drive = "none1"
241
+ backend_defaults = "auto"
242
logical_block_size = 512 (512 B)
243
physical_block_size = 512 (512 B)
244
min_io_size = 0 (0 B)
245
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qco
246
dev: floppy, id ""
247
unit = 0 (0x0)
248
drive = "none0"
249
+ backend_defaults = "auto"
250
logical_block_size = 512 (512 B)
251
physical_block_size = 512 (512 B)
252
min_io_size = 0 (0 B)
253
@@ -XXX,XX +XXX,XX @@ Testing: -fda TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl
254
dev: floppy, id ""
255
unit = 1 (0x1)
256
drive = "none0"
257
+ backend_defaults = "auto"
258
logical_block_size = 512 (512 B)
259
physical_block_size = 512 (512 B)
260
min_io_size = 0 (0 B)
261
@@ -XXX,XX +XXX,XX @@ Testing: -fda TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl
262
dev: floppy, id ""
263
unit = 0 (0x0)
264
drive = "floppy0"
265
+ backend_defaults = "auto"
266
logical_block_size = 512 (512 B)
267
physical_block_size = 512 (512 B)
268
min_io_size = 0 (0 B)
269
@@ -XXX,XX +XXX,XX @@ Testing: -fda TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl
270
dev: floppy, id ""
271
unit = 1 (0x1)
272
drive = "none0"
273
+ backend_defaults = "auto"
274
logical_block_size = 512 (512 B)
275
physical_block_size = 512 (512 B)
276
min_io_size = 0 (0 B)
277
@@ -XXX,XX +XXX,XX @@ Testing: -fda TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl
278
dev: floppy, id ""
279
unit = 0 (0x0)
280
drive = "floppy0"
281
+ backend_defaults = "auto"
282
logical_block_size = 512 (512 B)
283
physical_block_size = 512 (512 B)
284
min_io_size = 0 (0 B)
285
@@ -XXX,XX +XXX,XX @@ Testing: -fdb TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl
286
dev: floppy, id ""
287
unit = 0 (0x0)
288
drive = "none0"
289
+ backend_defaults = "auto"
290
logical_block_size = 512 (512 B)
291
physical_block_size = 512 (512 B)
292
min_io_size = 0 (0 B)
293
@@ -XXX,XX +XXX,XX @@ Testing: -fdb TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl
294
dev: floppy, id ""
295
unit = 1 (0x1)
296
drive = "floppy1"
297
+ backend_defaults = "auto"
298
logical_block_size = 512 (512 B)
299
physical_block_size = 512 (512 B)
300
min_io_size = 0 (0 B)
301
@@ -XXX,XX +XXX,XX @@ Testing: -fdb TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl
302
dev: floppy, id ""
303
unit = 0 (0x0)
304
drive = "none0"
305
+ backend_defaults = "auto"
306
logical_block_size = 512 (512 B)
307
physical_block_size = 512 (512 B)
308
min_io_size = 0 (0 B)
309
@@ -XXX,XX +XXX,XX @@ Testing: -fdb TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl
310
dev: floppy, id ""
311
unit = 1 (0x1)
312
drive = "floppy1"
313
+ backend_defaults = "auto"
314
logical_block_size = 512 (512 B)
315
physical_block_size = 512 (512 B)
316
min_io_size = 0 (0 B)
317
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.q
318
dev: floppy, id ""
319
unit = 1 (0x1)
320
drive = "none0"
321
+ backend_defaults = "auto"
322
logical_block_size = 512 (512 B)
323
physical_block_size = 512 (512 B)
324
min_io_size = 0 (0 B)
325
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.q
326
dev: floppy, id ""
327
unit = 0 (0x0)
328
drive = "floppy0"
329
+ backend_defaults = "auto"
330
logical_block_size = 512 (512 B)
331
physical_block_size = 512 (512 B)
332
min_io_size = 0 (0 B)
333
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.q
334
dev: floppy, id ""
335
unit = 1 (0x1)
336
drive = "none0"
337
+ backend_defaults = "auto"
338
logical_block_size = 512 (512 B)
339
physical_block_size = 512 (512 B)
340
min_io_size = 0 (0 B)
341
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.q
342
dev: floppy, id ""
343
unit = 0 (0x0)
344
drive = "floppy0"
345
+ backend_defaults = "auto"
346
logical_block_size = 512 (512 B)
347
physical_block_size = 512 (512 B)
348
min_io_size = 0 (0 B)
349
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -global floppy.drive=none0 -device
350
dev: floppy, id ""
351
unit = 0 (0x0)
352
drive = "none0"
353
+ backend_defaults = "auto"
354
logical_block_size = 512 (512 B)
355
physical_block_size = 512 (512 B)
356
min_io_size = 0 (0 B)
357
@@ -XXX,XX +XXX,XX @@ Testing: -device floppy
358
dev: floppy, id ""
359
unit = 0 (0x0)
360
drive = ""
361
+ backend_defaults = "auto"
362
logical_block_size = 512 (512 B)
363
physical_block_size = 512 (512 B)
364
min_io_size = 0 (0 B)
365
@@ -XXX,XX +XXX,XX @@ Testing: -device floppy,drive-type=120
366
dev: floppy, id ""
367
unit = 0 (0x0)
368
drive = ""
369
+ backend_defaults = "auto"
370
logical_block_size = 512 (512 B)
371
physical_block_size = 512 (512 B)
372
min_io_size = 0 (0 B)
373
@@ -XXX,XX +XXX,XX @@ Testing: -device floppy,drive-type=144
374
dev: floppy, id ""
375
unit = 0 (0x0)
376
drive = ""
377
+ backend_defaults = "auto"
378
logical_block_size = 512 (512 B)
379
physical_block_size = 512 (512 B)
380
min_io_size = 0 (0 B)
381
@@ -XXX,XX +XXX,XX @@ Testing: -device floppy,drive-type=288
382
dev: floppy, id ""
383
unit = 0 (0x0)
384
drive = ""
385
+ backend_defaults = "auto"
386
logical_block_size = 512 (512 B)
387
physical_block_size = 512 (512 B)
388
min_io_size = 0 (0 B)
389
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,drive-t
390
dev: floppy, id ""
391
unit = 0 (0x0)
392
drive = "none0"
393
+ backend_defaults = "auto"
394
logical_block_size = 512 (512 B)
395
physical_block_size = 512 (512 B)
396
min_io_size = 0 (0 B)
397
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,drive-t
398
dev: floppy, id ""
399
unit = 0 (0x0)
400
drive = "none0"
401
+ backend_defaults = "auto"
402
logical_block_size = 512 (512 B)
403
physical_block_size = 512 (512 B)
404
min_io_size = 0 (0 B)
405
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,logical
406
dev: floppy, id ""
407
unit = 0 (0x0)
408
drive = "none0"
409
+ backend_defaults = "auto"
410
logical_block_size = 512 (512 B)
411
physical_block_size = 512 (512 B)
412
min_io_size = 0 (0 B)
413
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,physica
414
dev: floppy, id ""
415
unit = 0 (0x0)
416
drive = "none0"
417
+ backend_defaults = "auto"
418
logical_block_size = 512 (512 B)
419
physical_block_size = 512 (512 B)
420
min_io_size = 0 (0 B)
421
--
152
--
422
2.31.1
153
2.31.1
423
154
155
diff view generated by jsdifflib
1
BHs must be deleted before the AioContext is finalized. If not, it's a
1
From: Thomas Huth <thuth@redhat.com>
2
bug and probably indicates that some part of the program still expects
3
the BH to run in the future. That can lead to memory leaks, inconsistent
4
state, or just hangs.
5
2
6
Unfortunately the assert(flags & BH_DELETED) call in aio_ctx_finalize()
3
The code in vpc.c uses BDRVVPCState->footer.type in various places
7
is difficult to debug because the assertion failure contains no
4
to decide whether the image is a fixed-size (VHD_FIXED) or a dynamic
8
information about the BH!
5
(VHD_DYNAMIC) image. However, we never check that this field really
6
contains VHD_FIXED if we detected a fixed size image in vpc_open(),
7
so a wrong value here could cause quite some trouble during runtime.
9
8
10
Use the QEMUBH name field added in the previous patch to show a useful
9
Suggested-by: Kevin Wolf <kwolf@redhat.com>
11
error when a leaked BH is detected.
10
Signed-off-by: Thomas Huth <thuth@redhat.com>
11
Message-Id: <20211012082702.792259-1-thuth@redhat.com>
12
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
13
---
14
block/vpc.c | 3 ++-
15
1 file changed, 2 insertions(+), 1 deletion(-)
12
16
13
Suggested-by: Eric Ernst <eric.g.ernst@gmail.com>
17
diff --git a/block/vpc.c b/block/vpc.c
14
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
15
Message-Id: <20210414200247.917496-3-stefanha@redhat.com>
16
---
17
util/async.c | 16 ++++++++++++++--
18
1 file changed, 14 insertions(+), 2 deletions(-)
19
20
diff --git a/util/async.c b/util/async.c
21
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
22
--- a/util/async.c
19
--- a/block/vpc.c
23
+++ b/util/async.c
20
+++ b/block/vpc.c
24
@@ -XXX,XX +XXX,XX @@ aio_ctx_finalize(GSource *source)
21
@@ -XXX,XX +XXX,XX @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,
25
assert(QSIMPLEQ_EMPTY(&ctx->bh_slice_list));
22
if (ret < 0) {
26
23
goto fail;
27
while ((bh = aio_bh_dequeue(&ctx->bh_list, &flags))) {
24
}
28
- /* qemu_bh_delete() must have been called on BHs in this AioContext */
25
- if (strncmp(footer->creator, "conectix", 8)) {
29
- assert(flags & BH_DELETED);
26
+ if (strncmp(footer->creator, "conectix", 8) ||
30
+ /*
27
+ be32_to_cpu(footer->type) != VHD_FIXED) {
31
+ * qemu_bh_delete() must have been called on BHs in this AioContext. In
28
error_setg(errp, "invalid VPC image");
32
+ * many cases memory leaks, hangs, or inconsistent state occur when a
29
ret = -EINVAL;
33
+ * BH is leaked because something still expects it to run.
30
goto fail;
34
+ *
35
+ * If you hit this, fix the lifecycle of the BH so that
36
+ * qemu_bh_delete() and any associated cleanup is called before the
37
+ * AioContext is finalized.
38
+ */
39
+ if (unlikely(!(flags & BH_DELETED))) {
40
+ fprintf(stderr, "%s: BH '%s' leaked, aborting...\n",
41
+ __func__, bh->name);
42
+ abort();
43
+ }
44
45
g_free(bh);
46
}
47
--
31
--
48
2.31.1
32
2.31.1
49
33
34
diff view generated by jsdifflib