1
The following changes since commit bfec359afba088aaacc7d316f43302f28c6e642a:
1
The following changes since commit 804b30d25f8d70dc2dea951883ea92235274a50c:
2
2
3
Merge remote-tracking branch 'remotes/armbru/tags/pull-qdev-2017-04-21' into staging (2017-04-21 11:42:03 +0100)
3
Merge remote-tracking branch 'remotes/legoater/tags/pull-ppc-20220130' into staging (2022-01-31 11:10:08 +0000)
4
4
5
are available in the git repository at:
5
are available in the Git repository at:
6
6
7
git://github.com/codyprime/qemu-kvm-jtc.git tags/block-pull-request
7
https://gitlab.com/hreitz/qemu.git tags/pull-block-2022-02-01
8
8
9
for you to fetch changes up to 1507631e438930bc07f776f303af127a9cdb4d41:
9
for you to fetch changes up to 751486c18555169ca4baf59440275d5831140822:
10
10
11
qemu-iotests: _cleanup_qemu must be called on exit (2017-04-21 08:32:44 -0400)
11
block.h: remove outdated comment (2022-02-01 13:28:53 +0100)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
14
Block patches:
15
Block patches for 2.10
15
- Add support to the iotests to test qcow2's zstd compression mode
16
- Fix post-migration block node permissions
17
- iotests fixes (051 and mirror-ready-cancel-error)
18
- Remove an outdated comment
16
19
17
----------------------------------------------------------------
20
----------------------------------------------------------------
21
Emanuele Giuseppe Esposito (1):
22
block.h: remove outdated comment
18
23
19
Ashish Mittal (2):
24
Hanna Reitz (3):
20
block/vxhs.c: Add support for a new block device type called "vxhs"
25
iotests/MRCE: Write data to source
21
block/vxhs.c: Add qemu-iotests for new block device type "vxhs"
26
block-backend: Retain permissions after migration
27
iotests/migration-permissions: New test
22
28
23
Jeff Cody (10):
29
Thomas Huth (1):
24
qemu-iotests: exclude vxhs from image creation via protocol
30
tests/qemu-iotests: Fix 051 for binaries without 'lsi53c895a'
25
block: add bdrv_set_read_only() helper function
26
block: do not set BDS read_only if copy_on_read enabled
27
block: honor BDRV_O_ALLOW_RDWR when clearing bs->read_only
28
block: code movement
29
block: introduce bdrv_can_set_read_only()
30
block: use bdrv_can_set_read_only() during reopen
31
block/rbd - update variable names to more apt names
32
block/rbd: Add support for reopen()
33
qemu-iotests: _cleanup_qemu must be called on exit
34
31
35
block.c | 56 +++-
32
Vladimir Sementsov-Ogievskiy (19):
36
block/Makefile.objs | 2 +
33
iotests.py: img_info_log(): rename imgopts argument
37
block/bochs.c | 5 +-
34
iotests.py: implement unsupported_imgopts
38
block/cloop.c | 5 +-
35
iotests: specify some unsupported_imgopts for python iotests
39
block/dmg.c | 6 +-
36
iotests.py: qemu_img*("create"): support
40
block/rbd.c | 65 +++--
37
IMGOPTS='compression_type=zstd'
41
block/trace-events | 17 ++
38
iotests: drop qemu_img_verbose() helper
42
block/vvfat.c | 19 +-
39
iotests.py: rewrite default luks support in qemu_img
43
block/vxhs.c | 575 +++++++++++++++++++++++++++++++++++++++
40
iotest 303: explicit compression type
44
configure | 39 +++
41
iotest 065: explicit compression type
45
include/block/block.h | 2 +
42
iotests.py: filter out successful output of qemu-img create
46
qapi/block-core.json | 23 +-
43
iotests.py: filter compression type out
47
tests/qemu-iotests/017 | 1 +
44
iotest 302: use img_info_log() helper
48
tests/qemu-iotests/020 | 1 +
45
qcow2: simple case support for downgrading of qcow2 images with zstd
49
tests/qemu-iotests/028 | 1 +
46
iotests/common.rc: introduce _qcow2_dump_header helper
50
tests/qemu-iotests/029 | 1 +
47
iotests: massive use _qcow2_dump_header
51
tests/qemu-iotests/073 | 1 +
48
iotest 39: use _qcow2_dump_header
52
tests/qemu-iotests/094 | 11 +-
49
iotests: bash tests: filter compression type
53
tests/qemu-iotests/102 | 5 +-
50
iotests 60: more accurate set dirty bit in qcow2 header
54
tests/qemu-iotests/109 | 1 +
51
iotest 214: explicit compression type
55
tests/qemu-iotests/114 | 1 +
52
iotests: declare lack of support for compresion_type in IMGOPTS
56
tests/qemu-iotests/117 | 1 +
53
57
tests/qemu-iotests/130 | 2 +
54
include/block/block.h | 1 -
58
tests/qemu-iotests/134 | 1 +
55
block/block-backend.c | 11 ++
59
tests/qemu-iotests/140 | 1 +
56
block/qcow2.c | 58 +++++++++-
60
tests/qemu-iotests/141 | 1 +
57
tests/qemu-iotests/031 | 11 +-
61
tests/qemu-iotests/143 | 1 +
58
tests/qemu-iotests/036 | 6 +-
62
tests/qemu-iotests/156 | 2 +
59
tests/qemu-iotests/039 | 22 ++--
63
tests/qemu-iotests/158 | 1 +
60
tests/qemu-iotests/044 | 8 +-
64
tests/qemu-iotests/common | 6 +
61
tests/qemu-iotests/044.out | 1 +
65
tests/qemu-iotests/common.config | 13 +
62
tests/qemu-iotests/051 | 9 +-
66
tests/qemu-iotests/common.filter | 1 +
63
tests/qemu-iotests/060 | 22 ++--
67
tests/qemu-iotests/common.rc | 19 ++
64
tests/qemu-iotests/060.out | 2 +-
68
33 files changed, 844 insertions(+), 42 deletions(-)
65
tests/qemu-iotests/061 | 42 ++++----
69
create mode 100644 block/vxhs.c
66
tests/qemu-iotests/061.out | 12 +--
67
tests/qemu-iotests/065 | 19 ++--
68
tests/qemu-iotests/082.out | 14 +--
69
tests/qemu-iotests/112 | 3 +-
70
tests/qemu-iotests/137 | 2 +-
71
tests/qemu-iotests/149.out | 21 ----
72
tests/qemu-iotests/163 | 3 +-
73
tests/qemu-iotests/165 | 3 +-
74
tests/qemu-iotests/196 | 3 +-
75
tests/qemu-iotests/198.out | 4 +-
76
tests/qemu-iotests/206.out | 10 +-
77
tests/qemu-iotests/209 | 7 +-
78
tests/qemu-iotests/209.out | 2 +
79
tests/qemu-iotests/210 | 8 +-
80
tests/qemu-iotests/214 | 2 +-
81
tests/qemu-iotests/237.out | 3 -
82
tests/qemu-iotests/242 | 3 +-
83
tests/qemu-iotests/242.out | 10 +-
84
tests/qemu-iotests/246 | 3 +-
85
tests/qemu-iotests/254 | 3 +-
86
tests/qemu-iotests/255.out | 4 -
87
tests/qemu-iotests/260 | 3 +-
88
tests/qemu-iotests/274 | 3 +-
89
tests/qemu-iotests/274.out | 39 +------
90
tests/qemu-iotests/280.out | 1 -
91
tests/qemu-iotests/281 | 3 +-
92
tests/qemu-iotests/287 | 8 +-
93
tests/qemu-iotests/290 | 2 +-
94
tests/qemu-iotests/296.out | 10 +-
95
tests/qemu-iotests/302 | 4 +-
96
tests/qemu-iotests/302.out | 7 +-
97
tests/qemu-iotests/303 | 26 +++--
98
tests/qemu-iotests/303.out | 30 +++++-
99
tests/qemu-iotests/common.filter | 8 ++
100
tests/qemu-iotests/common.rc | 22 ++++
101
tests/qemu-iotests/iotests.py | 99 +++++++++++------
102
.../tests/migrate-bitmaps-postcopy-test | 3 +-
103
tests/qemu-iotests/tests/migrate-bitmaps-test | 3 +-
104
.../qemu-iotests/tests/migration-permissions | 101 ++++++++++++++++++
105
.../tests/migration-permissions.out | 5 +
106
.../tests/mirror-ready-cancel-error | 7 +-
107
.../tests/remove-bitmap-from-backing | 3 +-
108
54 files changed, 483 insertions(+), 236 deletions(-)
109
create mode 100755 tests/qemu-iotests/tests/migration-permissions
110
create mode 100644 tests/qemu-iotests/tests/migration-permissions.out
70
111
71
--
112
--
72
2.9.3
113
2.34.1
73
114
74
115
diff view generated by jsdifflib
1
Introduce check function for setting read_only flags. Will return < 0 on
1
From: Thomas Huth <thuth@redhat.com>
2
error, with appropriate Error value set. Does not alter any flags.
3
2
4
Signed-off-by: Jeff Cody <jcody@redhat.com>
3
The lsi53c895a SCSI adaptor might not be enabled in each and every
5
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
4
x86 QEMU binary, e.g. it's disabled in the RHEL/CentOS build.
6
Reviewed-by: John Snow <jsnow@redhat.com>
5
Thus let's add a check to the 051 test so that it does not fail if
7
Message-id: e2bba34ac3bc76a0c42adc390413f358ae0566e8.1491597120.git.jcody@redhat.com
6
this device is not available.
7
8
Signed-off-by: Thomas Huth <thuth@redhat.com>
9
Message-Id: <20211206143404.247032-1-thuth@redhat.com>
10
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
8
---
11
---
9
block.c | 14 +++++++++++++-
12
tests/qemu-iotests/051 | 4 ++++
10
include/block/block.h | 1 +
13
1 file changed, 4 insertions(+)
11
2 files changed, 14 insertions(+), 1 deletion(-)
12
14
13
diff --git a/block.c b/block.c
15
diff --git a/tests/qemu-iotests/051 b/tests/qemu-iotests/051
14
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100755
15
--- a/block.c
17
--- a/tests/qemu-iotests/051
16
+++ b/block.c
18
+++ b/tests/qemu-iotests/051
17
@@ -XXX,XX +XXX,XX @@ bool bdrv_is_read_only(BlockDriverState *bs)
19
@@ -XXX,XX +XXX,XX @@ _supported_proto file
18
return bs->read_only;
20
_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file
19
}
21
_require_drivers nbd
20
22
21
-int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
23
+if [ "$QEMU_DEFAULT_MACHINE" = "pc" ]; then
22
+int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
24
+ _require_devices lsi53c895a
25
+fi
26
+
27
do_run_qemu()
23
{
28
{
24
/* Do not set read_only if copy_on_read is enabled */
29
echo Testing: "$@"
25
if (bs->copy_on_read && read_only) {
26
@@ -XXX,XX +XXX,XX @@ int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
27
return -EPERM;
28
}
29
30
+ return 0;
31
+}
32
+
33
+int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
34
+{
35
+ int ret = 0;
36
+
37
+ ret = bdrv_can_set_read_only(bs, read_only, errp);
38
+ if (ret < 0) {
39
+ return ret;
40
+ }
41
+
42
bs->read_only = read_only;
43
return 0;
44
}
45
diff --git a/include/block/block.h b/include/block/block.h
46
index XXXXXXX..XXXXXXX 100644
47
--- a/include/block/block.h
48
+++ b/include/block/block.h
49
@@ -XXX,XX +XXX,XX @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
50
int64_t sector_num, int nb_sectors, int *pnum);
51
52
bool bdrv_is_read_only(BlockDriverState *bs);
53
+int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, Error **errp);
54
int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp);
55
bool bdrv_is_sg(BlockDriverState *bs);
56
bool bdrv_is_inserted(BlockDriverState *bs);
57
--
30
--
58
2.9.3
31
2.34.1
59
32
60
33
diff view generated by jsdifflib
New patch
1
This test assumes that mirror flushes the source when entering the READY
2
state, and that the format level will pass that flush on to the protocol
3
level (where we intercept it with blkdebug).
1
4
5
However, apparently that does not happen when using a VMDK image with
6
zeroed_grain=on, which actually is the default set by testenv.py. Right
7
now, Python tests ignore IMGOPTS, though, so this has no effect; but
8
Vladimir has a series that will change this, so we need to fix this test
9
before that series lands.
10
11
We can fix it by writing data to the source before we start the mirror
12
job; apparently that makes the (VMDK) format layer change its mind and
13
pass on the pre-READY flush to the protocol level, so the test passes
14
again. (I presume, without any data written, mirror just does a 64M
15
zero write on the target, which VMDK with zeroed_grain=on basically just
16
ignores.)
17
18
Without this, we do not get a flush, and so blkdebug only sees a single
19
flush at the end of the job instead of two, and therefore does not
20
inject an error, which makes the block job complete instead of raising
21
an error.
22
23
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
24
Message-Id: <20211223165308.103793-1-hreitz@redhat.com>
25
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
26
---
27
tests/qemu-iotests/tests/mirror-ready-cancel-error | 7 ++++++-
28
1 file changed, 6 insertions(+), 1 deletion(-)
29
30
diff --git a/tests/qemu-iotests/tests/mirror-ready-cancel-error b/tests/qemu-iotests/tests/mirror-ready-cancel-error
31
index XXXXXXX..XXXXXXX 100755
32
--- a/tests/qemu-iotests/tests/mirror-ready-cancel-error
33
+++ b/tests/qemu-iotests/tests/mirror-ready-cancel-error
34
@@ -XXX,XX +XXX,XX @@ class TestMirrorReadyCancelError(iotests.QMPTestCase):
35
assert iotests.qemu_img_create('-f', iotests.imgfmt, target,
36
str(image_size)) == 0
37
38
+ # Ensure that mirror will copy something before READY so the
39
+ # target format layer will forward the pre-READY flush to its
40
+ # file child
41
+ assert iotests.qemu_io_silent('-c', 'write -P 1 0 64k', source) == 0
42
+
43
self.vm = iotests.VM()
44
self.vm.launch()
45
46
@@ -XXX,XX +XXX,XX @@ class TestMirrorReadyCancelError(iotests.QMPTestCase):
47
# Write something so will not leave the job immediately, but
48
# flush first (which will fail, thanks to blkdebug)
49
res = self.vm.qmp('human-monitor-command',
50
- command_line='qemu-io mirror-top "write 0 64k"')
51
+ command_line='qemu-io mirror-top "write -P 2 0 64k"')
52
self.assert_qmp(res, 'return', '')
53
54
# Drain status change events
55
--
56
2.34.1
57
58
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
We are going to support IMGOPTS environment variable like in bash
4
tests. Corresponding global variable in iotests.py should be called
5
imgopts. So to not interfere with function argument, rename it in
6
advance.
7
8
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
9
Reviewed-by: Max Reitz <mreitz@redhat.com>
10
Message-Id: <20211223160144.1097696-2-vsementsov@virtuozzo.com>
11
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
12
---
13
tests/qemu-iotests/210 | 8 ++++----
14
tests/qemu-iotests/iotests.py | 5 +++--
15
2 files changed, 7 insertions(+), 6 deletions(-)
16
17
diff --git a/tests/qemu-iotests/210 b/tests/qemu-iotests/210
18
index XXXXXXX..XXXXXXX 100755
19
--- a/tests/qemu-iotests/210
20
+++ b/tests/qemu-iotests/210
21
@@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.luks') as disk_path, \
22
'driver=luks,file.driver=file,file.filename=%s,key-secret=keysec0' % (disk_path),
23
filter_path=disk_path,
24
extra_args=['--object', 'secret,id=keysec0,data=foo'],
25
- imgopts=True)
26
+ use_image_opts=True)
27
28
#
29
# Successful image creation (with non-default options)
30
@@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.luks') as disk_path, \
31
'driver=luks,file.driver=file,file.filename=%s,key-secret=keysec0' % (disk_path),
32
filter_path=disk_path,
33
extra_args=['--object', 'secret,id=keysec0,data=foo'],
34
- imgopts=True)
35
+ use_image_opts=True)
36
37
#
38
# Invalid BlockdevRef
39
@@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.luks') as disk_path, \
40
'driver=luks,file.driver=file,file.filename=%s,key-secret=keysec0' % (disk_path),
41
filter_path=disk_path,
42
extra_args=['--object', 'secret,id=keysec0,data=foo'],
43
- imgopts=True)
44
+ use_image_opts=True)
45
46
#
47
# Invalid sizes
48
@@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.luks') as disk_path, \
49
'driver=luks,file.driver=file,file.filename=%s,key-secret=keysec0' % (disk_path),
50
filter_path=disk_path,
51
extra_args=['--object', 'secret,id=keysec0,data=foo'],
52
- imgopts=True)
53
+ use_image_opts=True)
54
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
55
index XXXXXXX..XXXXXXX 100644
56
--- a/tests/qemu-iotests/iotests.py
57
+++ b/tests/qemu-iotests/iotests.py
58
@@ -XXX,XX +XXX,XX @@ def qemu_img_log(*args):
59
log(result, filters=[filter_testfiles])
60
return result
61
62
-def img_info_log(filename, filter_path=None, imgopts=False, extra_args=()):
63
+def img_info_log(filename, filter_path=None, use_image_opts=False,
64
+ extra_args=()):
65
args = ['info']
66
- if imgopts:
67
+ if use_image_opts:
68
args.append('--image-opts')
69
else:
70
args += ['-f', imgfmt]
71
--
72
2.34.1
73
74
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
We are going to support some addition IMGOPTS in python iotests like
4
in bash iotests. Similarly to bash iotests, we want a way to skip some
5
tests which can't work with specific IMGOPTS.
6
7
Globally for python iotests we will not support things like
8
'data_file=$TEST_IMG.ext_data_file' in IMGOPTS, so, forbid this
9
globally in iotests.py.
10
11
Suggested-by: Hanna Reitz <hreitz@redhat.com>
12
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
13
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
14
Message-Id: <20211223160144.1097696-3-vsementsov@virtuozzo.com>
15
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
16
---
17
tests/qemu-iotests/iotests.py | 15 ++++++++++++++-
18
1 file changed, 14 insertions(+), 1 deletion(-)
19
20
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
21
index XXXXXXX..XXXXXXX 100644
22
--- a/tests/qemu-iotests/iotests.py
23
+++ b/tests/qemu-iotests/iotests.py
24
@@ -XXX,XX +XXX,XX @@ def _verify_virtio_scsi_pci_or_ccw() -> None:
25
notrun('Missing virtio-scsi-pci or virtio-scsi-ccw in QEMU binary')
26
27
28
+def _verify_imgopts(unsupported: Sequence[str] = ()) -> None:
29
+ imgopts = os.environ.get('IMGOPTS')
30
+ # One of usage examples for IMGOPTS is "data_file=$TEST_IMG.ext_data_file"
31
+ # but it supported only for bash tests. We don't have a concept of global
32
+ # TEST_IMG in iotests.py, not saying about somehow parsing $variables.
33
+ # So, for simplicity let's just not support any IMGOPTS with '$' inside.
34
+ unsup = list(unsupported) + ['$']
35
+ if imgopts and any(x in imgopts for x in unsup):
36
+ notrun(f'not suitable for this imgopts: {imgopts}')
37
+
38
+
39
def supports_quorum():
40
return 'quorum' in qemu_img_pipe('--help')
41
42
@@ -XXX,XX +XXX,XX @@ def execute_setup_common(supported_fmts: Sequence[str] = (),
43
unsupported_fmts: Sequence[str] = (),
44
supported_protocols: Sequence[str] = (),
45
unsupported_protocols: Sequence[str] = (),
46
- required_fmts: Sequence[str] = ()) -> bool:
47
+ required_fmts: Sequence[str] = (),
48
+ unsupported_imgopts: Sequence[str] = ()) -> bool:
49
"""
50
Perform necessary setup for either script-style or unittest-style tests.
51
52
@@ -XXX,XX +XXX,XX @@ def execute_setup_common(supported_fmts: Sequence[str] = (),
53
_verify_aio_mode(supported_aio_modes)
54
_verify_formats(required_fmts)
55
_verify_virtio_blk()
56
+ _verify_imgopts(unsupported_imgopts)
57
58
return debug
59
60
--
61
2.34.1
62
63
diff view generated by jsdifflib
New patch
1
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
3
We are going to support IMGOPTS for python iotests. Still some iotests
4
will not work with common IMGOPTS used with bash iotests like
5
specifying refcount_bits and compat qcow2 options. So we
6
should define corresponding unsupported_imgopts for now.
7
8
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
9
Message-Id: <20211223160144.1097696-4-vsementsov@virtuozzo.com>
10
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
11
---
12
tests/qemu-iotests/044 | 3 ++-
13
tests/qemu-iotests/065 | 3 ++-
14
tests/qemu-iotests/163 | 3 ++-
15
tests/qemu-iotests/165 | 3 ++-
16
tests/qemu-iotests/196 | 3 ++-
17
tests/qemu-iotests/242 | 3 ++-
18
tests/qemu-iotests/246 | 3 ++-
19
tests/qemu-iotests/254 | 3 ++-
20
tests/qemu-iotests/260 | 3 ++-
21
tests/qemu-iotests/274 | 3 ++-
22
tests/qemu-iotests/281 | 3 ++-
23
tests/qemu-iotests/303 | 3 ++-
24
tests/qemu-iotests/tests/migrate-bitmaps-postcopy-test | 3 ++-
25
tests/qemu-iotests/tests/migrate-bitmaps-test | 3 ++-
26
tests/qemu-iotests/tests/remove-bitmap-from-backing | 3 ++-
27
15 files changed, 30 insertions(+), 15 deletions(-)
28
29
diff --git a/tests/qemu-iotests/044 b/tests/qemu-iotests/044
30
index XXXXXXX..XXXXXXX 100755
31
--- a/tests/qemu-iotests/044
32
+++ b/tests/qemu-iotests/044
33
@@ -XXX,XX +XXX,XX @@ class TestRefcountTableGrowth(iotests.QMPTestCase):
34
35
if __name__ == '__main__':
36
iotests.main(supported_fmts=['qcow2'],
37
- supported_protocols=['file'])
38
+ supported_protocols=['file'],
39
+ unsupported_imgopts=['refcount_bits'])
40
diff --git a/tests/qemu-iotests/065 b/tests/qemu-iotests/065
41
index XXXXXXX..XXXXXXX 100755
42
--- a/tests/qemu-iotests/065
43
+++ b/tests/qemu-iotests/065
44
@@ -XXX,XX +XXX,XX @@ TestQMP = None
45
46
if __name__ == '__main__':
47
iotests.main(supported_fmts=['qcow2'],
48
- supported_protocols=['file'])
49
+ supported_protocols=['file'],
50
+ unsupported_imgopts=['refcount_bits'])
51
diff --git a/tests/qemu-iotests/163 b/tests/qemu-iotests/163
52
index XXXXXXX..XXXXXXX 100755
53
--- a/tests/qemu-iotests/163
54
+++ b/tests/qemu-iotests/163
55
@@ -XXX,XX +XXX,XX @@ ShrinkBaseClass = None
56
57
if __name__ == '__main__':
58
iotests.main(supported_fmts=['raw', 'qcow2'],
59
- supported_protocols=['file'])
60
+ supported_protocols=['file'],
61
+ unsupported_imgopts=['compat'])
62
diff --git a/tests/qemu-iotests/165 b/tests/qemu-iotests/165
63
index XXXXXXX..XXXXXXX 100755
64
--- a/tests/qemu-iotests/165
65
+++ b/tests/qemu-iotests/165
66
@@ -XXX,XX +XXX,XX @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase):
67
68
if __name__ == '__main__':
69
iotests.main(supported_fmts=['qcow2'],
70
- supported_protocols=['file'])
71
+ supported_protocols=['file'],
72
+ unsupported_imgopts=['compat'])
73
diff --git a/tests/qemu-iotests/196 b/tests/qemu-iotests/196
74
index XXXXXXX..XXXXXXX 100755
75
--- a/tests/qemu-iotests/196
76
+++ b/tests/qemu-iotests/196
77
@@ -XXX,XX +XXX,XX @@ class TestInvalidateAutoclear(iotests.QMPTestCase):
78
79
if __name__ == '__main__':
80
iotests.main(supported_fmts=['qcow2'],
81
- supported_protocols=['file'])
82
+ supported_protocols=['file'],
83
+ unsupported_imgopts=['compat'])
84
diff --git a/tests/qemu-iotests/242 b/tests/qemu-iotests/242
85
index XXXXXXX..XXXXXXX 100755
86
--- a/tests/qemu-iotests/242
87
+++ b/tests/qemu-iotests/242
88
@@ -XXX,XX +XXX,XX @@ from iotests import qemu_img_create, qemu_io, qemu_img_pipe, \
89
file_path, img_info_log, log, filter_qemu_io
90
91
iotests.script_initialize(supported_fmts=['qcow2'],
92
- supported_protocols=['file'])
93
+ supported_protocols=['file'],
94
+ unsupported_imgopts=['refcount_bits', 'compat'])
95
96
disk = file_path('disk')
97
chunk = 256 * 1024
98
diff --git a/tests/qemu-iotests/246 b/tests/qemu-iotests/246
99
index XXXXXXX..XXXXXXX 100755
100
--- a/tests/qemu-iotests/246
101
+++ b/tests/qemu-iotests/246
102
@@ -XXX,XX +XXX,XX @@
103
import iotests
104
from iotests import log
105
106
-iotests.script_initialize(supported_fmts=['qcow2'])
107
+iotests.script_initialize(supported_fmts=['qcow2'],
108
+ unsupported_imgopts=['compat'])
109
size = 64 * 1024 * 1024 * 1024
110
gran_small = 32 * 1024
111
gran_large = 128 * 1024
112
diff --git a/tests/qemu-iotests/254 b/tests/qemu-iotests/254
113
index XXXXXXX..XXXXXXX 100755
114
--- a/tests/qemu-iotests/254
115
+++ b/tests/qemu-iotests/254
116
@@ -XXX,XX +XXX,XX @@
117
import iotests
118
from iotests import qemu_img_create, file_path, log
119
120
-iotests.script_initialize(supported_fmts=['qcow2'])
121
+iotests.script_initialize(supported_fmts=['qcow2'],
122
+ unsupported_imgopts=['compat'])
123
124
disk, top = file_path('disk', 'top')
125
size = 1024 * 1024
126
diff --git a/tests/qemu-iotests/260 b/tests/qemu-iotests/260
127
index XXXXXXX..XXXXXXX 100755
128
--- a/tests/qemu-iotests/260
129
+++ b/tests/qemu-iotests/260
130
@@ -XXX,XX +XXX,XX @@ import iotests
131
from iotests import qemu_img_create, file_path, log, filter_qmp_event
132
133
iotests.script_initialize(
134
- supported_fmts=['qcow2']
135
+ supported_fmts=['qcow2'],
136
+ unsupported_imgopts=['compat']
137
)
138
139
base, top = file_path('base', 'top')
140
diff --git a/tests/qemu-iotests/274 b/tests/qemu-iotests/274
141
index XXXXXXX..XXXXXXX 100755
142
--- a/tests/qemu-iotests/274
143
+++ b/tests/qemu-iotests/274
144
@@ -XXX,XX +XXX,XX @@
145
import iotests
146
147
iotests.script_initialize(supported_fmts=['qcow2'],
148
- supported_platforms=['linux'])
149
+ supported_platforms=['linux'],
150
+ unsupported_imgopts=['refcount_bits', 'compat'])
151
152
size_short = 1 * 1024 * 1024
153
size_long = 2 * 1024 * 1024
154
diff --git a/tests/qemu-iotests/281 b/tests/qemu-iotests/281
155
index XXXXXXX..XXXXXXX 100755
156
--- a/tests/qemu-iotests/281
157
+++ b/tests/qemu-iotests/281
158
@@ -XXX,XX +XXX,XX @@ class TestBlockdevBackupAbort(iotests.QMPTestCase):
159
160
if __name__ == '__main__':
161
iotests.main(supported_fmts=['qcow2'],
162
- supported_protocols=['file'])
163
+ supported_protocols=['file'],
164
+ unsupported_imgopts=['compat'])
165
diff --git a/tests/qemu-iotests/303 b/tests/qemu-iotests/303
166
index XXXXXXX..XXXXXXX 100755
167
--- a/tests/qemu-iotests/303
168
+++ b/tests/qemu-iotests/303
169
@@ -XXX,XX +XXX,XX @@ import iotests
170
import subprocess
171
from iotests import qemu_img_create, qemu_io, file_path, log, filter_qemu_io
172
173
-iotests.script_initialize(supported_fmts=['qcow2'])
174
+iotests.script_initialize(supported_fmts=['qcow2'],
175
+ unsupported_imgopts=['refcount_bits', 'compat'])
176
177
disk = file_path('disk')
178
chunk = 1024 * 1024
179
diff --git a/tests/qemu-iotests/tests/migrate-bitmaps-postcopy-test b/tests/qemu-iotests/tests/migrate-bitmaps-postcopy-test
180
index XXXXXXX..XXXXXXX 100755
181
--- a/tests/qemu-iotests/tests/migrate-bitmaps-postcopy-test
182
+++ b/tests/qemu-iotests/tests/migrate-bitmaps-postcopy-test
183
@@ -XXX,XX +XXX,XX @@ class TestDirtyBitmapPostcopyMigration(iotests.QMPTestCase):
184
185
186
if __name__ == '__main__':
187
- iotests.main(supported_fmts=['qcow2'])
188
+ iotests.main(supported_fmts=['qcow2'],
189
+ unsupported_imgopts=['compat'])
190
diff --git a/tests/qemu-iotests/tests/migrate-bitmaps-test b/tests/qemu-iotests/tests/migrate-bitmaps-test
191
index XXXXXXX..XXXXXXX 100755
192
--- a/tests/qemu-iotests/tests/migrate-bitmaps-test
193
+++ b/tests/qemu-iotests/tests/migrate-bitmaps-test
194
@@ -XXX,XX +XXX,XX @@ def main() -> None:
195
196
iotests.main(
197
supported_fmts=['qcow2'],
198
- supported_protocols=['file']
199
+ supported_protocols=['file'],
200
+ unsupported_imgopts=['compat']
201
)
202
203
204
diff --git a/tests/qemu-iotests/tests/remove-bitmap-from-backing b/tests/qemu-iotests/tests/remove-bitmap-from-backing
205
index XXXXXXX..XXXXXXX 100755
206
--- a/tests/qemu-iotests/tests/remove-bitmap-from-backing
207
+++ b/tests/qemu-iotests/tests/remove-bitmap-from-backing
208
@@ -XXX,XX +XXX,XX @@
209
import iotests
210
from iotests import log, qemu_img_create, qemu_img, qemu_img_pipe
211
212
-iotests.script_initialize(supported_fmts=['qcow2'])
213
+iotests.script_initialize(supported_fmts=['qcow2'],
214
+ unsupported_imgopts=['compat'])
215
216
top, base = iotests.file_path('top', 'base')
217
size = '1M'
218
--
219
2.34.1
220
221
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
Adding support of IMGOPTS (like in bash tests) allows user to pass a
4
lot of different options. Still, some may require additional logic.
5
6
Now we want compression_type option, so add some smart logic around it:
7
ignore compression_type=zstd in IMGOPTS, if test want qcow2 in
8
compatibility mode. As well, ignore compression_type for non-qcow2
9
formats.
10
11
Note that we may instead add support only to qemu_img_create(), but
12
that works bad:
13
14
1. We'll have to update a lot of tests to use qemu_img_create instead
15
of qemu_img('create'). (still, we may want do it anyway, but no
16
reason to create a dependancy between task of supporting IMGOPTS and
17
updating a lot of tests)
18
19
2. Some tests use qemu_img_pipe('create', ..) - even more work on
20
updating
21
22
3. Even if we update all tests to go through qemu_img_create, we'll
23
need a way to avoid creating new tests using qemu_img*('create') -
24
add assertions.. That doesn't seem good.
25
26
So, let's add support of IMGOPTS to most generic
27
qemu_img_pipe_and_status().
28
29
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
30
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
31
Message-Id: <20211223160144.1097696-5-vsementsov@virtuozzo.com>
32
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
33
---
34
tests/qemu-iotests/iotests.py | 27 ++++++++++++++++++++++++++-
35
1 file changed, 26 insertions(+), 1 deletion(-)
36
37
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
38
index XXXXXXX..XXXXXXX 100644
39
--- a/tests/qemu-iotests/iotests.py
40
+++ b/tests/qemu-iotests/iotests.py
41
@@ -XXX,XX +XXX,XX @@
42
# along with this program. If not, see <http://www.gnu.org/licenses/>.
43
#
44
45
+import argparse
46
import atexit
47
import bz2
48
from collections import OrderedDict
49
@@ -XXX,XX +XXX,XX @@ def qemu_tool_pipe_and_status(tool: str, args: Sequence[str],
50
{-subp.returncode}: {cmd}\n')
51
return (output, subp.returncode)
52
53
+def qemu_img_create_prepare_args(args: List[str]) -> List[str]:
54
+ if not args or args[0] != 'create':
55
+ return list(args)
56
+ args = args[1:]
57
+
58
+ p = argparse.ArgumentParser(allow_abbrev=False)
59
+ p.add_argument('-f')
60
+ parsed, remaining = p.parse_known_args(args)
61
+
62
+ result = ['create']
63
+ if parsed.f is not None:
64
+ result += ['-f', parsed.f]
65
+
66
+ # IMGOPTS most probably contain options specific for the selected format,
67
+ # like extended_l2 or compression_type for qcow2. Test may want to create
68
+ # additional images in other formats that doesn't support these options.
69
+ # So, use IMGOPTS only for images created in imgfmt format.
70
+ if parsed.f == imgfmt and 'IMGOPTS' in os.environ:
71
+ result += ['-o', os.environ['IMGOPTS']]
72
+
73
+ result += remaining
74
+
75
+ return result
76
+
77
def qemu_img_pipe_and_status(*args: str) -> Tuple[str, int]:
78
"""
79
Run qemu-img and return both its output and its exit code
80
"""
81
- full_args = qemu_img_args + list(args)
82
+ full_args = qemu_img_args + qemu_img_create_prepare_args(list(args))
83
return qemu_tool_pipe_and_status('qemu-img', full_args)
84
85
def qemu_img(*args: str) -> int:
86
--
87
2.34.1
88
89
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
qemu_img_verbose() has a drawback of not going through generic
4
qemu_img_pipe_and_status(). qemu_img_verbose() is not very popular, so
5
update the only two users to qemu_img_log() and drop qemu_img_verbose()
6
at all.
7
8
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
9
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
10
Message-Id: <20211223160144.1097696-6-vsementsov@virtuozzo.com>
11
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
12
---
13
tests/qemu-iotests/044 | 5 +++--
14
tests/qemu-iotests/044.out | 1 +
15
tests/qemu-iotests/209 | 7 ++++---
16
tests/qemu-iotests/209.out | 2 ++
17
tests/qemu-iotests/iotests.py | 8 --------
18
5 files changed, 10 insertions(+), 13 deletions(-)
19
20
diff --git a/tests/qemu-iotests/044 b/tests/qemu-iotests/044
21
index XXXXXXX..XXXXXXX 100755
22
--- a/tests/qemu-iotests/044
23
+++ b/tests/qemu-iotests/044
24
@@ -XXX,XX +XXX,XX @@ import os
25
import qcow2
26
from qcow2 import QcowHeader
27
import iotests
28
-from iotests import qemu_img, qemu_img_verbose, qemu_io
29
+from iotests import qemu_img, qemu_img_log, qemu_io
30
import struct
31
import subprocess
32
import sys
33
@@ -XXX,XX +XXX,XX @@ class TestRefcountTableGrowth(iotests.QMPTestCase):
34
35
def test_grow_refcount_table(self):
36
qemu_io('-c', 'write 3800M 1M', test_img)
37
- qemu_img_verbose('check' , test_img)
38
+ qemu_img_log('check' , test_img)
39
pass
40
41
if __name__ == '__main__':
42
+ iotests.activate_logging()
43
iotests.main(supported_fmts=['qcow2'],
44
supported_protocols=['file'],
45
unsupported_imgopts=['refcount_bits'])
46
diff --git a/tests/qemu-iotests/044.out b/tests/qemu-iotests/044.out
47
index XXXXXXX..XXXXXXX 100644
48
--- a/tests/qemu-iotests/044.out
49
+++ b/tests/qemu-iotests/044.out
50
@@ -XXX,XX +XXX,XX @@
51
No errors were found on the image.
52
7292415/33554432 = 21.73% allocated, 0.00% fragmented, 0.00% compressed clusters
53
Image end offset: 4296217088
54
+
55
.
56
----------------------------------------------------------------------
57
Ran 1 tests
58
diff --git a/tests/qemu-iotests/209 b/tests/qemu-iotests/209
59
index XXXXXXX..XXXXXXX 100755
60
--- a/tests/qemu-iotests/209
61
+++ b/tests/qemu-iotests/209
62
@@ -XXX,XX +XXX,XX @@
63
#
64
65
import iotests
66
-from iotests import qemu_img_create, qemu_io, qemu_img_verbose, qemu_nbd, \
67
- file_path
68
+from iotests import qemu_img_create, qemu_io, qemu_img_log, qemu_nbd, \
69
+ file_path, log
70
71
iotests.script_initialize(supported_fmts=['qcow2'])
72
73
@@ -XXX,XX +XXX,XX @@ qemu_img_create('-f', iotests.imgfmt, disk, '1M')
74
qemu_io('-f', iotests.imgfmt, '-c', 'write 0 512K', disk)
75
76
qemu_nbd('-k', nbd_sock, '-x', 'exp', '-f', iotests.imgfmt, disk)
77
-qemu_img_verbose('map', '-f', 'raw', '--output=json', nbd_uri)
78
+qemu_img_log('map', '-f', 'raw', '--output=json', nbd_uri)
79
+log('done.') # avoid new line at the end of output file
80
diff --git a/tests/qemu-iotests/209.out b/tests/qemu-iotests/209.out
81
index XXXXXXX..XXXXXXX 100644
82
--- a/tests/qemu-iotests/209.out
83
+++ b/tests/qemu-iotests/209.out
84
@@ -XXX,XX +XXX,XX @@
85
[{ "start": 0, "length": 524288, "depth": 0, "present": true, "zero": false, "data": true, "offset": 0},
86
{ "start": 524288, "length": 524288, "depth": 0, "present": true, "zero": true, "data": false, "offset": 524288}]
87
+
88
+done.
89
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
90
index XXXXXXX..XXXXXXX 100644
91
--- a/tests/qemu-iotests/iotests.py
92
+++ b/tests/qemu-iotests/iotests.py
93
@@ -XXX,XX +XXX,XX @@ def qemu_img_measure(*args):
94
def qemu_img_check(*args):
95
return json.loads(qemu_img_pipe("check", "--output", "json", *args))
96
97
-def qemu_img_verbose(*args):
98
- '''Run qemu-img without suppressing its output and return the exit code'''
99
- exitcode = subprocess.call(qemu_img_args + list(args))
100
- if exitcode < 0:
101
- sys.stderr.write('qemu-img received signal %i: %s\n'
102
- % (-exitcode, ' '.join(qemu_img_args + list(args))))
103
- return exitcode
104
-
105
def qemu_img_pipe(*args: str) -> str:
106
'''Run qemu-img and return its output'''
107
return qemu_img_pipe_and_status(*args)[0]
108
--
109
2.34.1
110
111
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
Move the logic to more generic qemu_img_pipe_and_status(). Also behave
4
better when we have several -o options. And reuse argument parser of
5
course.
6
7
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
8
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
9
Message-Id: <20211223160144.1097696-7-vsementsov@virtuozzo.com>
10
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
11
---
12
tests/qemu-iotests/iotests.py | 36 +++++++++++++++++------------------
13
1 file changed, 17 insertions(+), 19 deletions(-)
14
15
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
16
index XXXXXXX..XXXXXXX 100644
17
--- a/tests/qemu-iotests/iotests.py
18
+++ b/tests/qemu-iotests/iotests.py
19
@@ -XXX,XX +XXX,XX @@ def qemu_img_create_prepare_args(args: List[str]) -> List[str]:
20
args = args[1:]
21
22
p = argparse.ArgumentParser(allow_abbrev=False)
23
+ # -o option may be specified several times
24
+ p.add_argument('-o', action='append', default=[])
25
p.add_argument('-f')
26
parsed, remaining = p.parse_known_args(args)
27
28
+ opts_list = parsed.o
29
+
30
result = ['create']
31
if parsed.f is not None:
32
result += ['-f', parsed.f]
33
@@ -XXX,XX +XXX,XX @@ def qemu_img_create_prepare_args(args: List[str]) -> List[str]:
34
# like extended_l2 or compression_type for qcow2. Test may want to create
35
# additional images in other formats that doesn't support these options.
36
# So, use IMGOPTS only for images created in imgfmt format.
37
- if parsed.f == imgfmt and 'IMGOPTS' in os.environ:
38
- result += ['-o', os.environ['IMGOPTS']]
39
+ imgopts = os.environ.get('IMGOPTS')
40
+ if imgopts and parsed.f == imgfmt:
41
+ opts_list.insert(0, imgopts)
42
+
43
+ # default luks support
44
+ if parsed.f == 'luks' and \
45
+ all('key-secret' not in opts for opts in opts_list):
46
+ result += ['--object', luks_default_secret_object]
47
+ opts_list.append(luks_default_key_secret_opt)
48
+
49
+ for opts in opts_list:
50
+ result += ['-o', opts]
51
52
result += remaining
53
54
@@ -XXX,XX +XXX,XX @@ def ordered_qmp(qmsg, conv_keys=True):
55
return qmsg
56
57
def qemu_img_create(*args):
58
- args = list(args)
59
-
60
- # default luks support
61
- if '-f' in args and args[args.index('-f') + 1] == 'luks':
62
- if '-o' in args:
63
- i = args.index('-o')
64
- if 'key-secret' not in args[i + 1]:
65
- args[i + 1].append(luks_default_key_secret_opt)
66
- args.insert(i + 2, '--object')
67
- args.insert(i + 3, luks_default_secret_object)
68
- else:
69
- args = ['-o', luks_default_key_secret_opt,
70
- '--object', luks_default_secret_object] + args
71
-
72
- args.insert(0, 'create')
73
-
74
- return qemu_img(*args)
75
+ return qemu_img('create', *args)
76
77
def qemu_img_measure(*args):
78
return json.loads(qemu_img_pipe("measure", "--output", "json", *args))
79
--
80
2.34.1
81
82
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
The test prints qcow2 header fields which depends on chosen compression
4
type. So, let's be explicit in what compression type we want and
5
independent of IMGOPTS. Test both existing compression types.
6
7
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
9
Message-Id: <20211223160144.1097696-8-vsementsov@virtuozzo.com>
10
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
11
---
12
tests/qemu-iotests/303 | 25 ++++++++++++++++---------
13
tests/qemu-iotests/303.out | 30 +++++++++++++++++++++++++++++-
14
2 files changed, 45 insertions(+), 10 deletions(-)
15
16
diff --git a/tests/qemu-iotests/303 b/tests/qemu-iotests/303
17
index XXXXXXX..XXXXXXX 100755
18
--- a/tests/qemu-iotests/303
19
+++ b/tests/qemu-iotests/303
20
@@ -XXX,XX +XXX,XX @@ def add_bitmap(num, begin, end, disabled):
21
log('')
22
23
24
-qemu_img_create('-f', iotests.imgfmt, disk, '10M')
25
-
26
-add_bitmap(1, 0, 6, False)
27
-add_bitmap(2, 6, 8, True)
28
-dump = ['./qcow2.py', disk, 'dump-header']
29
-subprocess.run(dump)
30
-# Dump the metadata in JSON format
31
-dump.append('-j')
32
-subprocess.run(dump)
33
+def test(compression_type: str, json_output: bool) -> None:
34
+ qemu_img_create('-f', iotests.imgfmt,
35
+ '-o', f'compression_type={compression_type}',
36
+ disk, '10M')
37
+ add_bitmap(1, 0, 6, False)
38
+ add_bitmap(2, 6, 8, True)
39
+
40
+ cmd = ['./qcow2.py', disk, 'dump-header']
41
+ if json_output:
42
+ cmd.append('-j')
43
+
44
+ subprocess.run(cmd)
45
+
46
+
47
+test('zlib', False)
48
+test('zstd', True)
49
diff --git a/tests/qemu-iotests/303.out b/tests/qemu-iotests/303.out
50
index XXXXXXX..XXXXXXX 100644
51
--- a/tests/qemu-iotests/303.out
52
+++ b/tests/qemu-iotests/303.out
53
@@ -XXX,XX +XXX,XX @@ extra_data_size 0
54
Bitmap table type size offset
55
0 all-zeroes 0 0
56
57
+Add bitmap 1
58
+wrote 1048576/1048576 bytes at offset 0
59
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
60
+
61
+wrote 1048576/1048576 bytes at offset 1048576
62
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
63
+
64
+wrote 1048576/1048576 bytes at offset 2097152
65
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
66
+
67
+wrote 1048576/1048576 bytes at offset 3145728
68
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
69
+
70
+wrote 1048576/1048576 bytes at offset 4194304
71
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
72
+
73
+wrote 1048576/1048576 bytes at offset 5242880
74
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
75
+
76
+
77
+Add bitmap 2
78
+wrote 1048576/1048576 bytes at offset 6291456
79
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
80
+
81
+wrote 1048576/1048576 bytes at offset 7340032
82
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
83
+
84
+
85
{
86
"magic": 1363560955,
87
"version": 3,
88
@@ -XXX,XX +XXX,XX @@ Bitmap table type size offset
89
"refcount_table_clusters": 1,
90
"nb_snapshots": 0,
91
"snapshot_offset": 0,
92
- "incompatible_features": 0,
93
+ "incompatible_features": 8,
94
"compatible_features": 0,
95
"autoclear_features": 1,
96
"refcount_order": 4,
97
--
98
2.34.1
99
100
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
The test checks different options. It of course fails if set
4
IMGOPTS='compression_type=zstd'. So, let's be explicit in what
5
compression type we want and independent of IMGOPTS. Test both existing
6
compression types.
7
8
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
9
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
10
Message-Id: <20211223160144.1097696-9-vsementsov@virtuozzo.com>
11
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
12
---
13
tests/qemu-iotests/065 | 16 ++++++++--------
14
1 file changed, 8 insertions(+), 8 deletions(-)
15
16
diff --git a/tests/qemu-iotests/065 b/tests/qemu-iotests/065
17
index XXXXXXX..XXXXXXX 100755
18
--- a/tests/qemu-iotests/065
19
+++ b/tests/qemu-iotests/065
20
@@ -XXX,XX +XXX,XX @@ class TestQMP(TestImageInfoSpecific):
21
22
class TestQCow2(TestQemuImgInfo):
23
'''Testing a qcow2 version 2 image'''
24
- img_options = 'compat=0.10'
25
+ img_options = 'compat=0.10,compression_type=zlib'
26
json_compare = { 'compat': '0.10', 'refcount-bits': 16,
27
'compression-type': 'zlib' }
28
human_compare = [ 'compat: 0.10', 'compression type: zlib',
29
@@ -XXX,XX +XXX,XX @@ class TestQCow2(TestQemuImgInfo):
30
31
class TestQCow3NotLazy(TestQemuImgInfo):
32
'''Testing a qcow2 version 3 image with lazy refcounts disabled'''
33
- img_options = 'compat=1.1,lazy_refcounts=off'
34
+ img_options = 'compat=1.1,lazy_refcounts=off,compression_type=zstd'
35
json_compare = { 'compat': '1.1', 'lazy-refcounts': False,
36
'refcount-bits': 16, 'corrupt': False,
37
- 'compression-type': 'zlib', 'extended-l2': False }
38
- human_compare = [ 'compat: 1.1', 'compression type: zlib',
39
+ 'compression-type': 'zstd', 'extended-l2': False }
40
+ human_compare = [ 'compat: 1.1', 'compression type: zstd',
41
'lazy refcounts: false', 'refcount bits: 16',
42
'corrupt: false', 'extended l2: false' ]
43
44
class TestQCow3Lazy(TestQemuImgInfo):
45
'''Testing a qcow2 version 3 image with lazy refcounts enabled'''
46
- img_options = 'compat=1.1,lazy_refcounts=on'
47
+ img_options = 'compat=1.1,lazy_refcounts=on,compression_type=zlib'
48
json_compare = { 'compat': '1.1', 'lazy-refcounts': True,
49
'refcount-bits': 16, 'corrupt': False,
50
'compression-type': 'zlib', 'extended-l2': False }
51
@@ -XXX,XX +XXX,XX @@ class TestQCow3Lazy(TestQemuImgInfo):
52
class TestQCow3NotLazyQMP(TestQMP):
53
'''Testing a qcow2 version 3 image with lazy refcounts disabled, opening
54
with lazy refcounts enabled'''
55
- img_options = 'compat=1.1,lazy_refcounts=off'
56
+ img_options = 'compat=1.1,lazy_refcounts=off,compression_type=zlib'
57
qemu_options = 'lazy-refcounts=on'
58
compare = { 'compat': '1.1', 'lazy-refcounts': False,
59
'refcount-bits': 16, 'corrupt': False,
60
@@ -XXX,XX +XXX,XX @@ class TestQCow3NotLazyQMP(TestQMP):
61
class TestQCow3LazyQMP(TestQMP):
62
'''Testing a qcow2 version 3 image with lazy refcounts enabled, opening
63
with lazy refcounts disabled'''
64
- img_options = 'compat=1.1,lazy_refcounts=on'
65
+ img_options = 'compat=1.1,lazy_refcounts=on,compression_type=zstd'
66
qemu_options = 'lazy-refcounts=off'
67
compare = { 'compat': '1.1', 'lazy-refcounts': True,
68
'refcount-bits': 16, 'corrupt': False,
69
- 'compression-type': 'zlib', 'extended-l2': False }
70
+ 'compression-type': 'zstd', 'extended-l2': False }
71
72
TestImageInfoSpecific = None
73
TestQemuImgInfo = None
74
--
75
2.34.1
76
77
diff view generated by jsdifflib
1
A few block drivers will set the BDS read_only flag from their
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
.bdrv_open() function. This means the bs->read_only flag could
3
be set after we enable copy_on_read, as the BDRV_O_COPY_ON_READ
4
flag check occurs prior to the call to bdrv->bdrv_open().
5
2
6
This adds an error return to bdrv_set_read_only(), and an error will be
3
The only "feature" of this "Formatting ..." line is that we have to
7
return if we try to set the BDS to read_only while copy_on_read is
4
update it every time we add new option. Let's drop it.
8
enabled.
9
5
10
This patch also changes the behavior of vvfat. Before, vvfat could
6
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
11
override the drive 'readonly' flag with its own, internal 'rw' flag.
7
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
8
Message-Id: <20211223160144.1097696-10-vsementsov@virtuozzo.com>
9
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
10
---
11
tests/qemu-iotests/149.out | 21 ---------------------
12
tests/qemu-iotests/237.out | 3 ---
13
tests/qemu-iotests/255.out | 4 ----
14
tests/qemu-iotests/274.out | 29 -----------------------------
15
tests/qemu-iotests/280.out | 1 -
16
tests/qemu-iotests/296.out | 10 +++-------
17
tests/qemu-iotests/iotests.py | 10 ++++++++--
18
7 files changed, 11 insertions(+), 67 deletions(-)
12
19
13
For instance, this -drive parameter would result in a writable image:
20
diff --git a/tests/qemu-iotests/149.out b/tests/qemu-iotests/149.out
14
21
index XXXXXXX..XXXXXXX 100644
15
"-drive format=vvfat,dir=/tmp/vvfat,rw,if=virtio,readonly=on"
22
--- a/tests/qemu-iotests/149.out
16
23
+++ b/tests/qemu-iotests/149.out
17
This is not correct. Now, attempting to use the above -drive parameter
24
@@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-xts-plain64-sha1.img
18
will result in an error (i.e., 'rw' is incompatible with 'readonly=on').
25
# ================= qemu-img aes-256-xts-plain64-sha1 =================
19
26
# Create image
20
Signed-off-by: Jeff Cody <jcody@redhat.com>
27
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-aes-256-xts-plain64-sha1.img 4194304M
21
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
28
-Formatting 'TEST_DIR/luks-aes-256-xts-plain64-sha1.img', fmt=luks size=4398046511104 key-secret=sec0 cipher-alg=aes-256 cipher-mode=xts ivgen-alg=plain64 hash-alg=sha1 iter-time=10
22
Reviewed-by: John Snow <jsnow@redhat.com>
29
23
Message-id: 0c5b4c1cc2c651471b131f21376dfd5ea24d2196.1491597120.git.jcody@redhat.com
30
# Open dev
24
---
31
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha1.img qiotest-145-aes-256-xts-plain64-sha1
25
block.c | 10 +++++++++-
32
@@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-twofish-256-xts-plain64-sha1.img
26
block/bochs.c | 5 ++++-
33
# ================= qemu-img twofish-256-xts-plain64-sha1 =================
27
block/cloop.c | 5 ++++-
34
# Create image
28
block/dmg.c | 6 +++++-
35
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=twofish-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-twofish-256-xts-plain64-sha1.img 4194304M
29
block/rbd.c | 11 ++++++++++-
36
-Formatting 'TEST_DIR/luks-twofish-256-xts-plain64-sha1.img', fmt=luks size=4398046511104 key-secret=sec0 cipher-alg=twofish-256 cipher-mode=xts ivgen-alg=plain64 hash-alg=sha1 iter-time=10
30
block/vvfat.c | 19 +++++++++++++++----
37
31
include/block/block.h | 2 +-
38
# Open dev
32
7 files changed, 48 insertions(+), 10 deletions(-)
39
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-twofish-256-xts-plain64-sha1.img qiotest-145-twofish-256-xts-plain64-sha1
33
40
@@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-serpent-256-xts-plain64-sha1.img
34
diff --git a/block.c b/block.c
41
# ================= qemu-img serpent-256-xts-plain64-sha1 =================
35
index XXXXXXX..XXXXXXX 100644
42
# Create image
36
--- a/block.c
43
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=serpent-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-serpent-256-xts-plain64-sha1.img 4194304M
37
+++ b/block.c
44
-Formatting 'TEST_DIR/luks-serpent-256-xts-plain64-sha1.img', fmt=luks size=4398046511104 key-secret=sec0 cipher-alg=serpent-256 cipher-mode=xts ivgen-alg=plain64 hash-alg=sha1 iter-time=10
38
@@ -XXX,XX +XXX,XX @@ void path_combine(char *dest, int dest_size,
45
39
}
46
# Open dev
40
}
47
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-serpent-256-xts-plain64-sha1.img qiotest-145-serpent-256-xts-plain64-sha1
41
48
@@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-cast5-128-cbc-plain64-sha1.img
42
-void bdrv_set_read_only(BlockDriverState *bs, bool read_only)
49
# ================= qemu-img cast5-128-cbc-plain64-sha1 =================
43
+int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
50
# Create image
44
{
51
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=cast5-128,cipher-mode=cbc,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-cast5-128-cbc-plain64-sha1.img 4194304M
45
+ /* Do not set read_only if copy_on_read is enabled */
52
-Formatting 'TEST_DIR/luks-cast5-128-cbc-plain64-sha1.img', fmt=luks size=4398046511104 key-secret=sec0 cipher-alg=cast5-128 cipher-mode=cbc ivgen-alg=plain64 hash-alg=sha1 iter-time=10
46
+ if (bs->copy_on_read && read_only) {
53
47
+ error_setg(errp, "Can't set node '%s' to r/o with copy-on-read enabled",
54
# Open dev
48
+ bdrv_get_device_or_node_name(bs));
55
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-cast5-128-cbc-plain64-sha1.img qiotest-145-cast5-128-cbc-plain64-sha1
49
+ return -EINVAL;
56
@@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-cbc-plain-sha1.img
50
+ }
57
# ================= qemu-img aes-256-cbc-plain-sha1 =================
51
+
58
# Create image
52
bs->read_only = read_only;
59
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=cbc,ivgen-alg=plain,hash-alg=sha1 TEST_DIR/luks-aes-256-cbc-plain-sha1.img 4194304M
53
+ return 0;
60
-Formatting 'TEST_DIR/luks-aes-256-cbc-plain-sha1.img', fmt=luks size=4398046511104 key-secret=sec0 cipher-alg=aes-256 cipher-mode=cbc ivgen-alg=plain hash-alg=sha1 iter-time=10
54
}
61
55
62
# Open dev
56
void bdrv_get_full_backing_filename_from_filename(const char *backed,
63
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-plain-sha1.img qiotest-145-aes-256-cbc-plain-sha1
57
diff --git a/block/bochs.c b/block/bochs.c
64
@@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-cbc-plain64-sha1.img
58
index XXXXXXX..XXXXXXX 100644
65
# ================= qemu-img aes-256-cbc-plain64-sha1 =================
59
--- a/block/bochs.c
66
# Create image
60
+++ b/block/bochs.c
67
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=cbc,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-aes-256-cbc-plain64-sha1.img 4194304M
61
@@ -XXX,XX +XXX,XX @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
68
-Formatting 'TEST_DIR/luks-aes-256-cbc-plain64-sha1.img', fmt=luks size=4398046511104 key-secret=sec0 cipher-alg=aes-256 cipher-mode=cbc ivgen-alg=plain64 hash-alg=sha1 iter-time=10
62
return -EINVAL;
69
63
}
70
# Open dev
64
71
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-plain64-sha1.img qiotest-145-aes-256-cbc-plain64-sha1
65
- bdrv_set_read_only(bs, true); /* no write support yet */
72
@@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-cbc-essiv-sha256-sha1.img
66
+ ret = bdrv_set_read_only(bs, true, errp); /* no write support yet */
73
# ================= qemu-img aes-256-cbc-essiv-sha256-sha1 =================
67
+ if (ret < 0) {
74
# Create image
68
+ return ret;
75
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=cbc,ivgen-alg=essiv,hash-alg=sha1,ivgen-hash-alg=sha256 TEST_DIR/luks-aes-256-cbc-essiv-sha256-sha1.img 4194304M
69
+ }
76
-Formatting 'TEST_DIR/luks-aes-256-cbc-essiv-sha256-sha1.img', fmt=luks size=4398046511104 key-secret=sec0 cipher-alg=aes-256 cipher-mode=cbc ivgen-alg=essiv ivgen-hash-alg=sha256 hash-alg=sha1 iter-time=10
70
77
71
ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs));
78
# Open dev
72
if (ret < 0) {
79
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-essiv-sha256-sha1.img qiotest-145-aes-256-cbc-essiv-sha256-sha1
73
diff --git a/block/cloop.c b/block/cloop.c
80
@@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-xts-essiv-sha256-sha1.img
74
index XXXXXXX..XXXXXXX 100644
81
# ================= qemu-img aes-256-xts-essiv-sha256-sha1 =================
75
--- a/block/cloop.c
82
# Create image
76
+++ b/block/cloop.c
83
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=essiv,hash-alg=sha1,ivgen-hash-alg=sha256 TEST_DIR/luks-aes-256-xts-essiv-sha256-sha1.img 4194304M
77
@@ -XXX,XX +XXX,XX @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags,
84
-Formatting 'TEST_DIR/luks-aes-256-xts-essiv-sha256-sha1.img', fmt=luks size=4398046511104 key-secret=sec0 cipher-alg=aes-256 cipher-mode=xts ivgen-alg=essiv ivgen-hash-alg=sha256 hash-alg=sha1 iter-time=10
78
return -EINVAL;
85
79
}
86
# Open dev
80
87
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-essiv-sha256-sha1.img qiotest-145-aes-256-xts-essiv-sha256-sha1
81
- bdrv_set_read_only(bs, true);
88
@@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-128-xts-plain64-sha256-sha1.img
82
+ ret = bdrv_set_read_only(bs, true, errp);
89
# ================= qemu-img aes-128-xts-plain64-sha256-sha1 =================
83
+ if (ret < 0) {
90
# Create image
84
+ return ret;
91
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-128,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-aes-128-xts-plain64-sha256-sha1.img 4194304M
85
+ }
92
-Formatting 'TEST_DIR/luks-aes-128-xts-plain64-sha256-sha1.img', fmt=luks size=4398046511104 key-secret=sec0 cipher-alg=aes-128 cipher-mode=xts ivgen-alg=plain64 hash-alg=sha1 iter-time=10
86
93
87
/* read header */
94
# Open dev
88
ret = bdrv_pread(bs->file, 128, &s->block_size, 4);
95
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-128-xts-plain64-sha256-sha1.img qiotest-145-aes-128-xts-plain64-sha256-sha1
89
diff --git a/block/dmg.c b/block/dmg.c
96
@@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-192-xts-plain64-sha256-sha1.img
90
index XXXXXXX..XXXXXXX 100644
97
# ================= qemu-img aes-192-xts-plain64-sha256-sha1 =================
91
--- a/block/dmg.c
98
# Create image
92
+++ b/block/dmg.c
99
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-192,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-aes-192-xts-plain64-sha256-sha1.img 4194304M
93
@@ -XXX,XX +XXX,XX @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags,
100
-Formatting 'TEST_DIR/luks-aes-192-xts-plain64-sha256-sha1.img', fmt=luks size=4398046511104 key-secret=sec0 cipher-alg=aes-192 cipher-mode=xts ivgen-alg=plain64 hash-alg=sha1 iter-time=10
94
return -EINVAL;
101
95
}
102
# Open dev
96
103
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-192-xts-plain64-sha256-sha1.img qiotest-145-aes-192-xts-plain64-sha256-sha1
97
+ ret = bdrv_set_read_only(bs, true, errp);
104
@@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-twofish-128-xts-plain64-sha1.img
98
+ if (ret < 0) {
105
# ================= qemu-img twofish-128-xts-plain64-sha1 =================
99
+ return ret;
106
# Create image
100
+ }
107
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=twofish-128,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-twofish-128-xts-plain64-sha1.img 4194304M
101
+
108
-Formatting 'TEST_DIR/luks-twofish-128-xts-plain64-sha1.img', fmt=luks size=4398046511104 key-secret=sec0 cipher-alg=twofish-128 cipher-mode=xts ivgen-alg=plain64 hash-alg=sha1 iter-time=10
102
block_module_load_one("dmg-bz2");
109
103
- bdrv_set_read_only(bs, true);
110
# Open dev
104
111
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-twofish-128-xts-plain64-sha1.img qiotest-145-twofish-128-xts-plain64-sha1
105
s->n_chunks = 0;
112
@@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-serpent-128-xts-plain64-sha1.img
106
s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL;
113
# ================= qemu-img serpent-128-xts-plain64-sha1 =================
107
diff --git a/block/rbd.c b/block/rbd.c
114
# Create image
108
index XXXXXXX..XXXXXXX 100644
115
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=serpent-128,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-serpent-128-xts-plain64-sha1.img 4194304M
109
--- a/block/rbd.c
116
-Formatting 'TEST_DIR/luks-serpent-128-xts-plain64-sha1.img', fmt=luks size=4398046511104 key-secret=sec0 cipher-alg=serpent-128 cipher-mode=xts ivgen-alg=plain64 hash-alg=sha1 iter-time=10
110
+++ b/block/rbd.c
117
111
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
118
# Open dev
112
goto failed_shutdown;
119
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-serpent-128-xts-plain64-sha1.img qiotest-145-serpent-128-xts-plain64-sha1
113
}
120
@@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-serpent-192-xts-plain64-sha1.img
114
121
# ================= qemu-img serpent-192-xts-plain64-sha1 =================
115
+ /* rbd_open is always r/w */
122
# Create image
116
r = rbd_open(s->io_ctx, s->name, &s->image, s->snap);
123
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=serpent-192,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-serpent-192-xts-plain64-sha1.img 4194304M
117
if (r < 0) {
124
-Formatting 'TEST_DIR/luks-serpent-192-xts-plain64-sha1.img', fmt=luks size=4398046511104 key-secret=sec0 cipher-alg=serpent-192 cipher-mode=xts ivgen-alg=plain64 hash-alg=sha1 iter-time=10
118
error_setg_errno(errp, -r, "error reading header from %s", s->name);
125
119
goto failed_open;
126
# Open dev
120
}
127
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-serpent-192-xts-plain64-sha1.img qiotest-145-serpent-192-xts-plain64-sha1
121
128
@@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-xts-plain64-sha224.img
122
- bdrv_set_read_only(bs, (s->snap != NULL));
129
# ================= qemu-img aes-256-xts-plain64-sha224 =================
123
+ /* If we are using an rbd snapshot, we must be r/o, otherwise
130
# Create image
124
+ * leave as-is */
131
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha224 TEST_DIR/luks-aes-256-xts-plain64-sha224.img 4194304M
125
+ if (s->snap != NULL) {
132
-Formatting 'TEST_DIR/luks-aes-256-xts-plain64-sha224.img', fmt=luks size=4398046511104 key-secret=sec0 cipher-alg=aes-256 cipher-mode=xts ivgen-alg=plain64 hash-alg=sha224 iter-time=10
126
+ r = bdrv_set_read_only(bs, true, &local_err);
133
127
+ if (r < 0) {
134
# Open dev
128
+ error_propagate(errp, local_err);
135
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha224.img qiotest-145-aes-256-xts-plain64-sha224
129
+ goto failed_open;
136
@@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-xts-plain64-sha256.img
130
+ }
137
# ================= qemu-img aes-256-xts-plain64-sha256 =================
131
+ }
138
# Create image
132
139
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha256 TEST_DIR/luks-aes-256-xts-plain64-sha256.img 4194304M
133
qemu_opts_del(opts);
140
-Formatting 'TEST_DIR/luks-aes-256-xts-plain64-sha256.img', fmt=luks size=4398046511104 key-secret=sec0 cipher-alg=aes-256 cipher-mode=xts ivgen-alg=plain64 hash-alg=sha256 iter-time=10
134
return 0;
141
135
diff --git a/block/vvfat.c b/block/vvfat.c
142
# Open dev
136
index XXXXXXX..XXXXXXX 100644
143
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha256.img qiotest-145-aes-256-xts-plain64-sha256
137
--- a/block/vvfat.c
144
@@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-xts-plain64-sha384.img
138
+++ b/block/vvfat.c
145
# ================= qemu-img aes-256-xts-plain64-sha384 =================
139
@@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
146
# Create image
140
147
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha384 TEST_DIR/luks-aes-256-xts-plain64-sha384.img 4194304M
141
s->current_cluster=0xffffffff;
148
-Formatting 'TEST_DIR/luks-aes-256-xts-plain64-sha384.img', fmt=luks size=4398046511104 key-secret=sec0 cipher-alg=aes-256 cipher-mode=xts ivgen-alg=plain64 hash-alg=sha384 iter-time=10
142
149
143
- /* read only is the default for safety */
150
# Open dev
144
- bdrv_set_read_only(bs, true);
151
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha384.img qiotest-145-aes-256-xts-plain64-sha384
145
s->qcow = NULL;
152
@@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-xts-plain64-sha512.img
146
s->qcow_filename = NULL;
153
# ================= qemu-img aes-256-xts-plain64-sha512 =================
147
s->fat2 = NULL;
154
# Create image
148
@@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
155
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha512 TEST_DIR/luks-aes-256-xts-plain64-sha512.img 4194304M
149
s->sector_count = cyls * heads * secs - (s->first_sectors_number - 1);
156
-Formatting 'TEST_DIR/luks-aes-256-xts-plain64-sha512.img', fmt=luks size=4398046511104 key-secret=sec0 cipher-alg=aes-256 cipher-mode=xts ivgen-alg=plain64 hash-alg=sha512 iter-time=10
150
157
151
if (qemu_opt_get_bool(opts, "rw", false)) {
158
# Open dev
152
- ret = enable_write_target(bs, errp);
159
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha512.img qiotest-145-aes-256-xts-plain64-sha512
153
+ if (!bdrv_is_read_only(bs)) {
160
@@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-xts-plain64-ripemd160.img
154
+ ret = enable_write_target(bs, errp);
161
# ================= qemu-img aes-256-xts-plain64-ripemd160 =================
155
+ if (ret < 0) {
162
# Create image
156
+ goto fail;
163
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=ripemd160 TEST_DIR/luks-aes-256-xts-plain64-ripemd160.img 4194304M
157
+ }
164
-Formatting 'TEST_DIR/luks-aes-256-xts-plain64-ripemd160.img', fmt=luks size=4398046511104 key-secret=sec0 cipher-alg=aes-256 cipher-mode=xts ivgen-alg=plain64 hash-alg=ripemd160 iter-time=10
158
+ } else {
165
159
+ ret = -EPERM;
166
# Open dev
160
+ error_setg(errp,
167
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-ripemd160.img qiotest-145-aes-256-xts-plain64-ripemd160
161
+ "Unable to set VVFAT to 'rw' when drive is read-only");
168
@@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-xts-plain-sha1-pwallslots.img
162
+ goto fail;
169
# ================= qemu-img aes-256-xts-plain-sha1-pwallslots =================
163
+ }
170
# Create image
164
+ } else {
171
qemu-img create -f luks --object secret,id=sec0,data=c2xvdDE=,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain,hash-alg=sha1 TEST_DIR/luks-aes-256-xts-plain-sha1-pwallslots.img 4194304M
165
+ /* read only is the default for safety */
172
-Formatting 'TEST_DIR/luks-aes-256-xts-plain-sha1-pwallslots.img', fmt=luks size=4398046511104 key-secret=sec0 cipher-alg=aes-256 cipher-mode=xts ivgen-alg=plain hash-alg=sha1 iter-time=10
166
+ ret = bdrv_set_read_only(bs, true, &local_err);
173
167
if (ret < 0) {
174
# Open dev
168
+ error_propagate(errp, local_err);
175
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain-sha1-pwallslots.img qiotest-145-aes-256-xts-plain-sha1-pwallslots
169
goto fail;
176
@@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-cbc-essiv-auto-sha1.img
170
}
177
# ================= qemu-img aes-256-cbc-essiv-auto-sha1 =================
171
- bdrv_set_read_only(bs, false);
178
# Create image
172
}
179
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=cbc,ivgen-alg=essiv,hash-alg=sha1 TEST_DIR/luks-aes-256-cbc-essiv-auto-sha1.img 4194304M
173
180
-Formatting 'TEST_DIR/luks-aes-256-cbc-essiv-auto-sha1.img', fmt=luks size=4398046511104 key-secret=sec0 cipher-alg=aes-256 cipher-mode=cbc ivgen-alg=essiv hash-alg=sha1 iter-time=10
174
bs->total_sectors = cyls * heads * secs;
181
175
diff --git a/include/block/block.h b/include/block/block.h
182
# Open dev
176
index XXXXXXX..XXXXXXX 100644
183
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-essiv-auto-sha1.img qiotest-145-aes-256-cbc-essiv-auto-sha1
177
--- a/include/block/block.h
184
@@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-cbc-plain64-sha256-sha1.img
178
+++ b/include/block/block.h
185
# ================= qemu-img aes-256-cbc-plain64-sha256-sha1 =================
179
@@ -XXX,XX +XXX,XX @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
186
# Create image
180
int64_t sector_num, int nb_sectors, int *pnum);
187
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=cbc,ivgen-alg=plain64,hash-alg=sha1,ivgen-hash-alg=sha256 TEST_DIR/luks-aes-256-cbc-plain64-sha256-sha1.img 4194304M
181
188
-Formatting 'TEST_DIR/luks-aes-256-cbc-plain64-sha256-sha1.img', fmt=luks size=4398046511104 key-secret=sec0 cipher-alg=aes-256 cipher-mode=cbc ivgen-alg=plain64 ivgen-hash-alg=sha256 hash-alg=sha1 iter-time=10
182
bool bdrv_is_read_only(BlockDriverState *bs);
189
183
-void bdrv_set_read_only(BlockDriverState *bs, bool read_only);
190
# Open dev
184
+int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp);
191
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-plain64-sha256-sha1.img qiotest-145-aes-256-cbc-plain64-sha256-sha1
185
bool bdrv_is_sg(BlockDriverState *bs);
192
diff --git a/tests/qemu-iotests/237.out b/tests/qemu-iotests/237.out
186
bool bdrv_is_inserted(BlockDriverState *bs);
193
index XXXXXXX..XXXXXXX 100644
187
int bdrv_media_changed(BlockDriverState *bs);
194
--- a/tests/qemu-iotests/237.out
195
+++ b/tests/qemu-iotests/237.out
196
@@ -XXX,XX +XXX,XX @@ Job failed: Cannot find device='this doesn't exist' nor node-name='this doesn't
197
198
=== Other subformats ===
199
200
-Formatting 'TEST_DIR/PID-t.vmdk.1', fmt=vmdk size=0 compat6=off hwversion=undefined
201
202
-Formatting 'TEST_DIR/PID-t.vmdk.2', fmt=vmdk size=0 compat6=off hwversion=undefined
203
204
-Formatting 'TEST_DIR/PID-t.vmdk.3', fmt=vmdk size=0 compat6=off hwversion=undefined
205
206
== Missing extent ==
207
208
diff --git a/tests/qemu-iotests/255.out b/tests/qemu-iotests/255.out
209
index XXXXXXX..XXXXXXX 100644
210
--- a/tests/qemu-iotests/255.out
211
+++ b/tests/qemu-iotests/255.out
212
@@ -XXX,XX +XXX,XX @@ Finishing a commit job with background reads
213
214
=== Create backing chain and start VM ===
215
216
-Formatting 'TEST_DIR/PID-t.qcow2.mid', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16
217
218
-Formatting 'TEST_DIR/PID-t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16
219
220
=== Start background read requests ===
221
222
@@ -XXX,XX +XXX,XX @@ Closing the VM while a job is being cancelled
223
224
=== Create images and start VM ===
225
226
-Formatting 'TEST_DIR/PID-src.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16
227
228
-Formatting 'TEST_DIR/PID-dst.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16
229
230
wrote 1048576/1048576 bytes at offset 0
231
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
232
diff --git a/tests/qemu-iotests/274.out b/tests/qemu-iotests/274.out
233
index XXXXXXX..XXXXXXX 100644
234
--- a/tests/qemu-iotests/274.out
235
+++ b/tests/qemu-iotests/274.out
236
@@ -XXX,XX +XXX,XX @@
237
== Commit tests ==
238
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=2097152 lazy_refcounts=off refcount_bits=16
239
240
-Formatting 'TEST_DIR/PID-mid', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1048576 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
241
242
-Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=2097152 backing_file=TEST_DIR/PID-mid backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
243
244
wrote 2097152/2097152 bytes at offset 0
245
2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
246
@@ -XXX,XX +XXX,XX @@ read 1048576/1048576 bytes at offset 1048576
247
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
248
249
=== Testing HMP commit (top -> mid) ===
250
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=2097152 lazy_refcounts=off refcount_bits=16
251
252
-Formatting 'TEST_DIR/PID-mid', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1048576 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
253
254
-Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=2097152 backing_file=TEST_DIR/PID-mid backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
255
256
wrote 2097152/2097152 bytes at offset 0
257
2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
258
@@ -XXX,XX +XXX,XX @@ read 1048576/1048576 bytes at offset 1048576
259
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
260
261
=== Testing QMP active commit (top -> mid) ===
262
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=2097152 lazy_refcounts=off refcount_bits=16
263
264
-Formatting 'TEST_DIR/PID-mid', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1048576 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
265
266
-Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=2097152 backing_file=TEST_DIR/PID-mid backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
267
268
wrote 2097152/2097152 bytes at offset 0
269
2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
270
@@ -XXX,XX +XXX,XX @@ read 1048576/1048576 bytes at offset 1048576
271
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
272
273
=== Testing qemu-img commit (top -> base) ===
274
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=2097152 lazy_refcounts=off refcount_bits=16
275
276
-Formatting 'TEST_DIR/PID-mid', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1048576 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
277
278
-Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=2097152 backing_file=TEST_DIR/PID-mid backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
279
280
wrote 2097152/2097152 bytes at offset 0
281
2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
282
@@ -XXX,XX +XXX,XX @@ read 1048576/1048576 bytes at offset 1048576
283
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
284
285
=== Testing QMP active commit (top -> base) ===
286
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=2097152 lazy_refcounts=off refcount_bits=16
287
288
-Formatting 'TEST_DIR/PID-mid', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1048576 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
289
290
-Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=2097152 backing_file=TEST_DIR/PID-mid backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
291
292
wrote 2097152/2097152 bytes at offset 0
293
2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
294
@@ -XXX,XX +XXX,XX @@ read 1048576/1048576 bytes at offset 1048576
295
296
== Resize tests ==
297
=== preallocation=off ===
298
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=6442450944 lazy_refcounts=off refcount_bits=16
299
300
-Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1073741824 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
301
302
wrote 65536/65536 bytes at offset 5368709120
303
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
304
@@ -XXX,XX +XXX,XX @@ read 65536/65536 bytes at offset 5368709120
305
{ "start": 1073741824, "length": 7516192768, "depth": 0, "present": true, "zero": true, "data": false}]
306
307
=== preallocation=metadata ===
308
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=34359738368 lazy_refcounts=off refcount_bits=16
309
310
-Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=32212254720 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
311
312
wrote 65536/65536 bytes at offset 33285996544
313
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
314
@@ -XXX,XX +XXX,XX @@ read 65536/65536 bytes at offset 33285996544
315
{ "start": 34896609280, "length": 536870912, "depth": 0, "present": true, "zero": true, "data": false, "offset": 2685075456}]
316
317
=== preallocation=falloc ===
318
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=10485760 lazy_refcounts=off refcount_bits=16
319
320
-Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=5242880 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
321
322
wrote 65536/65536 bytes at offset 9437184
323
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
324
@@ -XXX,XX +XXX,XX @@ read 65536/65536 bytes at offset 9437184
325
{ "start": 5242880, "length": 10485760, "depth": 0, "present": true, "zero": false, "data": true, "offset": 327680}]
326
327
=== preallocation=full ===
328
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=16777216 lazy_refcounts=off refcount_bits=16
329
330
-Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=8388608 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
331
332
wrote 65536/65536 bytes at offset 11534336
333
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
334
@@ -XXX,XX +XXX,XX @@ read 65536/65536 bytes at offset 11534336
335
{ "start": 8388608, "length": 4194304, "depth": 0, "present": true, "zero": false, "data": true, "offset": 327680}]
336
337
=== preallocation=off ===
338
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=393216 lazy_refcounts=off refcount_bits=16
339
340
-Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=259072 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
341
342
wrote 65536/65536 bytes at offset 259072
343
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
344
@@ -XXX,XX +XXX,XX @@ read 65536/65536 bytes at offset 259072
345
{ "start": 262144, "length": 262144, "depth": 0, "present": true, "zero": true, "data": false}]
346
347
=== preallocation=off ===
348
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=409600 lazy_refcounts=off refcount_bits=16
349
350
-Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=262144 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
351
352
wrote 65536/65536 bytes at offset 344064
353
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
354
@@ -XXX,XX +XXX,XX @@ read 65536/65536 bytes at offset 344064
355
{ "start": 262144, "length": 262144, "depth": 0, "present": true, "zero": true, "data": false}]
356
357
=== preallocation=off ===
358
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=524288 lazy_refcounts=off refcount_bits=16
359
360
-Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=262144 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
361
362
wrote 65536/65536 bytes at offset 446464
363
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
364
diff --git a/tests/qemu-iotests/280.out b/tests/qemu-iotests/280.out
365
index XXXXXXX..XXXXXXX 100644
366
--- a/tests/qemu-iotests/280.out
367
+++ b/tests/qemu-iotests/280.out
368
@@ -XXX,XX +XXX,XX @@
369
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
370
371
=== Launch VM ===
372
Enabling migration QMP events on VM...
373
diff --git a/tests/qemu-iotests/296.out b/tests/qemu-iotests/296.out
374
index XXXXXXX..XXXXXXX 100644
375
--- a/tests/qemu-iotests/296.out
376
+++ b/tests/qemu-iotests/296.out
377
@@ -XXX,XX +XXX,XX @@
378
-Formatting 'TEST_DIR/test.img', fmt=luks size=1048576 key-secret=keysec0 iter-time=10
379
380
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
381
{"return": {}}
382
@@ -XXX,XX +XXX,XX @@ Job failed: Failed to get shared "consistent read" lock
383
qemu-img: Failed to get shared "consistent read" lock
384
Is another process using the image [TEST_DIR/test.img]?
385
386
-.Formatting 'TEST_DIR/test.img', fmt=luks size=1048576 key-secret=keysec0 iter-time=10
387
-
388
+.
389
Job failed: Block node is read-only
390
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
391
{"return": {}}
392
@@ -XXX,XX +XXX,XX @@ Job failed: Failed to get shared "consistent read" lock
393
{"return": {}}
394
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
395
{"return": {}}
396
-.Formatting 'TEST_DIR/test.img', fmt=luks size=1048576 key-secret=keysec0 iter-time=10
397
-
398
+.
399
{"return": {}}
400
{"error": {"class": "GenericError", "desc": "Failed to get \"write\" lock"}}
401
-.Formatting 'TEST_DIR/test.img', fmt=luks size=1048576 key-secret=keysec0 iter-time=10
402
-
403
+.
404
{"return": {}}
405
{"return": {}}
406
.
407
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
408
index XXXXXXX..XXXXXXX 100644
409
--- a/tests/qemu-iotests/iotests.py
410
+++ b/tests/qemu-iotests/iotests.py
411
@@ -XXX,XX +XXX,XX @@ def qemu_tool_popen(args: Sequence[str],
412
413
414
def qemu_tool_pipe_and_status(tool: str, args: Sequence[str],
415
- connect_stderr: bool = True) -> Tuple[str, int]:
416
+ connect_stderr: bool = True,
417
+ drop_successful_output: bool = False) \
418
+ -> Tuple[str, int]:
419
"""
420
Run a tool and return both its output and its exit code
421
"""
422
@@ -XXX,XX +XXX,XX @@ def qemu_tool_pipe_and_status(tool: str, args: Sequence[str],
423
cmd = ' '.join(args)
424
sys.stderr.write(f'{tool} received signal \
425
{-subp.returncode}: {cmd}\n')
426
+ if drop_successful_output and subp.returncode == 0:
427
+ output = ''
428
return (output, subp.returncode)
429
430
def qemu_img_create_prepare_args(args: List[str]) -> List[str]:
431
@@ -XXX,XX +XXX,XX @@ def qemu_img_pipe_and_status(*args: str) -> Tuple[str, int]:
432
"""
433
Run qemu-img and return both its output and its exit code
434
"""
435
+ is_create = bool(args and args[0] == 'create')
436
full_args = qemu_img_args + qemu_img_create_prepare_args(list(args))
437
- return qemu_tool_pipe_and_status('qemu-img', full_args)
438
+ return qemu_tool_pipe_and_status('qemu-img', full_args,
439
+ drop_successful_output=is_create)
440
441
def qemu_img(*args: str) -> int:
442
'''Run qemu-img and return the exit code'''
188
--
443
--
189
2.9.3
444
2.34.1
190
445
191
446
diff view generated by jsdifflib
1
Update 'clientname' to be 'user', which tracks better with both
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
the QAPI and rados variable naming.
3
2
4
Update 'name' to be 'image_name', as it indicates the rbd image.
3
We want iotests pass with both the default zlib compression and with
5
Naming it 'image' would have been ideal, but we are using that for
4
IMGOPTS='compression_type=zstd'.
6
the rados_image_t value returned by rbd_open().
7
5
8
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
6
Actually the only test that is interested in real compression type in
9
Signed-off-by: Jeff Cody <jcody@redhat.com>
7
test output is 287 (test for qcow2 compression type) and it's in bash.
10
Reviewed-by: John Snow <jsnow@redhat.com>
8
So for now we can safely filter out compression type in all qcow2
11
Message-id: b7ec1fb2e1cf36f9b6911631447a5b0422590b7d.1491597120.git.jcody@redhat.com
9
tests.
10
11
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
12
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
13
Message-Id: <20211223160144.1097696-11-vsementsov@virtuozzo.com>
14
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
12
---
15
---
13
block/rbd.c | 33 +++++++++++++++++----------------
16
tests/qemu-iotests/206.out | 10 +++++-----
14
1 file changed, 17 insertions(+), 16 deletions(-)
17
tests/qemu-iotests/242.out | 10 +++++-----
18
tests/qemu-iotests/274.out | 10 +++++-----
19
tests/qemu-iotests/iotests.py | 2 ++
20
4 files changed, 17 insertions(+), 15 deletions(-)
15
21
16
diff --git a/block/rbd.c b/block/rbd.c
22
diff --git a/tests/qemu-iotests/206.out b/tests/qemu-iotests/206.out
17
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
18
--- a/block/rbd.c
24
--- a/tests/qemu-iotests/206.out
19
+++ b/block/rbd.c
25
+++ b/tests/qemu-iotests/206.out
20
@@ -XXX,XX +XXX,XX @@ typedef struct BDRVRBDState {
26
@@ -XXX,XX +XXX,XX @@ virtual size: 128 MiB (134217728 bytes)
21
rados_t cluster;
27
cluster_size: 65536
22
rados_ioctx_t io_ctx;
28
Format specific information:
23
rbd_image_t image;
29
compat: 1.1
24
- char *name;
30
- compression type: zlib
25
+ char *image_name;
31
+ compression type: COMPRESSION_TYPE
26
char *snap;
32
lazy refcounts: false
27
} BDRVRBDState;
33
refcount bits: 16
28
34
corrupt: false
29
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
35
@@ -XXX,XX +XXX,XX @@ virtual size: 64 MiB (67108864 bytes)
30
int64_t bytes = 0;
36
cluster_size: 65536
31
int64_t objsize;
37
Format specific information:
32
int obj_order = 0;
38
compat: 1.1
33
- const char *pool, *name, *conf, *clientname, *keypairs;
39
- compression type: zlib
34
+ const char *pool, *image_name, *conf, *user, *keypairs;
40
+ compression type: COMPRESSION_TYPE
35
const char *secretid;
41
lazy refcounts: false
36
rados_t cluster;
42
refcount bits: 16
37
rados_ioctx_t io_ctx;
43
corrupt: false
38
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
44
@@ -XXX,XX +XXX,XX @@ virtual size: 32 MiB (33554432 bytes)
39
*/
45
cluster_size: 2097152
40
pool = qdict_get_try_str(options, "pool");
46
Format specific information:
41
conf = qdict_get_try_str(options, "conf");
47
compat: 1.1
42
- clientname = qdict_get_try_str(options, "user");
48
- compression type: zlib
43
- name = qdict_get_try_str(options, "image");
49
+ compression type: COMPRESSION_TYPE
44
+ user = qdict_get_try_str(options, "user");
50
lazy refcounts: true
45
+ image_name = qdict_get_try_str(options, "image");
51
refcount bits: 1
46
keypairs = qdict_get_try_str(options, "=keyvalue-pairs");
52
corrupt: false
47
53
@@ -XXX,XX +XXX,XX @@ backing file: TEST_IMG.base
48
- ret = rados_create(&cluster, clientname);
54
backing file format: IMGFMT
49
+ ret = rados_create(&cluster, user);
55
Format specific information:
50
if (ret < 0) {
56
compat: 0.10
51
error_setg_errno(errp, -ret, "error initializing");
57
- compression type: zlib
52
goto exit;
58
+ compression type: COMPRESSION_TYPE
53
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
59
refcount bits: 16
54
goto shutdown;
60
55
}
61
=== Successful image creation (encrypted) ===
56
62
@@ -XXX,XX +XXX,XX @@ encrypted: yes
57
- ret = rbd_create(io_ctx, name, bytes, &obj_order);
63
cluster_size: 65536
58
+ ret = rbd_create(io_ctx, image_name, bytes, &obj_order);
64
Format specific information:
59
if (ret < 0) {
65
compat: 1.1
60
error_setg_errno(errp, -ret, "error rbd create");
66
- compression type: zlib
61
}
67
+ compression type: COMPRESSION_TYPE
62
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
68
lazy refcounts: false
63
Error **errp)
69
refcount bits: 16
64
{
70
encrypt:
65
BDRVRBDState *s = bs->opaque;
71
diff --git a/tests/qemu-iotests/242.out b/tests/qemu-iotests/242.out
66
- const char *pool, *snap, *conf, *clientname, *name, *keypairs;
72
index XXXXXXX..XXXXXXX 100644
67
+ const char *pool, *snap, *conf, *user, *image_name, *keypairs;
73
--- a/tests/qemu-iotests/242.out
68
const char *secretid;
74
+++ b/tests/qemu-iotests/242.out
69
QemuOpts *opts;
75
@@ -XXX,XX +XXX,XX @@ virtual size: 1 MiB (1048576 bytes)
70
Error *local_err = NULL;
76
cluster_size: 65536
71
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
77
Format specific information:
72
pool = qemu_opt_get(opts, "pool");
78
compat: 1.1
73
conf = qemu_opt_get(opts, "conf");
79
- compression type: zlib
74
snap = qemu_opt_get(opts, "snapshot");
80
+ compression type: COMPRESSION_TYPE
75
- clientname = qemu_opt_get(opts, "user");
81
lazy refcounts: false
76
- name = qemu_opt_get(opts, "image");
82
refcount bits: 16
77
+ user = qemu_opt_get(opts, "user");
83
corrupt: false
78
+ image_name = qemu_opt_get(opts, "image");
84
@@ -XXX,XX +XXX,XX @@ virtual size: 1 MiB (1048576 bytes)
79
keypairs = qemu_opt_get(opts, "=keyvalue-pairs");
85
cluster_size: 65536
80
86
Format specific information:
81
- if (!pool || !name) {
87
compat: 1.1
82
+ if (!pool || !image_name) {
88
- compression type: zlib
83
error_setg(errp, "Parameters 'pool' and 'image' are required");
89
+ compression type: COMPRESSION_TYPE
84
r = -EINVAL;
90
lazy refcounts: false
85
goto failed_opts;
91
bitmaps:
86
}
92
[0]:
87
93
@@ -XXX,XX +XXX,XX @@ virtual size: 1 MiB (1048576 bytes)
88
- r = rados_create(&s->cluster, clientname);
94
cluster_size: 65536
89
+ r = rados_create(&s->cluster, user);
95
Format specific information:
90
if (r < 0) {
96
compat: 1.1
91
error_setg_errno(errp, -r, "error initializing");
97
- compression type: zlib
92
goto failed_opts;
98
+ compression type: COMPRESSION_TYPE
93
}
99
lazy refcounts: false
94
100
bitmaps:
95
s->snap = g_strdup(snap);
101
[0]:
96
- s->name = g_strdup(name);
102
@@ -XXX,XX +XXX,XX @@ virtual size: 1 MiB (1048576 bytes)
97
+ s->image_name = g_strdup(image_name);
103
cluster_size: 65536
98
104
Format specific information:
99
/* try default location when conf=NULL, but ignore failure */
105
compat: 1.1
100
r = rados_conf_read_file(s->cluster, conf);
106
- compression type: zlib
101
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
107
+ compression type: COMPRESSION_TYPE
102
}
108
lazy refcounts: false
103
109
bitmaps:
104
/* rbd_open is always r/w */
110
[0]:
105
- r = rbd_open(s->io_ctx, s->name, &s->image, s->snap);
111
@@ -XXX,XX +XXX,XX @@ virtual size: 1 MiB (1048576 bytes)
106
+ r = rbd_open(s->io_ctx, s->image_name, &s->image, s->snap);
112
cluster_size: 65536
107
if (r < 0) {
113
Format specific information:
108
- error_setg_errno(errp, -r, "error reading header from %s", s->name);
114
compat: 1.1
109
+ error_setg_errno(errp, -r, "error reading header from %s",
115
- compression type: zlib
110
+ s->image_name);
116
+ compression type: COMPRESSION_TYPE
111
goto failed_open;
117
lazy refcounts: false
112
}
118
bitmaps:
113
119
[0]:
114
@@ -XXX,XX +XXX,XX @@ failed_open:
120
diff --git a/tests/qemu-iotests/274.out b/tests/qemu-iotests/274.out
115
failed_shutdown:
121
index XXXXXXX..XXXXXXX 100644
116
rados_shutdown(s->cluster);
122
--- a/tests/qemu-iotests/274.out
117
g_free(s->snap);
123
+++ b/tests/qemu-iotests/274.out
118
- g_free(s->name);
124
@@ -XXX,XX +XXX,XX @@ backing file: TEST_DIR/PID-base
119
+ g_free(s->image_name);
125
backing file format: IMGFMT
120
failed_opts:
126
Format specific information:
121
qemu_opts_del(opts);
127
compat: 1.1
122
g_free(mon_host);
128
- compression type: zlib
123
@@ -XXX,XX +XXX,XX @@ static void qemu_rbd_close(BlockDriverState *bs)
129
+ compression type: COMPRESSION_TYPE
124
rbd_close(s->image);
130
lazy refcounts: false
125
rados_ioctx_destroy(s->io_ctx);
131
refcount bits: 16
126
g_free(s->snap);
132
corrupt: false
127
- g_free(s->name);
133
@@ -XXX,XX +XXX,XX @@ backing file: TEST_DIR/PID-base
128
+ g_free(s->image_name);
134
backing file format: IMGFMT
129
rados_shutdown(s->cluster);
135
Format specific information:
130
}
136
compat: 1.1
137
- compression type: zlib
138
+ compression type: COMPRESSION_TYPE
139
lazy refcounts: false
140
refcount bits: 16
141
corrupt: false
142
@@ -XXX,XX +XXX,XX @@ backing file: TEST_DIR/PID-base
143
backing file format: IMGFMT
144
Format specific information:
145
compat: 1.1
146
- compression type: zlib
147
+ compression type: COMPRESSION_TYPE
148
lazy refcounts: false
149
refcount bits: 16
150
corrupt: false
151
@@ -XXX,XX +XXX,XX @@ virtual size: 2 MiB (2097152 bytes)
152
cluster_size: 65536
153
Format specific information:
154
compat: 1.1
155
- compression type: zlib
156
+ compression type: COMPRESSION_TYPE
157
lazy refcounts: false
158
refcount bits: 16
159
corrupt: false
160
@@ -XXX,XX +XXX,XX @@ backing file: TEST_DIR/PID-base
161
backing file format: IMGFMT
162
Format specific information:
163
compat: 1.1
164
- compression type: zlib
165
+ compression type: COMPRESSION_TYPE
166
lazy refcounts: false
167
refcount bits: 16
168
corrupt: false
169
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
170
index XXXXXXX..XXXXXXX 100644
171
--- a/tests/qemu-iotests/iotests.py
172
+++ b/tests/qemu-iotests/iotests.py
173
@@ -XXX,XX +XXX,XX @@ def filter_img_info(output, filename):
174
'uuid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
175
line)
176
line = re.sub('cid: [0-9]+', 'cid: XXXXXXXXXX', line)
177
+ line = re.sub('(compression type: )(zlib|zstd)', r'\1COMPRESSION_TYPE',
178
+ line)
179
lines.append(line)
180
return '\n'.join(lines)
131
181
132
--
182
--
133
2.9.3
183
2.34.1
134
184
135
185
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
Instead of qemu_img_log("info", ..) use generic helper img_info_log().
4
5
img_info_log() has smarter logic. For example it use filter_img_info()
6
to filter output, which in turns filter a compression type. So it will
7
help us in future when we implement a possibility to use zstd
8
compression by default (with help of some runtime config file or maybe
9
build option). For now to test you should recompile qemu with a small
10
addition into block/qcow2.c before
11
"if (qcow2_opts->has_compression_type":
12
13
if (!qcow2_opts->has_compression_type && version >= 3) {
14
qcow2_opts->has_compression_type = true;
15
qcow2_opts->compression_type = QCOW2_COMPRESSION_TYPE_ZSTD;
16
}
17
18
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
19
Reviewed-by: Max Reitz <mreitz@redhat.com>
20
Message-Id: <20211223160144.1097696-12-vsementsov@virtuozzo.com>
21
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
22
---
23
tests/qemu-iotests/302 | 4 +++-
24
tests/qemu-iotests/302.out | 7 +++----
25
2 files changed, 6 insertions(+), 5 deletions(-)
26
27
diff --git a/tests/qemu-iotests/302 b/tests/qemu-iotests/302
28
index XXXXXXX..XXXXXXX 100755
29
--- a/tests/qemu-iotests/302
30
+++ b/tests/qemu-iotests/302
31
@@ -XXX,XX +XXX,XX @@ from iotests import (
32
qemu_img_measure,
33
qemu_io,
34
qemu_nbd_popen,
35
+ img_info_log,
36
)
37
38
iotests.script_initialize(supported_fmts=["qcow2"])
39
@@ -XXX,XX +XXX,XX @@ with tarfile.open(tar_file, "w") as tar:
40
tar_file):
41
42
iotests.log("=== Target image info ===")
43
+ # Not img_info_log as it enforces imgfmt, but now we print info on raw
44
qemu_img_log("info", nbd_uri)
45
46
qemu_img(
47
@@ -XXX,XX +XXX,XX @@ with tarfile.open(tar_file, "w") as tar:
48
nbd_uri)
49
50
iotests.log("=== Converted image info ===")
51
- qemu_img_log("info", nbd_uri)
52
+ img_info_log(nbd_uri)
53
54
iotests.log("=== Converted image check ===")
55
qemu_img_log("check", nbd_uri)
56
diff --git a/tests/qemu-iotests/302.out b/tests/qemu-iotests/302.out
57
index XXXXXXX..XXXXXXX 100644
58
--- a/tests/qemu-iotests/302.out
59
+++ b/tests/qemu-iotests/302.out
60
@@ -XXX,XX +XXX,XX @@ virtual size: 448 KiB (458752 bytes)
61
disk size: unavailable
62
63
=== Converted image info ===
64
-image: nbd+unix:///exp?socket=SOCK_DIR/PID-nbd-sock
65
-file format: qcow2
66
+image: TEST_IMG
67
+file format: IMGFMT
68
virtual size: 1 GiB (1073741824 bytes)
69
-disk size: unavailable
70
cluster_size: 65536
71
Format specific information:
72
compat: 1.1
73
- compression type: zlib
74
+ compression type: COMPRESSION_TYPE
75
lazy refcounts: false
76
refcount bits: 16
77
corrupt: false
78
--
79
2.34.1
80
81
diff view generated by jsdifflib
1
From: Ashish Mittal <ashmit602@gmail.com>
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
2
3
Source code for the qnio library that this code loads can be downloaded from:
3
If image doesn't have any compressed cluster we can easily switch to
4
https://github.com/VeritasHyperScale/libqnio.git
4
zlib compression, which may allow to downgrade the image.
5
5
6
Sample command line using JSON syntax:
6
That's mostly needed to support IMGOPTS='compression_type=zstd' in some
7
./x86_64-softmmu/qemu-system-x86_64 -name instance-00000008 -S -vnc 0.0.0.0:0
7
iotests which do qcow2 downgrade.
8
-k en-us -vga cirrus -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
9
-msg timestamp=on
10
'json:{"driver":"vxhs","vdisk-id":"c3e9095a-a5ee-4dce-afeb-2a59fb387410",
11
"server":{"host":"172.172.17.4","port":"9999"}}'
12
8
13
Sample command line using URI syntax:
9
While being here also fix checkpatch complain against '#' in printf
14
qemu-img convert -f raw -O raw -n
10
formatting.
15
/var/lib/nova/instances/_base/0c5eacd5ebea5ed914b6a3e7b18f1ce734c386ad
16
vxhs://192.168.0.1:9999/c6718f6b-0401-441d-a8c3-1f0064d75ee0
17
11
18
Sample command line using TLS credentials (run in secure mode):
12
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
19
./qemu-io --object
13
Reviewed-by: Max Reitz <mreitz@redhat.com>
20
tls-creds-x509,id=tls0,dir=/etc/pki/qemu/vxhs,endpoint=client -c 'read
14
Message-Id: <20211223160144.1097696-13-vsementsov@virtuozzo.com>
21
-v 66000 2.5k' 'json:{"server.host": "127.0.0.1", "server.port": "9999",
15
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
22
"vdisk-id": "/test.raw", "driver": "vxhs", "tls-creds":"tls0"}'
16
---
17
block/qcow2.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++--
18
1 file changed, 56 insertions(+), 2 deletions(-)
23
19
24
Signed-off-by: Ashish Mittal <Ashish.Mittal@veritas.com>
20
diff --git a/block/qcow2.c b/block/qcow2.c
25
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
26
Reviewed-by: Jeff Cody <jcody@redhat.com>
27
Signed-off-by: Jeff Cody <jcody@redhat.com>
28
Message-id: 1491277689-24949-2-git-send-email-Ashish.Mittal@veritas.com
29
---
30
block/Makefile.objs | 2 +
31
block/trace-events | 17 ++
32
block/vxhs.c | 575 +++++++++++++++++++++++++++++++++++++++++++++++++++
33
configure | 39 ++++
34
qapi/block-core.json | 23 ++-
35
5 files changed, 654 insertions(+), 2 deletions(-)
36
create mode 100644 block/vxhs.c
37
38
diff --git a/block/Makefile.objs b/block/Makefile.objs
39
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
40
--- a/block/Makefile.objs
22
--- a/block/qcow2.c
41
+++ b/block/Makefile.objs
23
+++ b/block/qcow2.c
42
@@ -XXX,XX +XXX,XX @@ block-obj-$(CONFIG_LIBNFS) += nfs.o
24
@@ -XXX,XX +XXX,XX @@ static int qcow2_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
43
block-obj-$(CONFIG_CURL) += curl.o
25
return bs->drv->bdrv_co_preadv_part(bs, offset, qiov->size, qiov, 0, 0);
44
block-obj-$(CONFIG_RBD) += rbd.o
26
}
45
block-obj-$(CONFIG_GLUSTERFS) += gluster.o
27
46
+block-obj-$(CONFIG_VXHS) += vxhs.o
28
+static int qcow2_has_compressed_clusters(BlockDriverState *bs)
47
block-obj-$(CONFIG_LIBSSH2) += ssh.o
29
+{
48
block-obj-y += accounting.o dirty-bitmap.o
30
+ int64_t offset = 0;
49
block-obj-y += write-threshold.o
31
+ int64_t bytes = bdrv_getlength(bs);
50
@@ -XXX,XX +XXX,XX @@ rbd.o-cflags := $(RBD_CFLAGS)
51
rbd.o-libs := $(RBD_LIBS)
52
gluster.o-cflags := $(GLUSTERFS_CFLAGS)
53
gluster.o-libs := $(GLUSTERFS_LIBS)
54
+vxhs.o-libs := $(VXHS_LIBS)
55
ssh.o-cflags := $(LIBSSH2_CFLAGS)
56
ssh.o-libs := $(LIBSSH2_LIBS)
57
block-obj-$(if $(CONFIG_BZIP2),m,n) += dmg-bz2.o
58
diff --git a/block/trace-events b/block/trace-events
59
index XXXXXXX..XXXXXXX 100644
60
--- a/block/trace-events
61
+++ b/block/trace-events
62
@@ -XXX,XX +XXX,XX @@ qed_aio_write_data(void *s, void *acb, int ret, uint64_t offset, size_t len) "s
63
qed_aio_write_prefill(void *s, void *acb, uint64_t start, size_t len, uint64_t offset) "s %p acb %p start %"PRIu64" len %zu offset %"PRIu64
64
qed_aio_write_postfill(void *s, void *acb, uint64_t start, size_t len, uint64_t offset) "s %p acb %p start %"PRIu64" len %zu offset %"PRIu64
65
qed_aio_write_main(void *s, void *acb, int ret, uint64_t offset, size_t len) "s %p acb %p ret %d offset %"PRIu64" len %zu"
66
+
32
+
67
+# block/vxhs.c
33
+ if (bytes < 0) {
68
+vxhs_iio_callback(int error) "ctx is NULL: error %d"
34
+ return bytes;
69
+vxhs_iio_callback_chnfail(int err, int error) "QNIO channel failed, no i/o %d, %d"
70
+vxhs_iio_callback_unknwn(int opcode, int err) "unexpected opcode %d, errno %d"
71
+vxhs_aio_rw_invalid(int req) "Invalid I/O request iodir %d"
72
+vxhs_aio_rw_ioerr(char *guid, int iodir, uint64_t size, uint64_t off, void *acb, int ret, int err) "IO ERROR (vDisk %s) FOR : Read/Write = %d size = %lu offset = %lu ACB = %p. Error = %d, errno = %d"
73
+vxhs_get_vdisk_stat_err(char *guid, int ret, int err) "vDisk (%s) stat ioctl failed, ret = %d, errno = %d"
74
+vxhs_get_vdisk_stat(char *vdisk_guid, uint64_t vdisk_size) "vDisk %s stat ioctl returned size %lu"
75
+vxhs_complete_aio(void *acb, uint64_t ret) "aio failed acb %p ret %ld"
76
+vxhs_parse_uri_filename(const char *filename) "URI passed via bdrv_parse_filename %s"
77
+vxhs_open_vdiskid(const char *vdisk_id) "Opening vdisk-id %s"
78
+vxhs_open_hostinfo(char *of_vsa_addr, int port) "Adding host %s:%d to BDRVVXHSState"
79
+vxhs_open_iio_open(const char *host) "Failed to connect to storage agent on host %s"
80
+vxhs_parse_uri_hostinfo(char *host, int port) "Host: IP %s, Port %d"
81
+vxhs_close(char *vdisk_guid) "Closing vdisk %s"
82
+vxhs_get_creds(const char *cacert, const char *client_key, const char *client_cert) "cacert %s, client_key %s, client_cert %s"
83
diff --git a/block/vxhs.c b/block/vxhs.c
84
new file mode 100644
85
index XXXXXXX..XXXXXXX
86
--- /dev/null
87
+++ b/block/vxhs.c
88
@@ -XXX,XX +XXX,XX @@
89
+/*
90
+ * QEMU Block driver for Veritas HyperScale (VxHS)
91
+ *
92
+ * Copyright (c) 2017 Veritas Technologies LLC.
93
+ *
94
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
95
+ * See the COPYING file in the top-level directory.
96
+ *
97
+ */
98
+
99
+#include "qemu/osdep.h"
100
+#include <qnio/qnio_api.h>
101
+#include <sys/param.h>
102
+#include "block/block_int.h"
103
+#include "qapi/qmp/qerror.h"
104
+#include "qapi/qmp/qdict.h"
105
+#include "qapi/qmp/qstring.h"
106
+#include "trace.h"
107
+#include "qemu/uri.h"
108
+#include "qapi/error.h"
109
+#include "qemu/uuid.h"
110
+#include "crypto/tlscredsx509.h"
111
+
112
+#define VXHS_OPT_FILENAME "filename"
113
+#define VXHS_OPT_VDISK_ID "vdisk-id"
114
+#define VXHS_OPT_SERVER "server"
115
+#define VXHS_OPT_HOST "host"
116
+#define VXHS_OPT_PORT "port"
117
+
118
+/* Only accessed under QEMU global mutex */
119
+static uint32_t vxhs_ref;
120
+
121
+typedef enum {
122
+ VDISK_AIO_READ,
123
+ VDISK_AIO_WRITE,
124
+} VDISKAIOCmd;
125
+
126
+/*
127
+ * HyperScale AIO callbacks structure
128
+ */
129
+typedef struct VXHSAIOCB {
130
+ BlockAIOCB common;
131
+ int err;
132
+} VXHSAIOCB;
133
+
134
+typedef struct VXHSvDiskHostsInfo {
135
+ void *dev_handle; /* Device handle */
136
+ char *host; /* Host name or IP */
137
+ int port; /* Host's port number */
138
+} VXHSvDiskHostsInfo;
139
+
140
+/*
141
+ * Structure per vDisk maintained for state
142
+ */
143
+typedef struct BDRVVXHSState {
144
+ VXHSvDiskHostsInfo vdisk_hostinfo; /* Per host info */
145
+ char *vdisk_guid;
146
+ char *tlscredsid; /* tlscredsid */
147
+} BDRVVXHSState;
148
+
149
+static void vxhs_complete_aio_bh(void *opaque)
150
+{
151
+ VXHSAIOCB *acb = opaque;
152
+ BlockCompletionFunc *cb = acb->common.cb;
153
+ void *cb_opaque = acb->common.opaque;
154
+ int ret = 0;
155
+
156
+ if (acb->err != 0) {
157
+ trace_vxhs_complete_aio(acb, acb->err);
158
+ ret = (-EIO);
159
+ }
35
+ }
160
+
36
+
161
+ qemu_aio_unref(acb);
37
+ while (bytes != 0) {
162
+ cb(cb_opaque, ret);
38
+ int ret;
163
+}
39
+ QCow2SubclusterType type;
40
+ unsigned int cur_bytes = MIN(INT_MAX, bytes);
41
+ uint64_t host_offset;
164
+
42
+
165
+/*
43
+ ret = qcow2_get_host_offset(bs, offset, &cur_bytes, &host_offset,
166
+ * Called from a libqnio thread
44
+ &type);
167
+ */
45
+ if (ret < 0) {
168
+static void vxhs_iio_callback(void *ctx, uint32_t opcode, uint32_t error)
46
+ return ret;
169
+{
170
+ VXHSAIOCB *acb = NULL;
171
+
172
+ switch (opcode) {
173
+ case IRP_READ_REQUEST:
174
+ case IRP_WRITE_REQUEST:
175
+
176
+ /*
177
+ * ctx is VXHSAIOCB*
178
+ * ctx is NULL if error is QNIOERROR_CHANNEL_HUP
179
+ */
180
+ if (ctx) {
181
+ acb = ctx;
182
+ } else {
183
+ trace_vxhs_iio_callback(error);
184
+ goto out;
185
+ }
47
+ }
186
+
48
+
187
+ if (error) {
49
+ if (type == QCOW2_SUBCLUSTER_COMPRESSED) {
188
+ if (!acb->err) {
50
+ return 1;
189
+ acb->err = error;
190
+ }
191
+ trace_vxhs_iio_callback(error);
192
+ }
51
+ }
193
+
52
+
194
+ aio_bh_schedule_oneshot(bdrv_get_aio_context(acb->common.bs),
53
+ offset += cur_bytes;
195
+ vxhs_complete_aio_bh, acb);
54
+ bytes -= cur_bytes;
196
+ break;
197
+
198
+ default:
199
+ if (error == QNIOERROR_HUP) {
200
+ /*
201
+ * Channel failed, spontaneous notification,
202
+ * not in response to I/O
203
+ */
204
+ trace_vxhs_iio_callback_chnfail(error, errno);
205
+ } else {
206
+ trace_vxhs_iio_callback_unknwn(opcode, error);
207
+ }
208
+ break;
209
+ }
210
+out:
211
+ return;
212
+}
213
+
214
+static QemuOptsList runtime_opts = {
215
+ .name = "vxhs",
216
+ .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head),
217
+ .desc = {
218
+ {
219
+ .name = VXHS_OPT_FILENAME,
220
+ .type = QEMU_OPT_STRING,
221
+ .help = "URI to the Veritas HyperScale image",
222
+ },
223
+ {
224
+ .name = VXHS_OPT_VDISK_ID,
225
+ .type = QEMU_OPT_STRING,
226
+ .help = "UUID of the VxHS vdisk",
227
+ },
228
+ {
229
+ .name = "tls-creds",
230
+ .type = QEMU_OPT_STRING,
231
+ .help = "ID of the TLS/SSL credentials to use",
232
+ },
233
+ { /* end of list */ }
234
+ },
235
+};
236
+
237
+static QemuOptsList runtime_tcp_opts = {
238
+ .name = "vxhs_tcp",
239
+ .head = QTAILQ_HEAD_INITIALIZER(runtime_tcp_opts.head),
240
+ .desc = {
241
+ {
242
+ .name = VXHS_OPT_HOST,
243
+ .type = QEMU_OPT_STRING,
244
+ .help = "host address (ipv4 addresses)",
245
+ },
246
+ {
247
+ .name = VXHS_OPT_PORT,
248
+ .type = QEMU_OPT_NUMBER,
249
+ .help = "port number on which VxHSD is listening (default 9999)",
250
+ .def_value_str = "9999"
251
+ },
252
+ { /* end of list */ }
253
+ },
254
+};
255
+
256
+/*
257
+ * Parse incoming URI and populate *options with the host
258
+ * and device information
259
+ */
260
+static int vxhs_parse_uri(const char *filename, QDict *options)
261
+{
262
+ URI *uri = NULL;
263
+ char *port;
264
+ int ret = 0;
265
+
266
+ trace_vxhs_parse_uri_filename(filename);
267
+ uri = uri_parse(filename);
268
+ if (!uri || !uri->server || !uri->path) {
269
+ uri_free(uri);
270
+ return -EINVAL;
271
+ }
55
+ }
272
+
56
+
273
+ qdict_put(options, VXHS_OPT_SERVER".host", qstring_from_str(uri->server));
274
+
275
+ if (uri->port) {
276
+ port = g_strdup_printf("%d", uri->port);
277
+ qdict_put(options, VXHS_OPT_SERVER".port", qstring_from_str(port));
278
+ g_free(port);
279
+ }
280
+
281
+ qdict_put(options, "vdisk-id", qstring_from_str(uri->path));
282
+
283
+ trace_vxhs_parse_uri_hostinfo(uri->server, uri->port);
284
+ uri_free(uri);
285
+
286
+ return ret;
287
+}
288
+
289
+static void vxhs_parse_filename(const char *filename, QDict *options,
290
+ Error **errp)
291
+{
292
+ if (qdict_haskey(options, "vdisk-id") || qdict_haskey(options, "server")) {
293
+ error_setg(errp, "vdisk-id/server and a file name may not be specified "
294
+ "at the same time");
295
+ return;
296
+ }
297
+
298
+ if (strstr(filename, "://")) {
299
+ int ret = vxhs_parse_uri(filename, options);
300
+ if (ret < 0) {
301
+ error_setg(errp, "Invalid URI. URI should be of the form "
302
+ " vxhs://<host_ip>:<port>/<vdisk-id>");
303
+ }
304
+ }
305
+}
306
+
307
+static int vxhs_init_and_ref(void)
308
+{
309
+ if (vxhs_ref++ == 0) {
310
+ if (iio_init(QNIO_VERSION, vxhs_iio_callback)) {
311
+ return -ENODEV;
312
+ }
313
+ }
314
+ return 0;
57
+ return 0;
315
+}
58
+}
316
+
59
+
317
+static void vxhs_unref(void)
60
/*
318
+{
61
* Downgrades an image's version. To achieve this, any incompatible features
319
+ if (--vxhs_ref == 0) {
62
* have to be removed.
320
+ iio_fini();
63
@@ -XXX,XX +XXX,XX @@ static int qcow2_downgrade(BlockDriverState *bs, int target_version,
321
+ }
64
* the first place; if that happens nonetheless, returning -ENOTSUP is the
322
+}
65
* best thing to do anyway */
323
+
66
324
+static void vxhs_get_tls_creds(const char *id, char **cacert,
67
- if (s->incompatible_features) {
325
+ char **key, char **cert, Error **errp)
68
+ if (s->incompatible_features & ~QCOW2_INCOMPAT_COMPRESSION) {
326
+{
69
error_setg(errp, "Cannot downgrade an image with incompatible features "
327
+ Object *obj;
70
- "%#" PRIx64 " set", s->incompatible_features);
328
+ QCryptoTLSCreds *creds;
71
+ "0x%" PRIx64 " set",
329
+ QCryptoTLSCredsX509 *creds_x509;
72
+ s->incompatible_features & ~QCOW2_INCOMPAT_COMPRESSION);
330
+
73
return -ENOTSUP;
331
+ obj = object_resolve_path_component(
74
}
332
+ object_get_objects_root(), id);
75
333
+
76
@@ -XXX,XX +XXX,XX @@ static int qcow2_downgrade(BlockDriverState *bs, int target_version,
334
+ if (!obj) {
77
return ret;
335
+ error_setg(errp, "No TLS credentials with id '%s'",
78
}
336
+ id);
79
337
+ return;
80
+ if (s->incompatible_features & QCOW2_INCOMPAT_COMPRESSION) {
81
+ ret = qcow2_has_compressed_clusters(bs);
82
+ if (ret < 0) {
83
+ error_setg(errp, "Failed to check block status");
84
+ return -EINVAL;
85
+ }
86
+ if (ret) {
87
+ error_setg(errp, "Cannot downgrade an image with zstd compression "
88
+ "type and existing compressed clusters");
89
+ return -ENOTSUP;
90
+ }
91
+ /*
92
+ * No compressed clusters for now, so just chose default zlib
93
+ * compression.
94
+ */
95
+ s->incompatible_features &= ~QCOW2_INCOMPAT_COMPRESSION;
96
+ s->compression_type = QCOW2_COMPRESSION_TYPE_ZLIB;
338
+ }
97
+ }
339
+
98
+
340
+ creds_x509 = (QCryptoTLSCredsX509 *)
99
+ assert(s->incompatible_features == 0);
341
+ object_dynamic_cast(obj, TYPE_QCRYPTO_TLS_CREDS_X509);
342
+
100
+
343
+ if (!creds_x509) {
101
s->qcow_version = target_version;
344
+ error_setg(errp, "Object with id '%s' is not TLS credentials",
102
ret = qcow2_update_header(bs);
345
+ id);
103
if (ret < 0) {
346
+ return;
347
+ }
348
+
349
+ creds = &creds_x509->parent_obj;
350
+
351
+ if (creds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT) {
352
+ error_setg(errp,
353
+ "Expecting TLS credentials with a client endpoint");
354
+ return;
355
+ }
356
+
357
+ /*
358
+ * Get the cacert, client_cert and client_key file names.
359
+ */
360
+ if (!creds->dir) {
361
+ error_setg(errp, "TLS object missing 'dir' property value");
362
+ return;
363
+ }
364
+
365
+ *cacert = g_strdup_printf("%s/%s", creds->dir,
366
+ QCRYPTO_TLS_CREDS_X509_CA_CERT);
367
+ *cert = g_strdup_printf("%s/%s", creds->dir,
368
+ QCRYPTO_TLS_CREDS_X509_CLIENT_CERT);
369
+ *key = g_strdup_printf("%s/%s", creds->dir,
370
+ QCRYPTO_TLS_CREDS_X509_CLIENT_KEY);
371
+}
372
+
373
+static int vxhs_open(BlockDriverState *bs, QDict *options,
374
+ int bdrv_flags, Error **errp)
375
+{
376
+ BDRVVXHSState *s = bs->opaque;
377
+ void *dev_handlep;
378
+ QDict *backing_options = NULL;
379
+ QemuOpts *opts = NULL;
380
+ QemuOpts *tcp_opts = NULL;
381
+ char *of_vsa_addr = NULL;
382
+ Error *local_err = NULL;
383
+ const char *vdisk_id_opt;
384
+ const char *server_host_opt;
385
+ int ret = 0;
386
+ char *cacert = NULL;
387
+ char *client_key = NULL;
388
+ char *client_cert = NULL;
389
+
390
+ ret = vxhs_init_and_ref();
391
+ if (ret < 0) {
392
+ ret = -EINVAL;
393
+ goto out;
394
+ }
395
+
396
+ /* Create opts info from runtime_opts and runtime_tcp_opts list */
397
+ opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
398
+ tcp_opts = qemu_opts_create(&runtime_tcp_opts, NULL, 0, &error_abort);
399
+
400
+ qemu_opts_absorb_qdict(opts, options, &local_err);
401
+ if (local_err) {
402
+ ret = -EINVAL;
403
+ goto out;
404
+ }
405
+
406
+ /* vdisk-id is the disk UUID */
407
+ vdisk_id_opt = qemu_opt_get(opts, VXHS_OPT_VDISK_ID);
408
+ if (!vdisk_id_opt) {
409
+ error_setg(&local_err, QERR_MISSING_PARAMETER, VXHS_OPT_VDISK_ID);
410
+ ret = -EINVAL;
411
+ goto out;
412
+ }
413
+
414
+ /* vdisk-id may contain a leading '/' */
415
+ if (strlen(vdisk_id_opt) > UUID_FMT_LEN + 1) {
416
+ error_setg(&local_err, "vdisk-id cannot be more than %d characters",
417
+ UUID_FMT_LEN);
418
+ ret = -EINVAL;
419
+ goto out;
420
+ }
421
+
422
+ s->vdisk_guid = g_strdup(vdisk_id_opt);
423
+ trace_vxhs_open_vdiskid(vdisk_id_opt);
424
+
425
+ /* get the 'server.' arguments */
426
+ qdict_extract_subqdict(options, &backing_options, VXHS_OPT_SERVER".");
427
+
428
+ qemu_opts_absorb_qdict(tcp_opts, backing_options, &local_err);
429
+ if (local_err != NULL) {
430
+ ret = -EINVAL;
431
+ goto out;
432
+ }
433
+
434
+ server_host_opt = qemu_opt_get(tcp_opts, VXHS_OPT_HOST);
435
+ if (!server_host_opt) {
436
+ error_setg(&local_err, QERR_MISSING_PARAMETER,
437
+ VXHS_OPT_SERVER"."VXHS_OPT_HOST);
438
+ ret = -EINVAL;
439
+ goto out;
440
+ }
441
+
442
+ if (strlen(server_host_opt) > MAXHOSTNAMELEN) {
443
+ error_setg(&local_err, "server.host cannot be more than %d characters",
444
+ MAXHOSTNAMELEN);
445
+ ret = -EINVAL;
446
+ goto out;
447
+ }
448
+
449
+ /* check if we got tls-creds via the --object argument */
450
+ s->tlscredsid = g_strdup(qemu_opt_get(opts, "tls-creds"));
451
+ if (s->tlscredsid) {
452
+ vxhs_get_tls_creds(s->tlscredsid, &cacert, &client_key,
453
+ &client_cert, &local_err);
454
+ if (local_err != NULL) {
455
+ ret = -EINVAL;
456
+ goto out;
457
+ }
458
+ trace_vxhs_get_creds(cacert, client_key, client_cert);
459
+ }
460
+
461
+ s->vdisk_hostinfo.host = g_strdup(server_host_opt);
462
+ s->vdisk_hostinfo.port = g_ascii_strtoll(qemu_opt_get(tcp_opts,
463
+ VXHS_OPT_PORT),
464
+ NULL, 0);
465
+
466
+ trace_vxhs_open_hostinfo(s->vdisk_hostinfo.host,
467
+ s->vdisk_hostinfo.port);
468
+
469
+ of_vsa_addr = g_strdup_printf("of://%s:%d",
470
+ s->vdisk_hostinfo.host,
471
+ s->vdisk_hostinfo.port);
472
+
473
+ /*
474
+ * Open qnio channel to storage agent if not opened before
475
+ */
476
+ dev_handlep = iio_open(of_vsa_addr, s->vdisk_guid, 0,
477
+ cacert, client_key, client_cert);
478
+ if (dev_handlep == NULL) {
479
+ trace_vxhs_open_iio_open(of_vsa_addr);
480
+ ret = -ENODEV;
481
+ goto out;
482
+ }
483
+ s->vdisk_hostinfo.dev_handle = dev_handlep;
484
+
485
+out:
486
+ g_free(of_vsa_addr);
487
+ QDECREF(backing_options);
488
+ qemu_opts_del(tcp_opts);
489
+ qemu_opts_del(opts);
490
+ g_free(cacert);
491
+ g_free(client_key);
492
+ g_free(client_cert);
493
+
494
+ if (ret < 0) {
495
+ vxhs_unref();
496
+ error_propagate(errp, local_err);
497
+ g_free(s->vdisk_hostinfo.host);
498
+ g_free(s->vdisk_guid);
499
+ g_free(s->tlscredsid);
500
+ s->vdisk_guid = NULL;
501
+ }
502
+
503
+ return ret;
504
+}
505
+
506
+static const AIOCBInfo vxhs_aiocb_info = {
507
+ .aiocb_size = sizeof(VXHSAIOCB)
508
+};
509
+
510
+/*
511
+ * This allocates QEMU-VXHS callback for each IO
512
+ * and is passed to QNIO. When QNIO completes the work,
513
+ * it will be passed back through the callback.
514
+ */
515
+static BlockAIOCB *vxhs_aio_rw(BlockDriverState *bs, int64_t sector_num,
516
+ QEMUIOVector *qiov, int nb_sectors,
517
+ BlockCompletionFunc *cb, void *opaque,
518
+ VDISKAIOCmd iodir)
519
+{
520
+ VXHSAIOCB *acb = NULL;
521
+ BDRVVXHSState *s = bs->opaque;
522
+ size_t size;
523
+ uint64_t offset;
524
+ int iio_flags = 0;
525
+ int ret = 0;
526
+ void *dev_handle = s->vdisk_hostinfo.dev_handle;
527
+
528
+ offset = sector_num * BDRV_SECTOR_SIZE;
529
+ size = nb_sectors * BDRV_SECTOR_SIZE;
530
+ acb = qemu_aio_get(&vxhs_aiocb_info, bs, cb, opaque);
531
+
532
+ /*
533
+ * Initialize VXHSAIOCB.
534
+ */
535
+ acb->err = 0;
536
+
537
+ iio_flags = IIO_FLAG_ASYNC;
538
+
539
+ switch (iodir) {
540
+ case VDISK_AIO_WRITE:
541
+ ret = iio_writev(dev_handle, acb, qiov->iov, qiov->niov,
542
+ offset, (uint64_t)size, iio_flags);
543
+ break;
544
+ case VDISK_AIO_READ:
545
+ ret = iio_readv(dev_handle, acb, qiov->iov, qiov->niov,
546
+ offset, (uint64_t)size, iio_flags);
547
+ break;
548
+ default:
549
+ trace_vxhs_aio_rw_invalid(iodir);
550
+ goto errout;
551
+ }
552
+
553
+ if (ret != 0) {
554
+ trace_vxhs_aio_rw_ioerr(s->vdisk_guid, iodir, size, offset,
555
+ acb, ret, errno);
556
+ goto errout;
557
+ }
558
+ return &acb->common;
559
+
560
+errout:
561
+ qemu_aio_unref(acb);
562
+ return NULL;
563
+}
564
+
565
+static BlockAIOCB *vxhs_aio_readv(BlockDriverState *bs,
566
+ int64_t sector_num, QEMUIOVector *qiov,
567
+ int nb_sectors,
568
+ BlockCompletionFunc *cb, void *opaque)
569
+{
570
+ return vxhs_aio_rw(bs, sector_num, qiov, nb_sectors, cb,
571
+ opaque, VDISK_AIO_READ);
572
+}
573
+
574
+static BlockAIOCB *vxhs_aio_writev(BlockDriverState *bs,
575
+ int64_t sector_num, QEMUIOVector *qiov,
576
+ int nb_sectors,
577
+ BlockCompletionFunc *cb, void *opaque)
578
+{
579
+ return vxhs_aio_rw(bs, sector_num, qiov, nb_sectors,
580
+ cb, opaque, VDISK_AIO_WRITE);
581
+}
582
+
583
+static void vxhs_close(BlockDriverState *bs)
584
+{
585
+ BDRVVXHSState *s = bs->opaque;
586
+
587
+ trace_vxhs_close(s->vdisk_guid);
588
+
589
+ g_free(s->vdisk_guid);
590
+ s->vdisk_guid = NULL;
591
+
592
+ /*
593
+ * Close vDisk device
594
+ */
595
+ if (s->vdisk_hostinfo.dev_handle) {
596
+ iio_close(s->vdisk_hostinfo.dev_handle);
597
+ s->vdisk_hostinfo.dev_handle = NULL;
598
+ }
599
+
600
+ vxhs_unref();
601
+
602
+ /*
603
+ * Free the dynamically allocated host string etc
604
+ */
605
+ g_free(s->vdisk_hostinfo.host);
606
+ g_free(s->tlscredsid);
607
+ s->tlscredsid = NULL;
608
+ s->vdisk_hostinfo.host = NULL;
609
+ s->vdisk_hostinfo.port = 0;
610
+}
611
+
612
+static int64_t vxhs_get_vdisk_stat(BDRVVXHSState *s)
613
+{
614
+ int64_t vdisk_size = -1;
615
+ int ret = 0;
616
+ void *dev_handle = s->vdisk_hostinfo.dev_handle;
617
+
618
+ ret = iio_ioctl(dev_handle, IOR_VDISK_STAT, &vdisk_size, 0);
619
+ if (ret < 0) {
620
+ trace_vxhs_get_vdisk_stat_err(s->vdisk_guid, ret, errno);
621
+ return -EIO;
622
+ }
623
+
624
+ trace_vxhs_get_vdisk_stat(s->vdisk_guid, vdisk_size);
625
+ return vdisk_size;
626
+}
627
+
628
+/*
629
+ * Returns the size of vDisk in bytes. This is required
630
+ * by QEMU block upper block layer so that it is visible
631
+ * to guest.
632
+ */
633
+static int64_t vxhs_getlength(BlockDriverState *bs)
634
+{
635
+ BDRVVXHSState *s = bs->opaque;
636
+ int64_t vdisk_size;
637
+
638
+ vdisk_size = vxhs_get_vdisk_stat(s);
639
+ if (vdisk_size < 0) {
640
+ return -EIO;
641
+ }
642
+
643
+ return vdisk_size;
644
+}
645
+
646
+static BlockDriver bdrv_vxhs = {
647
+ .format_name = "vxhs",
648
+ .protocol_name = "vxhs",
649
+ .instance_size = sizeof(BDRVVXHSState),
650
+ .bdrv_file_open = vxhs_open,
651
+ .bdrv_parse_filename = vxhs_parse_filename,
652
+ .bdrv_close = vxhs_close,
653
+ .bdrv_getlength = vxhs_getlength,
654
+ .bdrv_aio_readv = vxhs_aio_readv,
655
+ .bdrv_aio_writev = vxhs_aio_writev,
656
+};
657
+
658
+static void bdrv_vxhs_init(void)
659
+{
660
+ bdrv_register(&bdrv_vxhs);
661
+}
662
+
663
+block_init(bdrv_vxhs_init);
664
diff --git a/configure b/configure
665
index XXXXXXX..XXXXXXX 100755
666
--- a/configure
667
+++ b/configure
668
@@ -XXX,XX +XXX,XX @@ numa=""
669
tcmalloc="no"
670
jemalloc="no"
671
replication="yes"
672
+vxhs=""
673
674
supported_cpu="no"
675
supported_os="no"
676
@@ -XXX,XX +XXX,XX @@ for opt do
677
;;
678
--enable-replication) replication="yes"
679
;;
680
+ --disable-vxhs) vxhs="no"
681
+ ;;
682
+ --enable-vxhs) vxhs="yes"
683
+ ;;
684
*)
685
echo "ERROR: unknown option $opt"
686
echo "Try '$0 --help' for more information"
687
@@ -XXX,XX +XXX,XX @@ disabled with --disable-FEATURE, default is enabled if available:
688
xfsctl xfsctl support
689
qom-cast-debug cast debugging support
690
tools build qemu-io, qemu-nbd and qemu-image tools
691
+ vxhs Veritas HyperScale vDisk backend support
692
693
NOTE: The object files are built at the place where configure is launched
694
EOF
695
@@ -XXX,XX +XXX,XX @@ if compile_prog "" "" ; then
696
fi
697
698
##########################################
699
+# Veritas HyperScale block driver VxHS
700
+# Check if libvxhs is installed
701
+
702
+if test "$vxhs" != "no" ; then
703
+ cat > $TMPC <<EOF
704
+#include <stdint.h>
705
+#include <qnio/qnio_api.h>
706
+
707
+void *vxhs_callback;
708
+
709
+int main(void) {
710
+ iio_init(QNIO_VERSION, vxhs_callback);
711
+ return 0;
712
+}
713
+EOF
714
+ vxhs_libs="-lvxhs -lssl"
715
+ if compile_prog "" "$vxhs_libs" ; then
716
+ vxhs=yes
717
+ else
718
+ if test "$vxhs" = "yes" ; then
719
+ feature_not_found "vxhs block device" "Install libvxhs See github"
720
+ fi
721
+ vxhs=no
722
+ fi
723
+fi
724
+
725
+##########################################
726
# End of CC checks
727
# After here, no more $cc or $ld runs
728
729
@@ -XXX,XX +XXX,XX @@ echo "tcmalloc support $tcmalloc"
730
echo "jemalloc support $jemalloc"
731
echo "avx2 optimization $avx2_opt"
732
echo "replication support $replication"
733
+echo "VxHS block device $vxhs"
734
735
if test "$sdl_too_old" = "yes"; then
736
echo "-> Your SDL version is too old - please upgrade to have SDL support"
737
@@ -XXX,XX +XXX,XX @@ if test "$pthread_setname_np" = "yes" ; then
738
echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
739
fi
740
741
+if test "$vxhs" = "yes" ; then
742
+ echo "CONFIG_VXHS=y" >> $config_host_mak
743
+ echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
744
+fi
745
+
746
if test "$tcg_interpreter" = "yes"; then
747
QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
748
elif test "$ARCH" = "sparc64" ; then
749
diff --git a/qapi/block-core.json b/qapi/block-core.json
750
index XXXXXXX..XXXXXXX 100644
751
--- a/qapi/block-core.json
752
+++ b/qapi/block-core.json
753
@@ -XXX,XX +XXX,XX @@
754
#
755
# Drivers that are supported in block device operations.
756
#
757
+# @vxhs: Since 2.10
758
+#
759
# Since: 2.9
760
##
761
{ 'enum': 'BlockdevDriver',
762
@@ -XXX,XX +XXX,XX @@
763
'host_device', 'http', 'https', 'iscsi', 'luks', 'nbd', 'nfs',
764
'null-aio', 'null-co', 'parallels', 'qcow', 'qcow2', 'qed',
765
'quorum', 'raw', 'rbd', 'replication', 'sheepdog', 'ssh',
766
- 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] }
767
+ 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat', 'vxhs' ] }
768
769
##
770
# @BlockdevOptionsFile:
771
@@ -XXX,XX +XXX,XX @@
772
'data': { '*offset': 'int', '*size': 'int' } }
773
774
##
775
+# @BlockdevOptionsVxHS:
776
+#
777
+# Driver specific block device options for VxHS
778
+#
779
+# @vdisk-id: UUID of VxHS volume
780
+# @server: vxhs server IP, port
781
+# @tls-creds: TLS credentials ID
782
+#
783
+# Since: 2.10
784
+##
785
+{ 'struct': 'BlockdevOptionsVxHS',
786
+ 'data': { 'vdisk-id': 'str',
787
+ 'server': 'InetSocketAddressBase',
788
+ '*tls-creds': 'str' } }
789
+
790
+##
791
# @BlockdevOptions:
792
#
793
# Options for creating a block device. Many options are available for all
794
@@ -XXX,XX +XXX,XX @@
795
'vhdx': 'BlockdevOptionsGenericFormat',
796
'vmdk': 'BlockdevOptionsGenericCOWFormat',
797
'vpc': 'BlockdevOptionsGenericFormat',
798
- 'vvfat': 'BlockdevOptionsVVFAT'
799
+ 'vvfat': 'BlockdevOptionsVVFAT',
800
+ 'vxhs': 'BlockdevOptionsVxHS'
801
} }
802
803
##
804
--
104
--
805
2.9.3
105
2.34.1
806
106
807
107
diff view generated by jsdifflib
1
This adds support for reopen in rbd, for changing between r/w and r/o.
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
2
3
Note, that this is only a flag change, but we will block a change from
3
We'll use it in tests instead of explicit qcow2.py. Then we are going
4
r/o to r/w if we are using an RBD internal snapshot.
4
to add some filtering in _qcow2_dump_header.
5
5
6
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
6
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7
Signed-off-by: Jeff Cody <jcody@redhat.com>
7
Reviewed-by: Max Reitz <mreitz@redhat.com>
8
Reviewed-by: John Snow <jsnow@redhat.com>
8
Message-Id: <20211223160144.1097696-14-vsementsov@virtuozzo.com>
9
Message-id: d4e87539167ec6527d44c97b164eabcccf96e4f3.1491597120.git.jcody@redhat.com
9
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
10
---
10
---
11
block/rbd.c | 21 +++++++++++++++++++++
11
tests/qemu-iotests/common.rc | 10 ++++++++++
12
1 file changed, 21 insertions(+)
12
1 file changed, 10 insertions(+)
13
13
14
diff --git a/block/rbd.c b/block/rbd.c
14
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
15
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
16
--- a/block/rbd.c
16
--- a/tests/qemu-iotests/common.rc
17
+++ b/block/rbd.c
17
+++ b/tests/qemu-iotests/common.rc
18
@@ -XXX,XX +XXX,XX @@ failed_opts:
18
@@ -XXX,XX +XXX,XX @@ _require_one_device_of()
19
return r;
19
_notrun "$* not available"
20
}
20
}
21
21
22
+_qcow2_dump_header()
23
+{
24
+ img="$1"
25
+ if [ -z "$img" ]; then
26
+ img="$TEST_IMG"
27
+ fi
22
+
28
+
23
+/* Since RBD is currently always opened R/W via the API,
29
+ $PYTHON qcow2.py "$img" dump-header
24
+ * we just need to check if we are using a snapshot or not, in
25
+ * order to determine if we will allow it to be R/W */
26
+static int qemu_rbd_reopen_prepare(BDRVReopenState *state,
27
+ BlockReopenQueue *queue, Error **errp)
28
+{
29
+ BDRVRBDState *s = state->bs->opaque;
30
+ int ret = 0;
31
+
32
+ if (s->snap && state->flags & BDRV_O_RDWR) {
33
+ error_setg(errp,
34
+ "Cannot change node '%s' to r/w when using RBD snapshot",
35
+ bdrv_get_device_or_node_name(state->bs));
36
+ ret = -EINVAL;
37
+ }
38
+
39
+ return ret;
40
+}
30
+}
41
+
31
+
42
static void qemu_rbd_close(BlockDriverState *bs)
32
# make sure this script returns success
43
{
33
true
44
BDRVRBDState *s = bs->opaque;
45
@@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_rbd = {
46
.bdrv_parse_filename = qemu_rbd_parse_filename,
47
.bdrv_file_open = qemu_rbd_open,
48
.bdrv_close = qemu_rbd_close,
49
+ .bdrv_reopen_prepare = qemu_rbd_reopen_prepare,
50
.bdrv_create = qemu_rbd_create,
51
.bdrv_has_zero_init = bdrv_has_zero_init_1,
52
.bdrv_get_info = qemu_rbd_getinfo,
53
--
34
--
54
2.9.3
35
2.34.1
55
36
56
37
diff view generated by jsdifflib
New patch
1
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
3
We are going to add filtering in _qcow2_dump_header and want all tests
4
use it.
5
6
The patch is generated by commands:
7
cd tests/qemu-iotests
8
sed -ie 's/$PYTHON qcow2.py "$TEST_IMG" dump-header\($\| \)/_qcow2_dump_header\1/' ??? tests/*
9
10
(the difficulty is to avoid converting dump-header-exts)
11
12
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
13
Reviewed-by: Max Reitz <mreitz@redhat.com>
14
Message-Id: <20211223160144.1097696-15-vsementsov@virtuozzo.com>
15
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
16
---
17
tests/qemu-iotests/031 | 6 +++---
18
tests/qemu-iotests/036 | 6 +++---
19
tests/qemu-iotests/039 | 20 ++++++++++----------
20
tests/qemu-iotests/060 | 20 ++++++++++----------
21
tests/qemu-iotests/061 | 36 ++++++++++++++++++------------------
22
tests/qemu-iotests/137 | 2 +-
23
tests/qemu-iotests/287 | 8 ++++----
24
7 files changed, 49 insertions(+), 49 deletions(-)
25
26
diff --git a/tests/qemu-iotests/031 b/tests/qemu-iotests/031
27
index XXXXXXX..XXXXXXX 100755
28
--- a/tests/qemu-iotests/031
29
+++ b/tests/qemu-iotests/031
30
@@ -XXX,XX +XXX,XX @@ for compat in "compat=0.10" "compat=1.1"; do
31
echo
32
_make_test_img -o $compat 64M
33
$PYTHON qcow2.py "$TEST_IMG" add-header-ext 0x12345678 "This is a test header extension"
34
- $PYTHON qcow2.py "$TEST_IMG" dump-header
35
+ _qcow2_dump_header
36
_check_test_img
37
38
echo
39
echo === Rewrite header with no backing file ===
40
echo
41
$QEMU_IMG rebase -u -b "" "$TEST_IMG"
42
- $PYTHON qcow2.py "$TEST_IMG" dump-header
43
+ _qcow2_dump_header
44
_check_test_img
45
46
echo
47
echo === Add a backing file and format ===
48
echo
49
$QEMU_IMG rebase -u -b "/some/backing/file/path" -F host_device "$TEST_IMG"
50
- $PYTHON qcow2.py "$TEST_IMG" dump-header
51
+ _qcow2_dump_header
52
done
53
54
# success, all done
55
diff --git a/tests/qemu-iotests/036 b/tests/qemu-iotests/036
56
index XXXXXXX..XXXXXXX 100755
57
--- a/tests/qemu-iotests/036
58
+++ b/tests/qemu-iotests/036
59
@@ -XXX,XX +XXX,XX @@ $PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 63
60
61
# Without feature table
62
$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857
63
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep features
64
+_qcow2_dump_header | grep features
65
$PYTHON qcow2.py "$TEST_IMG" dump-header-exts
66
_img_info
67
68
@@ -XXX,XX +XXX,XX @@ echo === Create image with unknown autoclear feature bit ===
69
echo
70
_make_test_img 64M
71
$PYTHON qcow2.py "$TEST_IMG" set-feature-bit autoclear 63
72
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep features
73
+_qcow2_dump_header | grep features
74
$PYTHON qcow2.py "$TEST_IMG" dump-header-exts
75
76
echo
77
@@ -XXX,XX +XXX,XX @@ echo === Repair image ===
78
echo
79
_check_test_img -r all
80
81
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep features
82
+_qcow2_dump_header | grep features
83
$PYTHON qcow2.py "$TEST_IMG" dump-header-exts
84
85
# success, all done
86
diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
87
index XXXXXXX..XXXXXXX 100755
88
--- a/tests/qemu-iotests/039
89
+++ b/tests/qemu-iotests/039
90
@@ -XXX,XX +XXX,XX @@ _make_test_img -o "compat=1.1,lazy_refcounts=on" $size
91
$QEMU_IO -c "write -P 0x5a 0 512" "$TEST_IMG" | _filter_qemu_io
92
93
# The dirty bit must not be set
94
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
95
+_qcow2_dump_header | grep incompatible_features
96
_check_test_img
97
98
echo
99
@@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "write -P 0x5a 0 512" \
100
| _filter_qemu_io
101
102
# The dirty bit must be set
103
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
104
+_qcow2_dump_header | grep incompatible_features
105
_check_test_img
106
107
echo
108
@@ -XXX,XX +XXX,XX @@ echo "== Read-only access must still work =="
109
$QEMU_IO -r -c "read -P 0x5a 0 512" "$TEST_IMG" | _filter_qemu_io
110
111
# The dirty bit must be set
112
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
113
+_qcow2_dump_header | grep incompatible_features
114
115
echo
116
echo "== Repairing the image file must succeed =="
117
@@ -XXX,XX +XXX,XX @@ echo "== Repairing the image file must succeed =="
118
_check_test_img -r all
119
120
# The dirty bit must not be set
121
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
122
+_qcow2_dump_header | grep incompatible_features
123
124
echo
125
echo "== Data should still be accessible after repair =="
126
@@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "write -P 0x5a 0 512" \
127
| _filter_qemu_io
128
129
# The dirty bit must be set
130
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
131
+_qcow2_dump_header | grep incompatible_features
132
133
$QEMU_IO -c "write 0 512" "$TEST_IMG" | _filter_qemu_io
134
135
# The dirty bit must not be set
136
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
137
+_qcow2_dump_header | grep incompatible_features
138
139
echo
140
echo "== Creating an image file with lazy_refcounts=off =="
141
@@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "write -P 0x5a 0 512" \
142
| _filter_qemu_io
143
144
# The dirty bit must not be set since lazy_refcounts=off
145
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
146
+_qcow2_dump_header | grep incompatible_features
147
_check_test_img
148
149
echo
150
@@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "write 0 512" "$TEST_IMG" | _filter_qemu_io
151
$QEMU_IMG commit "$TEST_IMG"
152
153
# The dirty bit must not be set
154
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
155
+_qcow2_dump_header | grep incompatible_features
156
$PYTHON qcow2.py "$TEST_IMG".base dump-header | grep incompatible_features
157
158
_check_test_img
159
@@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "reopen -o lazy-refcounts=on" \
160
| _filter_qemu_io
161
162
# The dirty bit must be set
163
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
164
+_qcow2_dump_header | grep incompatible_features
165
_check_test_img
166
167
_make_test_img -o "compat=1.1,lazy_refcounts=on" $size
168
@@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "reopen -o lazy-refcounts=off" \
169
| _filter_qemu_io
170
171
# The dirty bit must not be set
172
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
173
+_qcow2_dump_header | grep incompatible_features
174
_check_test_img
175
176
177
diff --git a/tests/qemu-iotests/060 b/tests/qemu-iotests/060
178
index XXXXXXX..XXXXXXX 100755
179
--- a/tests/qemu-iotests/060
180
+++ b/tests/qemu-iotests/060
181
@@ -XXX,XX +XXX,XX @@ poke_file "$TEST_IMG" "$l1_offset" "\x80\x00\x00\x00\x00\x03\x00\x00"
182
_check_test_img
183
184
# The corrupt bit should not be set anyway
185
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
186
+_qcow2_dump_header | grep incompatible_features
187
188
# Try to write something, thereby forcing the corrupt bit to be set
189
$QEMU_IO -c "$OPEN_RW" -c "write -P 0x2a 0 512" | _filter_qemu_io
190
191
# The corrupt bit must now be set
192
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
193
+_qcow2_dump_header | grep incompatible_features
194
195
# This information should be available through qemu-img info
196
_img_info --format-specific
197
@@ -XXX,XX +XXX,XX @@ poke_file "$TEST_IMG" "$(($rb_offset+8))" "\x00\x01"
198
# Redirect new data cluster onto refcount block
199
poke_file "$TEST_IMG" "$l2_offset" "\x80\x00\x00\x00\x00\x02\x00\x00"
200
_check_test_img
201
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
202
+_qcow2_dump_header | grep incompatible_features
203
$QEMU_IO -c "$OPEN_RW" -c "write -P 0x2a 0 512" | _filter_qemu_io
204
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
205
+_qcow2_dump_header | grep incompatible_features
206
207
# Try to fix it
208
_check_test_img -r all
209
210
# The corrupt bit should be cleared
211
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
212
+_qcow2_dump_header | grep incompatible_features
213
214
# Look if it's really really fixed
215
$QEMU_IO -c "$OPEN_RW" -c "write -P 0x2a 0 512" | _filter_qemu_io
216
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
217
+_qcow2_dump_header | grep incompatible_features
218
219
echo
220
echo "=== Testing cluster data reference into inactive L2 table ==="
221
@@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "$OPEN_RW" -c "write -P 2 0 512" | _filter_qemu_io
222
poke_file "$TEST_IMG" "$l2_offset_after_snapshot" \
223
"\x80\x00\x00\x00\x00\x04\x00\x00"
224
_check_test_img
225
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
226
+_qcow2_dump_header | grep incompatible_features
227
$QEMU_IO -c "$OPEN_RW" -c "write -P 3 0 512" | _filter_qemu_io
228
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
229
+_qcow2_dump_header | grep incompatible_features
230
_check_test_img -r all
231
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
232
+_qcow2_dump_header | grep incompatible_features
233
$QEMU_IO -c "$OPEN_RW" -c "write -P 4 0 512" | _filter_qemu_io
234
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
235
+_qcow2_dump_header | grep incompatible_features
236
237
# Check data
238
$QEMU_IO -c "$OPEN_RO" -c "read -P 4 0 512" | _filter_qemu_io
239
diff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061
240
index XXXXXXX..XXXXXXX 100755
241
--- a/tests/qemu-iotests/061
242
+++ b/tests/qemu-iotests/061
243
@@ -XXX,XX +XXX,XX @@ echo "=== Testing version downgrade with zero expansion ==="
244
echo
245
_make_test_img -o "compat=1.1,lazy_refcounts=on" 64M
246
$QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io
247
-$PYTHON qcow2.py "$TEST_IMG" dump-header
248
+_qcow2_dump_header
249
$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
250
-$PYTHON qcow2.py "$TEST_IMG" dump-header
251
+_qcow2_dump_header
252
$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
253
_check_test_img
254
255
@@ -XXX,XX +XXX,XX @@ _make_test_img -o "compat=1.1,lazy_refcounts=on" 64M
256
$QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io
257
$QEMU_IO -c "write -z 32M 128k" "$TEST_IMG" | _filter_qemu_io
258
$QEMU_IO -c map "$TEST_IMG" | _filter_qemu_io
259
-$PYTHON qcow2.py "$TEST_IMG" dump-header
260
+_qcow2_dump_header
261
$QEMU_IMG amend -o "compat=0.10" --image-opts \
262
driver=qcow2,file.filename=$TEST_IMG,l2-cache-entry-size=4096
263
-$PYTHON qcow2.py "$TEST_IMG" dump-header
264
+_qcow2_dump_header
265
$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
266
$QEMU_IO -c "read -P 0 32M 128k" "$TEST_IMG" | _filter_qemu_io
267
$QEMU_IO -c map "$TEST_IMG" | _filter_qemu_io
268
@@ -XXX,XX +XXX,XX @@ _make_test_img -o "compat=1.1,lazy_refcounts=on" 64M
269
_NO_VALGRIND \
270
$QEMU_IO -c "write -P 0x2a 0 128k" -c flush \
271
-c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 | _filter_qemu_io
272
-$PYTHON qcow2.py "$TEST_IMG" dump-header
273
+_qcow2_dump_header
274
$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
275
-$PYTHON qcow2.py "$TEST_IMG" dump-header
276
+_qcow2_dump_header
277
$QEMU_IO -c "read -P 0x2a 0 128k" "$TEST_IMG" | _filter_qemu_io
278
_check_test_img
279
280
@@ -XXX,XX +XXX,XX @@ echo
281
_make_test_img -o "compat=1.1" 64M
282
$PYTHON qcow2.py "$TEST_IMG" set-feature-bit compatible 42
283
$PYTHON qcow2.py "$TEST_IMG" set-feature-bit autoclear 42
284
-$PYTHON qcow2.py "$TEST_IMG" dump-header
285
+_qcow2_dump_header
286
$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
287
-$PYTHON qcow2.py "$TEST_IMG" dump-header
288
+_qcow2_dump_header
289
_check_test_img
290
291
echo
292
@@ -XXX,XX +XXX,XX @@ echo "=== Testing version upgrade and resize ==="
293
echo
294
_make_test_img -o "compat=0.10" 64M
295
$QEMU_IO -c "write -P 0x2a 42M 64k" "$TEST_IMG" | _filter_qemu_io
296
-$PYTHON qcow2.py "$TEST_IMG" dump-header
297
+_qcow2_dump_header
298
$QEMU_IMG amend -o "compat=1.1,lazy_refcounts=on,size=128M" "$TEST_IMG"
299
-$PYTHON qcow2.py "$TEST_IMG" dump-header
300
+_qcow2_dump_header
301
$QEMU_IO -c "read -P 0x2a 42M 64k" "$TEST_IMG" | _filter_qemu_io
302
_check_test_img
303
304
@@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "write -P 0x2a 24M 64k" "$TEST_IMG" | _filter_qemu_io
305
$QEMU_IMG snapshot -c foo "$TEST_IMG"
306
$QEMU_IMG resize "$TEST_IMG" 64M &&
307
echo "unexpected pass"
308
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep '^\(version\|size\|nb_snap\)'
309
+_qcow2_dump_header | grep '^\(version\|size\|nb_snap\)'
310
311
$QEMU_IMG amend -o "compat=1.1,size=128M" "$TEST_IMG" ||
312
echo "unexpected fail"
313
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep '^\(version\|size\|nb_snap\)'
314
+_qcow2_dump_header | grep '^\(version\|size\|nb_snap\)'
315
316
$QEMU_IMG snapshot -c bar "$TEST_IMG"
317
$QEMU_IMG resize --shrink "$TEST_IMG" 64M ||
318
echo "unexpected fail"
319
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep '^\(version\|size\|nb_snap\)'
320
+_qcow2_dump_header | grep '^\(version\|size\|nb_snap\)'
321
322
$QEMU_IMG amend -o "compat=0.10,size=32M" "$TEST_IMG" &&
323
echo "unexpected pass"
324
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep '^\(version\|size\|nb_snap\)'
325
+_qcow2_dump_header | grep '^\(version\|size\|nb_snap\)'
326
327
$QEMU_IMG snapshot -a bar "$TEST_IMG" ||
328
echo "unexpected fail"
329
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep '^\(version\|size\|nb_snap\)'
330
+_qcow2_dump_header | grep '^\(version\|size\|nb_snap\)'
331
332
$QEMU_IMG snapshot -d bar "$TEST_IMG"
333
$QEMU_IMG amend -o "compat=0.10,size=32M" "$TEST_IMG" ||
334
echo "unexpected fail"
335
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep '^\(version\|size\|nb_snap\)'
336
+_qcow2_dump_header | grep '^\(version\|size\|nb_snap\)'
337
338
_check_test_img
339
340
@@ -XXX,XX +XXX,XX @@ _make_test_img -o "compat=1.1,lazy_refcounts=on" 64M
341
_NO_VALGRIND \
342
$QEMU_IO -c "write -P 0x2a 0 128k" -c flush \
343
-c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 | _filter_qemu_io
344
-$PYTHON qcow2.py "$TEST_IMG" dump-header
345
+_qcow2_dump_header
346
$QEMU_IMG amend -o "lazy_refcounts=off" "$TEST_IMG"
347
-$PYTHON qcow2.py "$TEST_IMG" dump-header
348
+_qcow2_dump_header
349
$QEMU_IO -c "read -P 0x2a 0 128k" "$TEST_IMG" | _filter_qemu_io
350
_check_test_img
351
352
diff --git a/tests/qemu-iotests/137 b/tests/qemu-iotests/137
353
index XXXXXXX..XXXXXXX 100755
354
--- a/tests/qemu-iotests/137
355
+++ b/tests/qemu-iotests/137
356
@@ -XXX,XX +XXX,XX @@ $QEMU_IO \
357
358
# The dirty bit must not be set
359
# (Filter the external data file bit)
360
-if $PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features \
361
+if _qcow2_dump_header | grep incompatible_features \
362
| grep -q '\<0\>'
363
then
364
echo 'ERROR: Dirty bit set'
365
diff --git a/tests/qemu-iotests/287 b/tests/qemu-iotests/287
366
index XXXXXXX..XXXXXXX 100755
367
--- a/tests/qemu-iotests/287
368
+++ b/tests/qemu-iotests/287
369
@@ -XXX,XX +XXX,XX @@ echo
370
echo "=== Testing compression type incompatible bit setting for zlib ==="
371
echo
372
_make_test_img -o compression_type=zlib 64M
373
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
374
+_qcow2_dump_header | grep incompatible_features
375
376
echo
377
echo "=== Testing compression type incompatible bit setting for zstd ==="
378
echo
379
_make_test_img -o compression_type=zstd 64M
380
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
381
+_qcow2_dump_header | grep incompatible_features
382
383
echo
384
echo "=== Testing zlib with incompatible bit set ==="
385
@@ -XXX,XX +XXX,XX @@ echo
386
_make_test_img -o compression_type=zlib 64M
387
$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 3
388
# to make sure the bit was actually set
389
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
390
+_qcow2_dump_header | grep incompatible_features
391
392
if $QEMU_IMG info "$TEST_IMG" >/dev/null 2>&1 ; then
393
echo "Error: The image opened successfully. The image must not be opened."
394
@@ -XXX,XX +XXX,XX @@ echo
395
_make_test_img -o compression_type=zstd 64M
396
$PYTHON qcow2.py "$TEST_IMG" set-header incompatible_features 0
397
# to make sure the bit was actually unset
398
-$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
399
+_qcow2_dump_header | grep incompatible_features
400
401
if $QEMU_IMG info "$TEST_IMG" >/dev/null 2>&1 ; then
402
echo "Error: The image opened successfully. The image must not be opened."
403
--
404
2.34.1
405
406
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
_qcow2_dump_header has filter for compression type, so this change
4
makes test pass with IMGOPTS='compression_type=zstd'.
5
6
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7
Reviewed-by: Max Reitz <mreitz@redhat.com>
8
Message-Id: <20211223160144.1097696-16-vsementsov@virtuozzo.com>
9
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
10
---
11
tests/qemu-iotests/039 | 2 +-
12
1 file changed, 1 insertion(+), 1 deletion(-)
13
14
diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
15
index XXXXXXX..XXXXXXX 100755
16
--- a/tests/qemu-iotests/039
17
+++ b/tests/qemu-iotests/039
18
@@ -XXX,XX +XXX,XX @@ $QEMU_IMG commit "$TEST_IMG"
19
20
# The dirty bit must not be set
21
_qcow2_dump_header | grep incompatible_features
22
-$PYTHON qcow2.py "$TEST_IMG".base dump-header | grep incompatible_features
23
+_qcow2_dump_header "$TEST_IMG".base | grep incompatible_features
24
25
_check_test_img
26
TEST_IMG="$TEST_IMG".base _check_test_img
27
--
28
2.34.1
29
30
diff view generated by jsdifflib
1
From: Ashish Mittal <ashmit602@gmail.com>
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
2
3
These changes use a vxhs test server that is a part of the following
3
We want iotests pass with both the default zlib compression and with
4
repository:
4
IMGOPTS='compression_type=zstd'.
5
https://github.com/VeritasHyperScale/libqnio.git
5
6
6
Actually the only test that is interested in real compression type in
7
Signed-off-by: Ashish Mittal <Ashish.Mittal@veritas.com>
7
test output is 287 (test for qcow2 compression type), so implement
8
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
8
specific option for it.
9
Reviewed-by: Jeff Cody <jcody@redhat.com>
9
10
Signed-off-by: Jeff Cody <jcody@redhat.com>
10
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
11
Message-id: 1491277689-24949-3-git-send-email-Ashish.Mittal@veritas.com
11
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
12
Message-Id: <20211223160144.1097696-17-vsementsov@virtuozzo.com>
13
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
12
---
14
---
13
tests/qemu-iotests/common | 6 ++++++
15
tests/qemu-iotests/060.out | 2 +-
14
tests/qemu-iotests/common.config | 13 +++++++++++++
16
tests/qemu-iotests/061.out | 12 ++++++------
15
tests/qemu-iotests/common.filter | 1 +
17
tests/qemu-iotests/082.out | 14 +++++++-------
16
tests/qemu-iotests/common.rc | 19 +++++++++++++++++++
18
tests/qemu-iotests/198.out | 4 ++--
17
4 files changed, 39 insertions(+)
19
tests/qemu-iotests/287 | 8 ++++----
18
20
tests/qemu-iotests/common.filter | 8 ++++++++
19
diff --git a/tests/qemu-iotests/common b/tests/qemu-iotests/common
21
tests/qemu-iotests/common.rc | 14 +++++++++++++-
20
index XXXXXXX..XXXXXXX 100644
22
7 files changed, 41 insertions(+), 21 deletions(-)
21
--- a/tests/qemu-iotests/common
23
22
+++ b/tests/qemu-iotests/common
24
diff --git a/tests/qemu-iotests/060.out b/tests/qemu-iotests/060.out
23
@@ -XXX,XX +XXX,XX @@ check options
25
index XXXXXXX..XXXXXXX 100644
24
-ssh test ssh
26
--- a/tests/qemu-iotests/060.out
25
-nfs test nfs
27
+++ b/tests/qemu-iotests/060.out
26
-luks test luks
28
@@ -XXX,XX +XXX,XX @@ virtual size: 64 MiB (67108864 bytes)
27
+ -vxhs test vxhs
29
cluster_size: 65536
28
-xdiff graphical mode diff
30
Format specific information:
29
-nocache use O_DIRECT on backing file
31
compat: 1.1
30
-misalign misalign memory allocations
32
- compression type: zlib
31
@@ -XXX,XX +XXX,XX @@ testlist options
33
+ compression type: COMPRESSION_TYPE
32
xpand=false
34
lazy refcounts: false
33
;;
35
refcount bits: 16
34
36
corrupt: true
35
+ -vxhs)
37
diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out
36
+ IMGPROTO=vxhs
38
index XXXXXXX..XXXXXXX 100644
37
+ xpand=false
39
--- a/tests/qemu-iotests/061.out
38
+ ;;
40
+++ b/tests/qemu-iotests/061.out
39
+
41
@@ -XXX,XX +XXX,XX @@ virtual size: 64 MiB (67108864 bytes)
40
-ssh)
42
cluster_size: 65536
41
IMGPROTO=ssh
43
Format specific information:
42
xpand=false
44
compat: 1.1
43
diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/common.config
45
- compression type: zlib
44
index XXXXXXX..XXXXXXX 100644
46
+ compression type: COMPRESSION_TYPE
45
--- a/tests/qemu-iotests/common.config
47
lazy refcounts: false
46
+++ b/tests/qemu-iotests/common.config
48
refcount bits: 16
47
@@ -XXX,XX +XXX,XX @@ if [ -z "$QEMU_NBD_PROG" ]; then
49
data file: TEST_DIR/t.IMGFMT.data
48
export QEMU_NBD_PROG="`set_prog_path qemu-nbd`"
50
@@ -XXX,XX +XXX,XX @@ virtual size: 64 MiB (67108864 bytes)
49
fi
51
cluster_size: 65536
50
52
Format specific information:
51
+if [ -z "$QEMU_VXHS_PROG" ]; then
53
compat: 1.1
52
+ export QEMU_VXHS_PROG="`set_prog_path qnio_server`"
54
- compression type: zlib
53
+fi
55
+ compression type: COMPRESSION_TYPE
54
+
56
lazy refcounts: false
55
_qemu_wrapper()
57
refcount bits: 16
56
{
58
data file: foo
57
(
59
@@ -XXX,XX +XXX,XX @@ virtual size: 64 MiB (67108864 bytes)
58
@@ -XXX,XX +XXX,XX @@ _qemu_nbd_wrapper()
60
cluster_size: 65536
59
)
61
Format specific information:
60
}
62
compat: 1.1
61
63
- compression type: zlib
62
+_qemu_vxhs_wrapper()
64
+ compression type: COMPRESSION_TYPE
63
+{
65
lazy refcounts: false
64
+ (
66
refcount bits: 16
65
+ echo $BASHPID > "${TEST_DIR}/qemu-vxhs.pid"
67
data file raw: false
66
+ exec "$QEMU_VXHS_PROG" $QEMU_VXHS_OPTIONS "$@"
68
@@ -XXX,XX +XXX,XX @@ virtual size: 64 MiB (67108864 bytes)
67
+ )
69
cluster_size: 65536
68
+}
70
Format specific information:
69
+
71
compat: 1.1
70
export QEMU=_qemu_wrapper
72
- compression type: zlib
71
export QEMU_IMG=_qemu_img_wrapper
73
+ compression type: COMPRESSION_TYPE
72
export QEMU_IO=_qemu_io_wrapper
74
lazy refcounts: false
73
export QEMU_NBD=_qemu_nbd_wrapper
75
refcount bits: 16
74
+export QEMU_VXHS=_qemu_vxhs_wrapper
76
data file: TEST_DIR/t.IMGFMT.data
75
77
@@ -XXX,XX +XXX,XX @@ virtual size: 64 MiB (67108864 bytes)
76
QEMU_IMG_EXTRA_ARGS=
78
cluster_size: 65536
77
if [ "$IMGOPTSSYNTAX" = "true" ]; then
79
Format specific information:
80
compat: 1.1
81
- compression type: zlib
82
+ compression type: COMPRESSION_TYPE
83
lazy refcounts: false
84
refcount bits: 16
85
data file: TEST_DIR/t.IMGFMT.data
86
@@ -XXX,XX +XXX,XX @@ virtual size: 64 MiB (67108864 bytes)
87
cluster_size: 65536
88
Format specific information:
89
compat: 1.1
90
- compression type: zlib
91
+ compression type: COMPRESSION_TYPE
92
lazy refcounts: false
93
refcount bits: 16
94
data file: TEST_DIR/t.IMGFMT.data
95
diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out
96
index XXXXXXX..XXXXXXX 100644
97
--- a/tests/qemu-iotests/082.out
98
+++ b/tests/qemu-iotests/082.out
99
@@ -XXX,XX +XXX,XX @@ virtual size: 128 MiB (134217728 bytes)
100
cluster_size: 4096
101
Format specific information:
102
compat: 1.1
103
- compression type: zlib
104
+ compression type: COMPRESSION_TYPE
105
lazy refcounts: true
106
refcount bits: 16
107
corrupt: false
108
@@ -XXX,XX +XXX,XX @@ virtual size: 128 MiB (134217728 bytes)
109
cluster_size: 8192
110
Format specific information:
111
compat: 1.1
112
- compression type: zlib
113
+ compression type: COMPRESSION_TYPE
114
lazy refcounts: true
115
refcount bits: 16
116
corrupt: false
117
@@ -XXX,XX +XXX,XX @@ virtual size: 128 MiB (134217728 bytes)
118
cluster_size: 4096
119
Format specific information:
120
compat: 1.1
121
- compression type: zlib
122
+ compression type: COMPRESSION_TYPE
123
lazy refcounts: true
124
refcount bits: 16
125
corrupt: false
126
@@ -XXX,XX +XXX,XX @@ virtual size: 128 MiB (134217728 bytes)
127
cluster_size: 8192
128
Format specific information:
129
compat: 1.1
130
- compression type: zlib
131
+ compression type: COMPRESSION_TYPE
132
lazy refcounts: true
133
refcount bits: 16
134
corrupt: false
135
@@ -XXX,XX +XXX,XX @@ virtual size: 128 MiB (134217728 bytes)
136
cluster_size: 65536
137
Format specific information:
138
compat: 1.1
139
- compression type: zlib
140
+ compression type: COMPRESSION_TYPE
141
lazy refcounts: true
142
refcount bits: 16
143
corrupt: false
144
@@ -XXX,XX +XXX,XX @@ virtual size: 130 MiB (136314880 bytes)
145
cluster_size: 65536
146
Format specific information:
147
compat: 1.1
148
- compression type: zlib
149
+ compression type: COMPRESSION_TYPE
150
lazy refcounts: false
151
refcount bits: 16
152
corrupt: false
153
@@ -XXX,XX +XXX,XX @@ virtual size: 132 MiB (138412032 bytes)
154
cluster_size: 65536
155
Format specific information:
156
compat: 1.1
157
- compression type: zlib
158
+ compression type: COMPRESSION_TYPE
159
lazy refcounts: true
160
refcount bits: 16
161
corrupt: false
162
diff --git a/tests/qemu-iotests/198.out b/tests/qemu-iotests/198.out
163
index XXXXXXX..XXXXXXX 100644
164
--- a/tests/qemu-iotests/198.out
165
+++ b/tests/qemu-iotests/198.out
166
@@ -XXX,XX +XXX,XX @@ image: json:{ /* filtered */ }
167
file format: IMGFMT
168
virtual size: 16 MiB (16777216 bytes)
169
Format specific information:
170
- compression type: zlib
171
+ compression type: COMPRESSION_TYPE
172
encrypt:
173
ivgen alg: plain64
174
hash alg: sha256
175
@@ -XXX,XX +XXX,XX @@ virtual size: 16 MiB (16777216 bytes)
176
backing file: TEST_DIR/t.IMGFMT.base
177
backing file format: IMGFMT
178
Format specific information:
179
- compression type: zlib
180
+ compression type: COMPRESSION_TYPE
181
encrypt:
182
ivgen alg: plain64
183
hash alg: sha256
184
diff --git a/tests/qemu-iotests/287 b/tests/qemu-iotests/287
185
index XXXXXXX..XXXXXXX 100755
186
--- a/tests/qemu-iotests/287
187
+++ b/tests/qemu-iotests/287
188
@@ -XXX,XX +XXX,XX @@ echo
189
echo "=== Testing compression type incompatible bit setting for zlib ==="
190
echo
191
_make_test_img -o compression_type=zlib 64M
192
-_qcow2_dump_header | grep incompatible_features
193
+_qcow2_dump_header --no-filter-compression | grep incompatible_features
194
195
echo
196
echo "=== Testing compression type incompatible bit setting for zstd ==="
197
echo
198
_make_test_img -o compression_type=zstd 64M
199
-_qcow2_dump_header | grep incompatible_features
200
+_qcow2_dump_header --no-filter-compression | grep incompatible_features
201
202
echo
203
echo "=== Testing zlib with incompatible bit set ==="
204
@@ -XXX,XX +XXX,XX @@ echo
205
_make_test_img -o compression_type=zlib 64M
206
$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 3
207
# to make sure the bit was actually set
208
-_qcow2_dump_header | grep incompatible_features
209
+_qcow2_dump_header --no-filter-compression | grep incompatible_features
210
211
if $QEMU_IMG info "$TEST_IMG" >/dev/null 2>&1 ; then
212
echo "Error: The image opened successfully. The image must not be opened."
213
@@ -XXX,XX +XXX,XX @@ echo
214
_make_test_img -o compression_type=zstd 64M
215
$PYTHON qcow2.py "$TEST_IMG" set-header incompatible_features 0
216
# to make sure the bit was actually unset
217
-_qcow2_dump_header | grep incompatible_features
218
+_qcow2_dump_header --no-filter-compression | grep incompatible_features
219
220
if $QEMU_IMG info "$TEST_IMG" >/dev/null 2>&1 ; then
221
echo "Error: The image opened successfully. The image must not be opened."
78
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
222
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
79
index XXXXXXX..XXXXXXX 100644
223
index XXXXXXX..XXXXXXX 100644
80
--- a/tests/qemu-iotests/common.filter
224
--- a/tests/qemu-iotests/common.filter
81
+++ b/tests/qemu-iotests/common.filter
225
+++ b/tests/qemu-iotests/common.filter
82
@@ -XXX,XX +XXX,XX @@ _filter_img_info()
226
@@ -XXX,XX +XXX,XX @@ _filter_img_info()
83
-e "s#$TEST_DIR#TEST_DIR#g" \
227
-e "/block_state_zero: \\(on\\|off\\)/d" \
84
-e "s#$IMGFMT#IMGFMT#g" \
228
-e "/log_size: [0-9]\\+/d" \
85
-e 's#nbd://127.0.0.1:10810$#TEST_DIR/t.IMGFMT#g' \
229
-e "s/iters: [0-9]\\+/iters: 1024/" \
86
+ -e 's#json.*vdisk-id.*vxhs"}}#TEST_DIR/t.IMGFMT#' \
230
+ -e 's/\(compression type: \)\(zlib\|zstd\)/\1COMPRESSION_TYPE/' \
87
-e "/encrypted: yes/d" \
231
-e "s/uuid: [-a-f0-9]\\+/uuid: 00000000-0000-0000-0000-000000000000/" | \
88
-e "/cluster_size: [0-9]\\+/d" \
232
while IFS='' read -r line; do
89
-e "/table_size: [0-9]\\+/d" \
233
if [[ $format_specific == 1 ]]; then
234
@@ -XXX,XX +XXX,XX @@ _filter_authz_check_tls()
235
$SED -e 's/TLS x509 authz check for .* is denied/TLS x509 authz check for DISTINGUISHED-NAME is denied/'
236
}
237
238
+_filter_qcow2_compression_type_bit()
239
+{
240
+ $SED -e 's/\(incompatible_features\s\+\)\[3\(, \)\?/\1[/' \
241
+ -e 's/\(incompatible_features.*\), 3\]/\1]/' \
242
+ -e 's/\(incompatible_features.*\), 3\(,.*\)/\1\2/'
243
+}
244
+
245
# make sure this script returns success
246
true
90
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
247
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
91
index XXXXXXX..XXXXXXX 100644
248
index XXXXXXX..XXXXXXX 100644
92
--- a/tests/qemu-iotests/common.rc
249
--- a/tests/qemu-iotests/common.rc
93
+++ b/tests/qemu-iotests/common.rc
250
+++ b/tests/qemu-iotests/common.rc
94
@@ -XXX,XX +XXX,XX @@ else
251
@@ -XXX,XX +XXX,XX @@ _img_info()
95
elif [ "$IMGPROTO" = "nfs" ]; then
252
-e "s#$TEST_DIR#TEST_DIR#g" \
96
TEST_DIR="nfs://127.0.0.1/$TEST_DIR"
253
-e "s#$SOCK_DIR/fuse-#TEST_DIR/#g" \
97
TEST_IMG=$TEST_DIR/t.$IMGFMT
254
-e "s#$IMGFMT#IMGFMT#g" \
98
+ elif [ "$IMGPROTO" = "vxhs" ]; then
255
+ -e 's/\(compression type: \)\(zlib\|zstd\)/\1COMPRESSION_TYPE/' \
99
+ TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT
256
-e "/^disk size:/ D" \
100
+ TEST_IMG="vxhs://127.0.0.1:9999/t.$IMGFMT"
257
-e "/actual-size/ D" | \
101
else
258
while IFS='' read -r line; do
102
TEST_IMG=$IMGPROTO:$TEST_DIR/t.$IMGFMT
259
@@ -XXX,XX +XXX,XX @@ _require_one_device_of()
260
261
_qcow2_dump_header()
262
{
263
+ if [[ "$1" == "--no-filter-compression" ]]; then
264
+ local filter_compression=0
265
+ shift
266
+ else
267
+ local filter_compression=1
268
+ fi
269
+
270
img="$1"
271
if [ -z "$img" ]; then
272
img="$TEST_IMG"
103
fi
273
fi
104
@@ -XXX,XX +XXX,XX @@ _make_test_img()
274
105
eval "$QEMU_NBD -v -t -b 127.0.0.1 -p 10810 -f $IMGFMT $TEST_IMG_FILE >/dev/null &"
275
- $PYTHON qcow2.py "$img" dump-header
106
sleep 1 # FIXME: qemu-nbd needs to be listening before we continue
276
+ if [[ $filter_compression == 0 ]]; then
107
fi
277
+ $PYTHON qcow2.py "$img" dump-header
108
+
278
+ else
109
+ # Start QNIO server on image directory for vxhs protocol
279
+ $PYTHON qcow2.py "$img" dump-header | _filter_qcow2_compression_type_bit
110
+ if [ $IMGPROTO = "vxhs" ]; then
111
+ eval "$QEMU_VXHS -d $TEST_DIR > /dev/null &"
112
+ sleep 1 # Wait for server to come up.
113
+ fi
280
+ fi
114
}
281
}
115
282
116
_rm_test_img()
283
# make sure this script returns success
117
@@ -XXX,XX +XXX,XX @@ _cleanup_test_img()
118
fi
119
rm -f "$TEST_IMG_FILE"
120
;;
121
+ vxhs)
122
+ if [ -f "${TEST_DIR}/qemu-vxhs.pid" ]; then
123
+ local QEMU_VXHS_PID
124
+ read QEMU_VXHS_PID < "${TEST_DIR}/qemu-vxhs.pid"
125
+ kill ${QEMU_VXHS_PID} >/dev/null 2>&1
126
+ rm -f "${TEST_DIR}/qemu-vxhs.pid"
127
+ fi
128
+ rm -f "$TEST_IMG_FILE"
129
+ ;;
130
+
131
file)
132
_rm_test_img "$TEST_DIR/t.$IMGFMT"
133
_rm_test_img "$TEST_DIR/t.$IMGFMT.orig"
134
--
284
--
135
2.9.3
285
2.34.1
136
286
137
287
diff view generated by jsdifflib
1
Signed-off-by: Jeff Cody <jcody@redhat.com>
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2
3
Reviewed-by: John Snow <jsnow@redhat.com>
3
Don't touch other incompatible bits, like compression-type. This makes
4
Message-id: 00aed7ffdd7be4b9ed9ce1007d50028a72b34ebe.1491597120.git.jcody@redhat.com
4
the test pass with IMGOPTS='compression_type=zstd'.
5
6
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7
Reviewed-by: Max Reitz <mreitz@redhat.com>
8
Message-Id: <20211223160144.1097696-18-vsementsov@virtuozzo.com>
9
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
5
---
10
---
6
block.c | 14 ++++++++------
11
tests/qemu-iotests/060 | 2 +-
7
1 file changed, 8 insertions(+), 6 deletions(-)
12
1 file changed, 1 insertion(+), 1 deletion(-)
8
13
9
diff --git a/block.c b/block.c
14
diff --git a/tests/qemu-iotests/060 b/tests/qemu-iotests/060
10
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100755
11
--- a/block.c
16
--- a/tests/qemu-iotests/060
12
+++ b/block.c
17
+++ b/tests/qemu-iotests/060
13
@@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
18
@@ -XXX,XX +XXX,XX @@ _make_test_img 64M
14
BlockDriver *drv;
19
# Let the refblock appear unaligned
15
QemuOpts *opts;
20
poke_file "$TEST_IMG" "$rt_offset" "\x00\x00\x00\x00\xff\xff\x2a\x00"
16
const char *value;
21
# Mark the image dirty, thus forcing an automatic check when opening it
17
+ bool read_only;
22
-poke_file "$TEST_IMG" 72 "\x00\x00\x00\x00\x00\x00\x00\x01"
18
23
+$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 0
19
assert(reopen_state != NULL);
24
# Open the image (qemu should refuse to do so)
20
assert(reopen_state->bs->drv != NULL);
25
$QEMU_IO -c close "$TEST_IMG" 2>&1 | _filter_testdir | _filter_imgfmt
21
@@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
22
qdict_put(reopen_state->options, "driver", qstring_from_str(value));
23
}
24
25
- /* if we are to stay read-only, do not allow permission change
26
- * to r/w */
27
- if (!(reopen_state->bs->open_flags & BDRV_O_ALLOW_RDWR) &&
28
- reopen_state->flags & BDRV_O_RDWR) {
29
- error_setg(errp, "Node '%s' is read only",
30
- bdrv_get_device_or_node_name(reopen_state->bs));
31
+ /* If we are to stay read-only, do not allow permission change
32
+ * to r/w. Attempting to set to r/w may fail if either BDRV_O_ALLOW_RDWR is
33
+ * not set, or if the BDS still has copy_on_read enabled */
34
+ read_only = !(reopen_state->flags & BDRV_O_RDWR);
35
+ ret = bdrv_can_set_read_only(reopen_state->bs, read_only, &local_err);
36
+ if (local_err) {
37
+ error_propagate(errp, local_err);
38
goto error;
39
}
40
26
41
--
27
--
42
2.9.3
28
2.34.1
43
29
44
30
diff view generated by jsdifflib
1
The protocol VXHS does not support image creation. Some tests expect
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
to be able to create images through the protocol. Exclude VXHS from
3
these tests.
4
2
5
Signed-off-by: Jeff Cody <jcody@redhat.com>
3
The test-case "Corrupted size field in compressed cluster descriptor"
4
heavily depends on zlib compression type. So, make it explicit. This
5
way test passes with IMGOPTS='compression_type=zstd'.
6
7
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
9
Message-Id: <20211223160144.1097696-19-vsementsov@virtuozzo.com>
10
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
6
---
11
---
7
tests/qemu-iotests/017 | 1 +
12
tests/qemu-iotests/214 | 2 +-
8
tests/qemu-iotests/020 | 1 +
13
1 file changed, 1 insertion(+), 1 deletion(-)
9
tests/qemu-iotests/029 | 1 +
10
tests/qemu-iotests/073 | 1 +
11
tests/qemu-iotests/114 | 1 +
12
tests/qemu-iotests/130 | 1 +
13
tests/qemu-iotests/134 | 1 +
14
tests/qemu-iotests/156 | 1 +
15
tests/qemu-iotests/158 | 1 +
16
9 files changed, 9 insertions(+)
17
14
18
diff --git a/tests/qemu-iotests/017 b/tests/qemu-iotests/017
15
diff --git a/tests/qemu-iotests/214 b/tests/qemu-iotests/214
19
index XXXXXXX..XXXXXXX 100755
16
index XXXXXXX..XXXXXXX 100755
20
--- a/tests/qemu-iotests/017
17
--- a/tests/qemu-iotests/214
21
+++ b/tests/qemu-iotests/017
18
+++ b/tests/qemu-iotests/214
22
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
19
@@ -XXX,XX +XXX,XX @@ echo
23
# Any format supporting backing files
20
# The L2 entries of the two compressed clusters are located at
24
_supported_fmt qcow qcow2 vmdk qed
21
# 0x800000 and 0x800008, their original values are 0x4008000000a00000
25
_supported_proto generic
22
# and 0x4008000000a00802 (5 sectors for compressed data each).
26
+_unsupported_proto vxhs
23
-_make_test_img 8M -o cluster_size=2M
27
_supported_os Linux
24
+_make_test_img 8M -o cluster_size=2M,compression_type=zlib
28
_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
25
$QEMU_IO -c "write -c -P 0x11 0 2M" -c "write -c -P 0x11 2M 2M" "$TEST_IMG" \
29
26
2>&1 | _filter_qemu_io | _filter_testdir
30
diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020
31
index XXXXXXX..XXXXXXX 100755
32
--- a/tests/qemu-iotests/020
33
+++ b/tests/qemu-iotests/020
34
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
35
# Any format supporting backing files
36
_supported_fmt qcow qcow2 vmdk qed
37
_supported_proto generic
38
+_unsupported_proto vxhs
39
_supported_os Linux
40
_unsupported_imgopts "subformat=monolithicFlat" \
41
"subformat=twoGbMaxExtentFlat" \
42
diff --git a/tests/qemu-iotests/029 b/tests/qemu-iotests/029
43
index XXXXXXX..XXXXXXX 100755
44
--- a/tests/qemu-iotests/029
45
+++ b/tests/qemu-iotests/029
46
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
47
# Any format supporting intenal snapshots
48
_supported_fmt qcow2
49
_supported_proto generic
50
+_unsupported_proto vxhs
51
_supported_os Linux
52
# Internal snapshots are (currently) impossible with refcount_bits=1
53
_unsupported_imgopts 'refcount_bits=1[^0-9]'
54
diff --git a/tests/qemu-iotests/073 b/tests/qemu-iotests/073
55
index XXXXXXX..XXXXXXX 100755
56
--- a/tests/qemu-iotests/073
57
+++ b/tests/qemu-iotests/073
58
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
59
60
_supported_fmt qcow2
61
_supported_proto generic
62
+_unsupported_proto vxhs
63
_supported_os Linux
64
65
CLUSTER_SIZE=64k
66
diff --git a/tests/qemu-iotests/114 b/tests/qemu-iotests/114
67
index XXXXXXX..XXXXXXX 100755
68
--- a/tests/qemu-iotests/114
69
+++ b/tests/qemu-iotests/114
70
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
71
72
_supported_fmt qcow2
73
_supported_proto generic
74
+_unsupported_proto vxhs
75
_supported_os Linux
76
77
78
diff --git a/tests/qemu-iotests/130 b/tests/qemu-iotests/130
79
index XXXXXXX..XXXXXXX 100755
80
--- a/tests/qemu-iotests/130
81
+++ b/tests/qemu-iotests/130
82
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
83
84
_supported_fmt qcow2
85
_supported_proto generic
86
+_unsupported_proto vxhs
87
_supported_os Linux
88
89
qemu_comm_method="monitor"
90
diff --git a/tests/qemu-iotests/134 b/tests/qemu-iotests/134
91
index XXXXXXX..XXXXXXX 100755
92
--- a/tests/qemu-iotests/134
93
+++ b/tests/qemu-iotests/134
94
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
95
96
_supported_fmt qcow2
97
_supported_proto generic
98
+_unsupported_proto vxhs
99
_supported_os Linux
100
101
102
diff --git a/tests/qemu-iotests/156 b/tests/qemu-iotests/156
103
index XXXXXXX..XXXXXXX 100755
104
--- a/tests/qemu-iotests/156
105
+++ b/tests/qemu-iotests/156
106
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
107
108
_supported_fmt qcow2 qed
109
_supported_proto generic
110
+_unsupported_proto vxhs
111
_supported_os Linux
112
113
# Create source disk
114
diff --git a/tests/qemu-iotests/158 b/tests/qemu-iotests/158
115
index XXXXXXX..XXXXXXX 100755
116
--- a/tests/qemu-iotests/158
117
+++ b/tests/qemu-iotests/158
118
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
119
120
_supported_fmt qcow2
121
_supported_proto generic
122
+_unsupported_proto vxhs
123
_supported_os Linux
124
125
27
126
--
28
--
127
2.9.3
29
2.34.1
128
30
129
31
diff view generated by jsdifflib
1
For the tests that use the common.qemu functions for running a QEMU
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
process, _cleanup_qemu must be called in the exit function.
3
2
4
If it is not, if the qemu process aborts, then not all of the droppings
3
compression_type can't be used if we want to create image with
5
are cleaned up (e.g. pidfile, fifos).
4
compat=0.10. So, skip these tests, not many of them.
6
5
7
This updates those tests that did not have a cleanup in qemu-iotests.
6
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
8
Message-Id: <20211223160144.1097696-20-vsementsov@virtuozzo.com>
9
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
10
---
11
tests/qemu-iotests/031 | 5 +++--
12
tests/qemu-iotests/051 | 5 +++--
13
tests/qemu-iotests/061 | 6 +++++-
14
tests/qemu-iotests/112 | 3 ++-
15
tests/qemu-iotests/290 | 2 +-
16
5 files changed, 14 insertions(+), 7 deletions(-)
8
17
9
(I swapped spaces for tabs in test 102 as well)
18
diff --git a/tests/qemu-iotests/031 b/tests/qemu-iotests/031
10
11
Reported-by: Eric Blake <eblake@redhat.com>
12
Reviewed-by: Eric Blake <eblake@redhat.com>
13
Signed-off-by: Jeff Cody <jcody@redhat.com>
14
Message-id: d59c2f6ad6c1da8b9b3c7f357c94a7122ccfc55a.1492544096.git.jcody@redhat.com
15
---
16
tests/qemu-iotests/028 | 1 +
17
tests/qemu-iotests/094 | 11 ++++++++---
18
tests/qemu-iotests/102 | 5 +++--
19
tests/qemu-iotests/109 | 1 +
20
tests/qemu-iotests/117 | 1 +
21
tests/qemu-iotests/130 | 1 +
22
tests/qemu-iotests/140 | 1 +
23
tests/qemu-iotests/141 | 1 +
24
tests/qemu-iotests/143 | 1 +
25
tests/qemu-iotests/156 | 1 +
26
10 files changed, 19 insertions(+), 5 deletions(-)
27
28
diff --git a/tests/qemu-iotests/028 b/tests/qemu-iotests/028
29
index XXXXXXX..XXXXXXX 100755
19
index XXXXXXX..XXXXXXX 100755
30
--- a/tests/qemu-iotests/028
20
--- a/tests/qemu-iotests/031
31
+++ b/tests/qemu-iotests/028
21
+++ b/tests/qemu-iotests/031
32
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
22
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
33
23
_supported_fmt qcow2
34
_cleanup()
24
_supported_proto file fuse
25
# We want to test compat=0.10, which does not support external data
26
-# files or refcount widths other than 16
27
-_unsupported_imgopts data_file 'refcount_bits=\([^1]\|.\([^6]\|$\)\)'
28
+# files or refcount widths other than 16 or compression type
29
+_unsupported_imgopts data_file compression_type \
30
+ 'refcount_bits=\([^1]\|.\([^6]\|$\)\)'
31
32
CLUSTER_SIZE=65536
33
34
diff --git a/tests/qemu-iotests/051 b/tests/qemu-iotests/051
35
index XXXXXXX..XXXXXXX 100755
36
--- a/tests/qemu-iotests/051
37
+++ b/tests/qemu-iotests/051
38
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow2
39
_supported_proto file
40
# A compat=0.10 image is created in this test which does not support anything
41
# other than refcount_bits=16;
42
-# it also will not support an external data file
43
-_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file
44
+# it also will not support an external data file and compression type
45
+_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file \
46
+ compression_type
47
_require_drivers nbd
48
49
if [ "$QEMU_DEFAULT_MACHINE" = "pc" ]; then
50
diff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061
51
index XXXXXXX..XXXXXXX 100755
52
--- a/tests/qemu-iotests/061
53
+++ b/tests/qemu-iotests/061
54
@@ -XXX,XX +XXX,XX @@ _supported_os Linux
55
# not work with it;
56
# we have explicit tests for various cluster sizes, the remaining tests
57
# require the default 64k cluster
58
-_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file cluster_size
59
+# we don't have explicit tests for zstd qcow2 compression type, as zstd may be
60
+# not compiled in. And we can't create compat images with comression type
61
+# extension
62
+_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file \
63
+ cluster_size compression_type
64
65
echo
66
echo "=== Testing version downgrade with zero expansion ==="
67
diff --git a/tests/qemu-iotests/112 b/tests/qemu-iotests/112
68
index XXXXXXX..XXXXXXX 100755
69
--- a/tests/qemu-iotests/112
70
+++ b/tests/qemu-iotests/112
71
@@ -XXX,XX +XXX,XX @@ _supported_proto file fuse
72
# This test will set refcount_bits on its own which would conflict with the
73
# manual setting; compat will be overridden as well;
74
# and external data files do not work well with our refcount testing
75
-_unsupported_imgopts refcount_bits 'compat=0.10' data_file
76
+# also, compression type is not supported with compat=0.10 used in test
77
+_unsupported_imgopts refcount_bits 'compat=0.10' data_file compression_type
78
79
print_refcount_bits()
35
{
80
{
36
+ _cleanup_qemu
81
diff --git a/tests/qemu-iotests/290 b/tests/qemu-iotests/290
37
rm -f "${TEST_IMG}.copy"
38
_cleanup_test_img
39
}
40
diff --git a/tests/qemu-iotests/094 b/tests/qemu-iotests/094
41
index XXXXXXX..XXXXXXX 100755
82
index XXXXXXX..XXXXXXX 100755
42
--- a/tests/qemu-iotests/094
83
--- a/tests/qemu-iotests/290
43
+++ b/tests/qemu-iotests/094
84
+++ b/tests/qemu-iotests/290
44
@@ -XXX,XX +XXX,XX @@ echo "QA output created by $seq"
85
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
45
here="$PWD"
86
_supported_fmt qcow2
46
status=1    # failure is the default!
87
_supported_proto file fuse
47
88
_supported_os Linux
48
-trap "exit \$status" 0 1 2 3 15
89
-_unsupported_imgopts 'compat=0.10' refcount_bits data_file
49
+_cleanup()
90
+_unsupported_imgopts 'compat=0.10' refcount_bits data_file compression_type
50
+{
91
51
+ _cleanup_qemu
92
echo
52
+ _cleanup_test_img
93
echo "### Test 'qemu-io -c discard' on a QCOW2 image without a backing file"
53
+ rm -f "$TEST_DIR/source.$IMGFMT"
54
+}
55
+
56
+trap "_cleanup; exit \$status" 0 1 2 3 15
57
58
# get standard environment, filters and checks
59
. ./common.rc
60
@@ -XXX,XX +XXX,XX @@ _send_qemu_cmd $QEMU_HANDLE \
61
62
wait=1 _cleanup_qemu
63
64
-_cleanup_test_img
65
-rm -f "$TEST_DIR/source.$IMGFMT"
66
67
# success, all done
68
echo '*** done'
69
diff --git a/tests/qemu-iotests/102 b/tests/qemu-iotests/102
70
index XXXXXXX..XXXXXXX 100755
71
--- a/tests/qemu-iotests/102
72
+++ b/tests/qemu-iotests/102
73
@@ -XXX,XX +XXX,XX @@ seq=$(basename $0)
74
echo "QA output created by $seq"
75
76
here=$PWD
77
-status=1    # failure is the default!
78
+status=1 # failure is the default!
79
80
_cleanup()
81
{
82
-    _cleanup_test_img
83
+ _cleanup_qemu
84
+ _cleanup_test_img
85
}
86
trap "_cleanup; exit \$status" 0 1 2 3 15
87
88
diff --git a/tests/qemu-iotests/109 b/tests/qemu-iotests/109
89
index XXXXXXX..XXXXXXX 100755
90
--- a/tests/qemu-iotests/109
91
+++ b/tests/qemu-iotests/109
92
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
93
94
_cleanup()
95
{
96
+ _cleanup_qemu
97
rm -f $TEST_IMG.src
98
    _cleanup_test_img
99
}
100
diff --git a/tests/qemu-iotests/117 b/tests/qemu-iotests/117
101
index XXXXXXX..XXXXXXX 100755
102
--- a/tests/qemu-iotests/117
103
+++ b/tests/qemu-iotests/117
104
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
105
106
_cleanup()
107
{
108
+ _cleanup_qemu
109
    _cleanup_test_img
110
}
111
trap "_cleanup; exit \$status" 0 1 2 3 15
112
diff --git a/tests/qemu-iotests/130 b/tests/qemu-iotests/130
113
index XXXXXXX..XXXXXXX 100755
114
--- a/tests/qemu-iotests/130
115
+++ b/tests/qemu-iotests/130
116
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
117
118
_cleanup()
119
{
120
+ _cleanup_qemu
121
_cleanup_test_img
122
}
123
trap "_cleanup; exit \$status" 0 1 2 3 15
124
diff --git a/tests/qemu-iotests/140 b/tests/qemu-iotests/140
125
index XXXXXXX..XXXXXXX 100755
126
--- a/tests/qemu-iotests/140
127
+++ b/tests/qemu-iotests/140
128
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
129
130
_cleanup()
131
{
132
+ _cleanup_qemu
133
_cleanup_test_img
134
rm -f "$TEST_DIR/nbd"
135
}
136
diff --git a/tests/qemu-iotests/141 b/tests/qemu-iotests/141
137
index XXXXXXX..XXXXXXX 100755
138
--- a/tests/qemu-iotests/141
139
+++ b/tests/qemu-iotests/141
140
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
141
142
_cleanup()
143
{
144
+ _cleanup_qemu
145
_cleanup_test_img
146
rm -f "$TEST_DIR/{b,m,o}.$IMGFMT"
147
}
148
diff --git a/tests/qemu-iotests/143 b/tests/qemu-iotests/143
149
index XXXXXXX..XXXXXXX 100755
150
--- a/tests/qemu-iotests/143
151
+++ b/tests/qemu-iotests/143
152
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
153
154
_cleanup()
155
{
156
+ _cleanup_qemu
157
rm -f "$TEST_DIR/nbd"
158
}
159
trap "_cleanup; exit \$status" 0 1 2 3 15
160
diff --git a/tests/qemu-iotests/156 b/tests/qemu-iotests/156
161
index XXXXXXX..XXXXXXX 100755
162
--- a/tests/qemu-iotests/156
163
+++ b/tests/qemu-iotests/156
164
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
165
166
_cleanup()
167
{
168
+ _cleanup_qemu
169
rm -f "$TEST_IMG{,.target}{,.backing,.overlay}"
170
}
171
trap "_cleanup; exit \$status" 0 1 2 3 15
172
--
94
--
173
2.9.3
95
2.34.1
174
96
175
97
diff view generated by jsdifflib
1
Move bdrv_is_read_only() up with its friends.
1
After migration, the permissions the guest device wants to impose on its
2
BlockBackend are stored in blk->perm and blk->shared_perm. In
3
blk_root_activate(), we take our permissions, but keep all shared
4
permissions open by calling `blk_set_perm(blk->perm, BLK_PERM_ALL)`.
2
5
3
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
6
Only afterwards (immediately or later, depending on the runstate) do we
4
Reviewed-by: John Snow <jsnow@redhat.com>
7
restrict the shared permissions by calling
5
Signed-off-by: Jeff Cody <jcody@redhat.com>
8
`blk_set_perm(blk->perm, blk->shared_perm)`. Unfortunately, our first
6
Message-id: 73b2399459760c32506f9407efb9dddb3a2789de.1491597120.git.jcody@redhat.com
9
call with shared_perm=BLK_PERM_ALL has overwritten blk->shared_perm to
10
be BLK_PERM_ALL, so this is a no-op and the set of shared permissions is
11
not restricted.
12
13
Fix this bug by saving the set of shared permissions before invoking
14
blk_set_perm() with BLK_PERM_ALL and restoring it afterwards.
15
16
Fixes: 5f7772c4d0cf32f4e779fcd5a69ae4dae24aeebf
17
("block-backend: Defer shared_perm tightening migration
18
completion")
19
Reported-by: Peng Liang <liangpeng10@huawei.com>
20
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
21
Message-Id: <20211125135317.186576-2-hreitz@redhat.com>
22
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
23
Tested-by: Peng Liang <liangpeng10@huawei.com>
7
---
24
---
8
block.c | 10 +++++-----
25
block/block-backend.c | 11 +++++++++++
9
1 file changed, 5 insertions(+), 5 deletions(-)
26
1 file changed, 11 insertions(+)
10
27
11
diff --git a/block.c b/block.c
28
diff --git a/block/block-backend.c b/block/block-backend.c
12
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
13
--- a/block.c
30
--- a/block/block-backend.c
14
+++ b/block.c
31
+++ b/block/block-backend.c
15
@@ -XXX,XX +XXX,XX @@ void path_combine(char *dest, int dest_size,
32
@@ -XXX,XX +XXX,XX @@ static void blk_root_activate(BdrvChild *child, Error **errp)
33
{
34
BlockBackend *blk = child->opaque;
35
Error *local_err = NULL;
36
+ uint64_t saved_shared_perm;
37
38
if (!blk->disable_perm) {
39
return;
40
@@ -XXX,XX +XXX,XX @@ static void blk_root_activate(BdrvChild *child, Error **errp)
41
42
blk->disable_perm = false;
43
44
+ /*
45
+ * blk->shared_perm contains the permissions we want to share once
46
+ * migration is really completely done. For now, we need to share
47
+ * all; but we also need to retain blk->shared_perm, which is
48
+ * overwritten by a successful blk_set_perm() call. Save it and
49
+ * restore it below.
50
+ */
51
+ saved_shared_perm = blk->shared_perm;
52
+
53
blk_set_perm(blk, blk->perm, BLK_PERM_ALL, &local_err);
54
if (local_err) {
55
error_propagate(errp, local_err);
56
blk->disable_perm = true;
57
return;
16
}
58
}
17
}
59
+ blk->shared_perm = saved_shared_perm;
18
60
19
+bool bdrv_is_read_only(BlockDriverState *bs)
61
if (runstate_check(RUN_STATE_INMIGRATE)) {
20
+{
62
/* Activation can happen when migration process is still active, for
21
+ return bs->read_only;
22
+}
23
+
24
int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
25
{
26
/* Do not set read_only if copy_on_read is enabled */
27
@@ -XXX,XX +XXX,XX @@ void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr)
28
*nb_sectors_ptr = nb_sectors < 0 ? 0 : nb_sectors;
29
}
30
31
-bool bdrv_is_read_only(BlockDriverState *bs)
32
-{
33
- return bs->read_only;
34
-}
35
-
36
bool bdrv_is_sg(BlockDriverState *bs)
37
{
38
return bs->sg;
39
--
63
--
40
2.9.3
64
2.34.1
41
65
42
66
diff view generated by jsdifflib
1
The BDRV_O_ALLOW_RDWR flag allows / prohibits the changing of
1
This test checks that a raw image in use by a virtio-blk device does not
2
the BDS 'read_only' state, but there are a few places where it
2
share the WRITE permission both before and after migration.
3
is ignored. In the bdrv_set_read_only() helper, make sure to
4
honor the flag.
5
3
6
Signed-off-by: Jeff Cody <jcody@redhat.com>
4
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
7
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
8
Reviewed-by: John Snow <jsnow@redhat.com>
9
Message-id: be2e5fb2d285cbece2b6d06bed54a6f56520d251.1491597120.git.jcody@redhat.com
10
---
5
---
11
block.c | 7 +++++++
6
.../qemu-iotests/tests/migration-permissions | 101 ++++++++++++++++++
12
1 file changed, 7 insertions(+)
7
.../tests/migration-permissions.out | 5 +
8
2 files changed, 106 insertions(+)
9
create mode 100755 tests/qemu-iotests/tests/migration-permissions
10
create mode 100644 tests/qemu-iotests/tests/migration-permissions.out
13
11
14
diff --git a/block.c b/block.c
12
diff --git a/tests/qemu-iotests/tests/migration-permissions b/tests/qemu-iotests/tests/migration-permissions
15
index XXXXXXX..XXXXXXX 100644
13
new file mode 100755
16
--- a/block.c
14
index XXXXXXX..XXXXXXX
17
+++ b/block.c
15
--- /dev/null
18
@@ -XXX,XX +XXX,XX @@ int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
16
+++ b/tests/qemu-iotests/tests/migration-permissions
19
return -EINVAL;
17
@@ -XXX,XX +XXX,XX @@
20
}
18
+#!/usr/bin/env python3
21
19
+# group: migration
22
+ /* Do not clear read_only if it is prohibited */
20
+#
23
+ if (!read_only && !(bs->open_flags & BDRV_O_ALLOW_RDWR)) {
21
+# Copyright (C) 2021 Red Hat, Inc.
24
+ error_setg(errp, "Node '%s' is read only",
22
+#
25
+ bdrv_get_device_or_node_name(bs));
23
+# This program is free software; you can redistribute it and/or modify
26
+ return -EPERM;
24
+# it under the terms of the GNU General Public License as published by
27
+ }
25
+# the Free Software Foundation; either version 2 of the License, or
26
+# (at your option) any later version.
27
+#
28
+# This program is distributed in the hope that it will be useful,
29
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
30
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31
+# GNU General Public License for more details.
32
+#
33
+# You should have received a copy of the GNU General Public License
34
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
35
+#
28
+
36
+
29
bs->read_only = read_only;
37
+import os
30
return 0;
38
+import iotests
31
}
39
+from iotests import imgfmt, qemu_img_create, qemu_io
40
+
41
+
42
+test_img = os.path.join(iotests.test_dir, 'test.img')
43
+mig_sock = os.path.join(iotests.sock_dir, 'mig.sock')
44
+
45
+
46
+class TestMigrationPermissions(iotests.QMPTestCase):
47
+ def setUp(self):
48
+ qemu_img_create('-f', imgfmt, test_img, '1M')
49
+
50
+ # Set up two VMs (source and destination) accessing the same raw
51
+ # image file with a virtio-blk device; prepare the destination for
52
+ # migration with .add_incoming() and enable migration events
53
+ vms = [None, None]
54
+ for i in range(2):
55
+ vms[i] = iotests.VM(path_suffix=f'{i}')
56
+ vms[i].add_blockdev(f'file,node-name=prot,filename={test_img}')
57
+ vms[i].add_blockdev(f'{imgfmt},node-name=fmt,file=prot')
58
+ vms[i].add_device('virtio-blk,drive=fmt')
59
+
60
+ if i == 1:
61
+ vms[i].add_incoming(f'unix:{mig_sock}')
62
+
63
+ vms[i].launch()
64
+
65
+ result = vms[i].qmp('migrate-set-capabilities',
66
+ capabilities=[
67
+ {'capability': 'events', 'state': True}
68
+ ])
69
+ self.assert_qmp(result, 'return', {})
70
+
71
+ self.vm_s = vms[0]
72
+ self.vm_d = vms[1]
73
+
74
+ def tearDown(self):
75
+ self.vm_s.shutdown()
76
+ self.vm_d.shutdown()
77
+ try:
78
+ os.remove(mig_sock)
79
+ except FileNotFoundError:
80
+ pass
81
+ os.remove(test_img)
82
+
83
+ # Migrate an image in use by a virtio-blk device to another VM and
84
+ # verify that the WRITE permission is unshared both before and after
85
+ # migration
86
+ def test_post_migration_permissions(self):
87
+ # Try to access the image R/W, which should fail because virtio-blk
88
+ # has not been configured with share-rw=on
89
+ log = qemu_io('-f', imgfmt, '-c', 'quit', test_img)
90
+ if not log.strip():
91
+ print('ERROR (pre-migration): qemu-io should not be able to '
92
+ 'access this image, but it reported no error')
93
+ else:
94
+ # This is the expected output
95
+ assert 'Is another process using the image' in log
96
+
97
+ # Now migrate the VM
98
+ self.vm_s.qmp('migrate', uri=f'unix:{mig_sock}')
99
+ assert self.vm_s.wait_migration(None)
100
+ assert self.vm_d.wait_migration(None)
101
+
102
+ # Try the same qemu-io access again, verifying that the WRITE
103
+ # permission remains unshared
104
+ log = qemu_io('-f', imgfmt, '-c', 'quit', test_img)
105
+ if not log.strip():
106
+ print('ERROR (post-migration): qemu-io should not be able to '
107
+ 'access this image, but it reported no error')
108
+ else:
109
+ # This is the expected output
110
+ assert 'Is another process using the image' in log
111
+
112
+
113
+if __name__ == '__main__':
114
+ # Only works with raw images because we are testing the
115
+ # BlockBackend permissions; image format drivers may additionally
116
+ # unshare permissions and thus tamper with the result
117
+ iotests.main(supported_fmts=['raw'],
118
+ supported_protocols=['file'])
119
diff --git a/tests/qemu-iotests/tests/migration-permissions.out b/tests/qemu-iotests/tests/migration-permissions.out
120
new file mode 100644
121
index XXXXXXX..XXXXXXX
122
--- /dev/null
123
+++ b/tests/qemu-iotests/tests/migration-permissions.out
124
@@ -XXX,XX +XXX,XX @@
125
+.
126
+----------------------------------------------------------------------
127
+Ran 1 tests
128
+
129
+OK
32
--
130
--
33
2.9.3
131
2.34.1
34
132
35
133
diff view generated by jsdifflib
1
We have a helper wrapper for checking for the BDS read_only flag,
1
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
2
add a helper wrapper to set the read_only flag as well.
3
2
4
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
3
The comment "disk I/O throttling" doesn't make any sense at all
5
Signed-off-by: Jeff Cody <jcody@redhat.com>
4
any more. It was added in commit 0563e191516 to describe
6
Reviewed-by: John Snow <jsnow@redhat.com>
5
bdrv_io_limits_enable()/disable(), which were removed in commit
7
Message-id: 9b18972d05f5fa2ac16c014f0af98d680553048d.1491597120.git.jcody@redhat.com
6
97148076, so the comment is just a forgotten leftover.
7
8
Suggested-by: Kevin Wolf <kwolf@redhat.com>
9
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
10
Message-Id: <20220131125615.74612-1-eesposit@redhat.com>
11
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
12
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
8
---
13
---
9
block.c | 5 +++++
14
include/block/block.h | 1 -
10
block/bochs.c | 2 +-
15
1 file changed, 1 deletion(-)
11
block/cloop.c | 2 +-
12
block/dmg.c | 2 +-
13
block/rbd.c | 2 +-
14
block/vvfat.c | 4 ++--
15
include/block/block.h | 1 +
16
7 files changed, 12 insertions(+), 6 deletions(-)
17
16
18
diff --git a/block.c b/block.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/block.c
21
+++ b/block.c
22
@@ -XXX,XX +XXX,XX @@ void path_combine(char *dest, int dest_size,
23
}
24
}
25
26
+void bdrv_set_read_only(BlockDriverState *bs, bool read_only)
27
+{
28
+ bs->read_only = read_only;
29
+}
30
+
31
void bdrv_get_full_backing_filename_from_filename(const char *backed,
32
const char *backing,
33
char *dest, size_t sz,
34
diff --git a/block/bochs.c b/block/bochs.c
35
index XXXXXXX..XXXXXXX 100644
36
--- a/block/bochs.c
37
+++ b/block/bochs.c
38
@@ -XXX,XX +XXX,XX @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
39
return -EINVAL;
40
}
41
42
- bs->read_only = true; /* no write support yet */
43
+ bdrv_set_read_only(bs, true); /* no write support yet */
44
45
ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs));
46
if (ret < 0) {
47
diff --git a/block/cloop.c b/block/cloop.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/block/cloop.c
50
+++ b/block/cloop.c
51
@@ -XXX,XX +XXX,XX @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags,
52
return -EINVAL;
53
}
54
55
- bs->read_only = true;
56
+ bdrv_set_read_only(bs, true);
57
58
/* read header */
59
ret = bdrv_pread(bs->file, 128, &s->block_size, 4);
60
diff --git a/block/dmg.c b/block/dmg.c
61
index XXXXXXX..XXXXXXX 100644
62
--- a/block/dmg.c
63
+++ b/block/dmg.c
64
@@ -XXX,XX +XXX,XX @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags,
65
}
66
67
block_module_load_one("dmg-bz2");
68
- bs->read_only = true;
69
+ bdrv_set_read_only(bs, true);
70
71
s->n_chunks = 0;
72
s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL;
73
diff --git a/block/rbd.c b/block/rbd.c
74
index XXXXXXX..XXXXXXX 100644
75
--- a/block/rbd.c
76
+++ b/block/rbd.c
77
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
78
goto failed_open;
79
}
80
81
- bs->read_only = (s->snap != NULL);
82
+ bdrv_set_read_only(bs, (s->snap != NULL));
83
84
qemu_opts_del(opts);
85
return 0;
86
diff --git a/block/vvfat.c b/block/vvfat.c
87
index XXXXXXX..XXXXXXX 100644
88
--- a/block/vvfat.c
89
+++ b/block/vvfat.c
90
@@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
91
s->current_cluster=0xffffffff;
92
93
/* read only is the default for safety */
94
- bs->read_only = true;
95
+ bdrv_set_read_only(bs, true);
96
s->qcow = NULL;
97
s->qcow_filename = NULL;
98
s->fat2 = NULL;
99
@@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
100
if (ret < 0) {
101
goto fail;
102
}
103
- bs->read_only = false;
104
+ bdrv_set_read_only(bs, false);
105
}
106
107
bs->total_sectors = cyls * heads * secs;
108
diff --git a/include/block/block.h b/include/block/block.h
17
diff --git a/include/block/block.h b/include/block/block.h
109
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
110
--- a/include/block/block.h
19
--- a/include/block/block.h
111
+++ b/include/block/block.h
20
+++ b/include/block/block.h
112
@@ -XXX,XX +XXX,XX @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
21
@@ -XXX,XX +XXX,XX @@ typedef unsigned int BdrvChildRole;
113
int64_t sector_num, int nb_sectors, int *pnum);
22
char *bdrv_perm_names(uint64_t perm);
114
23
uint64_t bdrv_qapi_perm_to_blk_perm(BlockPermission qapi_perm);
115
bool bdrv_is_read_only(BlockDriverState *bs);
24
116
+void bdrv_set_read_only(BlockDriverState *bs, bool read_only);
25
-/* disk I/O throttling */
117
bool bdrv_is_sg(BlockDriverState *bs);
26
void bdrv_init(void);
118
bool bdrv_is_inserted(BlockDriverState *bs);
27
void bdrv_init_with_whitelist(void);
119
int bdrv_media_changed(BlockDriverState *bs);
28
bool bdrv_uses_whitelist(void);
120
--
29
--
121
2.9.3
30
2.34.1
122
31
123
32
diff view generated by jsdifflib