1
The following changes since commit 73e0f70e097b7c92a5ce16ee35b53afe119b20d7:
1
The following changes since commit 9ba37026fcf6b7f3f096c0cca3e1e7307802486b:
2
2
3
Merge tag 'pull-lu-20211123' of https://gitlab.com/rth7680/qemu into staging (2021-11-23 11:33:14 +0100)
3
Update version for v8.1.0-rc2 release (2023-08-02 08:22:45 -0700)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
https://gitlab.com/hreitz/qemu.git tags/pull-block-2021-11-23
7
https://gitlab.com/stefanha/qemu.git tags/block-pull-request
8
8
9
for you to fetch changes up to 4dd218fd0717ed3cddb69c01eeb9da630107d89d:
9
for you to fetch changes up to 9b06d0d076271d76e5384d767ef94a676f0a9efd:
10
10
11
iotests/149: Skip on unsupported ciphers (2021-11-23 15:39:12 +0100)
11
block/blkio: add more comments on the fd passing handling (2023-08-03 11:28:43 -0400)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Block patches for 6.2-rc2:
14
Pull request
15
- Fix memory leak in vvfat when vvfat_open() fails
15
16
- iotest fixes for the gnutls crypto backend
16
Fix for an fd leak in the blkio block driver.
17
17
18
----------------------------------------------------------------
18
----------------------------------------------------------------
19
Daniella Lee (1):
20
block/vvfat.c fix leak when failure occurs
21
19
22
Hanna Reitz (2):
20
Stefano Garzarella (2):
23
iotests: Use aes-128-cbc
21
block/blkio: close the fd when blkio_connect() fails
24
iotests/149: Skip on unsupported ciphers
22
block/blkio: add more comments on the fd passing handling
25
23
26
block/vvfat.c | 16 ++++++++++++----
24
block/blkio.c | 28 +++++++++++++++++++++-------
27
tests/qemu-iotests/149 | 23 ++++++++++++++++++-----
25
1 file changed, 21 insertions(+), 7 deletions(-)
28
tests/qemu-iotests/206 | 4 ++--
29
tests/qemu-iotests/206.out | 6 +++---
30
tests/qemu-iotests/210 | 4 ++--
31
tests/qemu-iotests/210.out | 6 +++---
32
6 files changed, 40 insertions(+), 19 deletions(-)
33
26
34
--
27
--
35
2.33.1
28
2.41.0
36
37
diff view generated by jsdifflib
Deleted patch
1
From: Daniella Lee <daniellalee111@gmail.com>
2
1
3
Function vvfat_open called function enable_write_target and init_directories,
4
and these functions malloc new memory for BDRVVVFATState::qcow_filename,
5
BDRVVVFATState::used_clusters, and BDRVVVFATState::cluster_buff.
6
7
When the specified folder does not exist ,it may contains memory leak.
8
After init_directories function is executed, the vvfat_open return -EIO,
9
and bdrv_open_driver goto label open_failed,
10
the program use g_free(bs->opaque) to release BDRVVVFATState struct
11
without members mentioned.
12
13
command line:
14
qemu-system-x86_64 -hdb <vdisk qcow file> -usb -device usb-storage,drive=fat16
15
-drive file=fat:rw:fat-type=16:"<path of a host folder does not exist>",
16
id=fat16,format=raw,if=none
17
18
enable_write_target called:
19
(gdb) bt
20
at ../block/vvfat.c:3114
21
flags=155650, errp=0x7fffffffd780) at ../block/vvfat.c:1236
22
node_name=0x0, options=0x555556fa45d0, open_flags=155650,
23
errp=0x7fffffffd890) at ../block.c:1558
24
errp=0x7fffffffd890) at ../block.c:1852
25
reference=0x0, options=0x555556fa45d0, flags=40962, parent=0x555556f98cd0,
26
child_class=0x555556b1d6a0 <child_of_bds>, child_role=19,
27
errp=0x7fffffffda90) at ../block.c:3779
28
options=0x555556f9cfc0, bdref_key=0x555556239bb8 "file",
29
parent=0x555556f98cd0, child_class=0x555556b1d6a0 <child_of_bds>,
30
child_role=19, allow_none=true, errp=0x7fffffffda90) at ../block.c:3419
31
reference=0x0, options=0x555556f9cfc0, flags=8194, parent=0x0,
32
child_class=0x0, child_role=0, errp=0x555556c98c40 <error_fatal>)
33
at ../block.c:3726
34
options=0x555556f757b0, flags=0, errp=0x555556c98c40 <error_fatal>)
35
at ../block.c:3872
36
options=0x555556f757b0, flags=0, errp=0x555556c98c40 <error_fatal>)
37
at ../block/block-backend.c:436
38
bs_opts=0x555556f757b0, errp=0x555556c98c40 <error_fatal>)
39
at ../blockdev.c:608
40
errp=0x555556c98c40 <error_fatal>) at ../blockdev.c:992
41
......
42
43
Signed-off-by: Daniella Lee <daniellalee111@gmail.com>
44
Message-Id: <20211119112553.352222-1-daniellalee111@gmail.com>
45
[hreitz: Took commit message from v1]
46
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
47
---
48
block/vvfat.c | 16 ++++++++++++----
49
1 file changed, 12 insertions(+), 4 deletions(-)
50
51
diff --git a/block/vvfat.c b/block/vvfat.c
52
index XXXXXXX..XXXXXXX 100644
53
--- a/block/vvfat.c
54
+++ b/block/vvfat.c
55
@@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
56
57
qemu_co_mutex_init(&s->lock);
58
59
- ret = 0;
60
+ qemu_opts_del(opts);
61
+
62
+ return 0;
63
+
64
fail:
65
+ g_free(s->qcow_filename);
66
+ s->qcow_filename = NULL;
67
+ g_free(s->cluster_buffer);
68
+ s->cluster_buffer = NULL;
69
+ g_free(s->used_clusters);
70
+ s->used_clusters = NULL;
71
+
72
qemu_opts_del(opts);
73
return ret;
74
}
75
@@ -XXX,XX +XXX,XX @@ static int enable_write_target(BlockDriverState *bs, Error **errp)
76
int size = sector2cluster(s, s->sector_count);
77
QDict *options;
78
79
- s->used_clusters = calloc(size, 1);
80
+ s->used_clusters = g_malloc0(size);
81
82
array_init(&(s->commits), sizeof(commit_t));
83
84
@@ -XXX,XX +XXX,XX @@ static int enable_write_target(BlockDriverState *bs, Error **errp)
85
return 0;
86
87
err:
88
- g_free(s->qcow_filename);
89
- s->qcow_filename = NULL;
90
return ret;
91
}
92
93
--
94
2.33.1
95
96
diff view generated by jsdifflib
1
Whenever qemu-img or qemu-io report that some cipher is unsupported,
1
From: Stefano Garzarella <sgarzare@redhat.com>
2
skip the whole test, because that is probably because qemu has been
3
configured with the gnutls crypto backend.
4
2
5
We could taylor the algorithm list to what gnutls supports, but this is
3
libblkio drivers take ownership of `fd` only after a successful
6
a test that is run rather rarely anyway (because it requires
4
blkio_connect(), so if it fails, we are still the owners.
7
password-less sudo), and so it seems better and easier to skip it. When
8
this test is intentionally run to check LUKS compatibility, it seems
9
better not to limit the algorithms but keep the list extensive.
10
5
11
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
6
Fixes: cad2ccc395 ("block/blkio: use qemu_open() to support fd passing for virtio-blk")
12
Message-Id: <20211117151707.52549-3-hreitz@redhat.com>
7
Suggested-by: Hanna Czenczek <hreitz@redhat.com>
13
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
8
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
9
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
10
Message-id: 20230803082825.25293-2-sgarzare@redhat.com
11
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14
---
12
---
15
tests/qemu-iotests/149 | 23 ++++++++++++++++++-----
13
block/blkio.c | 11 ++++++++---
16
1 file changed, 18 insertions(+), 5 deletions(-)
14
1 file changed, 8 insertions(+), 3 deletions(-)
17
15
18
diff --git a/tests/qemu-iotests/149 b/tests/qemu-iotests/149
16
diff --git a/block/blkio.c b/block/blkio.c
19
index XXXXXXX..XXXXXXX 100755
17
index XXXXXXX..XXXXXXX 100644
20
--- a/tests/qemu-iotests/149
18
--- a/block/blkio.c
21
+++ b/tests/qemu-iotests/149
19
+++ b/block/blkio.c
22
@@ -XXX,XX +XXX,XX @@ def create_image(config, size_mb):
20
@@ -XXX,XX +XXX,XX @@ static int blkio_virtio_blk_connect(BlockDriverState *bs, QDict *options,
23
fn.truncate(size_mb * 1024 * 1024)
21
const char *path = qdict_get_try_str(options, "path");
24
22
BDRVBlkioState *s = bs->opaque;
25
23
bool fd_supported = false;
26
+def check_cipher_support(config, output):
24
- int fd, ret;
27
+ """Check the output of qemu-img or qemu-io for mention of the respective
25
+ int fd = -1, ret;
28
+ cipher algorithm being unsupported, and if so, skip this test.
26
29
+ (Returns `output` for convenience.)"""
27
if (!path) {
28
error_setg(errp, "missing 'path' option");
29
@@ -XXX,XX +XXX,XX @@ static int blkio_virtio_blk_connect(BlockDriverState *bs, QDict *options,
30
if (ret < 0) {
31
fd_supported = false;
32
qemu_close(fd);
33
+ fd = -1;
34
}
35
}
36
}
37
@@ -XXX,XX +XXX,XX @@ static int blkio_virtio_blk_connect(BlockDriverState *bs, QDict *options,
38
}
39
40
ret = blkio_connect(s->blkio);
41
+ if (ret < 0 && fd >= 0) {
42
+ /* Failed to give the FD to libblkio, close it */
43
+ qemu_close(fd);
44
+ fd = -1;
45
+ }
30
+
46
+
31
+ if 'Unsupported cipher algorithm' in output:
47
/*
32
+ iotests.notrun('Unsupported cipher algorithm '
48
* If the libblkio driver doesn't support the `fd` property, blkio_connect()
33
+ f'{config.cipher}-{config.keylen}-{config.mode}; '
49
* will fail with -EINVAL. So let's try calling blkio_connect() again by
34
+ 'consider configuring qemu with a different crypto '
50
* directly setting `path`.
35
+ 'backend')
51
*/
36
+ return output
52
if (fd_supported && ret == -EINVAL) {
37
+
53
- qemu_close(fd);
38
def qemu_img_create(config, size_mb):
54
-
39
"""Create and format a disk image with LUKS using qemu-img"""
55
/*
40
56
* We need to clear the `fd` property we set previously by setting
41
@@ -XXX,XX +XXX,XX @@ def qemu_img_create(config, size_mb):
57
* it to -1.
42
"%dM" % size_mb]
43
44
iotests.log("qemu-img " + " ".join(args), filters=[iotests.filter_test_dir])
45
- iotests.log(iotests.qemu_img_pipe(*args), filters=[iotests.filter_test_dir])
46
+ iotests.log(check_cipher_support(config, iotests.qemu_img_pipe(*args)),
47
+ filters=[iotests.filter_test_dir])
48
49
def qemu_io_image_args(config, dev=False):
50
"""Get the args for access an image or device with qemu-io"""
51
@@ -XXX,XX +XXX,XX @@ def qemu_io_write_pattern(config, pattern, offset_mb, size_mb, dev=False):
52
args = ["-c", "write -P 0x%x %dM %dM" % (pattern, offset_mb, size_mb)]
53
args.extend(qemu_io_image_args(config, dev))
54
iotests.log("qemu-io " + " ".join(args), filters=[iotests.filter_test_dir])
55
- iotests.log(iotests.qemu_io(*args), filters=[iotests.filter_test_dir,
56
- iotests.filter_qemu_io])
57
+ iotests.log(check_cipher_support(config, iotests.qemu_io(*args)),
58
+ filters=[iotests.filter_test_dir, iotests.filter_qemu_io])
59
60
61
def qemu_io_read_pattern(config, pattern, offset_mb, size_mb, dev=False):
62
@@ -XXX,XX +XXX,XX @@ def qemu_io_read_pattern(config, pattern, offset_mb, size_mb, dev=False):
63
args = ["-c", "read -P 0x%x %dM %dM" % (pattern, offset_mb, size_mb)]
64
args.extend(qemu_io_image_args(config, dev))
65
iotests.log("qemu-io " + " ".join(args), filters=[iotests.filter_test_dir])
66
- iotests.log(iotests.qemu_io(*args), filters=[iotests.filter_test_dir,
67
- iotests.filter_qemu_io])
68
+ iotests.log(check_cipher_support(config, iotests.qemu_io(*args)),
69
+ filters=[iotests.filter_test_dir, iotests.filter_qemu_io])
70
71
72
def test_once(config, qemu_img=False):
73
--
58
--
74
2.33.1
59
2.41.0
75
76
diff view generated by jsdifflib
1
Our gnutls crypto backend (which is the default as of 8bd0931f6)
1
From: Stefano Garzarella <sgarzare@redhat.com>
2
supports neither twofish-128 nor the CTR mode. CBC and aes-128 are
3
supported by all of our backends (as far as I can tell), so use
4
aes-128-cbc in our iotests.
5
2
6
(We could also use e.g. aes-256-cbc, but the different key sizes would
3
As Hanna pointed out, it is not clear in the code why qemu_open()
7
lead to different key slot offsets and so change the reference output
4
can fail, and why blkio_set_int("fd") is not enough to discover
8
more, which is why I went with aes-128.)
5
the `fd` property support.
9
6
10
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
7
Let's fix them by adding more details in the code comments.
11
Message-Id: <20211117151707.52549-2-hreitz@redhat.com>
8
12
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
9
Suggested-by: Hanna Czenczek <hreitz@redhat.com>
13
Tested-by: Thomas Huth <thuth@redhat.com>
10
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
11
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
12
Message-id: 20230803082825.25293-3-sgarzare@redhat.com
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14
---
14
---
15
tests/qemu-iotests/206 | 4 ++--
15
block/blkio.c | 15 ++++++++++++---
16
tests/qemu-iotests/206.out | 6 +++---
16
1 file changed, 12 insertions(+), 3 deletions(-)
17
tests/qemu-iotests/210 | 4 ++--
18
tests/qemu-iotests/210.out | 6 +++---
19
4 files changed, 10 insertions(+), 10 deletions(-)
20
17
21
diff --git a/tests/qemu-iotests/206 b/tests/qemu-iotests/206
18
diff --git a/block/blkio.c b/block/blkio.c
22
index XXXXXXX..XXXXXXX 100755
23
--- a/tests/qemu-iotests/206
24
+++ b/tests/qemu-iotests/206
25
@@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.qcow2') as disk_path, \
26
'encrypt': {
27
'format': 'luks',
28
'key-secret': 'keysec0',
29
- 'cipher-alg': 'twofish-128',
30
- 'cipher-mode': 'ctr',
31
+ 'cipher-alg': 'aes-128',
32
+ 'cipher-mode': 'cbc',
33
'ivgen-alg': 'plain64',
34
'ivgen-hash-alg': 'md5',
35
'hash-alg': 'sha1',
36
diff --git a/tests/qemu-iotests/206.out b/tests/qemu-iotests/206.out
37
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
38
--- a/tests/qemu-iotests/206.out
20
--- a/block/blkio.c
39
+++ b/tests/qemu-iotests/206.out
21
+++ b/block/blkio.c
40
@@ -XXX,XX +XXX,XX @@ Format specific information:
22
@@ -XXX,XX +XXX,XX @@ static int blkio_virtio_blk_connect(BlockDriverState *bs, QDict *options,
41
23
*/
42
=== Successful image creation (encrypted) ===
24
fd = qemu_open(path, O_RDWR, NULL);
43
25
if (fd < 0) {
44
-{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "qcow2", "encrypt": {"cipher-alg": "twofish-128", "cipher-mode": "ctr", "format": "luks", "hash-alg": "sha1", "iter-time": 10, "ivgen-alg": "plain64", "ivgen-hash-alg": "md5", "key-secret": "keysec0"}, "file": {"driver": "file", "filename": "TEST_DIR/PID-t.qcow2"}, "size": 33554432}}}
26
+ /*
45
+{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "qcow2", "encrypt": {"cipher-alg": "aes-128", "cipher-mode": "cbc", "format": "luks", "hash-alg": "sha1", "iter-time": 10, "ivgen-alg": "plain64", "ivgen-hash-alg": "md5", "key-secret": "keysec0"}, "file": {"driver": "file", "filename": "TEST_DIR/PID-t.qcow2"}, "size": 33554432}}}
27
+ * qemu_open() can fail if the user specifies a path that is not
46
{"return": {}}
28
+ * a file or device, for example in the case of Unix Domain Socket
47
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
29
+ * for the virtio-blk-vhost-user driver. In such cases let's have
48
{"return": {}}
30
+ * libblkio open the path directly.
49
@@ -XXX,XX +XXX,XX @@ Format specific information:
31
+ */
50
encrypt:
32
fd_supported = false;
51
ivgen alg: plain64
33
} else {
52
hash alg: sha1
34
ret = blkio_set_int(s->blkio, "fd", fd);
53
- cipher alg: twofish-128
35
@@ -XXX,XX +XXX,XX @@ static int blkio_virtio_blk_connect(BlockDriverState *bs, QDict *options,
54
+ cipher alg: aes-128
36
}
55
uuid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
37
56
format: luks
38
/*
57
- cipher mode: ctr
39
- * If the libblkio driver doesn't support the `fd` property, blkio_connect()
58
+ cipher mode: cbc
40
- * will fail with -EINVAL. So let's try calling blkio_connect() again by
59
slots:
41
- * directly setting `path`.
60
[0]:
42
+ * Before https://gitlab.com/libblkio/libblkio/-/merge_requests/208
61
active: true
43
+ * (libblkio <= v1.3.0), setting the `fd` property is not enough to check
62
diff --git a/tests/qemu-iotests/210 b/tests/qemu-iotests/210
44
+ * whether the driver supports the `fd` property or not. In that case,
63
index XXXXXXX..XXXXXXX 100755
45
+ * blkio_connect() will fail with -EINVAL.
64
--- a/tests/qemu-iotests/210
46
+ * So let's try calling blkio_connect() again by directly setting `path`
65
+++ b/tests/qemu-iotests/210
47
+ * to cover this scenario.
66
@@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.luks') as disk_path, \
48
*/
67
},
49
if (fd_supported && ret == -EINVAL) {
68
'size': size,
50
/*
69
'key-secret': 'keysec0',
70
- 'cipher-alg': 'twofish-128',
71
- 'cipher-mode': 'ctr',
72
+ 'cipher-alg': 'aes-128',
73
+ 'cipher-mode': 'cbc',
74
'ivgen-alg': 'plain64',
75
'ivgen-hash-alg': 'md5',
76
'hash-alg': 'sha1',
77
diff --git a/tests/qemu-iotests/210.out b/tests/qemu-iotests/210.out
78
index XXXXXXX..XXXXXXX 100644
79
--- a/tests/qemu-iotests/210.out
80
+++ b/tests/qemu-iotests/210.out
81
@@ -XXX,XX +XXX,XX @@ Format specific information:
82
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
83
{"return": {}}
84
85
-{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"cipher-alg": "twofish-128", "cipher-mode": "ctr", "driver": "luks", "file": {"driver": "file", "filename": "TEST_DIR/PID-t.luks"}, "hash-alg": "sha1", "iter-time": 10, "ivgen-alg": "plain64", "ivgen-hash-alg": "md5", "key-secret": "keysec0", "size": 67108864}}}
86
+{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"cipher-alg": "aes-128", "cipher-mode": "cbc", "driver": "luks", "file": {"driver": "file", "filename": "TEST_DIR/PID-t.luks"}, "hash-alg": "sha1", "iter-time": 10, "ivgen-alg": "plain64", "ivgen-hash-alg": "md5", "key-secret": "keysec0", "size": 67108864}}}
87
{"return": {}}
88
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
89
{"return": {}}
90
@@ -XXX,XX +XXX,XX @@ encrypted: yes
91
Format specific information:
92
ivgen alg: plain64
93
hash alg: sha1
94
- cipher alg: twofish-128
95
+ cipher alg: aes-128
96
uuid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
97
- cipher mode: ctr
98
+ cipher mode: cbc
99
slots:
100
[0]:
101
active: true
102
--
51
--
103
2.33.1
52
2.41.0
104
105
diff view generated by jsdifflib