1
The following changes since commit 19eb2d4e736dc895f31fbd6b520e514f10cc08e0:
1
The following changes since commit 1d60bb4b14601e38ed17384277aa4c30c57925d3:
2
2
3
Merge remote-tracking branch 'remotes/thibault/tags/samuel-thibault' into staging (2019-05-07 10:43:32 +0100)
3
Merge tag 'pull-request-2022-03-15v2' of https://gitlab.com/thuth/qemu into staging (2022-03-16 10:43:58 +0000)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
https://git.xanclic.moe/XanClic/qemu.git tags/pull-block-2019-05-07
7
https://gitlab.com/stefanha/qemu.git tags/block-pull-request
8
8
9
for you to fetch changes up to 1278dce7927301bf3d004a40061dbd2c1e0846a8:
9
for you to fetch changes up to fc8796465c6cd4091efe6a2f8b353f07324f49c7:
10
10
11
iotests: Fix iotests 110 and 126 (2019-05-07 17:14:21 +0200)
11
aio-posix: fix spurious ->poll_ready() callbacks in main loop (2022-03-17 11:23:18 +0000)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Block patches:
14
Pull request
15
- Fixes to qcow2's implementation of qemu-img check
15
16
- Our SSH driver now supports bdrv_refresh_filename()
16
Bug fixes for 7.0.
17
- Miscellaneous fixes
18
17
19
----------------------------------------------------------------
18
----------------------------------------------------------------
20
Alberto Garcia (2):
21
block: Assert that drv->bdrv_child_perm is set in bdrv_child_perm()
22
commit: Use bdrv_append() in commit_start()
23
19
24
Andrey Shinkevich (1):
20
Haiyue Wang (1):
25
qcow2: discard bitmap when removed
21
aio-posix: fix build failure io_uring 2.2
26
22
27
Max Reitz (3):
23
Stefan Hajnoczi (1):
28
block/ssh: Implement .bdrv_refresh_filename()
24
aio-posix: fix spurious ->poll_ready() callbacks in main loop
29
block/ssh: Implement .bdrv_dirname()
30
iotests: Fix iotests 110 and 126
31
25
32
Vladimir Sementsov-Ogievskiy (5):
26
util/aio-posix.h | 1 +
33
qcow2-refcount: fix check_oflag_copied
27
util/aio-posix.c | 32 ++++++++++++++++++--------------
34
qcow2-refcount: avoid eating RAM
28
util/fdmon-io_uring.c | 4 ++++
35
qcow2-refcount: check_refcounts_l2: reduce ignored overlaps
29
3 files changed, 23 insertions(+), 14 deletions(-)
36
qcow2-refcount: check_refcounts_l2: don't count fixed cluster as
37
allocated
38
qcow2-refcount: don't mask corruptions under internal errors
39
40
block.c | 9 ++--
41
block/commit.c | 11 +----
42
block/qcow2-bitmap.c | 2 +-
43
block/qcow2-refcount.c | 80 ++++++++++++++++++++++-------------
44
block/ssh.c | 73 +++++++++++++++++++++++++++++---
45
tests/qemu-iotests/110 | 10 +++--
46
tests/qemu-iotests/126 | 10 +++--
47
tests/qemu-iotests/138 | 12 +++---
48
tests/qemu-iotests/138.out | 5 ++-
49
tests/qemu-iotests/207 | 10 ++---
50
tests/qemu-iotests/207.out | 10 ++---
51
tests/qemu-iotests/common.rc | 2 +-
52
tests/qemu-iotests/iotests.py | 2 +-
53
13 files changed, 159 insertions(+), 77 deletions(-)
54
30
55
--
31
--
56
2.20.1
32
2.35.1
57
33
58
diff view generated by jsdifflib
Deleted patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
1
3
Increase corruptions_fixed only after successful fix.
4
5
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
6
Reviewed-by: Max Reitz <mreitz@redhat.com>
7
Message-id: 20190227131433.197063-2-vsementsov@virtuozzo.com
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
10
block/qcow2-refcount.c | 8 ++++----
11
1 file changed, 4 insertions(+), 4 deletions(-)
12
13
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/block/qcow2-refcount.c
16
+++ b/block/qcow2-refcount.c
17
@@ -XXX,XX +XXX,XX @@ static int check_oflag_copied(BlockDriverState *bs, BdrvCheckResult *res,
18
for (i = 0; i < s->l1_size; i++) {
19
uint64_t l1_entry = s->l1_table[i];
20
uint64_t l2_offset = l1_entry & L1E_OFFSET_MASK;
21
- bool l2_dirty = false;
22
+ int l2_dirty = 0;
23
24
if (!l2_offset) {
25
continue;
26
@@ -XXX,XX +XXX,XX @@ static int check_oflag_copied(BlockDriverState *bs, BdrvCheckResult *res,
27
l2_table[j] = cpu_to_be64(refcount == 1
28
? l2_entry | QCOW_OFLAG_COPIED
29
: l2_entry & ~QCOW_OFLAG_COPIED);
30
- l2_dirty = true;
31
- res->corruptions_fixed++;
32
+ l2_dirty++;
33
} else {
34
res->corruptions++;
35
}
36
@@ -XXX,XX +XXX,XX @@ static int check_oflag_copied(BlockDriverState *bs, BdrvCheckResult *res,
37
}
38
}
39
40
- if (l2_dirty) {
41
+ if (l2_dirty > 0) {
42
ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_ACTIVE_L2,
43
l2_offset, s->cluster_size,
44
false);
45
@@ -XXX,XX +XXX,XX @@ static int check_oflag_copied(BlockDriverState *bs, BdrvCheckResult *res,
46
res->check_errors++;
47
goto fail;
48
}
49
+ res->corruptions_fixed += l2_dirty;
50
}
51
}
52
53
--
54
2.20.1
55
56
diff view generated by jsdifflib
Deleted patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
1
3
qcow2_inc_refcounts_imrt() (through realloc_refcount_array()) can eat
4
an unpredictable amount of memory on corrupted table entries, which are
5
referencing regions far beyond the end of file.
6
7
Prevent this, by skipping such regions from further processing.
8
9
Interesting that iotest 138 checks exactly the behavior which we fix
10
here. So, change the test appropriately.
11
12
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
13
Reviewed-by: Max Reitz <mreitz@redhat.com>
14
Message-id: 20190227131433.197063-3-vsementsov@virtuozzo.com
15
Signed-off-by: Max Reitz <mreitz@redhat.com>
16
---
17
block/qcow2-refcount.c | 19 +++++++++++++++++++
18
tests/qemu-iotests/138 | 12 +++++-------
19
tests/qemu-iotests/138.out | 5 ++++-
20
3 files changed, 28 insertions(+), 8 deletions(-)
21
22
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
23
index XXXXXXX..XXXXXXX 100644
24
--- a/block/qcow2-refcount.c
25
+++ b/block/qcow2-refcount.c
26
@@ -XXX,XX +XXX,XX @@ int qcow2_inc_refcounts_imrt(BlockDriverState *bs, BdrvCheckResult *res,
27
{
28
BDRVQcow2State *s = bs->opaque;
29
uint64_t start, last, cluster_offset, k, refcount;
30
+ int64_t file_len;
31
int ret;
32
33
if (size <= 0) {
34
return 0;
35
}
36
37
+ file_len = bdrv_getlength(bs->file->bs);
38
+ if (file_len < 0) {
39
+ return file_len;
40
+ }
41
+
42
+ /*
43
+ * Last cluster of qcow2 image may be semi-allocated, so it may be OK to
44
+ * reference some space after file end but it should be less than one
45
+ * cluster.
46
+ */
47
+ if (offset + size - file_len >= s->cluster_size) {
48
+ fprintf(stderr, "ERROR: counting reference for region exceeding the "
49
+ "end of the file by one cluster or more: offset 0x%" PRIx64
50
+ " size 0x%" PRIx64 "\n", offset, size);
51
+ res->corruptions++;
52
+ return 0;
53
+ }
54
+
55
start = start_of_cluster(s, offset);
56
last = start_of_cluster(s, offset + size - 1);
57
for(cluster_offset = start; cluster_offset <= last;
58
diff --git a/tests/qemu-iotests/138 b/tests/qemu-iotests/138
59
index XXXXXXX..XXXXXXX 100755
60
--- a/tests/qemu-iotests/138
61
+++ b/tests/qemu-iotests/138
62
@@ -XXX,XX +XXX,XX @@ $QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io
63
# Put the data cluster at a multiple of 2 TB, resulting in the image apparently
64
# having a multiple of 2^32 clusters
65
# (To be more specific: It is at 32 PB)
66
-poke_file "$TEST_IMG" 2048 "\x80\x80\x00\x00\x00\x00\x00\x00"
67
+poke_file "$TEST_IMG" $((2048 + 8)) "\x00\x80\x00\x00\x00\x00\x00\x00"
68
69
# An offset of 32 PB results in qemu-img check having to allocate an in-memory
70
-# refcount table of 128 TB (16 bit refcounts, 512 byte clusters).
71
-# This should be generally too much for any system and thus fail.
72
-# What this test is checking is that the qcow2 driver actually tries to allocate
73
-# such a large amount of memory (and is consequently aborting) instead of having
74
-# truncated the cluster count somewhere (which would result in much less memory
75
-# being allocated and then a segfault occurring).
76
+# refcount table of 128 TB (16 bit refcounts, 512 byte clusters), if qemu-img
77
+# don't check that referenced data cluster is far beyond the end of file.
78
+# But starting from 4.0, qemu-img does this check, and instead of "Cannot
79
+# allocate memory", we have an error showing that l2 entry is invalid.
80
_check_test_img
81
82
# success, all done
83
diff --git a/tests/qemu-iotests/138.out b/tests/qemu-iotests/138.out
84
index XXXXXXX..XXXXXXX 100644
85
--- a/tests/qemu-iotests/138.out
86
+++ b/tests/qemu-iotests/138.out
87
@@ -XXX,XX +XXX,XX @@ QA output created by 138
88
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=512
89
wrote 512/512 bytes at offset 0
90
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
91
-qemu-img: Check failed: Cannot allocate memory
92
+ERROR: counting reference for region exceeding the end of the file by one cluster or more: offset 0x80000000000000 size 0x200
93
+
94
+1 errors were found on the image.
95
+Data may be corrupted, or further writes to the image may corrupt it.
96
*** done
97
--
98
2.20.1
99
100
diff view generated by jsdifflib
Deleted patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
1
3
Reduce number of structures ignored in overlap check: when checking
4
active table ignore active tables, when checking inactive table ignore
5
inactive ones.
6
7
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
9
Message-id: 20190227131433.197063-4-vsementsov@virtuozzo.com
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
---
12
block/qcow2-refcount.c | 16 +++++++++-------
13
1 file changed, 9 insertions(+), 7 deletions(-)
14
15
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/block/qcow2-refcount.c
18
+++ b/block/qcow2-refcount.c
19
@@ -XXX,XX +XXX,XX @@ enum {
20
static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
21
void **refcount_table,
22
int64_t *refcount_table_size, int64_t l2_offset,
23
- int flags, BdrvCheckMode fix)
24
+ int flags, BdrvCheckMode fix, bool active)
25
{
26
BDRVQcow2State *s = bs->opaque;
27
uint64_t *l2_table, l2_entry;
28
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
29
if (fix & BDRV_FIX_ERRORS) {
30
uint64_t l2e_offset =
31
l2_offset + (uint64_t)i * sizeof(uint64_t);
32
+ int ign = active ? QCOW2_OL_ACTIVE_L2 :
33
+ QCOW2_OL_INACTIVE_L2;
34
35
l2_entry = QCOW_OFLAG_ZERO;
36
l2_table[i] = cpu_to_be64(l2_entry);
37
- ret = qcow2_pre_write_overlap_check(bs,
38
- QCOW2_OL_ACTIVE_L2 | QCOW2_OL_INACTIVE_L2,
39
+ ret = qcow2_pre_write_overlap_check(bs, ign,
40
l2e_offset, sizeof(uint64_t), false);
41
if (ret < 0) {
42
fprintf(stderr, "ERROR: Overlap check failed\n");
43
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l1(BlockDriverState *bs,
44
void **refcount_table,
45
int64_t *refcount_table_size,
46
int64_t l1_table_offset, int l1_size,
47
- int flags, BdrvCheckMode fix)
48
+ int flags, BdrvCheckMode fix, bool active)
49
{
50
BDRVQcow2State *s = bs->opaque;
51
uint64_t *l1_table = NULL, l2_offset, l1_size2;
52
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l1(BlockDriverState *bs,
53
/* Process and check L2 entries */
54
ret = check_refcounts_l2(bs, res, refcount_table,
55
refcount_table_size, l2_offset, flags,
56
- fix);
57
+ fix, active);
58
if (ret < 0) {
59
goto fail;
60
}
61
@@ -XXX,XX +XXX,XX @@ static int calculate_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
62
/* current L1 table */
63
ret = check_refcounts_l1(bs, res, refcount_table, nb_clusters,
64
s->l1_table_offset, s->l1_size, CHECK_FRAG_INFO,
65
- fix);
66
+ fix, true);
67
if (ret < 0) {
68
return ret;
69
}
70
@@ -XXX,XX +XXX,XX @@ static int calculate_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
71
continue;
72
}
73
ret = check_refcounts_l1(bs, res, refcount_table, nb_clusters,
74
- sn->l1_table_offset, sn->l1_size, 0, fix);
75
+ sn->l1_table_offset, sn->l1_size, 0, fix,
76
+ false);
77
if (ret < 0) {
78
return ret;
79
}
80
--
81
2.20.1
82
83
diff view generated by jsdifflib
Deleted patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
1
3
Do not count a cluster which is fixed to be ZERO as allocated.
4
5
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
6
Reviewed-by: Max Reitz <mreitz@redhat.com>
7
Message-id: 20190227131433.197063-5-vsementsov@virtuozzo.com
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
10
block/qcow2-refcount.c | 18 +++++++++---------
11
1 file changed, 9 insertions(+), 9 deletions(-)
12
13
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/block/qcow2-refcount.c
16
+++ b/block/qcow2-refcount.c
17
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
18
{
19
uint64_t offset = l2_entry & L2E_OFFSET_MASK;
20
21
- if (flags & CHECK_FRAG_INFO) {
22
- res->bfi.allocated_clusters++;
23
- if (next_contiguous_offset &&
24
- offset != next_contiguous_offset) {
25
- res->bfi.fragmented_clusters++;
26
- }
27
- next_contiguous_offset = offset + s->cluster_size;
28
- }
29
-
30
/* Correct offsets are cluster aligned */
31
if (offset_into_cluster(s, offset)) {
32
if (qcow2_get_cluster_type(bs, l2_entry) ==
33
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
34
}
35
}
36
37
+ if (flags & CHECK_FRAG_INFO) {
38
+ res->bfi.allocated_clusters++;
39
+ if (next_contiguous_offset &&
40
+ offset != next_contiguous_offset) {
41
+ res->bfi.fragmented_clusters++;
42
+ }
43
+ next_contiguous_offset = offset + s->cluster_size;
44
+ }
45
+
46
/* Mark cluster as used */
47
if (!has_data_file(bs)) {
48
ret = qcow2_inc_refcounts_imrt(bs, res, refcount_table,
49
--
50
2.20.1
51
52
diff view generated by jsdifflib
Deleted patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
1
3
No reasons for not reporting found corruptions as corruptions in case
4
of some internal errors, especially in case of just failed to fix l2
5
entry (and in this case, missed corruptions may influence comparing
6
logic, when we calculate difference between corruptions fields of two
7
results)
8
9
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
10
Message-id: 20190227131433.197063-6-vsementsov@virtuozzo.com
11
Reviewed-by: Max Reitz <mreitz@redhat.com>
12
Signed-off-by: Max Reitz <mreitz@redhat.com>
13
---
14
block/qcow2-refcount.c | 19 +++++++++----------
15
1 file changed, 9 insertions(+), 10 deletions(-)
16
17
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/block/qcow2-refcount.c
20
+++ b/block/qcow2-refcount.c
21
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
22
23
/* Correct offsets are cluster aligned */
24
if (offset_into_cluster(s, offset)) {
25
+ res->corruptions++;
26
+
27
if (qcow2_get_cluster_type(bs, l2_entry) ==
28
QCOW2_CLUSTER_ZERO_ALLOC)
29
{
30
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
31
/* Do not abort, continue checking the rest of this
32
* L2 table's entries */
33
} else {
34
+ res->corruptions--;
35
res->corruptions_fixed++;
36
/* Skip marking the cluster as used
37
* (it is unused now) */
38
continue;
39
}
40
- } else {
41
- res->corruptions++;
42
}
43
} else {
44
fprintf(stderr, "ERROR offset=%" PRIx64 ": Data cluster is "
45
"not properly aligned; L2 entry corrupted.\n", offset);
46
- res->corruptions++;
47
}
48
}
49
50
@@ -XXX,XX +XXX,XX @@ static int check_oflag_copied(BlockDriverState *bs, BdrvCheckResult *res,
51
continue;
52
}
53
if ((refcount == 1) != ((l1_entry & QCOW_OFLAG_COPIED) != 0)) {
54
+ res->corruptions++;
55
fprintf(stderr, "%s OFLAG_COPIED L2 cluster: l1_index=%d "
56
"l1_entry=%" PRIx64 " refcount=%" PRIu64 "\n",
57
repair ? "Repairing" : "ERROR", i, l1_entry, refcount);
58
@@ -XXX,XX +XXX,XX @@ static int check_oflag_copied(BlockDriverState *bs, BdrvCheckResult *res,
59
res->check_errors++;
60
goto fail;
61
}
62
+ res->corruptions--;
63
res->corruptions_fixed++;
64
- } else {
65
- res->corruptions++;
66
}
67
}
68
69
@@ -XXX,XX +XXX,XX @@ static int check_oflag_copied(BlockDriverState *bs, BdrvCheckResult *res,
70
}
71
}
72
if ((refcount == 1) != ((l2_entry & QCOW_OFLAG_COPIED) != 0)) {
73
+ res->corruptions++;
74
fprintf(stderr, "%s OFLAG_COPIED data cluster: "
75
"l2_entry=%" PRIx64 " refcount=%" PRIu64 "\n",
76
repair ? "Repairing" : "ERROR", l2_entry, refcount);
77
@@ -XXX,XX +XXX,XX @@ static int check_oflag_copied(BlockDriverState *bs, BdrvCheckResult *res,
78
? l2_entry | QCOW_OFLAG_COPIED
79
: l2_entry & ~QCOW_OFLAG_COPIED);
80
l2_dirty++;
81
- } else {
82
- res->corruptions++;
83
}
84
}
85
}
86
@@ -XXX,XX +XXX,XX @@ static int check_oflag_copied(BlockDriverState *bs, BdrvCheckResult *res,
87
res->check_errors++;
88
goto fail;
89
}
90
+ res->corruptions -= l2_dirty;
91
res->corruptions_fixed += l2_dirty;
92
}
93
}
94
@@ -XXX,XX +XXX,XX @@ static int check_refblocks(BlockDriverState *bs, BdrvCheckResult *res,
95
}
96
97
if (cluster >= *nb_clusters) {
98
+ res->corruptions++;
99
fprintf(stderr, "%s refcount block %" PRId64 " is outside image\n",
100
fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i);
101
102
@@ -XXX,XX +XXX,XX @@ static int check_refblocks(BlockDriverState *bs, BdrvCheckResult *res,
103
goto resize_fail;
104
}
105
106
+ res->corruptions--;
107
res->corruptions_fixed++;
108
ret = qcow2_inc_refcounts_imrt(bs, res,
109
refcount_table, nb_clusters,
110
@@ -XXX,XX +XXX,XX @@ static int check_refblocks(BlockDriverState *bs, BdrvCheckResult *res,
111
continue;
112
113
resize_fail:
114
- res->corruptions++;
115
*rebuild = true;
116
fprintf(stderr, "ERROR could not resize image: %s\n",
117
strerror(-ret));
118
- } else {
119
- res->corruptions++;
120
}
121
continue;
122
}
123
--
124
2.20.1
125
126
diff view generated by jsdifflib
Deleted patch
1
From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
2
1
3
Bitmap data may take a lot of disk space, so it's better to discard it
4
always.
5
6
Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
7
Message-id: 1551346019-293202-1-git-send-email-andrey.shinkevich@virtuozzo.com
8
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
9
[mreitz: Use the commit message proposed by Vladimir]
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
---
12
block/qcow2-bitmap.c | 2 +-
13
1 file changed, 1 insertion(+), 1 deletion(-)
14
15
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/block/qcow2-bitmap.c
18
+++ b/block/qcow2-bitmap.c
19
@@ -XXX,XX +XXX,XX @@ static void clear_bitmap_table(BlockDriverState *bs, uint64_t *bitmap_table,
20
continue;
21
}
22
23
- qcow2_free_clusters(bs, addr, s->cluster_size, QCOW2_DISCARD_OTHER);
24
+ qcow2_free_clusters(bs, addr, s->cluster_size, QCOW2_DISCARD_ALWAYS);
25
bitmap_table[i] = 0;
26
}
27
}
28
--
29
2.20.1
30
31
diff view generated by jsdifflib
1
ssh_bdrv_dirname() is basically the generic bdrv_dirname(), except it
1
From: Haiyue Wang <haiyue.wang@intel.com>
2
takes care not to silently chop off any query string (i.e.,
3
host_key_check).
4
2
5
Signed-off-by: Max Reitz <mreitz@redhat.com>
3
The io_uring fixed "Don't truncate addr fields to 32-bit on 32-bit":
6
Tested-by: Richard W.M. Jones <rjones@redhat.com>
4
https://git.kernel.dk/cgit/liburing/commit/?id=d84c29b19ed0b130000619cff40141bb1fc3615b
7
Message-id: 20190225190828.17726-3-mreitz@redhat.com
5
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
6
This leads to build failure:
7
../util/fdmon-io_uring.c: In function ‘add_poll_remove_sqe’:
8
../util/fdmon-io_uring.c:182:36: error: passing argument 2 of ‘io_uring_prep_poll_remove’ makes integer from pointer without a cast [-Werror=int-conversion]
9
182 | io_uring_prep_poll_remove(sqe, node);
10
| ^~~~
11
| |
12
| AioHandler *
13
In file included from /root/io/qemu/include/block/aio.h:18,
14
from ../util/aio-posix.h:20,
15
from ../util/fdmon-io_uring.c:49:
16
/usr/include/liburing.h:415:17: note: expected ‘__u64’ {aka ‘long long unsigned int’} but argument is of type ‘AioHandler *’
17
415 | __u64 user_data)
18
| ~~~~~~^~~~~~~~~
19
cc1: all warnings being treated as errors
20
21
Use LIBURING_HAVE_DATA64 to check whether the io_uring supports 64-bit
22
variants of the get/set userdata, to convert the paramter to the right
23
data type.
24
25
Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
26
Message-Id: <20220221162401.45415-1-haiyue.wang@intel.com>
27
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9
---
28
---
10
block/ssh.c | 21 +++++++++++++++++++++
29
util/fdmon-io_uring.c | 4 ++++
11
1 file changed, 21 insertions(+)
30
1 file changed, 4 insertions(+)
12
31
13
diff --git a/block/ssh.c b/block/ssh.c
32
diff --git a/util/fdmon-io_uring.c b/util/fdmon-io_uring.c
14
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
15
--- a/block/ssh.c
34
--- a/util/fdmon-io_uring.c
16
+++ b/block/ssh.c
35
+++ b/util/fdmon-io_uring.c
17
@@ -XXX,XX +XXX,XX @@ static void ssh_refresh_filename(BlockDriverState *bs)
36
@@ -XXX,XX +XXX,XX @@ static void add_poll_remove_sqe(AioContext *ctx, AioHandler *node)
18
}
37
{
38
struct io_uring_sqe *sqe = get_sqe(ctx);
39
40
+#ifdef LIBURING_HAVE_DATA64
41
+ io_uring_prep_poll_remove(sqe, (__u64)(uintptr_t)node);
42
+#else
43
io_uring_prep_poll_remove(sqe, node);
44
+#endif
19
}
45
}
20
46
21
+static char *ssh_bdrv_dirname(BlockDriverState *bs, Error **errp)
47
/* Add a timeout that self-cancels when another cqe becomes ready */
22
+{
23
+ if (qdict_haskey(bs->full_open_options, "host_key_check")) {
24
+ /*
25
+ * We cannot generate a simple prefix if we would have to
26
+ * append a query string.
27
+ */
28
+ error_setg(errp,
29
+ "Cannot generate a base directory with host_key_check set");
30
+ return NULL;
31
+ }
32
+
33
+ if (bs->exact_filename[0] == '\0') {
34
+ error_setg(errp, "Cannot generate a base directory for this ssh node");
35
+ return NULL;
36
+ }
37
+
38
+ return path_combine(bs->exact_filename, "");
39
+}
40
+
41
static const char *const ssh_strong_runtime_opts[] = {
42
"host",
43
"port",
44
@@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_ssh = {
45
.bdrv_co_truncate = ssh_co_truncate,
46
.bdrv_co_flush_to_disk = ssh_co_flush,
47
.bdrv_refresh_filename = ssh_refresh_filename,
48
+ .bdrv_dirname = ssh_bdrv_dirname,
49
.create_opts = &ssh_create_opts,
50
.strong_runtime_opts = ssh_strong_runtime_opts,
51
};
52
--
48
--
53
2.20.1
49
2.35.1
54
50
55
51
diff view generated by jsdifflib
1
This requires some changes to keep iotests 104 and 207 working.
1
When ->poll() succeeds the AioHandler is placed on the ready list with
2
revents set to the magic value 0. This magic value causes
3
aio_dispatch_handler() to invoke ->poll_ready() instead of ->io_read()
4
for G_IO_IN or ->io_write() for G_IO_OUT.
2
5
3
qemu-img info in 104 will now return a filename including the user name
6
This magic value 0 hack works for the IOThread where AioHandlers are
4
and the port, which need to be filtered by adjusting REMOTE_TEST_DIR in
7
placed on ->ready_list and processed by aio_dispatch_ready_handlers().
5
common.rc. This additional information has to be marked optional,
8
It does not work for the main loop where all AioHandlers are processed
6
however (which is simple as REMOTE_TEST_DIR is a regex), because
9
by aio_dispatch_handlers(), even those that are not ready and have a
7
otherwise 197 and 215 would fail: They use it (indirectly) to filter
10
revents value of 0.
8
qemu-img create output which contains a backing filename they have
9
passed to it -- which probably does not contain a user name or port
10
number.
11
11
12
The problem in 207 is a nice one to have: qemu-img info used to return
12
As a result the main loop invokes ->poll_ready() on AioHandlers that are
13
json:{} filenames, but with this patch it returns nice plain ones. We
13
not ready. These spurious ->poll_ready() calls waste CPU cycles and
14
now need to adjust the filtering to hide the user name (and port number
14
could lead to crashes if the code assumes ->poll() must have succeeded
15
while we are at it). The simplest way to do this is to include both in
15
before ->poll_ready() is called (a reasonable asumption but I haven't
16
iotests.remote_filename() so that bdrv_refresh_filename() will not
16
seen it in practice).
17
change it, and then iotests.img_info_log() will filter it correctly
18
automatically.
19
17
20
Signed-off-by: Max Reitz <mreitz@redhat.com>
18
Stop using revents to track whether ->poll_ready() will be called on an
21
Tested-by: Richard W.M. Jones <rjones@redhat.com>
19
AioHandler. Introduce a separate AioHandler->poll_ready field instead.
22
Message-id: 20190225190828.17726-2-mreitz@redhat.com
20
This eliminates spurious ->poll_ready() calls in the main loop.
23
Signed-off-by: Max Reitz <mreitz@redhat.com>
21
22
Fixes: 826cc32423db2a99d184dbf4f507c737d7e7a4ae ("aio-posix: split poll check from ready handler")
23
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
24
Reported-by: Jason Wang <jasowang@redhat.com>
25
Tested-by: Jason Wang <jasowang@redhat.com>
26
Message-id: 20220223155703.136833-1-stefanha@redhat.com
27
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
24
---
28
---
25
block/ssh.c | 52 +++++++++++++++++++++++++++++++----
29
util/aio-posix.h | 1 +
26
tests/qemu-iotests/207 | 10 +++----
30
util/aio-posix.c | 32 ++++++++++++++++++--------------
27
tests/qemu-iotests/207.out | 10 +++----
31
2 files changed, 19 insertions(+), 14 deletions(-)
28
tests/qemu-iotests/common.rc | 2 +-
29
tests/qemu-iotests/iotests.py | 2 +-
30
5 files changed, 59 insertions(+), 17 deletions(-)
31
32
32
diff --git a/block/ssh.c b/block/ssh.c
33
diff --git a/util/aio-posix.h b/util/aio-posix.h
33
index XXXXXXX..XXXXXXX 100644
34
index XXXXXXX..XXXXXXX 100644
34
--- a/block/ssh.c
35
--- a/util/aio-posix.h
35
+++ b/block/ssh.c
36
+++ b/util/aio-posix.h
36
@@ -XXX,XX +XXX,XX @@ typedef struct BDRVSSHState {
37
@@ -XXX,XX +XXX,XX @@ struct AioHandler {
37
38
unsigned flags; /* see fdmon-io_uring.c */
38
/* Used to warn if 'flush' is not supported. */
39
#endif
39
bool unsafe_flush_warning;
40
int64_t poll_idle_timeout; /* when to stop userspace polling */
40
+
41
+ bool poll_ready; /* has polling detected an event? */
41
+ /*
42
bool is_external;
42
+ * Store the user name for ssh_refresh_filename() because the
43
};
43
+ * default depends on the system you are on -- therefore, when we
44
44
+ * generate a filename, it should always contain the user name we
45
diff --git a/util/aio-posix.c b/util/aio-posix.c
45
+ * are actually using.
46
index XXXXXXX..XXXXXXX 100644
46
+ */
47
--- a/util/aio-posix.c
47
+ char *user;
48
+++ b/util/aio-posix.c
48
} BDRVSSHState;
49
@@ -XXX,XX +XXX,XX @@
49
50
#include "trace.h"
50
static void ssh_state_init(BDRVSSHState *s)
51
#include "aio-posix.h"
51
@@ -XXX,XX +XXX,XX @@ static void ssh_state_init(BDRVSSHState *s)
52
52
53
-/*
53
static void ssh_state_free(BDRVSSHState *s)
54
- * G_IO_IN and G_IO_OUT are not appropriate revents values for polling, since
54
{
55
- * the handler may not need to access the file descriptor. For example, the
55
+ g_free(s->user);
56
- * handler doesn't need to read from an EventNotifier if it polled a memory
56
+
57
- * location and a read syscall would be slow. Define our own unique revents
57
if (s->sftp_handle) {
58
- * value to indicate that polling determined this AioHandler is ready.
58
libssh2_sftp_close(s->sftp_handle);
59
- */
59
}
60
-#define REVENTS_POLL_READY 0
60
@@ -XXX,XX +XXX,XX @@ static int connect_to_ssh(BDRVSSHState *s, BlockdevOptionsSsh *opts,
61
-
61
int ssh_flags, int creat_mode, Error **errp)
62
/* Stop userspace polling on a handler if it isn't active for some time */
62
{
63
#define POLL_IDLE_INTERVAL_NS (7 * NANOSECONDS_PER_SECOND)
63
int r, ret;
64
64
- const char *user;
65
@@ -XXX,XX +XXX,XX @@ void aio_add_ready_handler(AioHandlerList *ready_list,
65
long port = 0;
66
QLIST_INSERT_HEAD(ready_list, node, node_ready);
66
67
if (opts->has_user) {
68
- user = opts->user;
69
+ s->user = g_strdup(opts->user);
70
} else {
71
- user = g_get_user_name();
72
- if (!user) {
73
+ s->user = g_strdup(g_get_user_name());
74
+ if (!s->user) {
75
error_setg_errno(errp, errno, "Can't get user name");
76
ret = -errno;
77
goto err;
78
@@ -XXX,XX +XXX,XX @@ static int connect_to_ssh(BDRVSSHState *s, BlockdevOptionsSsh *opts,
79
}
80
81
/* Authenticate. */
82
- ret = authenticate(s, user, errp);
83
+ ret = authenticate(s, s->user, errp);
84
if (ret < 0) {
85
goto err;
86
}
87
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn ssh_co_truncate(BlockDriverState *bs, int64_t offset,
88
return ssh_grow_file(s, offset, errp);
89
}
67
}
90
68
91
+static void ssh_refresh_filename(BlockDriverState *bs)
69
+static void aio_add_poll_ready_handler(AioHandlerList *ready_list,
70
+ AioHandler *node)
92
+{
71
+{
93
+ BDRVSSHState *s = bs->opaque;
72
+ QLIST_SAFE_REMOVE(node, node_ready); /* remove from nested parent's list */
94
+ const char *path, *host_key_check;
73
+ node->poll_ready = true;
95
+ int ret;
74
+ QLIST_INSERT_HEAD(ready_list, node, node_ready);
96
+
97
+ /*
98
+ * None of these options can be represented in a plain "host:port"
99
+ * format, so if any was given, we have to abort.
100
+ */
101
+ if (s->inet->has_ipv4 || s->inet->has_ipv6 || s->inet->has_to ||
102
+ s->inet->has_numeric)
103
+ {
104
+ return;
105
+ }
106
+
107
+ path = qdict_get_try_str(bs->full_open_options, "path");
108
+ assert(path); /* mandatory option */
109
+
110
+ host_key_check = qdict_get_try_str(bs->full_open_options, "host_key_check");
111
+
112
+ ret = snprintf(bs->exact_filename, sizeof(bs->exact_filename),
113
+ "ssh://%s@%s:%s%s%s%s",
114
+ s->user, s->inet->host, s->inet->port, path,
115
+ host_key_check ? "?host_key_check=" : "",
116
+ host_key_check ?: "");
117
+ if (ret >= sizeof(bs->exact_filename)) {
118
+ /* An overflow makes the filename unusable, so do not report any */
119
+ bs->exact_filename[0] = '\0';
120
+ }
121
+}
75
+}
122
+
76
+
123
static const char *const ssh_strong_runtime_opts[] = {
77
static AioHandler *find_aio_handler(AioContext *ctx, int fd)
124
"host",
78
{
125
"port",
79
AioHandler *node;
126
@@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_ssh = {
80
@@ -XXX,XX +XXX,XX @@ static bool aio_remove_fd_handler(AioContext *ctx, AioHandler *node)
127
.bdrv_getlength = ssh_getlength,
81
}
128
.bdrv_co_truncate = ssh_co_truncate,
82
129
.bdrv_co_flush_to_disk = ssh_co_flush,
83
node->pfd.revents = 0;
130
+ .bdrv_refresh_filename = ssh_refresh_filename,
84
+ node->poll_ready = false;
131
.create_opts = &ssh_create_opts,
85
132
.strong_runtime_opts = ssh_strong_runtime_opts,
86
/* If the fd monitor has already marked it deleted, leave it alone */
133
};
87
if (QLIST_IS_INSERTED(node, node_deleted)) {
134
diff --git a/tests/qemu-iotests/207 b/tests/qemu-iotests/207
88
@@ -XXX,XX +XXX,XX @@ static bool poll_set_started(AioContext *ctx, AioHandlerList *ready_list,
135
index XXXXXXX..XXXXXXX 100755
89
136
--- a/tests/qemu-iotests/207
90
/* Poll one last time in case ->io_poll_end() raced with the event */
137
+++ b/tests/qemu-iotests/207
91
if (!started && node->io_poll(node->opaque)) {
138
@@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.img') as disk_path, \
92
- aio_add_ready_handler(ready_list, node, REVENTS_POLL_READY);
139
'size': 4194304 })
93
+ aio_add_poll_ready_handler(ready_list, node);
140
vm.shutdown()
94
progress = true;
141
95
}
142
- iotests.img_info_log(remote_path, filter_path=disk_path)
96
}
143
+ iotests.img_info_log(remote_path)
97
@@ -XXX,XX +XXX,XX @@ bool aio_pending(AioContext *ctx)
144
iotests.log("")
98
QLIST_FOREACH_RCU(node, &ctx->aio_handlers, node) {
145
iotests.img_info_log(disk_path)
99
int revents;
146
100
147
@@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.img') as disk_path, \
101
+ /* TODO should this check poll ready? */
148
'size': 8388608 })
102
revents = node->pfd.revents & node->pfd.events;
149
vm.shutdown()
103
if (revents & (G_IO_IN | G_IO_HUP | G_IO_ERR) && node->io_read &&
150
104
aio_node_check(ctx, node->is_external)) {
151
- iotests.img_info_log(remote_path, filter_path=disk_path)
105
@@ -XXX,XX +XXX,XX @@ static void aio_free_deleted_handlers(AioContext *ctx)
152
+ iotests.img_info_log(remote_path)
106
static bool aio_dispatch_handler(AioContext *ctx, AioHandler *node)
153
107
{
154
vm.launch()
108
bool progress = false;
155
blockdev_create(vm, { 'driver': 'ssh',
109
+ bool poll_ready;
156
@@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.img') as disk_path, \
110
int revents;
157
'size': 4194304 })
111
158
vm.shutdown()
112
revents = node->pfd.revents & node->pfd.events;
159
113
node->pfd.revents = 0;
160
- iotests.img_info_log(remote_path, filter_path=disk_path)
114
161
+ iotests.img_info_log(remote_path)
115
+ poll_ready = node->poll_ready;
162
116
+ node->poll_ready = false;
163
md5_key = subprocess.check_output(
117
+
164
'ssh-keyscan -t rsa 127.0.0.1 2>/dev/null | grep -v "\\^#" | ' +
118
/*
165
@@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.img') as disk_path, \
119
* Start polling AioHandlers when they become ready because activity is
166
'size': 8388608 })
120
* likely to continue. Note that starvation is theoretically possible when
167
vm.shutdown()
121
@@ -XXX,XX +XXX,XX @@ static bool aio_dispatch_handler(AioContext *ctx, AioHandler *node)
168
122
QLIST_INSERT_HEAD(&ctx->poll_aio_handlers, node, node_poll);
169
- iotests.img_info_log(remote_path, filter_path=disk_path)
123
}
170
+ iotests.img_info_log(remote_path)
124
if (!QLIST_IS_INSERTED(node, node_deleted) &&
171
125
- revents == 0 &&
172
sha1_key = subprocess.check_output(
126
+ poll_ready && revents == 0 &&
173
'ssh-keyscan -t rsa 127.0.0.1 2>/dev/null | grep -v "\\^#" | ' +
127
aio_node_check(ctx, node->is_external) &&
174
@@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.img') as disk_path, \
128
node->io_poll_ready) {
175
'size': 4194304 })
129
node->io_poll_ready(node->opaque);
176
vm.shutdown()
130
@@ -XXX,XX +XXX,XX @@ static bool run_poll_handlers_once(AioContext *ctx,
177
131
QLIST_FOREACH_SAFE(node, &ctx->poll_aio_handlers, node_poll, tmp) {
178
- iotests.img_info_log(remote_path, filter_path=disk_path)
132
if (aio_node_check(ctx, node->is_external) &&
179
+ iotests.img_info_log(remote_path)
133
node->io_poll(node->opaque)) {
180
134
- aio_add_ready_handler(ready_list, node, REVENTS_POLL_READY);
181
#
135
+ aio_add_poll_ready_handler(ready_list, node);
182
# Invalid path and user
136
183
diff --git a/tests/qemu-iotests/207.out b/tests/qemu-iotests/207.out
137
node->poll_idle_timeout = now + POLL_IDLE_INTERVAL_NS;
184
index XXXXXXX..XXXXXXX 100644
138
185
--- a/tests/qemu-iotests/207.out
139
@@ -XXX,XX +XXX,XX @@ static bool remove_idle_poll_handlers(AioContext *ctx,
186
+++ b/tests/qemu-iotests/207.out
140
* this causes progress.
187
@@ -XXX,XX +XXX,XX @@
141
*/
188
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
142
if (node->io_poll(node->opaque)) {
189
{"return": {}}
143
- aio_add_ready_handler(ready_list, node,
190
144
- REVENTS_POLL_READY);
191
-image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "server.port": "22", "driver": "ssh", "path": "TEST_IMG"}}
145
+ aio_add_poll_ready_handler(ready_list, node);
192
+image: TEST_IMG
146
progress = true;
193
file format: IMGFMT
147
}
194
virtual size: 4 MiB (4194304 bytes)
148
}
195
196
@@ -XXX,XX +XXX,XX @@ virtual size: 4 MiB (4194304 bytes)
197
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
198
{"return": {}}
199
200
-image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "server.port": "22", "driver": "ssh", "path": "TEST_IMG"}}
201
+image: TEST_IMG
202
file format: IMGFMT
203
virtual size: 8 MiB (8388608 bytes)
204
205
@@ -XXX,XX +XXX,XX @@ virtual size: 8 MiB (8388608 bytes)
206
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
207
{"return": {}}
208
209
-image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "server.port": "22", "driver": "ssh", "path": "TEST_IMG"}}
210
+image: TEST_IMG
211
file format: IMGFMT
212
virtual size: 4 MiB (4194304 bytes)
213
214
@@ -XXX,XX +XXX,XX @@ Job failed: remote host key does not match host_key_check 'wrong'
215
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
216
{"return": {}}
217
218
-image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "server.port": "22", "driver": "ssh", "path": "TEST_IMG"}}
219
+image: TEST_IMG
220
file format: IMGFMT
221
virtual size: 8 MiB (8388608 bytes)
222
223
@@ -XXX,XX +XXX,XX @@ Job failed: remote host key does not match host_key_check 'wrong'
224
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
225
{"return": {}}
226
227
-image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "server.port": "22", "driver": "ssh", "path": "TEST_IMG"}}
228
+image: TEST_IMG
229
file format: IMGFMT
230
virtual size: 4 MiB (4194304 bytes)
231
232
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
233
index XXXXXXX..XXXXXXX 100644
234
--- a/tests/qemu-iotests/common.rc
235
+++ b/tests/qemu-iotests/common.rc
236
@@ -XXX,XX +XXX,XX @@ else
237
TEST_IMG="nbd:127.0.0.1:10810"
238
elif [ "$IMGPROTO" = "ssh" ]; then
239
TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT
240
- REMOTE_TEST_DIR="ssh://127.0.0.1$TEST_DIR"
241
+ REMOTE_TEST_DIR="ssh://\\($USER@\\)\\?127.0.0.1\\(:[0-9]\\+\\)\\?$TEST_DIR"
242
TEST_IMG="ssh://127.0.0.1$TEST_IMG_FILE"
243
elif [ "$IMGPROTO" = "nfs" ]; then
244
TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT
245
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
246
index XXXXXXX..XXXXXXX 100644
247
--- a/tests/qemu-iotests/iotests.py
248
+++ b/tests/qemu-iotests/iotests.py
249
@@ -XXX,XX +XXX,XX @@ def remote_filename(path):
250
if imgproto == 'file':
251
return path
252
elif imgproto == 'ssh':
253
- return "ssh://127.0.0.1%s" % (path)
254
+ return "ssh://%s@127.0.0.1:22%s" % (os.environ.get('USER'), path)
255
else:
256
raise Exception("Protocol %s not supported" % (imgproto))
257
258
--
149
--
259
2.20.1
150
2.35.1
260
261
diff view generated by jsdifflib
Deleted patch
1
From: Alberto Garcia <berto@igalia.com>
2
1
3
There is no need to check for this because all block drivers that have
4
children implement bdrv_child_perm and all callers already ensure that
5
bs->drv is set.
6
7
Furthermore, if this check would fail then the callers would end up
8
with uninitialized values for nperm and nshared.
9
10
This patch replaces the check with an assertion.
11
12
Signed-off-by: Alberto Garcia <berto@igalia.com>
13
Message-id: 20190404112953.4058-1-berto@igalia.com
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
16
block.c | 9 ++++-----
17
1 file changed, 4 insertions(+), 5 deletions(-)
18
19
diff --git a/block.c b/block.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/block.c
22
+++ b/block.c
23
@@ -XXX,XX +XXX,XX @@ static void bdrv_child_perm(BlockDriverState *bs, BlockDriverState *child_bs,
24
uint64_t parent_perm, uint64_t parent_shared,
25
uint64_t *nperm, uint64_t *nshared)
26
{
27
- if (bs->drv && bs->drv->bdrv_child_perm) {
28
- bs->drv->bdrv_child_perm(bs, c, role, reopen_queue,
29
- parent_perm, parent_shared,
30
- nperm, nshared);
31
- }
32
+ assert(bs->drv && bs->drv->bdrv_child_perm);
33
+ bs->drv->bdrv_child_perm(bs, c, role, reopen_queue,
34
+ parent_perm, parent_shared,
35
+ nperm, nshared);
36
/* TODO Take force_share from reopen_queue */
37
if (child_bs && child_bs->force_share) {
38
*nshared = BLK_PERM_ALL;
39
--
40
2.20.1
41
42
diff view generated by jsdifflib
Deleted patch
1
From: Alberto Garcia <berto@igalia.com>
2
1
3
This function combines bdrv_set_backing_hd() and bdrv_replace_node()
4
so we can use it to simplify the code a bit in commit_start().
5
6
Signed-off-by: Alberto Garcia <berto@igalia.com>
7
Message-id: 20190403143748.9790-1-berto@igalia.com
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
10
block/commit.c | 11 +----------
11
1 file changed, 1 insertion(+), 10 deletions(-)
12
13
diff --git a/block/commit.c b/block/commit.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/block/commit.c
16
+++ b/block/commit.c
17
@@ -XXX,XX +XXX,XX @@ void commit_start(const char *job_id, BlockDriverState *bs,
18
commit_top_bs->total_sectors = top->total_sectors;
19
bdrv_set_aio_context(commit_top_bs, bdrv_get_aio_context(top));
20
21
- bdrv_set_backing_hd(commit_top_bs, top, &local_err);
22
+ bdrv_append(commit_top_bs, top, &local_err);
23
if (local_err) {
24
- bdrv_unref(commit_top_bs);
25
- commit_top_bs = NULL;
26
- error_propagate(errp, local_err);
27
- goto fail;
28
- }
29
- bdrv_replace_node(top, commit_top_bs, &local_err);
30
- if (local_err) {
31
- bdrv_unref(commit_top_bs);
32
commit_top_bs = NULL;
33
error_propagate(errp, local_err);
34
goto fail;
35
}
36
37
s->commit_top_bs = commit_top_bs;
38
- bdrv_unref(commit_top_bs);
39
40
/* Block all nodes between top and base, because they will
41
* disappear from the chain after this operation. */
42
--
43
2.20.1
44
45
diff view generated by jsdifflib
Deleted patch
1
A recent patch results in qemu-img reporting the backing file format of
2
vmdk images as vmdk. This broke iotests 110 and 126.
3
1
4
Fixes: 7502be838e2fb62cc00f9e55f632e0b88ead5e6e
5
Signed-off-by: Max Reitz <mreitz@redhat.com>
6
Message-id: 20190415154129.31021-1-mreitz@redhat.com
7
Signed-off-by: Max Reitz <mreitz@redhat.com>
8
---
9
tests/qemu-iotests/110 | 10 +++++++---
10
tests/qemu-iotests/126 | 10 +++++++---
11
2 files changed, 14 insertions(+), 6 deletions(-)
12
13
diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110
14
index XXXXXXX..XXXXXXX 100755
15
--- a/tests/qemu-iotests/110
16
+++ b/tests/qemu-iotests/110
17
@@ -XXX,XX +XXX,XX @@ TEST_IMG="$TEST_IMG.base" _make_test_img 64M
18
_make_test_img -b "$TEST_IMG_REL.base" 64M
19
# qemu should be able to reconstruct the filename, so relative backing names
20
# should work
21
+# (We have to filter the backing file format because vmdk always
22
+# reports it (as vmdk), whereas other image formats would do so only
23
+# with the backing_fmt creation option, which neither vmdk nor qcow
24
+# support)
25
TEST_IMG="json:{'driver':'$IMGFMT','file':{'driver':'file','filename':'$TEST_IMG'}}" \
26
- _img_info | _filter_img_info
27
+ _img_info | _filter_img_info | grep -v 'backing file format'
28
29
echo
30
echo '=== Non-reconstructable filename ==='
31
@@ -XXX,XX +XXX,XX @@ TEST_IMG="json:{
32
}
33
]
34
}
35
-}" _img_info | _filter_img_info
36
+}" _img_info | _filter_img_info | grep -v 'backing file format'
37
38
echo
39
echo '=== Backing name is always relative to the backed image ==='
40
@@ -XXX,XX +XXX,XX @@ TEST_IMG="json:{
41
}
42
]
43
}
44
-}" _img_info | _filter_img_info
45
+}" _img_info | _filter_img_info | grep -v 'backing file format'
46
47
48
# success, all done
49
diff --git a/tests/qemu-iotests/126 b/tests/qemu-iotests/126
50
index XXXXXXX..XXXXXXX 100755
51
--- a/tests/qemu-iotests/126
52
+++ b/tests/qemu-iotests/126
53
@@ -XXX,XX +XXX,XX @@ TOP_IMG="$TEST_DIR/image:top.$IMGFMT"
54
TEST_IMG=$BASE_IMG _make_test_img 64M
55
TEST_IMG=$TOP_IMG _make_test_img -b ./image:base.$IMGFMT
56
57
-# The default cluster size depends on the image format
58
-TEST_IMG=$TOP_IMG _img_info | grep -v 'cluster_size'
59
+# (1) The default cluster size depends on the image format
60
+# (2) vmdk only supports vmdk backing files, so it always reports the
61
+# format of its backing file as such (but neither it nor qcow
62
+# support the backing_fmt creation option, so we cannot use that to
63
+# harmonize the output across all image formats this test supports)
64
+TEST_IMG=$TOP_IMG _img_info | grep -ve 'cluster_size' -e 'backing file format'
65
66
_rm_test_img "$BASE_IMG"
67
_rm_test_img "$TOP_IMG"
68
@@ -XXX,XX +XXX,XX @@ TOP_IMG="file:image:top.$IMGFMT"
69
TEST_IMG=$BASE_IMG _make_test_img 64M
70
TEST_IMG=$TOP_IMG _make_test_img -b "$BASE_IMG"
71
72
-TEST_IMG=$TOP_IMG _img_info | grep -v 'cluster_size'
73
+TEST_IMG=$TOP_IMG _img_info | grep -ve 'cluster_size' -e 'backing file format'
74
75
_rm_test_img "$BASE_IMG"
76
_rm_test_img "image:top.$IMGFMT"
77
--
78
2.20.1
79
80
diff view generated by jsdifflib