1 | The following changes since commit 804b30d25f8d70dc2dea951883ea92235274a50c: | 1 | The following changes since commit 474f3938d79ab36b9231c9ad3b5a9314c2aeacde: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/legoater/tags/pull-ppc-20220130' into staging (2022-01-31 11:10:08 +0000) | 3 | Merge remote-tracking branch 'remotes/amarkovic/tags/mips-queue-jun-21-2019' into staging (2019-06-21 15:40:50 +0100) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | https://gitlab.com/hreitz/qemu.git tags/pull-block-2022-02-01 | 7 | https://github.com/XanClic/qemu.git tags/pull-block-2019-06-24 |
8 | 8 | ||
9 | for you to fetch changes up to 751486c18555169ca4baf59440275d5831140822: | 9 | for you to fetch changes up to ab5d4a30f7f3803ca5106b370969c1b7b54136f8: |
10 | 10 | ||
11 | block.h: remove outdated comment (2022-02-01 13:28:53 +0100) | 11 | iotests: Fix 205 for concurrent runs (2019-06-24 16:01:40 +0200) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Block patches: | 14 | Block patches: |
15 | - Add support to the iotests to test qcow2's zstd compression mode | 15 | - The SSH block driver now uses libssh instead of libssh2 |
16 | - Fix post-migration block node permissions | 16 | - The VMDK block driver gets read-only support for the seSparse |
17 | - iotests fixes (051 and mirror-ready-cancel-error) | 17 | subformat |
18 | - Remove an outdated comment | 18 | - Various fixes |
19 | |||
20 | --- | ||
21 | |||
22 | v2: | ||
23 | - Squashed Pino's fix for pre-0.8 libssh into the libssh patch | ||
19 | 24 | ||
20 | ---------------------------------------------------------------- | 25 | ---------------------------------------------------------------- |
21 | Emanuele Giuseppe Esposito (1): | 26 | Anton Nefedov (1): |
22 | block.h: remove outdated comment | 27 | iotest 134: test cluster-misaligned encrypted write |
23 | 28 | ||
24 | Hanna Reitz (3): | 29 | Klaus Birkelund Jensen (1): |
25 | iotests/MRCE: Write data to source | 30 | nvme: do not advertise support for unsupported arbitration mechanism |
26 | block-backend: Retain permissions after migration | ||
27 | iotests/migration-permissions: New test | ||
28 | 31 | ||
29 | Thomas Huth (1): | 32 | Max Reitz (1): |
30 | tests/qemu-iotests: Fix 051 for binaries without 'lsi53c895a' | 33 | iotests: Fix 205 for concurrent runs |
31 | 34 | ||
32 | Vladimir Sementsov-Ogievskiy (19): | 35 | Pino Toscano (1): |
33 | iotests.py: img_info_log(): rename imgopts argument | 36 | ssh: switch from libssh2 to libssh |
34 | iotests.py: implement unsupported_imgopts | ||
35 | iotests: specify some unsupported_imgopts for python iotests | ||
36 | iotests.py: qemu_img*("create"): support | ||
37 | IMGOPTS='compression_type=zstd' | ||
38 | iotests: drop qemu_img_verbose() helper | ||
39 | iotests.py: rewrite default luks support in qemu_img | ||
40 | iotest 303: explicit compression type | ||
41 | iotest 065: explicit compression type | ||
42 | iotests.py: filter out successful output of qemu-img create | ||
43 | iotests.py: filter compression type out | ||
44 | iotest 302: use img_info_log() helper | ||
45 | qcow2: simple case support for downgrading of qcow2 images with zstd | ||
46 | iotests/common.rc: introduce _qcow2_dump_header helper | ||
47 | iotests: massive use _qcow2_dump_header | ||
48 | iotest 39: use _qcow2_dump_header | ||
49 | iotests: bash tests: filter compression type | ||
50 | iotests 60: more accurate set dirty bit in qcow2 header | ||
51 | iotest 214: explicit compression type | ||
52 | iotests: declare lack of support for compresion_type in IMGOPTS | ||
53 | 37 | ||
54 | include/block/block.h | 1 - | 38 | Sam Eiderman (3): |
55 | block/block-backend.c | 11 ++ | 39 | vmdk: Fix comment regarding max l1_size coverage |
56 | block/qcow2.c | 58 +++++++++- | 40 | vmdk: Reduce the max bound for L1 table size |
57 | tests/qemu-iotests/031 | 11 +- | 41 | vmdk: Add read-only support for seSparse snapshots |
58 | tests/qemu-iotests/036 | 6 +- | 42 | |
59 | tests/qemu-iotests/039 | 22 ++-- | 43 | Vladimir Sementsov-Ogievskiy (1): |
60 | tests/qemu-iotests/044 | 8 +- | 44 | blockdev: enable non-root nodes for transaction drive-backup source |
61 | tests/qemu-iotests/044.out | 1 + | 45 | |
62 | tests/qemu-iotests/051 | 9 +- | 46 | configure | 65 +- |
63 | tests/qemu-iotests/060 | 22 ++-- | 47 | block/Makefile.objs | 6 +- |
64 | tests/qemu-iotests/060.out | 2 +- | 48 | block/ssh.c | 652 ++++++++++-------- |
65 | tests/qemu-iotests/061 | 42 ++++---- | 49 | block/vmdk.c | 372 +++++++++- |
66 | tests/qemu-iotests/061.out | 12 +-- | 50 | blockdev.c | 2 +- |
67 | tests/qemu-iotests/065 | 19 ++-- | 51 | hw/block/nvme.c | 1 - |
68 | tests/qemu-iotests/082.out | 14 +-- | 52 | .travis.yml | 4 +- |
69 | tests/qemu-iotests/112 | 3 +- | 53 | block/trace-events | 14 +- |
70 | tests/qemu-iotests/137 | 2 +- | 54 | docs/qemu-block-drivers.texi | 2 +- |
71 | tests/qemu-iotests/149.out | 21 ---- | 55 | .../dockerfiles/debian-win32-cross.docker | 1 - |
72 | tests/qemu-iotests/163 | 3 +- | 56 | .../dockerfiles/debian-win64-cross.docker | 1 - |
73 | tests/qemu-iotests/165 | 3 +- | 57 | tests/docker/dockerfiles/fedora.docker | 4 +- |
74 | tests/qemu-iotests/196 | 3 +- | 58 | tests/docker/dockerfiles/ubuntu.docker | 2 +- |
75 | tests/qemu-iotests/198.out | 4 +- | 59 | tests/docker/dockerfiles/ubuntu1804.docker | 2 +- |
76 | tests/qemu-iotests/206.out | 10 +- | 60 | tests/qemu-iotests/059.out | 2 +- |
77 | tests/qemu-iotests/209 | 7 +- | 61 | tests/qemu-iotests/134 | 9 + |
78 | tests/qemu-iotests/209.out | 2 + | 62 | tests/qemu-iotests/134.out | 10 + |
79 | tests/qemu-iotests/210 | 8 +- | 63 | tests/qemu-iotests/205 | 2 +- |
80 | tests/qemu-iotests/214 | 2 +- | 64 | tests/qemu-iotests/207 | 54 +- |
81 | tests/qemu-iotests/237.out | 3 - | 65 | tests/qemu-iotests/207.out | 2 +- |
82 | tests/qemu-iotests/242 | 3 +- | 66 | 20 files changed, 823 insertions(+), 384 deletions(-) |
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 | ||
111 | 67 | ||
112 | -- | 68 | -- |
113 | 2.34.1 | 69 | 2.21.0 |
114 | 70 | ||
115 | 71 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Thomas Huth <thuth@redhat.com> | ||
2 | 1 | ||
3 | The lsi53c895a SCSI adaptor might not be enabled in each and every | ||
4 | x86 QEMU binary, e.g. it's disabled in the RHEL/CentOS build. | ||
5 | Thus let's add a check to the 051 test so that it does not fail if | ||
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> | ||
11 | --- | ||
12 | tests/qemu-iotests/051 | 4 ++++ | ||
13 | 1 file changed, 4 insertions(+) | ||
14 | |||
15 | diff --git a/tests/qemu-iotests/051 b/tests/qemu-iotests/051 | ||
16 | index XXXXXXX..XXXXXXX 100755 | ||
17 | --- a/tests/qemu-iotests/051 | ||
18 | +++ b/tests/qemu-iotests/051 | ||
19 | @@ -XXX,XX +XXX,XX @@ _supported_proto file | ||
20 | _unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file | ||
21 | _require_drivers nbd | ||
22 | |||
23 | +if [ "$QEMU_DEFAULT_MACHINE" = "pc" ]; then | ||
24 | + _require_devices lsi53c895a | ||
25 | +fi | ||
26 | + | ||
27 | do_run_qemu() | ||
28 | { | ||
29 | echo Testing: "$@" | ||
30 | -- | ||
31 | 2.34.1 | ||
32 | |||
33 | diff view generated by jsdifflib |
Deleted 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). | ||
4 | 1 | ||
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 |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
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 |
1 | From: Emanuele Giuseppe Esposito <eesposit@redhat.com> | 1 | From: Klaus Birkelund Jensen <klaus@birkelund.eu> |
---|---|---|---|
2 | 2 | ||
3 | The comment "disk I/O throttling" doesn't make any sense at all | 3 | The device mistakenly reports that the Weighted Round Robin with Urgent |
4 | any more. It was added in commit 0563e191516 to describe | 4 | Priority Class arbitration mechanism is supported. |
5 | bdrv_io_limits_enable()/disable(), which were removed in commit | ||
6 | 97148076, so the comment is just a forgotten leftover. | ||
7 | 5 | ||
8 | Suggested-by: Kevin Wolf <kwolf@redhat.com> | 6 | It is not. |
9 | Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> | 7 | |
10 | Message-Id: <20220131125615.74612-1-eesposit@redhat.com> | 8 | Signed-off-by: Klaus Birkelund Jensen <klaus.jensen@cnexlabs.com> |
11 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 9 | Message-id: 20190606092530.14206-1-klaus@birkelund.eu |
12 | Signed-off-by: Hanna Reitz <hreitz@redhat.com> | 10 | Acked-by: Maxim Levitsky <mlevitsk@redhat.com> |
11 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
13 | --- | 12 | --- |
14 | include/block/block.h | 1 - | 13 | hw/block/nvme.c | 1 - |
15 | 1 file changed, 1 deletion(-) | 14 | 1 file changed, 1 deletion(-) |
16 | 15 | ||
17 | diff --git a/include/block/block.h b/include/block/block.h | 16 | diff --git a/hw/block/nvme.c b/hw/block/nvme.c |
18 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/block/block.h | 18 | --- a/hw/block/nvme.c |
20 | +++ b/include/block/block.h | 19 | +++ b/hw/block/nvme.c |
21 | @@ -XXX,XX +XXX,XX @@ typedef unsigned int BdrvChildRole; | 20 | @@ -XXX,XX +XXX,XX @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) |
22 | char *bdrv_perm_names(uint64_t perm); | 21 | n->bar.cap = 0; |
23 | uint64_t bdrv_qapi_perm_to_blk_perm(BlockPermission qapi_perm); | 22 | NVME_CAP_SET_MQES(n->bar.cap, 0x7ff); |
24 | 23 | NVME_CAP_SET_CQR(n->bar.cap, 1); | |
25 | -/* disk I/O throttling */ | 24 | - NVME_CAP_SET_AMS(n->bar.cap, 1); |
26 | void bdrv_init(void); | 25 | NVME_CAP_SET_TO(n->bar.cap, 0xf); |
27 | void bdrv_init_with_whitelist(void); | 26 | NVME_CAP_SET_CSS(n->bar.cap, 1); |
28 | bool bdrv_uses_whitelist(void); | 27 | NVME_CAP_SET_MPSMAX(n->bar.cap, 4); |
29 | -- | 28 | -- |
30 | 2.34.1 | 29 | 2.21.0 |
31 | 30 | ||
32 | 31 | diff view generated by jsdifflib |
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | The test-case "Corrupted size field in compressed cluster descriptor" | 3 | We forget to enable it for transaction .prepare, while it is already |
4 | heavily depends on zlib compression type. So, make it explicit. This | 4 | enabled in do_drive_backup since commit a2d665c1bc362 |
5 | way test passes with IMGOPTS='compression_type=zstd'. | 5 | "blockdev: loosen restrictions on drive-backup source node" |
6 | 6 | ||
7 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 7 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
8 | Reviewed-by: Max Reitz <mreitz@redhat.com> | 8 | Message-id: 20190618140804.59214-1-vsementsov@virtuozzo.com |
9 | Message-Id: <20211223160144.1097696-19-vsementsov@virtuozzo.com> | 9 | Reviewed-by: John Snow <jsnow@redhat.com> |
10 | Signed-off-by: Hanna Reitz <hreitz@redhat.com> | 10 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
11 | --- | 11 | --- |
12 | tests/qemu-iotests/214 | 2 +- | 12 | blockdev.c | 2 +- |
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | 13 | 1 file changed, 1 insertion(+), 1 deletion(-) |
14 | 14 | ||
15 | diff --git a/tests/qemu-iotests/214 b/tests/qemu-iotests/214 | 15 | diff --git a/blockdev.c b/blockdev.c |
16 | index XXXXXXX..XXXXXXX 100755 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/tests/qemu-iotests/214 | 17 | --- a/blockdev.c |
18 | +++ b/tests/qemu-iotests/214 | 18 | +++ b/blockdev.c |
19 | @@ -XXX,XX +XXX,XX @@ echo | 19 | @@ -XXX,XX +XXX,XX @@ static void drive_backup_prepare(BlkActionState *common, Error **errp) |
20 | # The L2 entries of the two compressed clusters are located at | 20 | assert(common->action->type == TRANSACTION_ACTION_KIND_DRIVE_BACKUP); |
21 | # 0x800000 and 0x800008, their original values are 0x4008000000a00000 | 21 | backup = common->action->u.drive_backup.data; |
22 | # and 0x4008000000a00802 (5 sectors for compressed data each). | 22 | |
23 | -_make_test_img 8M -o cluster_size=2M | 23 | - bs = qmp_get_root_bs(backup->device, errp); |
24 | +_make_test_img 8M -o cluster_size=2M,compression_type=zlib | 24 | + bs = bdrv_lookup_bs(backup->device, backup->device, errp); |
25 | $QEMU_IO -c "write -c -P 0x11 0 2M" -c "write -c -P 0x11 2M 2M" "$TEST_IMG" \ | 25 | if (!bs) { |
26 | 2>&1 | _filter_qemu_io | _filter_testdir | 26 | return; |
27 | 27 | } | |
28 | -- | 28 | -- |
29 | 2.34.1 | 29 | 2.21.0 |
30 | 30 | ||
31 | 31 | diff view generated by jsdifflib |
1 | This test checks that a raw image in use by a virtio-blk device does not | 1 | From: Anton Nefedov <anton.nefedov@virtuozzo.com> |
---|---|---|---|
2 | share the WRITE permission both before and after migration. | ||
3 | 2 | ||
4 | Signed-off-by: Hanna Reitz <hreitz@redhat.com> | 3 | COW (even empty/zero) areas require encryption too |
4 | |||
5 | Signed-off-by: Anton Nefedov <anton.nefedov@virtuozzo.com> | ||
6 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
7 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
8 | Reviewed-by: Alberto Garcia <berto@igalia.com> | ||
9 | Message-id: 20190516143028.81155-1-anton.nefedov@virtuozzo.com | ||
10 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
5 | --- | 11 | --- |
6 | .../qemu-iotests/tests/migration-permissions | 101 ++++++++++++++++++ | 12 | tests/qemu-iotests/134 | 9 +++++++++ |
7 | .../tests/migration-permissions.out | 5 + | 13 | tests/qemu-iotests/134.out | 10 ++++++++++ |
8 | 2 files changed, 106 insertions(+) | 14 | 2 files changed, 19 insertions(+) |
9 | create mode 100755 tests/qemu-iotests/tests/migration-permissions | ||
10 | create mode 100644 tests/qemu-iotests/tests/migration-permissions.out | ||
11 | 15 | ||
12 | diff --git a/tests/qemu-iotests/tests/migration-permissions b/tests/qemu-iotests/tests/migration-permissions | 16 | diff --git a/tests/qemu-iotests/134 b/tests/qemu-iotests/134 |
13 | new file mode 100755 | 17 | index XXXXXXX..XXXXXXX 100755 |
14 | index XXXXXXX..XXXXXXX | 18 | --- a/tests/qemu-iotests/134 |
15 | --- /dev/null | 19 | +++ b/tests/qemu-iotests/134 |
16 | +++ b/tests/qemu-iotests/tests/migration-permissions | 20 | @@ -XXX,XX +XXX,XX @@ echo |
17 | @@ -XXX,XX +XXX,XX @@ | 21 | echo "== reading whole image ==" |
18 | +#!/usr/bin/env python3 | 22 | $QEMU_IO --object $SECRET -c "read 0 $size" --image-opts $IMGSPEC | _filter_qemu_io | _filter_testdir |
19 | +# group: migration | 23 | |
20 | +# | 24 | +echo |
21 | +# Copyright (C) 2021 Red Hat, Inc. | 25 | +echo "== rewriting cluster part ==" |
22 | +# | 26 | +$QEMU_IO --object $SECRET -c "write -P 0xb 512 512" --image-opts $IMGSPEC | _filter_qemu_io | _filter_testdir |
23 | +# This program is free software; you can redistribute it and/or modify | ||
24 | +# it under the terms of the GNU General Public License as published by | ||
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 | +# | ||
36 | + | 27 | + |
37 | +import os | 28 | +echo |
38 | +import iotests | 29 | +echo "== verify pattern ==" |
39 | +from iotests import imgfmt, qemu_img_create, qemu_io | 30 | +$QEMU_IO --object $SECRET -c "read -P 0 0 512" --image-opts $IMGSPEC | _filter_qemu_io | _filter_testdir |
31 | +$QEMU_IO --object $SECRET -c "read -P 0xb 512 512" --image-opts $IMGSPEC | _filter_qemu_io | _filter_testdir | ||
40 | + | 32 | + |
33 | echo | ||
34 | echo "== rewriting whole image ==" | ||
35 | $QEMU_IO --object $SECRET -c "write -P 0xa 0 $size" --image-opts $IMGSPEC | _filter_qemu_io | _filter_testdir | ||
36 | diff --git a/tests/qemu-iotests/134.out b/tests/qemu-iotests/134.out | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/tests/qemu-iotests/134.out | ||
39 | +++ b/tests/qemu-iotests/134.out | ||
40 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 encryption=on encrypt. | ||
41 | read 134217728/134217728 bytes at offset 0 | ||
42 | 128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
43 | |||
44 | +== rewriting cluster part == | ||
45 | +wrote 512/512 bytes at offset 512 | ||
46 | +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
41 | + | 47 | + |
42 | +test_img = os.path.join(iotests.test_dir, 'test.img') | 48 | +== verify pattern == |
43 | +mig_sock = os.path.join(iotests.sock_dir, 'mig.sock') | 49 | +read 512/512 bytes at offset 0 |
50 | +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
51 | +read 512/512 bytes at offset 512 | ||
52 | +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
44 | + | 53 | + |
45 | + | 54 | == rewriting whole image == |
46 | +class TestMigrationPermissions(iotests.QMPTestCase): | 55 | wrote 134217728/134217728 bytes at offset 0 |
47 | + def setUp(self): | 56 | 128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
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 | ||
130 | -- | 57 | -- |
131 | 2.34.1 | 58 | 2.21.0 |
132 | 59 | ||
133 | 60 | diff view generated by jsdifflib |
1 | After migration, the permissions the guest device wants to impose on its | 1 | From: Sam Eiderman <shmuel.eiderman@oracle.com> |
---|---|---|---|
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)`. | ||
5 | 2 | ||
6 | Only afterwards (immediately or later, depending on the runstate) do we | 3 | Commit b0651b8c246d ("vmdk: Move l1_size check into vmdk_add_extent") |
7 | restrict the shared permissions by calling | 4 | extended the l1_size check from VMDK4 to VMDK3 but did not update the |
8 | `blk_set_perm(blk->perm, blk->shared_perm)`. Unfortunately, our first | 5 | default coverage in the moved comment. |
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 | 6 | ||
13 | Fix this bug by saving the set of shared permissions before invoking | 7 | The previous vmdk4 calculation: |
14 | blk_set_perm() with BLK_PERM_ALL and restoring it afterwards. | ||
15 | 8 | ||
16 | Fixes: 5f7772c4d0cf32f4e779fcd5a69ae4dae24aeebf | 9 | (512 * 1024 * 1024) * 512(l2 entries) * 65536(grain) = 16PB |
17 | ("block-backend: Defer shared_perm tightening migration | 10 | |
18 | completion") | 11 | The added vmdk3 calculation: |
19 | Reported-by: Peng Liang <liangpeng10@huawei.com> | 12 | |
20 | Signed-off-by: Hanna Reitz <hreitz@redhat.com> | 13 | (512 * 1024 * 1024) * 4096(l2 entries) * 512(grain) = 1PB |
21 | Message-Id: <20211125135317.186576-2-hreitz@redhat.com> | 14 | |
22 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 15 | Adding the calculation of vmdk3 to the comment. |
23 | Tested-by: Peng Liang <liangpeng10@huawei.com> | 16 | |
17 | In any case, VMware does not offer virtual disks more than 2TB for | ||
18 | vmdk4/vmdk3 or 64TB for the new undocumented seSparse format which is | ||
19 | not implemented yet in qemu. | ||
20 | |||
21 | Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com> | ||
22 | Reviewed-by: Eyal Moscovici <eyal.moscovici@oracle.com> | ||
23 | Reviewed-by: Liran Alon <liran.alon@oracle.com> | ||
24 | Reviewed-by: Arbel Moshe <arbel.moshe@oracle.com> | ||
25 | Signed-off-by: Sam Eiderman <shmuel.eiderman@oracle.com> | ||
26 | Message-id: 20190620091057.47441-2-shmuel.eiderman@oracle.com | ||
27 | Reviewed-by: yuchenlin <yuchenlin@synology.com> | ||
28 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
29 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
24 | --- | 30 | --- |
25 | block/block-backend.c | 11 +++++++++++ | 31 | block/vmdk.c | 11 ++++++++--- |
26 | 1 file changed, 11 insertions(+) | 32 | 1 file changed, 8 insertions(+), 3 deletions(-) |
27 | 33 | ||
28 | diff --git a/block/block-backend.c b/block/block-backend.c | 34 | diff --git a/block/vmdk.c b/block/vmdk.c |
29 | index XXXXXXX..XXXXXXX 100644 | 35 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/block/block-backend.c | 36 | --- a/block/vmdk.c |
31 | +++ b/block/block-backend.c | 37 | +++ b/block/vmdk.c |
32 | @@ -XXX,XX +XXX,XX @@ static void blk_root_activate(BdrvChild *child, Error **errp) | 38 | @@ -XXX,XX +XXX,XX @@ static int vmdk_add_extent(BlockDriverState *bs, |
33 | { | 39 | return -EFBIG; |
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; | ||
58 | } | 40 | } |
59 | + blk->shared_perm = saved_shared_perm; | 41 | if (l1_size > 512 * 1024 * 1024) { |
60 | 42 | - /* Although with big capacity and small l1_entry_sectors, we can get a | |
61 | if (runstate_check(RUN_STATE_INMIGRATE)) { | 43 | + /* |
62 | /* Activation can happen when migration process is still active, for | 44 | + * Although with big capacity and small l1_entry_sectors, we can get a |
45 | * big l1_size, we don't want unbounded value to allocate the table. | ||
46 | - * Limit it to 512M, which is 16PB for default cluster and L2 table | ||
47 | - * size */ | ||
48 | + * Limit it to 512M, which is: | ||
49 | + * 16PB - for default "Hosted Sparse Extent" (VMDK4) | ||
50 | + * cluster size: 64KB, L2 table size: 512 entries | ||
51 | + * 1PB - for default "ESXi Host Sparse Extent" (VMDK3/vmfsSparse) | ||
52 | + * cluster size: 512B, L2 table size: 4096 entries | ||
53 | + */ | ||
54 | error_setg(errp, "L1 size too big"); | ||
55 | return -EFBIG; | ||
56 | } | ||
63 | -- | 57 | -- |
64 | 2.34.1 | 58 | 2.21.0 |
65 | 59 | ||
66 | 60 | diff view generated by jsdifflib |
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 1 | From: Sam Eiderman <shmuel.eiderman@oracle.com> |
---|---|---|---|
2 | 2 | ||
3 | compression_type can't be used if we want to create image with | 3 | 512M of L1 entries is a very loose bound, only 32M are required to store |
4 | compat=0.10. So, skip these tests, not many of them. | 4 | the maximal supported VMDK file size of 2TB. |
5 | 5 | ||
6 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 6 | Fixed qemu-iotest 59# - now failure occures before on impossible L1 |
7 | Reviewed-by: Hanna Reitz <hreitz@redhat.com> | 7 | table size. |
8 | Message-Id: <20211223160144.1097696-20-vsementsov@virtuozzo.com> | 8 | |
9 | Signed-off-by: Hanna Reitz <hreitz@redhat.com> | 9 | Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com> |
10 | Reviewed-by: Eyal Moscovici <eyal.moscovici@oracle.com> | ||
11 | Reviewed-by: Liran Alon <liran.alon@oracle.com> | ||
12 | Reviewed-by: Arbel Moshe <arbel.moshe@oracle.com> | ||
13 | Signed-off-by: Sam Eiderman <shmuel.eiderman@oracle.com> | ||
14 | Message-id: 20190620091057.47441-3-shmuel.eiderman@oracle.com | ||
15 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
16 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
10 | --- | 17 | --- |
11 | tests/qemu-iotests/031 | 5 +++-- | 18 | block/vmdk.c | 13 +++++++------ |
12 | tests/qemu-iotests/051 | 5 +++-- | 19 | tests/qemu-iotests/059.out | 2 +- |
13 | tests/qemu-iotests/061 | 6 +++++- | 20 | 2 files changed, 8 insertions(+), 7 deletions(-) |
14 | tests/qemu-iotests/112 | 3 ++- | ||
15 | tests/qemu-iotests/290 | 2 +- | ||
16 | 5 files changed, 14 insertions(+), 7 deletions(-) | ||
17 | 21 | ||
18 | diff --git a/tests/qemu-iotests/031 b/tests/qemu-iotests/031 | 22 | diff --git a/block/vmdk.c b/block/vmdk.c |
19 | index XXXXXXX..XXXXXXX 100755 | 23 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/tests/qemu-iotests/031 | 24 | --- a/block/vmdk.c |
21 | +++ b/tests/qemu-iotests/031 | 25 | +++ b/block/vmdk.c |
22 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 26 | @@ -XXX,XX +XXX,XX @@ static int vmdk_add_extent(BlockDriverState *bs, |
23 | _supported_fmt qcow2 | 27 | error_setg(errp, "Invalid granularity, image may be corrupt"); |
24 | _supported_proto file fuse | 28 | return -EFBIG; |
25 | # We want to test compat=0.10, which does not support external data | 29 | } |
26 | -# files or refcount widths other than 16 | 30 | - if (l1_size > 512 * 1024 * 1024) { |
27 | -_unsupported_imgopts data_file 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' | 31 | + if (l1_size > 32 * 1024 * 1024) { |
28 | +# files or refcount widths other than 16 or compression type | 32 | /* |
29 | +_unsupported_imgopts data_file compression_type \ | 33 | * Although with big capacity and small l1_entry_sectors, we can get a |
30 | + 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' | 34 | * big l1_size, we don't want unbounded value to allocate the table. |
31 | 35 | - * Limit it to 512M, which is: | |
32 | CLUSTER_SIZE=65536 | 36 | - * 16PB - for default "Hosted Sparse Extent" (VMDK4) |
33 | 37 | - * cluster size: 64KB, L2 table size: 512 entries | |
34 | diff --git a/tests/qemu-iotests/051 b/tests/qemu-iotests/051 | 38 | - * 1PB - for default "ESXi Host Sparse Extent" (VMDK3/vmfsSparse) |
35 | index XXXXXXX..XXXXXXX 100755 | 39 | - * cluster size: 512B, L2 table size: 4096 entries |
36 | --- a/tests/qemu-iotests/051 | 40 | + * Limit it to 32M, which is enough to store: |
37 | +++ b/tests/qemu-iotests/051 | 41 | + * 8TB - for both VMDK3 & VMDK4 with |
38 | @@ -XXX,XX +XXX,XX @@ _supported_fmt qcow2 | 42 | + * minimal cluster size: 512B |
39 | _supported_proto file | 43 | + * minimal L2 table size: 512 entries |
40 | # A compat=0.10 image is created in this test which does not support anything | 44 | + * 8 TB is still more than the maximal value supported for |
41 | # other than refcount_bits=16; | 45 | + * VMDK3 & VMDK4 which is 2TB. |
42 | -# it also will not support an external data file | 46 | */ |
43 | -_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file | 47 | error_setg(errp, "L1 size too big"); |
44 | +# it also will not support an external data file and compression type | 48 | return -EFBIG; |
45 | +_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file \ | 49 | diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out |
46 | + compression_type | 50 | index XXXXXXX..XXXXXXX 100644 |
47 | _require_drivers nbd | 51 | --- a/tests/qemu-iotests/059.out |
48 | 52 | +++ b/tests/qemu-iotests/059.out | |
49 | if [ "$QEMU_DEFAULT_MACHINE" = "pc" ]; then | 53 | @@ -XXX,XX +XXX,XX @@ Offset Length Mapped to File |
50 | diff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061 | 54 | 0x140000000 0x10000 0x50000 TEST_DIR/t-s003.vmdk |
51 | index XXXXXXX..XXXXXXX 100755 | 55 | |
52 | --- a/tests/qemu-iotests/061 | 56 | === Testing afl image with a very large capacity === |
53 | +++ b/tests/qemu-iotests/061 | 57 | -qemu-img: Can't get image size 'TEST_DIR/afl9.IMGFMT': File too large |
54 | @@ -XXX,XX +XXX,XX @@ _supported_os Linux | 58 | +qemu-img: Could not open 'TEST_DIR/afl9.IMGFMT': L1 size too big |
55 | # not work with it; | 59 | *** done |
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() | ||
80 | { | ||
81 | diff --git a/tests/qemu-iotests/290 b/tests/qemu-iotests/290 | ||
82 | index XXXXXXX..XXXXXXX 100755 | ||
83 | --- a/tests/qemu-iotests/290 | ||
84 | +++ b/tests/qemu-iotests/290 | ||
85 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
86 | _supported_fmt qcow2 | ||
87 | _supported_proto file fuse | ||
88 | _supported_os Linux | ||
89 | -_unsupported_imgopts 'compat=0.10' refcount_bits data_file | ||
90 | +_unsupported_imgopts 'compat=0.10' refcount_bits data_file compression_type | ||
91 | |||
92 | echo | ||
93 | echo "### Test 'qemu-io -c discard' on a QCOW2 image without a backing file" | ||
94 | -- | 60 | -- |
95 | 2.34.1 | 61 | 2.21.0 |
96 | 62 | ||
97 | 63 | diff view generated by jsdifflib |
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 1 | From: Sam Eiderman <shmuel.eiderman@oracle.com> |
---|---|---|---|
2 | 2 | ||
3 | If image doesn't have any compressed cluster we can easily switch to | 3 | Until ESXi 6.5 VMware used the vmfsSparse format for snapshots (VMDK3 in |
4 | zlib compression, which may allow to downgrade the image. | 4 | QEMU). |
5 | 5 | ||
6 | That's mostly needed to support IMGOPTS='compression_type=zstd' in some | 6 | This format was lacking in the following: |
7 | iotests which do qcow2 downgrade. | 7 | |
8 | 8 | * Grain directory (L1) and grain table (L2) entries were 32-bit, | |
9 | While being here also fix checkpatch complain against '#' in printf | 9 | allowing access to only 2TB (slightly less) of data. |
10 | formatting. | 10 | * The grain size (default) was 512 bytes - leading to data |
11 | 11 | fragmentation and many grain tables. | |
12 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 12 | * For space reclamation purposes, it was necessary to find all the |
13 | Reviewed-by: Max Reitz <mreitz@redhat.com> | 13 | grains which are not pointed to by any grain table - so a reverse |
14 | Message-Id: <20211223160144.1097696-13-vsementsov@virtuozzo.com> | 14 | mapping of "offset of grain in vmdk" to "grain table" must be |
15 | Signed-off-by: Hanna Reitz <hreitz@redhat.com> | 15 | constructed - which takes large amounts of CPU/RAM. |
16 | |||
17 | The format specification can be found in VMware's documentation: | ||
18 | https://www.vmware.com/support/developer/vddk/vmdk_50_technote.pdf | ||
19 | |||
20 | In ESXi 6.5, to support snapshot files larger than 2TB, a new format was | ||
21 | introduced: SESparse (Space Efficient). | ||
22 | |||
23 | This format fixes the above issues: | ||
24 | |||
25 | * All entries are now 64-bit. | ||
26 | * The grain size (default) is 4KB. | ||
27 | * Grain directory and grain tables are now located at the beginning | ||
28 | of the file. | ||
29 | + seSparse format reserves space for all grain tables. | ||
30 | + Grain tables can be addressed using an index. | ||
31 | + Grains are located in the end of the file and can also be | ||
32 | addressed with an index. | ||
33 | - seSparse vmdks of large disks (64TB) have huge preallocated | ||
34 | headers - mainly due to L2 tables, even for empty snapshots. | ||
35 | * The header contains a reverse mapping ("backmap") of "offset of | ||
36 | grain in vmdk" to "grain table" and a bitmap ("free bitmap") which | ||
37 | specifies for each grain - whether it is allocated or not. | ||
38 | Using these data structures we can implement space reclamation | ||
39 | efficiently. | ||
40 | * Due to the fact that the header now maintains two mappings: | ||
41 | * The regular one (grain directory & grain tables) | ||
42 | * A reverse one (backmap and free bitmap) | ||
43 | These data structures can lose consistency upon crash and result | ||
44 | in a corrupted VMDK. | ||
45 | Therefore, a journal is also added to the VMDK and is replayed | ||
46 | when the VMware reopens the file after a crash. | ||
47 | |||
48 | Since ESXi 6.7 - SESparse is the only snapshot format available. | ||
49 | |||
50 | Unfortunately, VMware does not provide documentation regarding the new | ||
51 | seSparse format. | ||
52 | |||
53 | This commit is based on black-box research of the seSparse format. | ||
54 | Various in-guest block operations and their effect on the snapshot file | ||
55 | were tested. | ||
56 | |||
57 | The only VMware provided source of information (regarding the underlying | ||
58 | implementation) was a log file on the ESXi: | ||
59 | |||
60 | /var/log/hostd.log | ||
61 | |||
62 | Whenever an seSparse snapshot is created - the log is being populated | ||
63 | with seSparse records. | ||
64 | |||
65 | Relevant log records are of the form: | ||
66 | |||
67 | [...] Const Header: | ||
68 | [...] constMagic = 0xcafebabe | ||
69 | [...] version = 2.1 | ||
70 | [...] capacity = 204800 | ||
71 | [...] grainSize = 8 | ||
72 | [...] grainTableSize = 64 | ||
73 | [...] flags = 0 | ||
74 | [...] Extents: | ||
75 | [...] Header : <1 : 1> | ||
76 | [...] JournalHdr : <2 : 2> | ||
77 | [...] Journal : <2048 : 2048> | ||
78 | [...] GrainDirectory : <4096 : 2048> | ||
79 | [...] GrainTables : <6144 : 2048> | ||
80 | [...] FreeBitmap : <8192 : 2048> | ||
81 | [...] BackMap : <10240 : 2048> | ||
82 | [...] Grain : <12288 : 204800> | ||
83 | [...] Volatile Header: | ||
84 | [...] volatileMagic = 0xcafecafe | ||
85 | [...] FreeGTNumber = 0 | ||
86 | [...] nextTxnSeqNumber = 0 | ||
87 | [...] replayJournal = 0 | ||
88 | |||
89 | The sizes that are seen in the log file are in sectors. | ||
90 | Extents are of the following format: <offset : size> | ||
91 | |||
92 | This commit is a strict implementation which enforces: | ||
93 | * magics | ||
94 | * version number 2.1 | ||
95 | * grain size of 8 sectors (4KB) | ||
96 | * grain table size of 64 sectors | ||
97 | * zero flags | ||
98 | * extent locations | ||
99 | |||
100 | Additionally, this commit proivdes only a subset of the functionality | ||
101 | offered by seSparse's format: | ||
102 | * Read-only | ||
103 | * No journal replay | ||
104 | * No space reclamation | ||
105 | * No unmap support | ||
106 | |||
107 | Hence, journal header, journal, free bitmap and backmap extents are | ||
108 | unused, only the "classic" (L1 -> L2 -> data) grain access is | ||
109 | implemented. | ||
110 | |||
111 | However there are several differences in the grain access itself. | ||
112 | Grain directory (L1): | ||
113 | * Grain directory entries are indexes (not offsets) to grain | ||
114 | tables. | ||
115 | * Valid grain directory entries have their highest nibble set to | ||
116 | 0x1. | ||
117 | * Since grain tables are always located in the beginning of the | ||
118 | file - the index can fit into 32 bits - so we can use its low | ||
119 | part if it's valid. | ||
120 | Grain table (L2): | ||
121 | * Grain table entries are indexes (not offsets) to grains. | ||
122 | * If the highest nibble of the entry is: | ||
123 | 0x0: | ||
124 | The grain in not allocated. | ||
125 | The rest of the bytes are 0. | ||
126 | 0x1: | ||
127 | The grain is unmapped - guest sees a zero grain. | ||
128 | The rest of the bits point to the previously mapped grain, | ||
129 | see 0x3 case. | ||
130 | 0x2: | ||
131 | The grain is zero. | ||
132 | 0x3: | ||
133 | The grain is allocated - to get the index calculate: | ||
134 | ((entry & 0x0fff000000000000) >> 48) | | ||
135 | ((entry & 0x0000ffffffffffff) << 12) | ||
136 | * The difference between 0x1 and 0x2 is that 0x1 is an unallocated | ||
137 | grain which results from the guest using sg_unmap to unmap the | ||
138 | grain - but the grain itself still exists in the grain extent - a | ||
139 | space reclamation procedure should delete it. | ||
140 | Unmapping a zero grain has no effect (0x2 will not change to 0x1) | ||
141 | but unmapping an unallocated grain will (0x0 to 0x1) - naturally. | ||
142 | |||
143 | In order to implement seSparse some fields had to be changed to support | ||
144 | both 32-bit and 64-bit entry sizes. | ||
145 | |||
146 | Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com> | ||
147 | Reviewed-by: Eyal Moscovici <eyal.moscovici@oracle.com> | ||
148 | Reviewed-by: Arbel Moshe <arbel.moshe@oracle.com> | ||
149 | Signed-off-by: Sam Eiderman <shmuel.eiderman@oracle.com> | ||
150 | Message-id: 20190620091057.47441-4-shmuel.eiderman@oracle.com | ||
151 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
16 | --- | 152 | --- |
17 | block/qcow2.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++-- | 153 | block/vmdk.c | 358 ++++++++++++++++++++++++++++++++++++++++++++++++--- |
18 | 1 file changed, 56 insertions(+), 2 deletions(-) | 154 | 1 file changed, 342 insertions(+), 16 deletions(-) |
19 | 155 | ||
20 | diff --git a/block/qcow2.c b/block/qcow2.c | 156 | diff --git a/block/vmdk.c b/block/vmdk.c |
21 | index XXXXXXX..XXXXXXX 100644 | 157 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/block/qcow2.c | 158 | --- a/block/vmdk.c |
23 | +++ b/block/qcow2.c | 159 | +++ b/block/vmdk.c |
24 | @@ -XXX,XX +XXX,XX @@ static int qcow2_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, | 160 | @@ -XXX,XX +XXX,XX @@ typedef struct { |
25 | return bs->drv->bdrv_co_preadv_part(bs, offset, qiov->size, qiov, 0, 0); | 161 | uint16_t compressAlgorithm; |
162 | } QEMU_PACKED VMDK4Header; | ||
163 | |||
164 | +typedef struct VMDKSESparseConstHeader { | ||
165 | + uint64_t magic; | ||
166 | + uint64_t version; | ||
167 | + uint64_t capacity; | ||
168 | + uint64_t grain_size; | ||
169 | + uint64_t grain_table_size; | ||
170 | + uint64_t flags; | ||
171 | + uint64_t reserved1; | ||
172 | + uint64_t reserved2; | ||
173 | + uint64_t reserved3; | ||
174 | + uint64_t reserved4; | ||
175 | + uint64_t volatile_header_offset; | ||
176 | + uint64_t volatile_header_size; | ||
177 | + uint64_t journal_header_offset; | ||
178 | + uint64_t journal_header_size; | ||
179 | + uint64_t journal_offset; | ||
180 | + uint64_t journal_size; | ||
181 | + uint64_t grain_dir_offset; | ||
182 | + uint64_t grain_dir_size; | ||
183 | + uint64_t grain_tables_offset; | ||
184 | + uint64_t grain_tables_size; | ||
185 | + uint64_t free_bitmap_offset; | ||
186 | + uint64_t free_bitmap_size; | ||
187 | + uint64_t backmap_offset; | ||
188 | + uint64_t backmap_size; | ||
189 | + uint64_t grains_offset; | ||
190 | + uint64_t grains_size; | ||
191 | + uint8_t pad[304]; | ||
192 | +} QEMU_PACKED VMDKSESparseConstHeader; | ||
193 | + | ||
194 | +typedef struct VMDKSESparseVolatileHeader { | ||
195 | + uint64_t magic; | ||
196 | + uint64_t free_gt_number; | ||
197 | + uint64_t next_txn_seq_number; | ||
198 | + uint64_t replay_journal; | ||
199 | + uint8_t pad[480]; | ||
200 | +} QEMU_PACKED VMDKSESparseVolatileHeader; | ||
201 | + | ||
202 | #define L2_CACHE_SIZE 16 | ||
203 | |||
204 | typedef struct VmdkExtent { | ||
205 | @@ -XXX,XX +XXX,XX @@ typedef struct VmdkExtent { | ||
206 | bool compressed; | ||
207 | bool has_marker; | ||
208 | bool has_zero_grain; | ||
209 | + bool sesparse; | ||
210 | + uint64_t sesparse_l2_tables_offset; | ||
211 | + uint64_t sesparse_clusters_offset; | ||
212 | + int32_t entry_size; | ||
213 | int version; | ||
214 | int64_t sectors; | ||
215 | int64_t end_sector; | ||
216 | int64_t flat_start_offset; | ||
217 | int64_t l1_table_offset; | ||
218 | int64_t l1_backup_table_offset; | ||
219 | - uint32_t *l1_table; | ||
220 | + void *l1_table; | ||
221 | uint32_t *l1_backup_table; | ||
222 | unsigned int l1_size; | ||
223 | uint32_t l1_entry_sectors; | ||
224 | |||
225 | unsigned int l2_size; | ||
226 | - uint32_t *l2_cache; | ||
227 | + void *l2_cache; | ||
228 | uint32_t l2_cache_offsets[L2_CACHE_SIZE]; | ||
229 | uint32_t l2_cache_counts[L2_CACHE_SIZE]; | ||
230 | |||
231 | @@ -XXX,XX +XXX,XX @@ static int vmdk_add_extent(BlockDriverState *bs, | ||
232 | * minimal L2 table size: 512 entries | ||
233 | * 8 TB is still more than the maximal value supported for | ||
234 | * VMDK3 & VMDK4 which is 2TB. | ||
235 | + * 64TB - for "ESXi seSparse Extent" | ||
236 | + * minimal cluster size: 512B (default is 4KB) | ||
237 | + * L2 table size: 4096 entries (const). | ||
238 | + * 64TB is more than the maximal value supported for | ||
239 | + * seSparse VMDKs (which is slightly less than 64TB) | ||
240 | */ | ||
241 | error_setg(errp, "L1 size too big"); | ||
242 | return -EFBIG; | ||
243 | @@ -XXX,XX +XXX,XX @@ static int vmdk_add_extent(BlockDriverState *bs, | ||
244 | extent->l2_size = l2_size; | ||
245 | extent->cluster_sectors = flat ? sectors : cluster_sectors; | ||
246 | extent->next_cluster_sector = ROUND_UP(nb_sectors, cluster_sectors); | ||
247 | + extent->entry_size = sizeof(uint32_t); | ||
248 | |||
249 | if (s->num_extents > 1) { | ||
250 | extent->end_sector = (*(extent - 1)).end_sector + extent->sectors; | ||
251 | @@ -XXX,XX +XXX,XX @@ static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent, | ||
252 | int i; | ||
253 | |||
254 | /* read the L1 table */ | ||
255 | - l1_size = extent->l1_size * sizeof(uint32_t); | ||
256 | + l1_size = extent->l1_size * extent->entry_size; | ||
257 | extent->l1_table = g_try_malloc(l1_size); | ||
258 | if (l1_size && extent->l1_table == NULL) { | ||
259 | return -ENOMEM; | ||
260 | @@ -XXX,XX +XXX,XX @@ static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent, | ||
261 | goto fail_l1; | ||
262 | } | ||
263 | for (i = 0; i < extent->l1_size; i++) { | ||
264 | - le32_to_cpus(&extent->l1_table[i]); | ||
265 | + if (extent->entry_size == sizeof(uint64_t)) { | ||
266 | + le64_to_cpus((uint64_t *)extent->l1_table + i); | ||
267 | + } else { | ||
268 | + assert(extent->entry_size == sizeof(uint32_t)); | ||
269 | + le32_to_cpus((uint32_t *)extent->l1_table + i); | ||
270 | + } | ||
271 | } | ||
272 | |||
273 | if (extent->l1_backup_table_offset) { | ||
274 | + assert(!extent->sesparse); | ||
275 | extent->l1_backup_table = g_try_malloc(l1_size); | ||
276 | if (l1_size && extent->l1_backup_table == NULL) { | ||
277 | ret = -ENOMEM; | ||
278 | @@ -XXX,XX +XXX,XX @@ static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent, | ||
279 | } | ||
280 | |||
281 | extent->l2_cache = | ||
282 | - g_new(uint32_t, extent->l2_size * L2_CACHE_SIZE); | ||
283 | + g_malloc(extent->entry_size * extent->l2_size * L2_CACHE_SIZE); | ||
284 | return 0; | ||
285 | fail_l1b: | ||
286 | g_free(extent->l1_backup_table); | ||
287 | @@ -XXX,XX +XXX,XX @@ static int vmdk_open_vmfs_sparse(BlockDriverState *bs, | ||
288 | return ret; | ||
26 | } | 289 | } |
27 | 290 | ||
28 | +static int qcow2_has_compressed_clusters(BlockDriverState *bs) | 291 | +#define SESPARSE_CONST_HEADER_MAGIC UINT64_C(0x00000000cafebabe) |
292 | +#define SESPARSE_VOLATILE_HEADER_MAGIC UINT64_C(0x00000000cafecafe) | ||
293 | + | ||
294 | +/* Strict checks - format not officially documented */ | ||
295 | +static int check_se_sparse_const_header(VMDKSESparseConstHeader *header, | ||
296 | + Error **errp) | ||
29 | +{ | 297 | +{ |
30 | + int64_t offset = 0; | 298 | + header->magic = le64_to_cpu(header->magic); |
31 | + int64_t bytes = bdrv_getlength(bs); | 299 | + header->version = le64_to_cpu(header->version); |
32 | + | 300 | + header->grain_size = le64_to_cpu(header->grain_size); |
33 | + if (bytes < 0) { | 301 | + header->grain_table_size = le64_to_cpu(header->grain_table_size); |
34 | + return bytes; | 302 | + header->flags = le64_to_cpu(header->flags); |
35 | + } | 303 | + header->reserved1 = le64_to_cpu(header->reserved1); |
36 | + | 304 | + header->reserved2 = le64_to_cpu(header->reserved2); |
37 | + while (bytes != 0) { | 305 | + header->reserved3 = le64_to_cpu(header->reserved3); |
38 | + int ret; | 306 | + header->reserved4 = le64_to_cpu(header->reserved4); |
39 | + QCow2SubclusterType type; | 307 | + |
40 | + unsigned int cur_bytes = MIN(INT_MAX, bytes); | 308 | + header->volatile_header_offset = |
41 | + uint64_t host_offset; | 309 | + le64_to_cpu(header->volatile_header_offset); |
42 | + | 310 | + header->volatile_header_size = le64_to_cpu(header->volatile_header_size); |
43 | + ret = qcow2_get_host_offset(bs, offset, &cur_bytes, &host_offset, | 311 | + |
44 | + &type); | 312 | + header->journal_header_offset = le64_to_cpu(header->journal_header_offset); |
45 | + if (ret < 0) { | 313 | + header->journal_header_size = le64_to_cpu(header->journal_header_size); |
46 | + return ret; | 314 | + |
47 | + } | 315 | + header->journal_offset = le64_to_cpu(header->journal_offset); |
48 | + | 316 | + header->journal_size = le64_to_cpu(header->journal_size); |
49 | + if (type == QCOW2_SUBCLUSTER_COMPRESSED) { | 317 | + |
50 | + return 1; | 318 | + header->grain_dir_offset = le64_to_cpu(header->grain_dir_offset); |
51 | + } | 319 | + header->grain_dir_size = le64_to_cpu(header->grain_dir_size); |
52 | + | 320 | + |
53 | + offset += cur_bytes; | 321 | + header->grain_tables_offset = le64_to_cpu(header->grain_tables_offset); |
54 | + bytes -= cur_bytes; | 322 | + header->grain_tables_size = le64_to_cpu(header->grain_tables_size); |
323 | + | ||
324 | + header->free_bitmap_offset = le64_to_cpu(header->free_bitmap_offset); | ||
325 | + header->free_bitmap_size = le64_to_cpu(header->free_bitmap_size); | ||
326 | + | ||
327 | + header->backmap_offset = le64_to_cpu(header->backmap_offset); | ||
328 | + header->backmap_size = le64_to_cpu(header->backmap_size); | ||
329 | + | ||
330 | + header->grains_offset = le64_to_cpu(header->grains_offset); | ||
331 | + header->grains_size = le64_to_cpu(header->grains_size); | ||
332 | + | ||
333 | + if (header->magic != SESPARSE_CONST_HEADER_MAGIC) { | ||
334 | + error_setg(errp, "Bad const header magic: 0x%016" PRIx64, | ||
335 | + header->magic); | ||
336 | + return -EINVAL; | ||
337 | + } | ||
338 | + | ||
339 | + if (header->version != 0x0000000200000001) { | ||
340 | + error_setg(errp, "Unsupported version: 0x%016" PRIx64, | ||
341 | + header->version); | ||
342 | + return -ENOTSUP; | ||
343 | + } | ||
344 | + | ||
345 | + if (header->grain_size != 8) { | ||
346 | + error_setg(errp, "Unsupported grain size: %" PRIu64, | ||
347 | + header->grain_size); | ||
348 | + return -ENOTSUP; | ||
349 | + } | ||
350 | + | ||
351 | + if (header->grain_table_size != 64) { | ||
352 | + error_setg(errp, "Unsupported grain table size: %" PRIu64, | ||
353 | + header->grain_table_size); | ||
354 | + return -ENOTSUP; | ||
355 | + } | ||
356 | + | ||
357 | + if (header->flags != 0) { | ||
358 | + error_setg(errp, "Unsupported flags: 0x%016" PRIx64, | ||
359 | + header->flags); | ||
360 | + return -ENOTSUP; | ||
361 | + } | ||
362 | + | ||
363 | + if (header->reserved1 != 0 || header->reserved2 != 0 || | ||
364 | + header->reserved3 != 0 || header->reserved4 != 0) { | ||
365 | + error_setg(errp, "Unsupported reserved bits:" | ||
366 | + " 0x%016" PRIx64 " 0x%016" PRIx64 | ||
367 | + " 0x%016" PRIx64 " 0x%016" PRIx64, | ||
368 | + header->reserved1, header->reserved2, | ||
369 | + header->reserved3, header->reserved4); | ||
370 | + return -ENOTSUP; | ||
371 | + } | ||
372 | + | ||
373 | + /* check that padding is 0 */ | ||
374 | + if (!buffer_is_zero(header->pad, sizeof(header->pad))) { | ||
375 | + error_setg(errp, "Unsupported non-zero const header padding"); | ||
376 | + return -ENOTSUP; | ||
55 | + } | 377 | + } |
56 | + | 378 | + |
57 | + return 0; | 379 | + return 0; |
58 | +} | 380 | +} |
59 | + | 381 | + |
60 | /* | 382 | +static int check_se_sparse_volatile_header(VMDKSESparseVolatileHeader *header, |
61 | * Downgrades an image's version. To achieve this, any incompatible features | 383 | + Error **errp) |
62 | * have to be removed. | 384 | +{ |
63 | @@ -XXX,XX +XXX,XX @@ static int qcow2_downgrade(BlockDriverState *bs, int target_version, | 385 | + header->magic = le64_to_cpu(header->magic); |
64 | * the first place; if that happens nonetheless, returning -ENOTSUP is the | 386 | + header->free_gt_number = le64_to_cpu(header->free_gt_number); |
65 | * best thing to do anyway */ | 387 | + header->next_txn_seq_number = le64_to_cpu(header->next_txn_seq_number); |
66 | 388 | + header->replay_journal = le64_to_cpu(header->replay_journal); | |
67 | - if (s->incompatible_features) { | 389 | + |
68 | + if (s->incompatible_features & ~QCOW2_INCOMPAT_COMPRESSION) { | 390 | + if (header->magic != SESPARSE_VOLATILE_HEADER_MAGIC) { |
69 | error_setg(errp, "Cannot downgrade an image with incompatible features " | 391 | + error_setg(errp, "Bad volatile header magic: 0x%016" PRIx64, |
70 | - "%#" PRIx64 " set", s->incompatible_features); | 392 | + header->magic); |
71 | + "0x%" PRIx64 " set", | 393 | + return -EINVAL; |
72 | + s->incompatible_features & ~QCOW2_INCOMPAT_COMPRESSION); | 394 | + } |
73 | return -ENOTSUP; | 395 | + |
74 | } | 396 | + if (header->replay_journal) { |
75 | 397 | + error_setg(errp, "Image is dirty, Replaying journal not supported"); | |
76 | @@ -XXX,XX +XXX,XX @@ static int qcow2_downgrade(BlockDriverState *bs, int target_version, | 398 | + return -ENOTSUP; |
77 | return ret; | 399 | + } |
78 | } | 400 | + |
79 | 401 | + /* check that padding is 0 */ | |
80 | + if (s->incompatible_features & QCOW2_INCOMPAT_COMPRESSION) { | 402 | + if (!buffer_is_zero(header->pad, sizeof(header->pad))) { |
81 | + ret = qcow2_has_compressed_clusters(bs); | 403 | + error_setg(errp, "Unsupported non-zero volatile header padding"); |
82 | + if (ret < 0) { | 404 | + return -ENOTSUP; |
83 | + error_setg(errp, "Failed to check block status"); | 405 | + } |
84 | + return -EINVAL; | 406 | + |
407 | + return 0; | ||
408 | +} | ||
409 | + | ||
410 | +static int vmdk_open_se_sparse(BlockDriverState *bs, | ||
411 | + BdrvChild *file, | ||
412 | + int flags, Error **errp) | ||
413 | +{ | ||
414 | + int ret; | ||
415 | + VMDKSESparseConstHeader const_header; | ||
416 | + VMDKSESparseVolatileHeader volatile_header; | ||
417 | + VmdkExtent *extent; | ||
418 | + | ||
419 | + ret = bdrv_apply_auto_read_only(bs, | ||
420 | + "No write support for seSparse images available", errp); | ||
421 | + if (ret < 0) { | ||
422 | + return ret; | ||
423 | + } | ||
424 | + | ||
425 | + assert(sizeof(const_header) == SECTOR_SIZE); | ||
426 | + | ||
427 | + ret = bdrv_pread(file, 0, &const_header, sizeof(const_header)); | ||
428 | + if (ret < 0) { | ||
429 | + bdrv_refresh_filename(file->bs); | ||
430 | + error_setg_errno(errp, -ret, | ||
431 | + "Could not read const header from file '%s'", | ||
432 | + file->bs->filename); | ||
433 | + return ret; | ||
434 | + } | ||
435 | + | ||
436 | + /* check const header */ | ||
437 | + ret = check_se_sparse_const_header(&const_header, errp); | ||
438 | + if (ret < 0) { | ||
439 | + return ret; | ||
440 | + } | ||
441 | + | ||
442 | + assert(sizeof(volatile_header) == SECTOR_SIZE); | ||
443 | + | ||
444 | + ret = bdrv_pread(file, | ||
445 | + const_header.volatile_header_offset * SECTOR_SIZE, | ||
446 | + &volatile_header, sizeof(volatile_header)); | ||
447 | + if (ret < 0) { | ||
448 | + bdrv_refresh_filename(file->bs); | ||
449 | + error_setg_errno(errp, -ret, | ||
450 | + "Could not read volatile header from file '%s'", | ||
451 | + file->bs->filename); | ||
452 | + return ret; | ||
453 | + } | ||
454 | + | ||
455 | + /* check volatile header */ | ||
456 | + ret = check_se_sparse_volatile_header(&volatile_header, errp); | ||
457 | + if (ret < 0) { | ||
458 | + return ret; | ||
459 | + } | ||
460 | + | ||
461 | + ret = vmdk_add_extent(bs, file, false, | ||
462 | + const_header.capacity, | ||
463 | + const_header.grain_dir_offset * SECTOR_SIZE, | ||
464 | + 0, | ||
465 | + const_header.grain_dir_size * | ||
466 | + SECTOR_SIZE / sizeof(uint64_t), | ||
467 | + const_header.grain_table_size * | ||
468 | + SECTOR_SIZE / sizeof(uint64_t), | ||
469 | + const_header.grain_size, | ||
470 | + &extent, | ||
471 | + errp); | ||
472 | + if (ret < 0) { | ||
473 | + return ret; | ||
474 | + } | ||
475 | + | ||
476 | + extent->sesparse = true; | ||
477 | + extent->sesparse_l2_tables_offset = const_header.grain_tables_offset; | ||
478 | + extent->sesparse_clusters_offset = const_header.grains_offset; | ||
479 | + extent->entry_size = sizeof(uint64_t); | ||
480 | + | ||
481 | + ret = vmdk_init_tables(bs, extent, errp); | ||
482 | + if (ret) { | ||
483 | + /* free extent allocated by vmdk_add_extent */ | ||
484 | + vmdk_free_last_extent(bs); | ||
485 | + } | ||
486 | + | ||
487 | + return ret; | ||
488 | +} | ||
489 | + | ||
490 | static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf, | ||
491 | QDict *options, Error **errp); | ||
492 | |||
493 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, | ||
494 | * RW [size in sectors] SPARSE "file-name.vmdk" | ||
495 | * RW [size in sectors] VMFS "file-name.vmdk" | ||
496 | * RW [size in sectors] VMFSSPARSE "file-name.vmdk" | ||
497 | + * RW [size in sectors] SESPARSE "file-name.vmdk" | ||
498 | */ | ||
499 | flat_offset = -1; | ||
500 | matches = sscanf(p, "%10s %" SCNd64 " %10s \"%511[^\n\r\"]\" %" SCNd64, | ||
501 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, | ||
502 | |||
503 | if (sectors <= 0 || | ||
504 | (strcmp(type, "FLAT") && strcmp(type, "SPARSE") && | ||
505 | - strcmp(type, "VMFS") && strcmp(type, "VMFSSPARSE")) || | ||
506 | + strcmp(type, "VMFS") && strcmp(type, "VMFSSPARSE") && | ||
507 | + strcmp(type, "SESPARSE")) || | ||
508 | (strcmp(access, "RW"))) { | ||
509 | continue; | ||
510 | } | ||
511 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, | ||
512 | return ret; | ||
513 | } | ||
514 | extent = &s->extents[s->num_extents - 1]; | ||
515 | + } else if (!strcmp(type, "SESPARSE")) { | ||
516 | + ret = vmdk_open_se_sparse(bs, extent_file, bs->open_flags, errp); | ||
517 | + if (ret) { | ||
518 | + bdrv_unref_child(bs, extent_file); | ||
519 | + return ret; | ||
520 | + } | ||
521 | + extent = &s->extents[s->num_extents - 1]; | ||
522 | } else { | ||
523 | error_setg(errp, "Unsupported extent type '%s'", type); | ||
524 | bdrv_unref_child(bs, extent_file); | ||
525 | @@ -XXX,XX +XXX,XX @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf, | ||
526 | if (strcmp(ct, "monolithicFlat") && | ||
527 | strcmp(ct, "vmfs") && | ||
528 | strcmp(ct, "vmfsSparse") && | ||
529 | + strcmp(ct, "seSparse") && | ||
530 | strcmp(ct, "twoGbMaxExtentSparse") && | ||
531 | strcmp(ct, "twoGbMaxExtentFlat")) { | ||
532 | error_setg(errp, "Unsupported image type '%s'", ct); | ||
533 | @@ -XXX,XX +XXX,XX @@ static int get_cluster_offset(BlockDriverState *bs, | ||
534 | { | ||
535 | unsigned int l1_index, l2_offset, l2_index; | ||
536 | int min_index, i, j; | ||
537 | - uint32_t min_count, *l2_table; | ||
538 | + uint32_t min_count; | ||
539 | + void *l2_table; | ||
540 | bool zeroed = false; | ||
541 | int64_t ret; | ||
542 | int64_t cluster_sector; | ||
543 | + unsigned int l2_size_bytes = extent->l2_size * extent->entry_size; | ||
544 | |||
545 | if (m_data) { | ||
546 | m_data->valid = 0; | ||
547 | @@ -XXX,XX +XXX,XX @@ static int get_cluster_offset(BlockDriverState *bs, | ||
548 | if (l1_index >= extent->l1_size) { | ||
549 | return VMDK_ERROR; | ||
550 | } | ||
551 | - l2_offset = extent->l1_table[l1_index]; | ||
552 | + if (extent->sesparse) { | ||
553 | + uint64_t l2_offset_u64; | ||
554 | + | ||
555 | + assert(extent->entry_size == sizeof(uint64_t)); | ||
556 | + | ||
557 | + l2_offset_u64 = ((uint64_t *)extent->l1_table)[l1_index]; | ||
558 | + if (l2_offset_u64 == 0) { | ||
559 | + l2_offset = 0; | ||
560 | + } else if ((l2_offset_u64 & 0xffffffff00000000) != 0x1000000000000000) { | ||
561 | + /* | ||
562 | + * Top most nibble is 0x1 if grain table is allocated. | ||
563 | + * strict check - top most 4 bytes must be 0x10000000 since max | ||
564 | + * supported size is 64TB for disk - so no more than 64TB / 16MB | ||
565 | + * grain directories which is smaller than uint32, | ||
566 | + * where 16MB is the only supported default grain table coverage. | ||
567 | + */ | ||
568 | + return VMDK_ERROR; | ||
569 | + } else { | ||
570 | + l2_offset_u64 = l2_offset_u64 & 0x00000000ffffffff; | ||
571 | + l2_offset_u64 = extent->sesparse_l2_tables_offset + | ||
572 | + l2_offset_u64 * l2_size_bytes / SECTOR_SIZE; | ||
573 | + if (l2_offset_u64 > 0x00000000ffffffff) { | ||
574 | + return VMDK_ERROR; | ||
575 | + } | ||
576 | + l2_offset = (unsigned int)(l2_offset_u64); | ||
85 | + } | 577 | + } |
86 | + if (ret) { | 578 | + } else { |
87 | + error_setg(errp, "Cannot downgrade an image with zstd compression " | 579 | + assert(extent->entry_size == sizeof(uint32_t)); |
88 | + "type and existing compressed clusters"); | 580 | + l2_offset = ((uint32_t *)extent->l1_table)[l1_index]; |
581 | + } | ||
582 | if (!l2_offset) { | ||
583 | return VMDK_UNALLOC; | ||
584 | } | ||
585 | @@ -XXX,XX +XXX,XX @@ static int get_cluster_offset(BlockDriverState *bs, | ||
586 | extent->l2_cache_counts[j] >>= 1; | ||
587 | } | ||
588 | } | ||
589 | - l2_table = extent->l2_cache + (i * extent->l2_size); | ||
590 | + l2_table = (char *)extent->l2_cache + (i * l2_size_bytes); | ||
591 | goto found; | ||
592 | } | ||
593 | } | ||
594 | @@ -XXX,XX +XXX,XX @@ static int get_cluster_offset(BlockDriverState *bs, | ||
595 | min_index = i; | ||
596 | } | ||
597 | } | ||
598 | - l2_table = extent->l2_cache + (min_index * extent->l2_size); | ||
599 | + l2_table = (char *)extent->l2_cache + (min_index * l2_size_bytes); | ||
600 | BLKDBG_EVENT(extent->file, BLKDBG_L2_LOAD); | ||
601 | if (bdrv_pread(extent->file, | ||
602 | (int64_t)l2_offset * 512, | ||
603 | l2_table, | ||
604 | - extent->l2_size * sizeof(uint32_t) | ||
605 | - ) != extent->l2_size * sizeof(uint32_t)) { | ||
606 | + l2_size_bytes | ||
607 | + ) != l2_size_bytes) { | ||
608 | return VMDK_ERROR; | ||
609 | } | ||
610 | |||
611 | @@ -XXX,XX +XXX,XX @@ static int get_cluster_offset(BlockDriverState *bs, | ||
612 | extent->l2_cache_counts[min_index] = 1; | ||
613 | found: | ||
614 | l2_index = ((offset >> 9) / extent->cluster_sectors) % extent->l2_size; | ||
615 | - cluster_sector = le32_to_cpu(l2_table[l2_index]); | ||
616 | |||
617 | - if (extent->has_zero_grain && cluster_sector == VMDK_GTE_ZEROED) { | ||
618 | - zeroed = true; | ||
619 | + if (extent->sesparse) { | ||
620 | + cluster_sector = le64_to_cpu(((uint64_t *)l2_table)[l2_index]); | ||
621 | + switch (cluster_sector & 0xf000000000000000) { | ||
622 | + case 0x0000000000000000: | ||
623 | + /* unallocated grain */ | ||
624 | + if (cluster_sector != 0) { | ||
625 | + return VMDK_ERROR; | ||
626 | + } | ||
627 | + break; | ||
628 | + case 0x1000000000000000: | ||
629 | + /* scsi-unmapped grain - fallthrough */ | ||
630 | + case 0x2000000000000000: | ||
631 | + /* zero grain */ | ||
632 | + zeroed = true; | ||
633 | + break; | ||
634 | + case 0x3000000000000000: | ||
635 | + /* allocated grain */ | ||
636 | + cluster_sector = (((cluster_sector & 0x0fff000000000000) >> 48) | | ||
637 | + ((cluster_sector & 0x0000ffffffffffff) << 12)); | ||
638 | + cluster_sector = extent->sesparse_clusters_offset + | ||
639 | + cluster_sector * extent->cluster_sectors; | ||
640 | + break; | ||
641 | + default: | ||
642 | + return VMDK_ERROR; | ||
643 | + } | ||
644 | + } else { | ||
645 | + cluster_sector = le32_to_cpu(((uint32_t *)l2_table)[l2_index]); | ||
646 | + | ||
647 | + if (extent->has_zero_grain && cluster_sector == VMDK_GTE_ZEROED) { | ||
648 | + zeroed = true; | ||
649 | + } | ||
650 | } | ||
651 | |||
652 | if (!cluster_sector || zeroed) { | ||
653 | if (!allocate) { | ||
654 | return zeroed ? VMDK_ZEROED : VMDK_UNALLOC; | ||
655 | } | ||
656 | + assert(!extent->sesparse); | ||
657 | |||
658 | if (extent->next_cluster_sector >= VMDK_EXTENT_MAX_SECTORS) { | ||
659 | return VMDK_ERROR; | ||
660 | @@ -XXX,XX +XXX,XX @@ static int get_cluster_offset(BlockDriverState *bs, | ||
661 | m_data->l1_index = l1_index; | ||
662 | m_data->l2_index = l2_index; | ||
663 | m_data->l2_offset = l2_offset; | ||
664 | - m_data->l2_cache_entry = &l2_table[l2_index]; | ||
665 | + m_data->l2_cache_entry = ((uint32_t *)l2_table) + l2_index; | ||
666 | } | ||
667 | } | ||
668 | *cluster_offset = cluster_sector << BDRV_SECTOR_BITS; | ||
669 | @@ -XXX,XX +XXX,XX @@ static int vmdk_pwritev(BlockDriverState *bs, uint64_t offset, | ||
670 | if (!extent) { | ||
671 | return -EIO; | ||
672 | } | ||
673 | + if (extent->sesparse) { | ||
89 | + return -ENOTSUP; | 674 | + return -ENOTSUP; |
90 | + } | 675 | + } |
91 | + /* | 676 | offset_in_cluster = vmdk_find_offset_in_cluster(extent, offset); |
92 | + * No compressed clusters for now, so just chose default zlib | 677 | n_bytes = MIN(bytes, extent->cluster_sectors * BDRV_SECTOR_SIZE |
93 | + * compression. | 678 | - offset_in_cluster); |
94 | + */ | ||
95 | + s->incompatible_features &= ~QCOW2_INCOMPAT_COMPRESSION; | ||
96 | + s->compression_type = QCOW2_COMPRESSION_TYPE_ZLIB; | ||
97 | + } | ||
98 | + | ||
99 | + assert(s->incompatible_features == 0); | ||
100 | + | ||
101 | s->qcow_version = target_version; | ||
102 | ret = qcow2_update_header(bs); | ||
103 | if (ret < 0) { | ||
104 | -- | 679 | -- |
105 | 2.34.1 | 680 | 2.21.0 |
106 | 681 | ||
107 | 682 | diff view generated by jsdifflib |
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 1 | From: Pino Toscano <ptoscano@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | We are going to support some addition IMGOPTS in python iotests like | 3 | Rewrite the implementation of the ssh block driver to use libssh instead |
4 | in bash iotests. Similarly to bash iotests, we want a way to skip some | 4 | of libssh2. The libssh library has various advantages over libssh2: |
5 | tests which can't work with specific IMGOPTS. | 5 | - easier API for authentication (for example for using ssh-agent) |
6 | - easier API for known_hosts handling | ||
7 | - supports newer types of keys in known_hosts | ||
6 | 8 | ||
7 | Globally for python iotests we will not support things like | 9 | Use APIs/features available in libssh 0.8 conditionally, to support |
8 | 'data_file=$TEST_IMG.ext_data_file' in IMGOPTS, so, forbid this | 10 | older versions (which are not recommended though). |
9 | globally in iotests.py. | ||
10 | 11 | ||
11 | Suggested-by: Hanna Reitz <hreitz@redhat.com> | 12 | Adjust the iotest 207 according to the different error message, and to |
12 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 13 | find the default key type for localhost (to properly compare the |
13 | Reviewed-by: Hanna Reitz <hreitz@redhat.com> | 14 | fingerprint with). |
14 | Message-Id: <20211223160144.1097696-3-vsementsov@virtuozzo.com> | 15 | Contributed-by: Max Reitz <mreitz@redhat.com> |
15 | Signed-off-by: Hanna Reitz <hreitz@redhat.com> | 16 | |
17 | Adjust the various Docker/Travis scripts to use libssh when available | ||
18 | instead of libssh2. The mingw/mxe testing is dropped for now, as there | ||
19 | are no packages for it. | ||
20 | |||
21 | Signed-off-by: Pino Toscano <ptoscano@redhat.com> | ||
22 | Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
23 | Acked-by: Alex Bennée <alex.bennee@linaro.org> | ||
24 | Message-id: 20190620200840.17655-1-ptoscano@redhat.com | ||
25 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
26 | Message-id: 5873173.t2JhDm7DL7@lindworm.usersys.redhat.com | ||
27 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
16 | --- | 28 | --- |
17 | tests/qemu-iotests/iotests.py | 15 ++++++++++++++- | 29 | configure | 65 +- |
18 | 1 file changed, 14 insertions(+), 1 deletion(-) | 30 | block/Makefile.objs | 6 +- |
31 | block/ssh.c | 652 ++++++++++-------- | ||
32 | .travis.yml | 4 +- | ||
33 | block/trace-events | 14 +- | ||
34 | docs/qemu-block-drivers.texi | 2 +- | ||
35 | .../dockerfiles/debian-win32-cross.docker | 1 - | ||
36 | .../dockerfiles/debian-win64-cross.docker | 1 - | ||
37 | tests/docker/dockerfiles/fedora.docker | 4 +- | ||
38 | tests/docker/dockerfiles/ubuntu.docker | 2 +- | ||
39 | tests/docker/dockerfiles/ubuntu1804.docker | 2 +- | ||
40 | tests/qemu-iotests/207 | 54 +- | ||
41 | tests/qemu-iotests/207.out | 2 +- | ||
42 | 13 files changed, 449 insertions(+), 360 deletions(-) | ||
19 | 43 | ||
20 | diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py | 44 | diff --git a/configure b/configure |
45 | index XXXXXXX..XXXXXXX 100755 | ||
46 | --- a/configure | ||
47 | +++ b/configure | ||
48 | @@ -XXX,XX +XXX,XX @@ auth_pam="" | ||
49 | vte="" | ||
50 | virglrenderer="" | ||
51 | tpm="" | ||
52 | -libssh2="" | ||
53 | +libssh="" | ||
54 | live_block_migration="yes" | ||
55 | numa="" | ||
56 | tcmalloc="no" | ||
57 | @@ -XXX,XX +XXX,XX @@ for opt do | ||
58 | ;; | ||
59 | --enable-tpm) tpm="yes" | ||
60 | ;; | ||
61 | - --disable-libssh2) libssh2="no" | ||
62 | + --disable-libssh) libssh="no" | ||
63 | ;; | ||
64 | - --enable-libssh2) libssh2="yes" | ||
65 | + --enable-libssh) libssh="yes" | ||
66 | ;; | ||
67 | --disable-live-block-migration) live_block_migration="no" | ||
68 | ;; | ||
69 | @@ -XXX,XX +XXX,XX @@ disabled with --disable-FEATURE, default is enabled if available: | ||
70 | coroutine-pool coroutine freelist (better performance) | ||
71 | glusterfs GlusterFS backend | ||
72 | tpm TPM support | ||
73 | - libssh2 ssh block device support | ||
74 | + libssh ssh block device support | ||
75 | numa libnuma support | ||
76 | libxml2 for Parallels image format | ||
77 | tcmalloc tcmalloc support | ||
78 | @@ -XXX,XX +XXX,XX @@ EOF | ||
79 | fi | ||
80 | |||
81 | ########################################## | ||
82 | -# libssh2 probe | ||
83 | -min_libssh2_version=1.2.8 | ||
84 | -if test "$libssh2" != "no" ; then | ||
85 | - if $pkg_config --atleast-version=$min_libssh2_version libssh2; then | ||
86 | - libssh2_cflags=$($pkg_config libssh2 --cflags) | ||
87 | - libssh2_libs=$($pkg_config libssh2 --libs) | ||
88 | - libssh2=yes | ||
89 | +# libssh probe | ||
90 | +if test "$libssh" != "no" ; then | ||
91 | + if $pkg_config --exists libssh; then | ||
92 | + libssh_cflags=$($pkg_config libssh --cflags) | ||
93 | + libssh_libs=$($pkg_config libssh --libs) | ||
94 | + libssh=yes | ||
95 | else | ||
96 | - if test "$libssh2" = "yes" ; then | ||
97 | - error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2" | ||
98 | + if test "$libssh" = "yes" ; then | ||
99 | + error_exit "libssh required for --enable-libssh" | ||
100 | fi | ||
101 | - libssh2=no | ||
102 | + libssh=no | ||
103 | fi | ||
104 | fi | ||
105 | |||
106 | ########################################## | ||
107 | -# libssh2_sftp_fsync probe | ||
108 | +# Check for libssh 0.8 | ||
109 | +# This is done like this instead of using the LIBSSH_VERSION_* and | ||
110 | +# SSH_VERSION_* macros because some distributions in the past shipped | ||
111 | +# snapshots of the future 0.8 from Git, and those snapshots did not | ||
112 | +# have updated version numbers (still referring to 0.7.0). | ||
113 | |||
114 | -if test "$libssh2" = "yes"; then | ||
115 | +if test "$libssh" = "yes"; then | ||
116 | cat > $TMPC <<EOF | ||
117 | -#include <stdio.h> | ||
118 | -#include <libssh2.h> | ||
119 | -#include <libssh2_sftp.h> | ||
120 | -int main(void) { | ||
121 | - LIBSSH2_SESSION *session; | ||
122 | - LIBSSH2_SFTP *sftp; | ||
123 | - LIBSSH2_SFTP_HANDLE *sftp_handle; | ||
124 | - session = libssh2_session_init (); | ||
125 | - sftp = libssh2_sftp_init (session); | ||
126 | - sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0); | ||
127 | - libssh2_sftp_fsync (sftp_handle); | ||
128 | - return 0; | ||
129 | -} | ||
130 | +#include <libssh/libssh.h> | ||
131 | +int main(void) { return ssh_get_server_publickey(NULL, NULL); } | ||
132 | EOF | ||
133 | - # libssh2_cflags/libssh2_libs defined in previous test. | ||
134 | - if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then | ||
135 | - QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS" | ||
136 | + if compile_prog "$libssh_cflags" "$libssh_libs"; then | ||
137 | + libssh_cflags="-DHAVE_LIBSSH_0_8 $libssh_cflags" | ||
138 | fi | ||
139 | fi | ||
140 | |||
141 | @@ -XXX,XX +XXX,XX @@ echo "GlusterFS support $glusterfs" | ||
142 | echo "gcov $gcov_tool" | ||
143 | echo "gcov enabled $gcov" | ||
144 | echo "TPM support $tpm" | ||
145 | -echo "libssh2 support $libssh2" | ||
146 | +echo "libssh support $libssh" | ||
147 | echo "QOM debugging $qom_cast_debug" | ||
148 | echo "Live block migration $live_block_migration" | ||
149 | echo "lzo support $lzo" | ||
150 | @@ -XXX,XX +XXX,XX @@ if test "$glusterfs_iocb_has_stat" = "yes" ; then | ||
151 | echo "CONFIG_GLUSTERFS_IOCB_HAS_STAT=y" >> $config_host_mak | ||
152 | fi | ||
153 | |||
154 | -if test "$libssh2" = "yes" ; then | ||
155 | - echo "CONFIG_LIBSSH2=m" >> $config_host_mak | ||
156 | - echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak | ||
157 | - echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak | ||
158 | +if test "$libssh" = "yes" ; then | ||
159 | + echo "CONFIG_LIBSSH=m" >> $config_host_mak | ||
160 | + echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak | ||
161 | + echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak | ||
162 | fi | ||
163 | |||
164 | if test "$live_block_migration" = "yes" ; then | ||
165 | diff --git a/block/Makefile.objs b/block/Makefile.objs | ||
21 | index XXXXXXX..XXXXXXX 100644 | 166 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/tests/qemu-iotests/iotests.py | 167 | --- a/block/Makefile.objs |
23 | +++ b/tests/qemu-iotests/iotests.py | 168 | +++ b/block/Makefile.objs |
24 | @@ -XXX,XX +XXX,XX @@ def _verify_virtio_scsi_pci_or_ccw() -> None: | 169 | @@ -XXX,XX +XXX,XX @@ block-obj-$(CONFIG_CURL) += curl.o |
25 | notrun('Missing virtio-scsi-pci or virtio-scsi-ccw in QEMU binary') | 170 | block-obj-$(CONFIG_RBD) += rbd.o |
26 | 171 | block-obj-$(CONFIG_GLUSTERFS) += gluster.o | |
27 | 172 | block-obj-$(CONFIG_VXHS) += vxhs.o | |
28 | +def _verify_imgopts(unsupported: Sequence[str] = ()) -> None: | 173 | -block-obj-$(CONFIG_LIBSSH2) += ssh.o |
29 | + imgopts = os.environ.get('IMGOPTS') | 174 | +block-obj-$(CONFIG_LIBSSH) += ssh.o |
30 | + # One of usage examples for IMGOPTS is "data_file=$TEST_IMG.ext_data_file" | 175 | block-obj-y += accounting.o dirty-bitmap.o |
31 | + # but it supported only for bash tests. We don't have a concept of global | 176 | block-obj-y += write-threshold.o |
32 | + # TEST_IMG in iotests.py, not saying about somehow parsing $variables. | 177 | block-obj-y += backup.o |
33 | + # So, for simplicity let's just not support any IMGOPTS with '$' inside. | 178 | @@ -XXX,XX +XXX,XX @@ rbd.o-libs := $(RBD_LIBS) |
34 | + unsup = list(unsupported) + ['$'] | 179 | gluster.o-cflags := $(GLUSTERFS_CFLAGS) |
35 | + if imgopts and any(x in imgopts for x in unsup): | 180 | gluster.o-libs := $(GLUSTERFS_LIBS) |
36 | + notrun(f'not suitable for this imgopts: {imgopts}') | 181 | vxhs.o-libs := $(VXHS_LIBS) |
37 | + | 182 | -ssh.o-cflags := $(LIBSSH2_CFLAGS) |
38 | + | 183 | -ssh.o-libs := $(LIBSSH2_LIBS) |
39 | def supports_quorum(): | 184 | +ssh.o-cflags := $(LIBSSH_CFLAGS) |
40 | return 'quorum' in qemu_img_pipe('--help') | 185 | +ssh.o-libs := $(LIBSSH_LIBS) |
41 | 186 | block-obj-dmg-bz2-$(CONFIG_BZIP2) += dmg-bz2.o | |
42 | @@ -XXX,XX +XXX,XX @@ def execute_setup_common(supported_fmts: Sequence[str] = (), | 187 | block-obj-$(if $(CONFIG_DMG),m,n) += $(block-obj-dmg-bz2-y) |
43 | unsupported_fmts: Sequence[str] = (), | 188 | dmg-bz2.o-libs := $(BZIP2_LIBS) |
44 | supported_protocols: Sequence[str] = (), | 189 | diff --git a/block/ssh.c b/block/ssh.c |
45 | unsupported_protocols: Sequence[str] = (), | 190 | index XXXXXXX..XXXXXXX 100644 |
46 | - required_fmts: Sequence[str] = ()) -> bool: | 191 | --- a/block/ssh.c |
47 | + required_fmts: Sequence[str] = (), | 192 | +++ b/block/ssh.c |
48 | + unsupported_imgopts: Sequence[str] = ()) -> bool: | 193 | @@ -XXX,XX +XXX,XX @@ |
49 | """ | 194 | |
50 | Perform necessary setup for either script-style or unittest-style tests. | 195 | #include "qemu/osdep.h" |
51 | 196 | ||
52 | @@ -XXX,XX +XXX,XX @@ def execute_setup_common(supported_fmts: Sequence[str] = (), | 197 | -#include <libssh2.h> |
53 | _verify_aio_mode(supported_aio_modes) | 198 | -#include <libssh2_sftp.h> |
54 | _verify_formats(required_fmts) | 199 | +#include <libssh/libssh.h> |
55 | _verify_virtio_blk() | 200 | +#include <libssh/sftp.h> |
56 | + _verify_imgopts(unsupported_imgopts) | 201 | |
57 | 202 | #include "block/block_int.h" | |
58 | return debug | 203 | #include "block/qdict.h" |
204 | @@ -XXX,XX +XXX,XX @@ | ||
205 | #include "trace.h" | ||
206 | |||
207 | /* | ||
208 | - * TRACE_LIBSSH2=<bitmask> enables tracing in libssh2 itself. Note | ||
209 | - * that this requires that libssh2 was specially compiled with the | ||
210 | - * `./configure --enable-debug' option, so most likely you will have | ||
211 | - * to compile it yourself. The meaning of <bitmask> is described | ||
212 | - * here: http://www.libssh2.org/libssh2_trace.html | ||
213 | + * TRACE_LIBSSH=<level> enables tracing in libssh itself. | ||
214 | + * The meaning of <level> is described here: | ||
215 | + * http://api.libssh.org/master/group__libssh__log.html | ||
216 | */ | ||
217 | -#define TRACE_LIBSSH2 0 /* or try: LIBSSH2_TRACE_SFTP */ | ||
218 | +#define TRACE_LIBSSH 0 /* see: SSH_LOG_* */ | ||
219 | |||
220 | typedef struct BDRVSSHState { | ||
221 | /* Coroutine. */ | ||
222 | @@ -XXX,XX +XXX,XX @@ typedef struct BDRVSSHState { | ||
223 | |||
224 | /* SSH connection. */ | ||
225 | int sock; /* socket */ | ||
226 | - LIBSSH2_SESSION *session; /* ssh session */ | ||
227 | - LIBSSH2_SFTP *sftp; /* sftp session */ | ||
228 | - LIBSSH2_SFTP_HANDLE *sftp_handle; /* sftp remote file handle */ | ||
229 | + ssh_session session; /* ssh session */ | ||
230 | + sftp_session sftp; /* sftp session */ | ||
231 | + sftp_file sftp_handle; /* sftp remote file handle */ | ||
232 | |||
233 | - /* See ssh_seek() function below. */ | ||
234 | - int64_t offset; | ||
235 | - bool offset_op_read; | ||
236 | - | ||
237 | - /* File attributes at open. We try to keep the .filesize field | ||
238 | + /* | ||
239 | + * File attributes at open. We try to keep the .size field | ||
240 | * updated if it changes (eg by writing at the end of the file). | ||
241 | */ | ||
242 | - LIBSSH2_SFTP_ATTRIBUTES attrs; | ||
243 | + sftp_attributes attrs; | ||
244 | |||
245 | InetSocketAddress *inet; | ||
246 | |||
247 | @@ -XXX,XX +XXX,XX @@ static void ssh_state_init(BDRVSSHState *s) | ||
248 | { | ||
249 | memset(s, 0, sizeof *s); | ||
250 | s->sock = -1; | ||
251 | - s->offset = -1; | ||
252 | qemu_co_mutex_init(&s->lock); | ||
253 | } | ||
254 | |||
255 | @@ -XXX,XX +XXX,XX @@ static void ssh_state_free(BDRVSSHState *s) | ||
256 | { | ||
257 | g_free(s->user); | ||
258 | |||
259 | + if (s->attrs) { | ||
260 | + sftp_attributes_free(s->attrs); | ||
261 | + } | ||
262 | if (s->sftp_handle) { | ||
263 | - libssh2_sftp_close(s->sftp_handle); | ||
264 | + sftp_close(s->sftp_handle); | ||
265 | } | ||
266 | if (s->sftp) { | ||
267 | - libssh2_sftp_shutdown(s->sftp); | ||
268 | + sftp_free(s->sftp); | ||
269 | } | ||
270 | if (s->session) { | ||
271 | - libssh2_session_disconnect(s->session, | ||
272 | - "from qemu ssh client: " | ||
273 | - "user closed the connection"); | ||
274 | - libssh2_session_free(s->session); | ||
275 | - } | ||
276 | - if (s->sock >= 0) { | ||
277 | - close(s->sock); | ||
278 | + ssh_disconnect(s->session); | ||
279 | + ssh_free(s->session); /* This frees s->sock */ | ||
280 | } | ||
281 | } | ||
282 | |||
283 | @@ -XXX,XX +XXX,XX @@ session_error_setg(Error **errp, BDRVSSHState *s, const char *fs, ...) | ||
284 | va_end(args); | ||
285 | |||
286 | if (s->session) { | ||
287 | - char *ssh_err; | ||
288 | + const char *ssh_err; | ||
289 | int ssh_err_code; | ||
290 | |||
291 | - /* This is not an errno. See <libssh2.h>. */ | ||
292 | - ssh_err_code = libssh2_session_last_error(s->session, | ||
293 | - &ssh_err, NULL, 0); | ||
294 | - error_setg(errp, "%s: %s (libssh2 error code: %d)", | ||
295 | + /* This is not an errno. See <libssh/libssh.h>. */ | ||
296 | + ssh_err = ssh_get_error(s->session); | ||
297 | + ssh_err_code = ssh_get_error_code(s->session); | ||
298 | + error_setg(errp, "%s: %s (libssh error code: %d)", | ||
299 | msg, ssh_err, ssh_err_code); | ||
300 | } else { | ||
301 | error_setg(errp, "%s", msg); | ||
302 | @@ -XXX,XX +XXX,XX @@ sftp_error_setg(Error **errp, BDRVSSHState *s, const char *fs, ...) | ||
303 | va_end(args); | ||
304 | |||
305 | if (s->sftp) { | ||
306 | - char *ssh_err; | ||
307 | + const char *ssh_err; | ||
308 | int ssh_err_code; | ||
309 | - unsigned long sftp_err_code; | ||
310 | + int sftp_err_code; | ||
311 | |||
312 | - /* This is not an errno. See <libssh2.h>. */ | ||
313 | - ssh_err_code = libssh2_session_last_error(s->session, | ||
314 | - &ssh_err, NULL, 0); | ||
315 | - /* See <libssh2_sftp.h>. */ | ||
316 | - sftp_err_code = libssh2_sftp_last_error((s)->sftp); | ||
317 | + /* This is not an errno. See <libssh/libssh.h>. */ | ||
318 | + ssh_err = ssh_get_error(s->session); | ||
319 | + ssh_err_code = ssh_get_error_code(s->session); | ||
320 | + /* See <libssh/sftp.h>. */ | ||
321 | + sftp_err_code = sftp_get_error(s->sftp); | ||
322 | |||
323 | error_setg(errp, | ||
324 | - "%s: %s (libssh2 error code: %d, sftp error code: %lu)", | ||
325 | + "%s: %s (libssh error code: %d, sftp error code: %d)", | ||
326 | msg, ssh_err, ssh_err_code, sftp_err_code); | ||
327 | } else { | ||
328 | error_setg(errp, "%s", msg); | ||
329 | @@ -XXX,XX +XXX,XX @@ sftp_error_setg(Error **errp, BDRVSSHState *s, const char *fs, ...) | ||
330 | |||
331 | static void sftp_error_trace(BDRVSSHState *s, const char *op) | ||
332 | { | ||
333 | - char *ssh_err; | ||
334 | + const char *ssh_err; | ||
335 | int ssh_err_code; | ||
336 | - unsigned long sftp_err_code; | ||
337 | + int sftp_err_code; | ||
338 | |||
339 | - /* This is not an errno. See <libssh2.h>. */ | ||
340 | - ssh_err_code = libssh2_session_last_error(s->session, | ||
341 | - &ssh_err, NULL, 0); | ||
342 | - /* See <libssh2_sftp.h>. */ | ||
343 | - sftp_err_code = libssh2_sftp_last_error((s)->sftp); | ||
344 | + /* This is not an errno. See <libssh/libssh.h>. */ | ||
345 | + ssh_err = ssh_get_error(s->session); | ||
346 | + ssh_err_code = ssh_get_error_code(s->session); | ||
347 | + /* See <libssh/sftp.h>. */ | ||
348 | + sftp_err_code = sftp_get_error(s->sftp); | ||
349 | |||
350 | trace_sftp_error(op, ssh_err, ssh_err_code, sftp_err_code); | ||
351 | } | ||
352 | @@ -XXX,XX +XXX,XX @@ static void ssh_parse_filename(const char *filename, QDict *options, | ||
353 | parse_uri(filename, options, errp); | ||
354 | } | ||
355 | |||
356 | -static int check_host_key_knownhosts(BDRVSSHState *s, | ||
357 | - const char *host, int port, Error **errp) | ||
358 | +static int check_host_key_knownhosts(BDRVSSHState *s, Error **errp) | ||
359 | { | ||
360 | - const char *home; | ||
361 | - char *knh_file = NULL; | ||
362 | - LIBSSH2_KNOWNHOSTS *knh = NULL; | ||
363 | - struct libssh2_knownhost *found; | ||
364 | - int ret, r; | ||
365 | - const char *hostkey; | ||
366 | - size_t len; | ||
367 | - int type; | ||
368 | - | ||
369 | - hostkey = libssh2_session_hostkey(s->session, &len, &type); | ||
370 | - if (!hostkey) { | ||
371 | + int ret; | ||
372 | +#ifdef HAVE_LIBSSH_0_8 | ||
373 | + enum ssh_known_hosts_e state; | ||
374 | + int r; | ||
375 | + ssh_key pubkey; | ||
376 | + enum ssh_keytypes_e pubkey_type; | ||
377 | + unsigned char *server_hash = NULL; | ||
378 | + size_t server_hash_len; | ||
379 | + char *fingerprint = NULL; | ||
380 | + | ||
381 | + state = ssh_session_is_known_server(s->session); | ||
382 | + trace_ssh_server_status(state); | ||
383 | + | ||
384 | + switch (state) { | ||
385 | + case SSH_KNOWN_HOSTS_OK: | ||
386 | + /* OK */ | ||
387 | + trace_ssh_check_host_key_knownhosts(); | ||
388 | + break; | ||
389 | + case SSH_KNOWN_HOSTS_CHANGED: | ||
390 | ret = -EINVAL; | ||
391 | - session_error_setg(errp, s, "failed to read remote host key"); | ||
392 | + r = ssh_get_server_publickey(s->session, &pubkey); | ||
393 | + if (r == 0) { | ||
394 | + r = ssh_get_publickey_hash(pubkey, SSH_PUBLICKEY_HASH_SHA256, | ||
395 | + &server_hash, &server_hash_len); | ||
396 | + pubkey_type = ssh_key_type(pubkey); | ||
397 | + ssh_key_free(pubkey); | ||
398 | + } | ||
399 | + if (r == 0) { | ||
400 | + fingerprint = ssh_get_fingerprint_hash(SSH_PUBLICKEY_HASH_SHA256, | ||
401 | + server_hash, | ||
402 | + server_hash_len); | ||
403 | + ssh_clean_pubkey_hash(&server_hash); | ||
404 | + } | ||
405 | + if (fingerprint) { | ||
406 | + error_setg(errp, | ||
407 | + "host key (%s key with fingerprint %s) does not match " | ||
408 | + "the one in known_hosts; this may be a possible attack", | ||
409 | + ssh_key_type_to_char(pubkey_type), fingerprint); | ||
410 | + ssh_string_free_char(fingerprint); | ||
411 | + } else { | ||
412 | + error_setg(errp, | ||
413 | + "host key does not match the one in known_hosts; this " | ||
414 | + "may be a possible attack"); | ||
415 | + } | ||
416 | goto out; | ||
417 | - } | ||
418 | - | ||
419 | - knh = libssh2_knownhost_init(s->session); | ||
420 | - if (!knh) { | ||
421 | + case SSH_KNOWN_HOSTS_OTHER: | ||
422 | ret = -EINVAL; | ||
423 | - session_error_setg(errp, s, | ||
424 | - "failed to initialize known hosts support"); | ||
425 | + error_setg(errp, | ||
426 | + "host key for this server not found, another type exists"); | ||
427 | + goto out; | ||
428 | + case SSH_KNOWN_HOSTS_UNKNOWN: | ||
429 | + ret = -EINVAL; | ||
430 | + error_setg(errp, "no host key was found in known_hosts"); | ||
431 | + goto out; | ||
432 | + case SSH_KNOWN_HOSTS_NOT_FOUND: | ||
433 | + ret = -ENOENT; | ||
434 | + error_setg(errp, "known_hosts file not found"); | ||
435 | + goto out; | ||
436 | + case SSH_KNOWN_HOSTS_ERROR: | ||
437 | + ret = -EINVAL; | ||
438 | + error_setg(errp, "error while checking the host"); | ||
439 | + goto out; | ||
440 | + default: | ||
441 | + ret = -EINVAL; | ||
442 | + error_setg(errp, "error while checking for known server (%d)", state); | ||
443 | goto out; | ||
444 | } | ||
445 | +#else /* !HAVE_LIBSSH_0_8 */ | ||
446 | + int state; | ||
447 | |||
448 | - home = getenv("HOME"); | ||
449 | - if (home) { | ||
450 | - knh_file = g_strdup_printf("%s/.ssh/known_hosts", home); | ||
451 | - } else { | ||
452 | - knh_file = g_strdup_printf("/root/.ssh/known_hosts"); | ||
453 | - } | ||
454 | - | ||
455 | - /* Read all known hosts from OpenSSH-style known_hosts file. */ | ||
456 | - libssh2_knownhost_readfile(knh, knh_file, LIBSSH2_KNOWNHOST_FILE_OPENSSH); | ||
457 | + state = ssh_is_server_known(s->session); | ||
458 | + trace_ssh_server_status(state); | ||
459 | |||
460 | - r = libssh2_knownhost_checkp(knh, host, port, hostkey, len, | ||
461 | - LIBSSH2_KNOWNHOST_TYPE_PLAIN| | ||
462 | - LIBSSH2_KNOWNHOST_KEYENC_RAW, | ||
463 | - &found); | ||
464 | - switch (r) { | ||
465 | - case LIBSSH2_KNOWNHOST_CHECK_MATCH: | ||
466 | + switch (state) { | ||
467 | + case SSH_SERVER_KNOWN_OK: | ||
468 | /* OK */ | ||
469 | - trace_ssh_check_host_key_knownhosts(found->key); | ||
470 | + trace_ssh_check_host_key_knownhosts(); | ||
471 | break; | ||
472 | - case LIBSSH2_KNOWNHOST_CHECK_MISMATCH: | ||
473 | + case SSH_SERVER_KNOWN_CHANGED: | ||
474 | ret = -EINVAL; | ||
475 | - session_error_setg(errp, s, | ||
476 | - "host key does not match the one in known_hosts" | ||
477 | - " (found key %s)", found->key); | ||
478 | + error_setg(errp, | ||
479 | + "host key does not match the one in known_hosts; this " | ||
480 | + "may be a possible attack"); | ||
481 | goto out; | ||
482 | - case LIBSSH2_KNOWNHOST_CHECK_NOTFOUND: | ||
483 | + case SSH_SERVER_FOUND_OTHER: | ||
484 | ret = -EINVAL; | ||
485 | - session_error_setg(errp, s, "no host key was found in known_hosts"); | ||
486 | + error_setg(errp, | ||
487 | + "host key for this server not found, another type exists"); | ||
488 | + goto out; | ||
489 | + case SSH_SERVER_FILE_NOT_FOUND: | ||
490 | + ret = -ENOENT; | ||
491 | + error_setg(errp, "known_hosts file not found"); | ||
492 | goto out; | ||
493 | - case LIBSSH2_KNOWNHOST_CHECK_FAILURE: | ||
494 | + case SSH_SERVER_NOT_KNOWN: | ||
495 | ret = -EINVAL; | ||
496 | - session_error_setg(errp, s, | ||
497 | - "failure matching the host key with known_hosts"); | ||
498 | + error_setg(errp, "no host key was found in known_hosts"); | ||
499 | + goto out; | ||
500 | + case SSH_SERVER_ERROR: | ||
501 | + ret = -EINVAL; | ||
502 | + error_setg(errp, "server error"); | ||
503 | goto out; | ||
504 | default: | ||
505 | ret = -EINVAL; | ||
506 | - session_error_setg(errp, s, "unknown error matching the host key" | ||
507 | - " with known_hosts (%d)", r); | ||
508 | + error_setg(errp, "error while checking for known server (%d)", state); | ||
509 | goto out; | ||
510 | } | ||
511 | +#endif /* !HAVE_LIBSSH_0_8 */ | ||
512 | |||
513 | /* known_hosts checking successful. */ | ||
514 | ret = 0; | ||
515 | |||
516 | out: | ||
517 | - if (knh != NULL) { | ||
518 | - libssh2_knownhost_free(knh); | ||
519 | - } | ||
520 | - g_free(knh_file); | ||
521 | return ret; | ||
522 | } | ||
523 | |||
524 | @@ -XXX,XX +XXX,XX @@ static int compare_fingerprint(const unsigned char *fingerprint, size_t len, | ||
525 | |||
526 | static int | ||
527 | check_host_key_hash(BDRVSSHState *s, const char *hash, | ||
528 | - int hash_type, size_t fingerprint_len, Error **errp) | ||
529 | + enum ssh_publickey_hash_type type, Error **errp) | ||
530 | { | ||
531 | - const char *fingerprint; | ||
532 | - | ||
533 | - fingerprint = libssh2_hostkey_hash(s->session, hash_type); | ||
534 | - if (!fingerprint) { | ||
535 | + int r; | ||
536 | + ssh_key pubkey; | ||
537 | + unsigned char *server_hash; | ||
538 | + size_t server_hash_len; | ||
539 | + | ||
540 | +#ifdef HAVE_LIBSSH_0_8 | ||
541 | + r = ssh_get_server_publickey(s->session, &pubkey); | ||
542 | +#else | ||
543 | + r = ssh_get_publickey(s->session, &pubkey); | ||
544 | +#endif | ||
545 | + if (r != SSH_OK) { | ||
546 | session_error_setg(errp, s, "failed to read remote host key"); | ||
547 | return -EINVAL; | ||
548 | } | ||
549 | |||
550 | - if(compare_fingerprint((unsigned char *) fingerprint, fingerprint_len, | ||
551 | - hash) != 0) { | ||
552 | + r = ssh_get_publickey_hash(pubkey, type, &server_hash, &server_hash_len); | ||
553 | + ssh_key_free(pubkey); | ||
554 | + if (r != 0) { | ||
555 | + session_error_setg(errp, s, | ||
556 | + "failed reading the hash of the server SSH key"); | ||
557 | + return -EINVAL; | ||
558 | + } | ||
559 | + | ||
560 | + r = compare_fingerprint(server_hash, server_hash_len, hash); | ||
561 | + ssh_clean_pubkey_hash(&server_hash); | ||
562 | + if (r != 0) { | ||
563 | error_setg(errp, "remote host key does not match host_key_check '%s'", | ||
564 | hash); | ||
565 | return -EPERM; | ||
566 | @@ -XXX,XX +XXX,XX @@ check_host_key_hash(BDRVSSHState *s, const char *hash, | ||
567 | return 0; | ||
568 | } | ||
569 | |||
570 | -static int check_host_key(BDRVSSHState *s, const char *host, int port, | ||
571 | - SshHostKeyCheck *hkc, Error **errp) | ||
572 | +static int check_host_key(BDRVSSHState *s, SshHostKeyCheck *hkc, Error **errp) | ||
573 | { | ||
574 | SshHostKeyCheckMode mode; | ||
575 | |||
576 | @@ -XXX,XX +XXX,XX @@ static int check_host_key(BDRVSSHState *s, const char *host, int port, | ||
577 | case SSH_HOST_KEY_CHECK_MODE_HASH: | ||
578 | if (hkc->u.hash.type == SSH_HOST_KEY_CHECK_HASH_TYPE_MD5) { | ||
579 | return check_host_key_hash(s, hkc->u.hash.hash, | ||
580 | - LIBSSH2_HOSTKEY_HASH_MD5, 16, errp); | ||
581 | + SSH_PUBLICKEY_HASH_MD5, errp); | ||
582 | } else if (hkc->u.hash.type == SSH_HOST_KEY_CHECK_HASH_TYPE_SHA1) { | ||
583 | return check_host_key_hash(s, hkc->u.hash.hash, | ||
584 | - LIBSSH2_HOSTKEY_HASH_SHA1, 20, errp); | ||
585 | + SSH_PUBLICKEY_HASH_SHA1, errp); | ||
586 | } | ||
587 | g_assert_not_reached(); | ||
588 | break; | ||
589 | case SSH_HOST_KEY_CHECK_MODE_KNOWN_HOSTS: | ||
590 | - return check_host_key_knownhosts(s, host, port, errp); | ||
591 | + return check_host_key_knownhosts(s, errp); | ||
592 | default: | ||
593 | g_assert_not_reached(); | ||
594 | } | ||
595 | @@ -XXX,XX +XXX,XX @@ static int check_host_key(BDRVSSHState *s, const char *host, int port, | ||
596 | return -EINVAL; | ||
597 | } | ||
598 | |||
599 | -static int authenticate(BDRVSSHState *s, const char *user, Error **errp) | ||
600 | +static int authenticate(BDRVSSHState *s, Error **errp) | ||
601 | { | ||
602 | int r, ret; | ||
603 | - const char *userauthlist; | ||
604 | - LIBSSH2_AGENT *agent = NULL; | ||
605 | - struct libssh2_agent_publickey *identity; | ||
606 | - struct libssh2_agent_publickey *prev_identity = NULL; | ||
607 | + int method; | ||
608 | |||
609 | - userauthlist = libssh2_userauth_list(s->session, user, strlen(user)); | ||
610 | - if (strstr(userauthlist, "publickey") == NULL) { | ||
611 | + /* Try to authenticate with the "none" method. */ | ||
612 | + r = ssh_userauth_none(s->session, NULL); | ||
613 | + if (r == SSH_AUTH_ERROR) { | ||
614 | ret = -EPERM; | ||
615 | - error_setg(errp, | ||
616 | - "remote server does not support \"publickey\" authentication"); | ||
617 | + session_error_setg(errp, s, "failed to authenticate using none " | ||
618 | + "authentication"); | ||
619 | goto out; | ||
620 | - } | ||
621 | - | ||
622 | - /* Connect to ssh-agent and try each identity in turn. */ | ||
623 | - agent = libssh2_agent_init(s->session); | ||
624 | - if (!agent) { | ||
625 | - ret = -EINVAL; | ||
626 | - session_error_setg(errp, s, "failed to initialize ssh-agent support"); | ||
627 | - goto out; | ||
628 | - } | ||
629 | - if (libssh2_agent_connect(agent)) { | ||
630 | - ret = -ECONNREFUSED; | ||
631 | - session_error_setg(errp, s, "failed to connect to ssh-agent"); | ||
632 | - goto out; | ||
633 | - } | ||
634 | - if (libssh2_agent_list_identities(agent)) { | ||
635 | - ret = -EINVAL; | ||
636 | - session_error_setg(errp, s, | ||
637 | - "failed requesting identities from ssh-agent"); | ||
638 | + } else if (r == SSH_AUTH_SUCCESS) { | ||
639 | + /* Authenticated! */ | ||
640 | + ret = 0; | ||
641 | goto out; | ||
642 | } | ||
643 | |||
644 | - for(;;) { | ||
645 | - r = libssh2_agent_get_identity(agent, &identity, prev_identity); | ||
646 | - if (r == 1) { /* end of list */ | ||
647 | - break; | ||
648 | - } | ||
649 | - if (r < 0) { | ||
650 | + method = ssh_userauth_list(s->session, NULL); | ||
651 | + trace_ssh_auth_methods(method); | ||
652 | + | ||
653 | + /* | ||
654 | + * Try to authenticate with publickey, using the ssh-agent | ||
655 | + * if available. | ||
656 | + */ | ||
657 | + if (method & SSH_AUTH_METHOD_PUBLICKEY) { | ||
658 | + r = ssh_userauth_publickey_auto(s->session, NULL, NULL); | ||
659 | + if (r == SSH_AUTH_ERROR) { | ||
660 | ret = -EINVAL; | ||
661 | - session_error_setg(errp, s, | ||
662 | - "failed to obtain identity from ssh-agent"); | ||
663 | + session_error_setg(errp, s, "failed to authenticate using " | ||
664 | + "publickey authentication"); | ||
665 | goto out; | ||
666 | - } | ||
667 | - r = libssh2_agent_userauth(agent, user, identity); | ||
668 | - if (r == 0) { | ||
669 | + } else if (r == SSH_AUTH_SUCCESS) { | ||
670 | /* Authenticated! */ | ||
671 | ret = 0; | ||
672 | goto out; | ||
673 | } | ||
674 | - /* Failed to authenticate with this identity, try the next one. */ | ||
675 | - prev_identity = identity; | ||
676 | } | ||
677 | |||
678 | ret = -EPERM; | ||
679 | @@ -XXX,XX +XXX,XX @@ static int authenticate(BDRVSSHState *s, const char *user, Error **errp) | ||
680 | "and the identities held by your ssh-agent"); | ||
681 | |||
682 | out: | ||
683 | - if (agent != NULL) { | ||
684 | - /* Note: libssh2 implementation implicitly calls | ||
685 | - * libssh2_agent_disconnect if necessary. | ||
686 | - */ | ||
687 | - libssh2_agent_free(agent); | ||
688 | - } | ||
689 | - | ||
690 | return ret; | ||
691 | } | ||
692 | |||
693 | @@ -XXX,XX +XXX,XX @@ static int connect_to_ssh(BDRVSSHState *s, BlockdevOptionsSsh *opts, | ||
694 | int ssh_flags, int creat_mode, Error **errp) | ||
695 | { | ||
696 | int r, ret; | ||
697 | - long port = 0; | ||
698 | + unsigned int port = 0; | ||
699 | + int new_sock = -1; | ||
700 | |||
701 | if (opts->has_user) { | ||
702 | s->user = g_strdup(opts->user); | ||
703 | @@ -XXX,XX +XXX,XX @@ static int connect_to_ssh(BDRVSSHState *s, BlockdevOptionsSsh *opts, | ||
704 | s->inet = opts->server; | ||
705 | opts->server = NULL; | ||
706 | |||
707 | - if (qemu_strtol(s->inet->port, NULL, 10, &port) < 0) { | ||
708 | + if (qemu_strtoui(s->inet->port, NULL, 10, &port) < 0) { | ||
709 | error_setg(errp, "Use only numeric port value"); | ||
710 | ret = -EINVAL; | ||
711 | goto err; | ||
712 | } | ||
713 | |||
714 | /* Open the socket and connect. */ | ||
715 | - s->sock = inet_connect_saddr(s->inet, errp); | ||
716 | - if (s->sock < 0) { | ||
717 | + new_sock = inet_connect_saddr(s->inet, errp); | ||
718 | + if (new_sock < 0) { | ||
719 | ret = -EIO; | ||
720 | goto err; | ||
721 | } | ||
722 | |||
723 | + /* | ||
724 | + * Try to disable the Nagle algorithm on TCP sockets to reduce latency, | ||
725 | + * but do not fail if it cannot be disabled. | ||
726 | + */ | ||
727 | + r = socket_set_nodelay(new_sock); | ||
728 | + if (r < 0) { | ||
729 | + warn_report("can't set TCP_NODELAY for the ssh server %s: %s", | ||
730 | + s->inet->host, strerror(errno)); | ||
731 | + } | ||
732 | + | ||
733 | /* Create SSH session. */ | ||
734 | - s->session = libssh2_session_init(); | ||
735 | + s->session = ssh_new(); | ||
736 | if (!s->session) { | ||
737 | ret = -EINVAL; | ||
738 | - session_error_setg(errp, s, "failed to initialize libssh2 session"); | ||
739 | + session_error_setg(errp, s, "failed to initialize libssh session"); | ||
740 | goto err; | ||
741 | } | ||
742 | |||
743 | -#if TRACE_LIBSSH2 != 0 | ||
744 | - libssh2_trace(s->session, TRACE_LIBSSH2); | ||
745 | -#endif | ||
746 | + /* | ||
747 | + * Make sure we are in blocking mode during the connection and | ||
748 | + * authentication phases. | ||
749 | + */ | ||
750 | + ssh_set_blocking(s->session, 1); | ||
751 | |||
752 | - r = libssh2_session_handshake(s->session, s->sock); | ||
753 | - if (r != 0) { | ||
754 | + r = ssh_options_set(s->session, SSH_OPTIONS_USER, s->user); | ||
755 | + if (r < 0) { | ||
756 | + ret = -EINVAL; | ||
757 | + session_error_setg(errp, s, | ||
758 | + "failed to set the user in the libssh session"); | ||
759 | + goto err; | ||
760 | + } | ||
761 | + | ||
762 | + r = ssh_options_set(s->session, SSH_OPTIONS_HOST, s->inet->host); | ||
763 | + if (r < 0) { | ||
764 | + ret = -EINVAL; | ||
765 | + session_error_setg(errp, s, | ||
766 | + "failed to set the host in the libssh session"); | ||
767 | + goto err; | ||
768 | + } | ||
769 | + | ||
770 | + if (port > 0) { | ||
771 | + r = ssh_options_set(s->session, SSH_OPTIONS_PORT, &port); | ||
772 | + if (r < 0) { | ||
773 | + ret = -EINVAL; | ||
774 | + session_error_setg(errp, s, | ||
775 | + "failed to set the port in the libssh session"); | ||
776 | + goto err; | ||
777 | + } | ||
778 | + } | ||
779 | + | ||
780 | + r = ssh_options_set(s->session, SSH_OPTIONS_COMPRESSION, "none"); | ||
781 | + if (r < 0) { | ||
782 | + ret = -EINVAL; | ||
783 | + session_error_setg(errp, s, | ||
784 | + "failed to disable the compression in the libssh " | ||
785 | + "session"); | ||
786 | + goto err; | ||
787 | + } | ||
788 | + | ||
789 | + /* Read ~/.ssh/config. */ | ||
790 | + r = ssh_options_parse_config(s->session, NULL); | ||
791 | + if (r < 0) { | ||
792 | + ret = -EINVAL; | ||
793 | + session_error_setg(errp, s, "failed to parse ~/.ssh/config"); | ||
794 | + goto err; | ||
795 | + } | ||
796 | + | ||
797 | + r = ssh_options_set(s->session, SSH_OPTIONS_FD, &new_sock); | ||
798 | + if (r < 0) { | ||
799 | + ret = -EINVAL; | ||
800 | + session_error_setg(errp, s, | ||
801 | + "failed to set the socket in the libssh session"); | ||
802 | + goto err; | ||
803 | + } | ||
804 | + /* libssh took ownership of the socket. */ | ||
805 | + s->sock = new_sock; | ||
806 | + new_sock = -1; | ||
807 | + | ||
808 | + /* Connect. */ | ||
809 | + r = ssh_connect(s->session); | ||
810 | + if (r != SSH_OK) { | ||
811 | ret = -EINVAL; | ||
812 | session_error_setg(errp, s, "failed to establish SSH session"); | ||
813 | goto err; | ||
814 | } | ||
815 | |||
816 | /* Check the remote host's key against known_hosts. */ | ||
817 | - ret = check_host_key(s, s->inet->host, port, opts->host_key_check, errp); | ||
818 | + ret = check_host_key(s, opts->host_key_check, errp); | ||
819 | if (ret < 0) { | ||
820 | goto err; | ||
821 | } | ||
822 | |||
823 | /* Authenticate. */ | ||
824 | - ret = authenticate(s, s->user, errp); | ||
825 | + ret = authenticate(s, errp); | ||
826 | if (ret < 0) { | ||
827 | goto err; | ||
828 | } | ||
829 | |||
830 | /* Start SFTP. */ | ||
831 | - s->sftp = libssh2_sftp_init(s->session); | ||
832 | + s->sftp = sftp_new(s->session); | ||
833 | if (!s->sftp) { | ||
834 | - session_error_setg(errp, s, "failed to initialize sftp handle"); | ||
835 | + session_error_setg(errp, s, "failed to create sftp handle"); | ||
836 | + ret = -EINVAL; | ||
837 | + goto err; | ||
838 | + } | ||
839 | + | ||
840 | + r = sftp_init(s->sftp); | ||
841 | + if (r < 0) { | ||
842 | + sftp_error_setg(errp, s, "failed to initialize sftp handle"); | ||
843 | ret = -EINVAL; | ||
844 | goto err; | ||
845 | } | ||
846 | |||
847 | /* Open the remote file. */ | ||
848 | trace_ssh_connect_to_ssh(opts->path, ssh_flags, creat_mode); | ||
849 | - s->sftp_handle = libssh2_sftp_open(s->sftp, opts->path, ssh_flags, | ||
850 | - creat_mode); | ||
851 | + s->sftp_handle = sftp_open(s->sftp, opts->path, ssh_flags, creat_mode); | ||
852 | if (!s->sftp_handle) { | ||
853 | - session_error_setg(errp, s, "failed to open remote file '%s'", | ||
854 | - opts->path); | ||
855 | + sftp_error_setg(errp, s, "failed to open remote file '%s'", | ||
856 | + opts->path); | ||
857 | ret = -EINVAL; | ||
858 | goto err; | ||
859 | } | ||
860 | |||
861 | - r = libssh2_sftp_fstat(s->sftp_handle, &s->attrs); | ||
862 | - if (r < 0) { | ||
863 | + /* Make sure the SFTP file is handled in blocking mode. */ | ||
864 | + sftp_file_set_blocking(s->sftp_handle); | ||
865 | + | ||
866 | + s->attrs = sftp_fstat(s->sftp_handle); | ||
867 | + if (!s->attrs) { | ||
868 | sftp_error_setg(errp, s, "failed to read file attributes"); | ||
869 | return -EINVAL; | ||
870 | } | ||
871 | @@ -XXX,XX +XXX,XX @@ static int connect_to_ssh(BDRVSSHState *s, BlockdevOptionsSsh *opts, | ||
872 | return 0; | ||
873 | |||
874 | err: | ||
875 | + if (s->attrs) { | ||
876 | + sftp_attributes_free(s->attrs); | ||
877 | + } | ||
878 | + s->attrs = NULL; | ||
879 | if (s->sftp_handle) { | ||
880 | - libssh2_sftp_close(s->sftp_handle); | ||
881 | + sftp_close(s->sftp_handle); | ||
882 | } | ||
883 | s->sftp_handle = NULL; | ||
884 | if (s->sftp) { | ||
885 | - libssh2_sftp_shutdown(s->sftp); | ||
886 | + sftp_free(s->sftp); | ||
887 | } | ||
888 | s->sftp = NULL; | ||
889 | if (s->session) { | ||
890 | - libssh2_session_disconnect(s->session, | ||
891 | - "from qemu ssh client: " | ||
892 | - "error opening connection"); | ||
893 | - libssh2_session_free(s->session); | ||
894 | + ssh_disconnect(s->session); | ||
895 | + ssh_free(s->session); | ||
896 | } | ||
897 | s->session = NULL; | ||
898 | + s->sock = -1; | ||
899 | + if (new_sock >= 0) { | ||
900 | + close(new_sock); | ||
901 | + } | ||
902 | |||
903 | return ret; | ||
904 | } | ||
905 | @@ -XXX,XX +XXX,XX @@ static int ssh_file_open(BlockDriverState *bs, QDict *options, int bdrv_flags, | ||
906 | |||
907 | ssh_state_init(s); | ||
908 | |||
909 | - ssh_flags = LIBSSH2_FXF_READ; | ||
910 | + ssh_flags = 0; | ||
911 | if (bdrv_flags & BDRV_O_RDWR) { | ||
912 | - ssh_flags |= LIBSSH2_FXF_WRITE; | ||
913 | + ssh_flags |= O_RDWR; | ||
914 | + } else { | ||
915 | + ssh_flags |= O_RDONLY; | ||
916 | } | ||
917 | |||
918 | opts = ssh_parse_options(options, errp); | ||
919 | @@ -XXX,XX +XXX,XX @@ static int ssh_file_open(BlockDriverState *bs, QDict *options, int bdrv_flags, | ||
920 | } | ||
921 | |||
922 | /* Go non-blocking. */ | ||
923 | - libssh2_session_set_blocking(s->session, 0); | ||
924 | + ssh_set_blocking(s->session, 0); | ||
925 | |||
926 | qapi_free_BlockdevOptionsSsh(opts); | ||
927 | |||
928 | return 0; | ||
929 | |||
930 | err: | ||
931 | - if (s->sock >= 0) { | ||
932 | - close(s->sock); | ||
933 | - } | ||
934 | - s->sock = -1; | ||
935 | - | ||
936 | qapi_free_BlockdevOptionsSsh(opts); | ||
937 | |||
938 | return ret; | ||
939 | @@ -XXX,XX +XXX,XX @@ static int ssh_grow_file(BDRVSSHState *s, int64_t offset, Error **errp) | ||
940 | { | ||
941 | ssize_t ret; | ||
942 | char c[1] = { '\0' }; | ||
943 | - int was_blocking = libssh2_session_get_blocking(s->session); | ||
944 | + int was_blocking = ssh_is_blocking(s->session); | ||
945 | |||
946 | /* offset must be strictly greater than the current size so we do | ||
947 | * not overwrite anything */ | ||
948 | - assert(offset > 0 && offset > s->attrs.filesize); | ||
949 | + assert(offset > 0 && offset > s->attrs->size); | ||
950 | |||
951 | - libssh2_session_set_blocking(s->session, 1); | ||
952 | + ssh_set_blocking(s->session, 1); | ||
953 | |||
954 | - libssh2_sftp_seek64(s->sftp_handle, offset - 1); | ||
955 | - ret = libssh2_sftp_write(s->sftp_handle, c, 1); | ||
956 | + sftp_seek64(s->sftp_handle, offset - 1); | ||
957 | + ret = sftp_write(s->sftp_handle, c, 1); | ||
958 | |||
959 | - libssh2_session_set_blocking(s->session, was_blocking); | ||
960 | + ssh_set_blocking(s->session, was_blocking); | ||
961 | |||
962 | if (ret < 0) { | ||
963 | sftp_error_setg(errp, s, "Failed to grow file"); | ||
964 | return -EIO; | ||
965 | } | ||
966 | |||
967 | - s->attrs.filesize = offset; | ||
968 | + s->attrs->size = offset; | ||
969 | return 0; | ||
970 | } | ||
971 | |||
972 | @@ -XXX,XX +XXX,XX @@ static int ssh_co_create(BlockdevCreateOptions *options, Error **errp) | ||
973 | ssh_state_init(&s); | ||
974 | |||
975 | ret = connect_to_ssh(&s, opts->location, | ||
976 | - LIBSSH2_FXF_READ|LIBSSH2_FXF_WRITE| | ||
977 | - LIBSSH2_FXF_CREAT|LIBSSH2_FXF_TRUNC, | ||
978 | + O_RDWR | O_CREAT | O_TRUNC, | ||
979 | 0644, errp); | ||
980 | if (ret < 0) { | ||
981 | goto fail; | ||
982 | @@ -XXX,XX +XXX,XX @@ static int ssh_has_zero_init(BlockDriverState *bs) | ||
983 | /* Assume false, unless we can positively prove it's true. */ | ||
984 | int has_zero_init = 0; | ||
985 | |||
986 | - if (s->attrs.flags & LIBSSH2_SFTP_ATTR_PERMISSIONS) { | ||
987 | - if (s->attrs.permissions & LIBSSH2_SFTP_S_IFREG) { | ||
988 | - has_zero_init = 1; | ||
989 | - } | ||
990 | + if (s->attrs->type == SSH_FILEXFER_TYPE_REGULAR) { | ||
991 | + has_zero_init = 1; | ||
992 | } | ||
993 | |||
994 | return has_zero_init; | ||
995 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn void co_yield(BDRVSSHState *s, BlockDriverState *bs) | ||
996 | .co = qemu_coroutine_self() | ||
997 | }; | ||
998 | |||
999 | - r = libssh2_session_block_directions(s->session); | ||
1000 | + r = ssh_get_poll_flags(s->session); | ||
1001 | |||
1002 | - if (r & LIBSSH2_SESSION_BLOCK_INBOUND) { | ||
1003 | + if (r & SSH_READ_PENDING) { | ||
1004 | rd_handler = restart_coroutine; | ||
1005 | } | ||
1006 | - if (r & LIBSSH2_SESSION_BLOCK_OUTBOUND) { | ||
1007 | + if (r & SSH_WRITE_PENDING) { | ||
1008 | wr_handler = restart_coroutine; | ||
1009 | } | ||
1010 | |||
1011 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn void co_yield(BDRVSSHState *s, BlockDriverState *bs) | ||
1012 | trace_ssh_co_yield_back(s->sock); | ||
1013 | } | ||
1014 | |||
1015 | -/* SFTP has a function `libssh2_sftp_seek64' which seeks to a position | ||
1016 | - * in the remote file. Notice that it just updates a field in the | ||
1017 | - * sftp_handle structure, so there is no network traffic and it cannot | ||
1018 | - * fail. | ||
1019 | - * | ||
1020 | - * However, `libssh2_sftp_seek64' does have a catastrophic effect on | ||
1021 | - * performance since it causes the handle to throw away all in-flight | ||
1022 | - * reads and buffered readahead data. Therefore this function tries | ||
1023 | - * to be intelligent about when to call the underlying libssh2 function. | ||
1024 | - */ | ||
1025 | -#define SSH_SEEK_WRITE 0 | ||
1026 | -#define SSH_SEEK_READ 1 | ||
1027 | -#define SSH_SEEK_FORCE 2 | ||
1028 | - | ||
1029 | -static void ssh_seek(BDRVSSHState *s, int64_t offset, int flags) | ||
1030 | -{ | ||
1031 | - bool op_read = (flags & SSH_SEEK_READ) != 0; | ||
1032 | - bool force = (flags & SSH_SEEK_FORCE) != 0; | ||
1033 | - | ||
1034 | - if (force || op_read != s->offset_op_read || offset != s->offset) { | ||
1035 | - trace_ssh_seek(offset); | ||
1036 | - libssh2_sftp_seek64(s->sftp_handle, offset); | ||
1037 | - s->offset = offset; | ||
1038 | - s->offset_op_read = op_read; | ||
1039 | - } | ||
1040 | -} | ||
1041 | - | ||
1042 | static coroutine_fn int ssh_read(BDRVSSHState *s, BlockDriverState *bs, | ||
1043 | int64_t offset, size_t size, | ||
1044 | QEMUIOVector *qiov) | ||
1045 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int ssh_read(BDRVSSHState *s, BlockDriverState *bs, | ||
1046 | |||
1047 | trace_ssh_read(offset, size); | ||
1048 | |||
1049 | - ssh_seek(s, offset, SSH_SEEK_READ); | ||
1050 | + trace_ssh_seek(offset); | ||
1051 | + sftp_seek64(s->sftp_handle, offset); | ||
1052 | |||
1053 | /* This keeps track of the current iovec element ('i'), where we | ||
1054 | * will write to next ('buf'), and the end of the current iovec | ||
1055 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int ssh_read(BDRVSSHState *s, BlockDriverState *bs, | ||
1056 | buf = i->iov_base; | ||
1057 | end_of_vec = i->iov_base + i->iov_len; | ||
1058 | |||
1059 | - /* libssh2 has a hard-coded limit of 2000 bytes per request, | ||
1060 | - * although it will also do readahead behind our backs. Therefore | ||
1061 | - * we may have to do repeated reads here until we have read 'size' | ||
1062 | - * bytes. | ||
1063 | - */ | ||
1064 | for (got = 0; got < size; ) { | ||
1065 | + size_t request_read_size; | ||
1066 | again: | ||
1067 | - trace_ssh_read_buf(buf, end_of_vec - buf); | ||
1068 | - r = libssh2_sftp_read(s->sftp_handle, buf, end_of_vec - buf); | ||
1069 | - trace_ssh_read_return(r); | ||
1070 | + /* | ||
1071 | + * The size of SFTP packets is limited to 32K bytes, so limit | ||
1072 | + * the amount of data requested to 16K, as libssh currently | ||
1073 | + * does not handle multiple requests on its own. | ||
1074 | + */ | ||
1075 | + request_read_size = MIN(end_of_vec - buf, 16384); | ||
1076 | + trace_ssh_read_buf(buf, end_of_vec - buf, request_read_size); | ||
1077 | + r = sftp_read(s->sftp_handle, buf, request_read_size); | ||
1078 | + trace_ssh_read_return(r, sftp_get_error(s->sftp)); | ||
1079 | |||
1080 | - if (r == LIBSSH2_ERROR_EAGAIN || r == LIBSSH2_ERROR_TIMEOUT) { | ||
1081 | + if (r == SSH_AGAIN) { | ||
1082 | co_yield(s, bs); | ||
1083 | goto again; | ||
1084 | } | ||
1085 | - if (r < 0) { | ||
1086 | - sftp_error_trace(s, "read"); | ||
1087 | - s->offset = -1; | ||
1088 | - return -EIO; | ||
1089 | - } | ||
1090 | - if (r == 0) { | ||
1091 | + if (r == SSH_EOF || (r == 0 && sftp_get_error(s->sftp) == SSH_FX_EOF)) { | ||
1092 | /* EOF: Short read so pad the buffer with zeroes and return it. */ | ||
1093 | qemu_iovec_memset(qiov, got, 0, size - got); | ||
1094 | return 0; | ||
1095 | } | ||
1096 | + if (r <= 0) { | ||
1097 | + sftp_error_trace(s, "read"); | ||
1098 | + return -EIO; | ||
1099 | + } | ||
1100 | |||
1101 | got += r; | ||
1102 | buf += r; | ||
1103 | - s->offset += r; | ||
1104 | if (buf >= end_of_vec && got < size) { | ||
1105 | i++; | ||
1106 | buf = i->iov_base; | ||
1107 | @@ -XXX,XX +XXX,XX @@ static int ssh_write(BDRVSSHState *s, BlockDriverState *bs, | ||
1108 | |||
1109 | trace_ssh_write(offset, size); | ||
1110 | |||
1111 | - ssh_seek(s, offset, SSH_SEEK_WRITE); | ||
1112 | + trace_ssh_seek(offset); | ||
1113 | + sftp_seek64(s->sftp_handle, offset); | ||
1114 | |||
1115 | /* This keeps track of the current iovec element ('i'), where we | ||
1116 | * will read from next ('buf'), and the end of the current iovec | ||
1117 | @@ -XXX,XX +XXX,XX @@ static int ssh_write(BDRVSSHState *s, BlockDriverState *bs, | ||
1118 | end_of_vec = i->iov_base + i->iov_len; | ||
1119 | |||
1120 | for (written = 0; written < size; ) { | ||
1121 | + size_t request_write_size; | ||
1122 | again: | ||
1123 | - trace_ssh_write_buf(buf, end_of_vec - buf); | ||
1124 | - r = libssh2_sftp_write(s->sftp_handle, buf, end_of_vec - buf); | ||
1125 | - trace_ssh_write_return(r); | ||
1126 | + /* | ||
1127 | + * Avoid too large data packets, as libssh currently does not | ||
1128 | + * handle multiple requests on its own. | ||
1129 | + */ | ||
1130 | + request_write_size = MIN(end_of_vec - buf, 131072); | ||
1131 | + trace_ssh_write_buf(buf, end_of_vec - buf, request_write_size); | ||
1132 | + r = sftp_write(s->sftp_handle, buf, request_write_size); | ||
1133 | + trace_ssh_write_return(r, sftp_get_error(s->sftp)); | ||
1134 | |||
1135 | - if (r == LIBSSH2_ERROR_EAGAIN || r == LIBSSH2_ERROR_TIMEOUT) { | ||
1136 | + if (r == SSH_AGAIN) { | ||
1137 | co_yield(s, bs); | ||
1138 | goto again; | ||
1139 | } | ||
1140 | if (r < 0) { | ||
1141 | sftp_error_trace(s, "write"); | ||
1142 | - s->offset = -1; | ||
1143 | return -EIO; | ||
1144 | } | ||
1145 | - /* The libssh2 API is very unclear about this. A comment in | ||
1146 | - * the code says "nothing was acked, and no EAGAIN was | ||
1147 | - * received!" which apparently means that no data got sent | ||
1148 | - * out, and the underlying channel didn't return any EAGAIN | ||
1149 | - * indication. I think this is a bug in either libssh2 or | ||
1150 | - * OpenSSH (server-side). In any case, forcing a seek (to | ||
1151 | - * discard libssh2 internal buffers), and then trying again | ||
1152 | - * works for me. | ||
1153 | - */ | ||
1154 | - if (r == 0) { | ||
1155 | - ssh_seek(s, offset + written, SSH_SEEK_WRITE|SSH_SEEK_FORCE); | ||
1156 | - co_yield(s, bs); | ||
1157 | - goto again; | ||
1158 | - } | ||
1159 | |||
1160 | written += r; | ||
1161 | buf += r; | ||
1162 | - s->offset += r; | ||
1163 | if (buf >= end_of_vec && written < size) { | ||
1164 | i++; | ||
1165 | buf = i->iov_base; | ||
1166 | end_of_vec = i->iov_base + i->iov_len; | ||
1167 | } | ||
1168 | |||
1169 | - if (offset + written > s->attrs.filesize) | ||
1170 | - s->attrs.filesize = offset + written; | ||
1171 | + if (offset + written > s->attrs->size) { | ||
1172 | + s->attrs->size = offset + written; | ||
1173 | + } | ||
1174 | } | ||
1175 | |||
1176 | return 0; | ||
1177 | @@ -XXX,XX +XXX,XX @@ static void unsafe_flush_warning(BDRVSSHState *s, const char *what) | ||
1178 | } | ||
1179 | } | ||
1180 | |||
1181 | -#ifdef HAS_LIBSSH2_SFTP_FSYNC | ||
1182 | +#ifdef HAVE_LIBSSH_0_8 | ||
1183 | |||
1184 | static coroutine_fn int ssh_flush(BDRVSSHState *s, BlockDriverState *bs) | ||
1185 | { | ||
1186 | int r; | ||
1187 | |||
1188 | trace_ssh_flush(); | ||
1189 | + | ||
1190 | + if (!sftp_extension_supported(s->sftp, "fsync@openssh.com", "1")) { | ||
1191 | + unsafe_flush_warning(s, "OpenSSH >= 6.3"); | ||
1192 | + return 0; | ||
1193 | + } | ||
1194 | again: | ||
1195 | - r = libssh2_sftp_fsync(s->sftp_handle); | ||
1196 | - if (r == LIBSSH2_ERROR_EAGAIN || r == LIBSSH2_ERROR_TIMEOUT) { | ||
1197 | + r = sftp_fsync(s->sftp_handle); | ||
1198 | + if (r == SSH_AGAIN) { | ||
1199 | co_yield(s, bs); | ||
1200 | goto again; | ||
1201 | } | ||
1202 | - if (r == LIBSSH2_ERROR_SFTP_PROTOCOL && | ||
1203 | - libssh2_sftp_last_error(s->sftp) == LIBSSH2_FX_OP_UNSUPPORTED) { | ||
1204 | - unsafe_flush_warning(s, "OpenSSH >= 6.3"); | ||
1205 | - return 0; | ||
1206 | - } | ||
1207 | if (r < 0) { | ||
1208 | sftp_error_trace(s, "fsync"); | ||
1209 | return -EIO; | ||
1210 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int ssh_co_flush(BlockDriverState *bs) | ||
1211 | return ret; | ||
1212 | } | ||
1213 | |||
1214 | -#else /* !HAS_LIBSSH2_SFTP_FSYNC */ | ||
1215 | +#else /* !HAVE_LIBSSH_0_8 */ | ||
1216 | |||
1217 | static coroutine_fn int ssh_co_flush(BlockDriverState *bs) | ||
1218 | { | ||
1219 | BDRVSSHState *s = bs->opaque; | ||
1220 | |||
1221 | - unsafe_flush_warning(s, "libssh2 >= 1.4.4"); | ||
1222 | + unsafe_flush_warning(s, "libssh >= 0.8.0"); | ||
1223 | return 0; | ||
1224 | } | ||
1225 | |||
1226 | -#endif /* !HAS_LIBSSH2_SFTP_FSYNC */ | ||
1227 | +#endif /* !HAVE_LIBSSH_0_8 */ | ||
1228 | |||
1229 | static int64_t ssh_getlength(BlockDriverState *bs) | ||
1230 | { | ||
1231 | BDRVSSHState *s = bs->opaque; | ||
1232 | int64_t length; | ||
1233 | |||
1234 | - /* Note we cannot make a libssh2 call here. */ | ||
1235 | - length = (int64_t) s->attrs.filesize; | ||
1236 | + /* Note we cannot make a libssh call here. */ | ||
1237 | + length = (int64_t) s->attrs->size; | ||
1238 | trace_ssh_getlength(length); | ||
1239 | |||
1240 | return length; | ||
1241 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn ssh_co_truncate(BlockDriverState *bs, int64_t offset, | ||
1242 | return -ENOTSUP; | ||
1243 | } | ||
1244 | |||
1245 | - if (offset < s->attrs.filesize) { | ||
1246 | + if (offset < s->attrs->size) { | ||
1247 | error_setg(errp, "ssh driver does not support shrinking files"); | ||
1248 | return -ENOTSUP; | ||
1249 | } | ||
1250 | |||
1251 | - if (offset == s->attrs.filesize) { | ||
1252 | + if (offset == s->attrs->size) { | ||
1253 | return 0; | ||
1254 | } | ||
1255 | |||
1256 | @@ -XXX,XX +XXX,XX @@ static void bdrv_ssh_init(void) | ||
1257 | { | ||
1258 | int r; | ||
1259 | |||
1260 | - r = libssh2_init(0); | ||
1261 | + r = ssh_init(); | ||
1262 | if (r != 0) { | ||
1263 | - fprintf(stderr, "libssh2 initialization failed, %d\n", r); | ||
1264 | + fprintf(stderr, "libssh initialization failed, %d\n", r); | ||
1265 | exit(EXIT_FAILURE); | ||
1266 | } | ||
1267 | |||
1268 | +#if TRACE_LIBSSH != 0 | ||
1269 | + ssh_set_log_level(TRACE_LIBSSH); | ||
1270 | +#endif | ||
1271 | + | ||
1272 | bdrv_register(&bdrv_ssh); | ||
1273 | } | ||
1274 | |||
1275 | diff --git a/.travis.yml b/.travis.yml | ||
1276 | index XXXXXXX..XXXXXXX 100644 | ||
1277 | --- a/.travis.yml | ||
1278 | +++ b/.travis.yml | ||
1279 | @@ -XXX,XX +XXX,XX @@ addons: | ||
1280 | - libseccomp-dev | ||
1281 | - libspice-protocol-dev | ||
1282 | - libspice-server-dev | ||
1283 | - - libssh2-1-dev | ||
1284 | + - libssh-dev | ||
1285 | - liburcu-dev | ||
1286 | - libusb-1.0-0-dev | ||
1287 | - libvte-2.91-dev | ||
1288 | @@ -XXX,XX +XXX,XX @@ matrix: | ||
1289 | - libseccomp-dev | ||
1290 | - libspice-protocol-dev | ||
1291 | - libspice-server-dev | ||
1292 | - - libssh2-1-dev | ||
1293 | + - libssh-dev | ||
1294 | - liburcu-dev | ||
1295 | - libusb-1.0-0-dev | ||
1296 | - libvte-2.91-dev | ||
1297 | diff --git a/block/trace-events b/block/trace-events | ||
1298 | index XXXXXXX..XXXXXXX 100644 | ||
1299 | --- a/block/trace-events | ||
1300 | +++ b/block/trace-events | ||
1301 | @@ -XXX,XX +XXX,XX @@ nbd_client_connect_success(const char *export_name) "export '%s'" | ||
1302 | # ssh.c | ||
1303 | ssh_restart_coroutine(void *co) "co=%p" | ||
1304 | ssh_flush(void) "fsync" | ||
1305 | -ssh_check_host_key_knownhosts(const char *key) "host key OK: %s" | ||
1306 | +ssh_check_host_key_knownhosts(void) "host key OK" | ||
1307 | ssh_connect_to_ssh(char *path, int flags, int mode) "opening file %s flags=0x%x creat_mode=0%o" | ||
1308 | ssh_co_yield(int sock, void *rd_handler, void *wr_handler) "s->sock=%d rd_handler=%p wr_handler=%p" | ||
1309 | ssh_co_yield_back(int sock) "s->sock=%d - back" | ||
1310 | ssh_getlength(int64_t length) "length=%" PRIi64 | ||
1311 | ssh_co_create_opts(uint64_t size) "total_size=%" PRIu64 | ||
1312 | ssh_read(int64_t offset, size_t size) "offset=%" PRIi64 " size=%zu" | ||
1313 | -ssh_read_buf(void *buf, size_t size) "sftp_read buf=%p size=%zu" | ||
1314 | -ssh_read_return(ssize_t ret) "sftp_read returned %zd" | ||
1315 | +ssh_read_buf(void *buf, size_t size, size_t actual_size) "sftp_read buf=%p size=%zu (actual size=%zu)" | ||
1316 | +ssh_read_return(ssize_t ret, int sftp_err) "sftp_read returned %zd (sftp error=%d)" | ||
1317 | ssh_write(int64_t offset, size_t size) "offset=%" PRIi64 " size=%zu" | ||
1318 | -ssh_write_buf(void *buf, size_t size) "sftp_write buf=%p size=%zu" | ||
1319 | -ssh_write_return(ssize_t ret) "sftp_write returned %zd" | ||
1320 | +ssh_write_buf(void *buf, size_t size, size_t actual_size) "sftp_write buf=%p size=%zu (actual size=%zu)" | ||
1321 | +ssh_write_return(ssize_t ret, int sftp_err) "sftp_write returned %zd (sftp error=%d)" | ||
1322 | ssh_seek(int64_t offset) "seeking to offset=%" PRIi64 | ||
1323 | +ssh_auth_methods(int methods) "auth methods=0x%x" | ||
1324 | +ssh_server_status(int status) "server status=%d" | ||
1325 | |||
1326 | # curl.c | ||
1327 | curl_timer_cb(long timeout_ms) "timer callback timeout_ms %ld" | ||
1328 | @@ -XXX,XX +XXX,XX @@ sheepdog_snapshot_create(const char *sn_name, const char *id) "%s %s" | ||
1329 | sheepdog_snapshot_create_inode(const char *name, uint32_t snap, uint32_t vdi) "s->inode: name %s snap_id 0x%" PRIx32 " vdi 0x%" PRIx32 | ||
1330 | |||
1331 | # ssh.c | ||
1332 | -sftp_error(const char *op, const char *ssh_err, int ssh_err_code, unsigned long sftp_err_code) "%s failed: %s (libssh2 error code: %d, sftp error code: %lu)" | ||
1333 | +sftp_error(const char *op, const char *ssh_err, int ssh_err_code, int sftp_err_code) "%s failed: %s (libssh error code: %d, sftp error code: %d)" | ||
1334 | diff --git a/docs/qemu-block-drivers.texi b/docs/qemu-block-drivers.texi | ||
1335 | index XXXXXXX..XXXXXXX 100644 | ||
1336 | --- a/docs/qemu-block-drivers.texi | ||
1337 | +++ b/docs/qemu-block-drivers.texi | ||
1338 | @@ -XXX,XX +XXX,XX @@ print a warning when @code{fsync} is not supported: | ||
1339 | |||
1340 | warning: ssh server @code{ssh.example.com:22} does not support fsync | ||
1341 | |||
1342 | -With sufficiently new versions of libssh2 and OpenSSH, @code{fsync} is | ||
1343 | +With sufficiently new versions of libssh and OpenSSH, @code{fsync} is | ||
1344 | supported. | ||
1345 | |||
1346 | @node disk_images_nvme | ||
1347 | diff --git a/tests/docker/dockerfiles/debian-win32-cross.docker b/tests/docker/dockerfiles/debian-win32-cross.docker | ||
1348 | index XXXXXXX..XXXXXXX 100644 | ||
1349 | --- a/tests/docker/dockerfiles/debian-win32-cross.docker | ||
1350 | +++ b/tests/docker/dockerfiles/debian-win32-cross.docker | ||
1351 | @@ -XXX,XX +XXX,XX @@ RUN DEBIAN_FRONTEND=noninteractive eatmydata \ | ||
1352 | mxe-$TARGET-w64-mingw32.shared-curl \ | ||
1353 | mxe-$TARGET-w64-mingw32.shared-glib \ | ||
1354 | mxe-$TARGET-w64-mingw32.shared-libgcrypt \ | ||
1355 | - mxe-$TARGET-w64-mingw32.shared-libssh2 \ | ||
1356 | mxe-$TARGET-w64-mingw32.shared-libusb1 \ | ||
1357 | mxe-$TARGET-w64-mingw32.shared-lzo \ | ||
1358 | mxe-$TARGET-w64-mingw32.shared-nettle \ | ||
1359 | diff --git a/tests/docker/dockerfiles/debian-win64-cross.docker b/tests/docker/dockerfiles/debian-win64-cross.docker | ||
1360 | index XXXXXXX..XXXXXXX 100644 | ||
1361 | --- a/tests/docker/dockerfiles/debian-win64-cross.docker | ||
1362 | +++ b/tests/docker/dockerfiles/debian-win64-cross.docker | ||
1363 | @@ -XXX,XX +XXX,XX @@ RUN DEBIAN_FRONTEND=noninteractive eatmydata \ | ||
1364 | mxe-$TARGET-w64-mingw32.shared-curl \ | ||
1365 | mxe-$TARGET-w64-mingw32.shared-glib \ | ||
1366 | mxe-$TARGET-w64-mingw32.shared-libgcrypt \ | ||
1367 | - mxe-$TARGET-w64-mingw32.shared-libssh2 \ | ||
1368 | mxe-$TARGET-w64-mingw32.shared-libusb1 \ | ||
1369 | mxe-$TARGET-w64-mingw32.shared-lzo \ | ||
1370 | mxe-$TARGET-w64-mingw32.shared-nettle \ | ||
1371 | diff --git a/tests/docker/dockerfiles/fedora.docker b/tests/docker/dockerfiles/fedora.docker | ||
1372 | index XXXXXXX..XXXXXXX 100644 | ||
1373 | --- a/tests/docker/dockerfiles/fedora.docker | ||
1374 | +++ b/tests/docker/dockerfiles/fedora.docker | ||
1375 | @@ -XXX,XX +XXX,XX @@ ENV PACKAGES \ | ||
1376 | libpng-devel \ | ||
1377 | librbd-devel \ | ||
1378 | libseccomp-devel \ | ||
1379 | - libssh2-devel \ | ||
1380 | + libssh-devel \ | ||
1381 | libubsan \ | ||
1382 | libusbx-devel \ | ||
1383 | libxml2-devel \ | ||
1384 | @@ -XXX,XX +XXX,XX @@ ENV PACKAGES \ | ||
1385 | mingw32-gtk3 \ | ||
1386 | mingw32-libjpeg-turbo \ | ||
1387 | mingw32-libpng \ | ||
1388 | - mingw32-libssh2 \ | ||
1389 | mingw32-libtasn1 \ | ||
1390 | mingw32-nettle \ | ||
1391 | mingw32-pixman \ | ||
1392 | @@ -XXX,XX +XXX,XX @@ ENV PACKAGES \ | ||
1393 | mingw64-gtk3 \ | ||
1394 | mingw64-libjpeg-turbo \ | ||
1395 | mingw64-libpng \ | ||
1396 | - mingw64-libssh2 \ | ||
1397 | mingw64-libtasn1 \ | ||
1398 | mingw64-nettle \ | ||
1399 | mingw64-pixman \ | ||
1400 | diff --git a/tests/docker/dockerfiles/ubuntu.docker b/tests/docker/dockerfiles/ubuntu.docker | ||
1401 | index XXXXXXX..XXXXXXX 100644 | ||
1402 | --- a/tests/docker/dockerfiles/ubuntu.docker | ||
1403 | +++ b/tests/docker/dockerfiles/ubuntu.docker | ||
1404 | @@ -XXX,XX +XXX,XX @@ ENV PACKAGES flex bison \ | ||
1405 | libsnappy-dev \ | ||
1406 | libspice-protocol-dev \ | ||
1407 | libspice-server-dev \ | ||
1408 | - libssh2-1-dev \ | ||
1409 | + libssh-dev \ | ||
1410 | libusb-1.0-0-dev \ | ||
1411 | libusbredirhost-dev \ | ||
1412 | libvdeplug-dev \ | ||
1413 | diff --git a/tests/docker/dockerfiles/ubuntu1804.docker b/tests/docker/dockerfiles/ubuntu1804.docker | ||
1414 | index XXXXXXX..XXXXXXX 100644 | ||
1415 | --- a/tests/docker/dockerfiles/ubuntu1804.docker | ||
1416 | +++ b/tests/docker/dockerfiles/ubuntu1804.docker | ||
1417 | @@ -XXX,XX +XXX,XX @@ ENV PACKAGES flex bison \ | ||
1418 | libsnappy-dev \ | ||
1419 | libspice-protocol-dev \ | ||
1420 | libspice-server-dev \ | ||
1421 | - libssh2-1-dev \ | ||
1422 | + libssh-dev \ | ||
1423 | libusb-1.0-0-dev \ | ||
1424 | libusbredirhost-dev \ | ||
1425 | libvdeplug-dev \ | ||
1426 | diff --git a/tests/qemu-iotests/207 b/tests/qemu-iotests/207 | ||
1427 | index XXXXXXX..XXXXXXX 100755 | ||
1428 | --- a/tests/qemu-iotests/207 | ||
1429 | +++ b/tests/qemu-iotests/207 | ||
1430 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.img') as disk_path, \ | ||
1431 | |||
1432 | iotests.img_info_log(remote_path) | ||
1433 | |||
1434 | - md5_key = subprocess.check_output( | ||
1435 | - 'ssh-keyscan -t rsa 127.0.0.1 2>/dev/null | grep -v "\\^#" | ' + | ||
1436 | - 'cut -d" " -f3 | base64 -d | md5sum -b | cut -d" " -f1', | ||
1437 | - shell=True).rstrip().decode('ascii') | ||
1438 | + keys = subprocess.check_output( | ||
1439 | + 'ssh-keyscan 127.0.0.1 2>/dev/null | grep -v "\\^#" | ' + | ||
1440 | + 'cut -d" " -f3', | ||
1441 | + shell=True).rstrip().decode('ascii').split('\n') | ||
1442 | + | ||
1443 | + # Mappings of base64 representations to digests | ||
1444 | + md5_keys = {} | ||
1445 | + sha1_keys = {} | ||
1446 | + | ||
1447 | + for key in keys: | ||
1448 | + md5_keys[key] = subprocess.check_output( | ||
1449 | + 'echo %s | base64 -d | md5sum -b | cut -d" " -f1' % key, | ||
1450 | + shell=True).rstrip().decode('ascii') | ||
1451 | + | ||
1452 | + sha1_keys[key] = subprocess.check_output( | ||
1453 | + 'echo %s | base64 -d | sha1sum -b | cut -d" " -f1' % key, | ||
1454 | + shell=True).rstrip().decode('ascii') | ||
1455 | |||
1456 | vm.launch() | ||
1457 | + | ||
1458 | + # Find correct key first | ||
1459 | + matching_key = None | ||
1460 | + for key in keys: | ||
1461 | + result = vm.qmp('blockdev-add', | ||
1462 | + driver='ssh', node_name='node0', path=disk_path, | ||
1463 | + server={ | ||
1464 | + 'host': '127.0.0.1', | ||
1465 | + 'port': '22', | ||
1466 | + }, host_key_check={ | ||
1467 | + 'mode': 'hash', | ||
1468 | + 'type': 'md5', | ||
1469 | + 'hash': md5_keys[key], | ||
1470 | + }) | ||
1471 | + | ||
1472 | + if 'error' not in result: | ||
1473 | + vm.qmp('blockdev-del', node_name='node0') | ||
1474 | + matching_key = key | ||
1475 | + break | ||
1476 | + | ||
1477 | + if matching_key is None: | ||
1478 | + vm.shutdown() | ||
1479 | + iotests.notrun('Did not find a key that fits 127.0.0.1') | ||
1480 | + | ||
1481 | blockdev_create(vm, { 'driver': 'ssh', | ||
1482 | 'location': { | ||
1483 | 'path': disk_path, | ||
1484 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.img') as disk_path, \ | ||
1485 | 'host-key-check': { | ||
1486 | 'mode': 'hash', | ||
1487 | 'type': 'md5', | ||
1488 | - 'hash': md5_key, | ||
1489 | + 'hash': md5_keys[matching_key], | ||
1490 | } | ||
1491 | }, | ||
1492 | 'size': 8388608 }) | ||
1493 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.img') as disk_path, \ | ||
1494 | |||
1495 | iotests.img_info_log(remote_path) | ||
1496 | |||
1497 | - sha1_key = subprocess.check_output( | ||
1498 | - 'ssh-keyscan -t rsa 127.0.0.1 2>/dev/null | grep -v "\\^#" | ' + | ||
1499 | - 'cut -d" " -f3 | base64 -d | sha1sum -b | cut -d" " -f1', | ||
1500 | - shell=True).rstrip().decode('ascii') | ||
1501 | - | ||
1502 | vm.launch() | ||
1503 | blockdev_create(vm, { 'driver': 'ssh', | ||
1504 | 'location': { | ||
1505 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.img') as disk_path, \ | ||
1506 | 'host-key-check': { | ||
1507 | 'mode': 'hash', | ||
1508 | 'type': 'sha1', | ||
1509 | - 'hash': sha1_key, | ||
1510 | + 'hash': sha1_keys[matching_key], | ||
1511 | } | ||
1512 | }, | ||
1513 | 'size': 4194304 }) | ||
1514 | diff --git a/tests/qemu-iotests/207.out b/tests/qemu-iotests/207.out | ||
1515 | index XXXXXXX..XXXXXXX 100644 | ||
1516 | --- a/tests/qemu-iotests/207.out | ||
1517 | +++ b/tests/qemu-iotests/207.out | ||
1518 | @@ -XXX,XX +XXX,XX @@ virtual size: 4 MiB (4194304 bytes) | ||
1519 | |||
1520 | {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "ssh", "location": {"host-key-check": {"mode": "none"}, "path": "/this/is/not/an/existing/path", "server": {"host": "127.0.0.1", "port": "22"}}, "size": 4194304}}} | ||
1521 | {"return": {}} | ||
1522 | -Job failed: failed to open remote file '/this/is/not/an/existing/path': Failed opening remote file (libssh2 error code: -31) | ||
1523 | +Job failed: failed to open remote file '/this/is/not/an/existing/path': SFTP server: No such file (libssh error code: 1, sftp error code: 2) | ||
1524 | {"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
1525 | {"return": {}} | ||
59 | 1526 | ||
60 | -- | 1527 | -- |
61 | 2.34.1 | 1528 | 2.21.0 |
62 | 1529 | ||
63 | 1530 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
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 |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
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 |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
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 |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
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 |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
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 |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
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 |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
3 | The only "feature" of this "Formatting ..." line is that we have to | ||
4 | update it every time we add new option. Let's drop it. | ||
5 | |||
6 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
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(-) | ||
19 | |||
20 | diff --git a/tests/qemu-iotests/149.out b/tests/qemu-iotests/149.out | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/tests/qemu-iotests/149.out | ||
23 | +++ b/tests/qemu-iotests/149.out | ||
24 | @@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-xts-plain64-sha1.img | ||
25 | # ================= qemu-img aes-256-xts-plain64-sha1 ================= | ||
26 | # Create image | ||
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 | ||
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 | ||
29 | |||
30 | # Open dev | ||
31 | sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha1.img qiotest-145-aes-256-xts-plain64-sha1 | ||
32 | @@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-twofish-256-xts-plain64-sha1.img | ||
33 | # ================= qemu-img twofish-256-xts-plain64-sha1 ================= | ||
34 | # Create image | ||
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 | ||
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 | ||
37 | |||
38 | # Open dev | ||
39 | sudo cryptsetup -q -v luksOpen TEST_DIR/luks-twofish-256-xts-plain64-sha1.img qiotest-145-twofish-256-xts-plain64-sha1 | ||
40 | @@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-serpent-256-xts-plain64-sha1.img | ||
41 | # ================= qemu-img serpent-256-xts-plain64-sha1 ================= | ||
42 | # Create image | ||
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 | ||
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 | ||
45 | |||
46 | # Open dev | ||
47 | sudo cryptsetup -q -v luksOpen TEST_DIR/luks-serpent-256-xts-plain64-sha1.img qiotest-145-serpent-256-xts-plain64-sha1 | ||
48 | @@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-cast5-128-cbc-plain64-sha1.img | ||
49 | # ================= qemu-img cast5-128-cbc-plain64-sha1 ================= | ||
50 | # Create image | ||
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 | ||
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 | ||
53 | |||
54 | # Open dev | ||
55 | sudo cryptsetup -q -v luksOpen TEST_DIR/luks-cast5-128-cbc-plain64-sha1.img qiotest-145-cast5-128-cbc-plain64-sha1 | ||
56 | @@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-cbc-plain-sha1.img | ||
57 | # ================= qemu-img aes-256-cbc-plain-sha1 ================= | ||
58 | # Create image | ||
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 | ||
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 | ||
61 | |||
62 | # Open dev | ||
63 | sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-plain-sha1.img qiotest-145-aes-256-cbc-plain-sha1 | ||
64 | @@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-cbc-plain64-sha1.img | ||
65 | # ================= qemu-img aes-256-cbc-plain64-sha1 ================= | ||
66 | # Create image | ||
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 | ||
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 | ||
69 | |||
70 | # Open dev | ||
71 | sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-plain64-sha1.img qiotest-145-aes-256-cbc-plain64-sha1 | ||
72 | @@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-cbc-essiv-sha256-sha1.img | ||
73 | # ================= qemu-img aes-256-cbc-essiv-sha256-sha1 ================= | ||
74 | # Create image | ||
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 | ||
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 | ||
77 | |||
78 | # Open dev | ||
79 | sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-essiv-sha256-sha1.img qiotest-145-aes-256-cbc-essiv-sha256-sha1 | ||
80 | @@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-xts-essiv-sha256-sha1.img | ||
81 | # ================= qemu-img aes-256-xts-essiv-sha256-sha1 ================= | ||
82 | # Create image | ||
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 | ||
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 | ||
85 | |||
86 | # Open dev | ||
87 | sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-essiv-sha256-sha1.img qiotest-145-aes-256-xts-essiv-sha256-sha1 | ||
88 | @@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-128-xts-plain64-sha256-sha1.img | ||
89 | # ================= qemu-img aes-128-xts-plain64-sha256-sha1 ================= | ||
90 | # Create image | ||
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 | ||
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 | ||
93 | |||
94 | # Open dev | ||
95 | sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-128-xts-plain64-sha256-sha1.img qiotest-145-aes-128-xts-plain64-sha256-sha1 | ||
96 | @@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-192-xts-plain64-sha256-sha1.img | ||
97 | # ================= qemu-img aes-192-xts-plain64-sha256-sha1 ================= | ||
98 | # Create image | ||
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 | ||
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 | ||
101 | |||
102 | # Open dev | ||
103 | sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-192-xts-plain64-sha256-sha1.img qiotest-145-aes-192-xts-plain64-sha256-sha1 | ||
104 | @@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-twofish-128-xts-plain64-sha1.img | ||
105 | # ================= qemu-img twofish-128-xts-plain64-sha1 ================= | ||
106 | # Create image | ||
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 | ||
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 | ||
109 | |||
110 | # Open dev | ||
111 | sudo cryptsetup -q -v luksOpen TEST_DIR/luks-twofish-128-xts-plain64-sha1.img qiotest-145-twofish-128-xts-plain64-sha1 | ||
112 | @@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-serpent-128-xts-plain64-sha1.img | ||
113 | # ================= qemu-img serpent-128-xts-plain64-sha1 ================= | ||
114 | # Create image | ||
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 | ||
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 | ||
117 | |||
118 | # Open dev | ||
119 | sudo cryptsetup -q -v luksOpen TEST_DIR/luks-serpent-128-xts-plain64-sha1.img qiotest-145-serpent-128-xts-plain64-sha1 | ||
120 | @@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-serpent-192-xts-plain64-sha1.img | ||
121 | # ================= qemu-img serpent-192-xts-plain64-sha1 ================= | ||
122 | # Create image | ||
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 | ||
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 | ||
125 | |||
126 | # Open dev | ||
127 | sudo cryptsetup -q -v luksOpen TEST_DIR/luks-serpent-192-xts-plain64-sha1.img qiotest-145-serpent-192-xts-plain64-sha1 | ||
128 | @@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-xts-plain64-sha224.img | ||
129 | # ================= qemu-img aes-256-xts-plain64-sha224 ================= | ||
130 | # Create image | ||
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 | ||
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 | ||
133 | |||
134 | # Open dev | ||
135 | sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha224.img qiotest-145-aes-256-xts-plain64-sha224 | ||
136 | @@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-xts-plain64-sha256.img | ||
137 | # ================= qemu-img aes-256-xts-plain64-sha256 ================= | ||
138 | # Create image | ||
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 | ||
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 | ||
141 | |||
142 | # Open dev | ||
143 | sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha256.img qiotest-145-aes-256-xts-plain64-sha256 | ||
144 | @@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-xts-plain64-sha384.img | ||
145 | # ================= qemu-img aes-256-xts-plain64-sha384 ================= | ||
146 | # Create image | ||
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 | ||
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 | ||
149 | |||
150 | # Open dev | ||
151 | sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha384.img qiotest-145-aes-256-xts-plain64-sha384 | ||
152 | @@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-xts-plain64-sha512.img | ||
153 | # ================= qemu-img aes-256-xts-plain64-sha512 ================= | ||
154 | # Create image | ||
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 | ||
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 | ||
157 | |||
158 | # Open dev | ||
159 | sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha512.img qiotest-145-aes-256-xts-plain64-sha512 | ||
160 | @@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-xts-plain64-ripemd160.img | ||
161 | # ================= qemu-img aes-256-xts-plain64-ripemd160 ================= | ||
162 | # Create image | ||
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 | ||
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 | ||
165 | |||
166 | # Open dev | ||
167 | sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-ripemd160.img qiotest-145-aes-256-xts-plain64-ripemd160 | ||
168 | @@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-xts-plain-sha1-pwallslots.img | ||
169 | # ================= qemu-img aes-256-xts-plain-sha1-pwallslots ================= | ||
170 | # Create image | ||
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 | ||
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 | ||
173 | |||
174 | # Open dev | ||
175 | sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain-sha1-pwallslots.img qiotest-145-aes-256-xts-plain-sha1-pwallslots | ||
176 | @@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-cbc-essiv-auto-sha1.img | ||
177 | # ================= qemu-img aes-256-cbc-essiv-auto-sha1 ================= | ||
178 | # Create image | ||
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 | ||
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 | ||
181 | |||
182 | # Open dev | ||
183 | sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-essiv-auto-sha1.img qiotest-145-aes-256-cbc-essiv-auto-sha1 | ||
184 | @@ -XXX,XX +XXX,XX @@ unlink TEST_DIR/luks-aes-256-cbc-plain64-sha256-sha1.img | ||
185 | # ================= qemu-img aes-256-cbc-plain64-sha256-sha1 ================= | ||
186 | # Create image | ||
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 | ||
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 | ||
189 | |||
190 | # Open dev | ||
191 | sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-plain64-sha256-sha1.img qiotest-145-aes-256-cbc-plain64-sha256-sha1 | ||
192 | diff --git a/tests/qemu-iotests/237.out b/tests/qemu-iotests/237.out | ||
193 | index XXXXXXX..XXXXXXX 100644 | ||
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''' | ||
443 | -- | ||
444 | 2.34.1 | ||
445 | |||
446 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
3 | We want iotests pass with both the default zlib compression and with | ||
4 | IMGOPTS='compression_type=zstd'. | ||
5 | |||
6 | Actually the only test that is interested in real compression type in | ||
7 | test output is 287 (test for qcow2 compression type) and it's in bash. | ||
8 | So for now we can safely filter out compression type in all qcow2 | ||
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> | ||
15 | --- | ||
16 | tests/qemu-iotests/206.out | 10 +++++----- | ||
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(-) | ||
21 | |||
22 | diff --git a/tests/qemu-iotests/206.out b/tests/qemu-iotests/206.out | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/tests/qemu-iotests/206.out | ||
25 | +++ b/tests/qemu-iotests/206.out | ||
26 | @@ -XXX,XX +XXX,XX @@ virtual size: 128 MiB (134217728 bytes) | ||
27 | cluster_size: 65536 | ||
28 | Format specific information: | ||
29 | compat: 1.1 | ||
30 | - compression type: zlib | ||
31 | + compression type: COMPRESSION_TYPE | ||
32 | lazy refcounts: false | ||
33 | refcount bits: 16 | ||
34 | corrupt: false | ||
35 | @@ -XXX,XX +XXX,XX @@ virtual size: 64 MiB (67108864 bytes) | ||
36 | cluster_size: 65536 | ||
37 | Format specific information: | ||
38 | compat: 1.1 | ||
39 | - compression type: zlib | ||
40 | + compression type: COMPRESSION_TYPE | ||
41 | lazy refcounts: false | ||
42 | refcount bits: 16 | ||
43 | corrupt: false | ||
44 | @@ -XXX,XX +XXX,XX @@ virtual size: 32 MiB (33554432 bytes) | ||
45 | cluster_size: 2097152 | ||
46 | Format specific information: | ||
47 | compat: 1.1 | ||
48 | - compression type: zlib | ||
49 | + compression type: COMPRESSION_TYPE | ||
50 | lazy refcounts: true | ||
51 | refcount bits: 1 | ||
52 | corrupt: false | ||
53 | @@ -XXX,XX +XXX,XX @@ backing file: TEST_IMG.base | ||
54 | backing file format: IMGFMT | ||
55 | Format specific information: | ||
56 | compat: 0.10 | ||
57 | - compression type: zlib | ||
58 | + compression type: COMPRESSION_TYPE | ||
59 | refcount bits: 16 | ||
60 | |||
61 | === Successful image creation (encrypted) === | ||
62 | @@ -XXX,XX +XXX,XX @@ encrypted: yes | ||
63 | cluster_size: 65536 | ||
64 | Format specific information: | ||
65 | compat: 1.1 | ||
66 | - compression type: zlib | ||
67 | + compression type: COMPRESSION_TYPE | ||
68 | lazy refcounts: false | ||
69 | refcount bits: 16 | ||
70 | encrypt: | ||
71 | diff --git a/tests/qemu-iotests/242.out b/tests/qemu-iotests/242.out | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/tests/qemu-iotests/242.out | ||
74 | +++ b/tests/qemu-iotests/242.out | ||
75 | @@ -XXX,XX +XXX,XX @@ virtual size: 1 MiB (1048576 bytes) | ||
76 | cluster_size: 65536 | ||
77 | Format specific information: | ||
78 | compat: 1.1 | ||
79 | - compression type: zlib | ||
80 | + compression type: COMPRESSION_TYPE | ||
81 | lazy refcounts: false | ||
82 | refcount bits: 16 | ||
83 | corrupt: false | ||
84 | @@ -XXX,XX +XXX,XX @@ virtual size: 1 MiB (1048576 bytes) | ||
85 | cluster_size: 65536 | ||
86 | Format specific information: | ||
87 | compat: 1.1 | ||
88 | - compression type: zlib | ||
89 | + compression type: COMPRESSION_TYPE | ||
90 | lazy refcounts: false | ||
91 | bitmaps: | ||
92 | [0]: | ||
93 | @@ -XXX,XX +XXX,XX @@ virtual size: 1 MiB (1048576 bytes) | ||
94 | cluster_size: 65536 | ||
95 | Format specific information: | ||
96 | compat: 1.1 | ||
97 | - compression type: zlib | ||
98 | + compression type: COMPRESSION_TYPE | ||
99 | lazy refcounts: false | ||
100 | bitmaps: | ||
101 | [0]: | ||
102 | @@ -XXX,XX +XXX,XX @@ virtual size: 1 MiB (1048576 bytes) | ||
103 | cluster_size: 65536 | ||
104 | Format specific information: | ||
105 | compat: 1.1 | ||
106 | - compression type: zlib | ||
107 | + compression type: COMPRESSION_TYPE | ||
108 | lazy refcounts: false | ||
109 | bitmaps: | ||
110 | [0]: | ||
111 | @@ -XXX,XX +XXX,XX @@ virtual size: 1 MiB (1048576 bytes) | ||
112 | cluster_size: 65536 | ||
113 | Format specific information: | ||
114 | compat: 1.1 | ||
115 | - compression type: zlib | ||
116 | + compression type: COMPRESSION_TYPE | ||
117 | lazy refcounts: false | ||
118 | bitmaps: | ||
119 | [0]: | ||
120 | diff --git a/tests/qemu-iotests/274.out b/tests/qemu-iotests/274.out | ||
121 | index XXXXXXX..XXXXXXX 100644 | ||
122 | --- a/tests/qemu-iotests/274.out | ||
123 | +++ b/tests/qemu-iotests/274.out | ||
124 | @@ -XXX,XX +XXX,XX @@ backing file: TEST_DIR/PID-base | ||
125 | backing file format: IMGFMT | ||
126 | Format specific information: | ||
127 | compat: 1.1 | ||
128 | - compression type: zlib | ||
129 | + compression type: COMPRESSION_TYPE | ||
130 | lazy refcounts: false | ||
131 | refcount bits: 16 | ||
132 | corrupt: false | ||
133 | @@ -XXX,XX +XXX,XX @@ backing file: TEST_DIR/PID-base | ||
134 | backing file format: IMGFMT | ||
135 | Format specific information: | ||
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) | ||
181 | |||
182 | -- | ||
183 | 2.34.1 | ||
184 | |||
185 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
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 |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
3 | We'll use it in tests instead of explicit qcow2.py. Then we are going | ||
4 | to add some filtering in _qcow2_dump_header. | ||
5 | |||
6 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
7 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
8 | Message-Id: <20211223160144.1097696-14-vsementsov@virtuozzo.com> | ||
9 | Signed-off-by: Hanna Reitz <hreitz@redhat.com> | ||
10 | --- | ||
11 | tests/qemu-iotests/common.rc | 10 ++++++++++ | ||
12 | 1 file changed, 10 insertions(+) | ||
13 | |||
14 | diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/tests/qemu-iotests/common.rc | ||
17 | +++ b/tests/qemu-iotests/common.rc | ||
18 | @@ -XXX,XX +XXX,XX @@ _require_one_device_of() | ||
19 | _notrun "$* not available" | ||
20 | } | ||
21 | |||
22 | +_qcow2_dump_header() | ||
23 | +{ | ||
24 | + img="$1" | ||
25 | + if [ -z "$img" ]; then | ||
26 | + img="$TEST_IMG" | ||
27 | + fi | ||
28 | + | ||
29 | + $PYTHON qcow2.py "$img" dump-header | ||
30 | +} | ||
31 | + | ||
32 | # make sure this script returns success | ||
33 | true | ||
34 | -- | ||
35 | 2.34.1 | ||
36 | |||
37 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
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 |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
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 |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
3 | We want iotests pass with both the default zlib compression and with | ||
4 | IMGOPTS='compression_type=zstd'. | ||
5 | |||
6 | Actually the only test that is interested in real compression type in | ||
7 | test output is 287 (test for qcow2 compression type), so implement | ||
8 | specific option for it. | ||
9 | |||
10 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.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> | ||
14 | --- | ||
15 | tests/qemu-iotests/060.out | 2 +- | ||
16 | tests/qemu-iotests/061.out | 12 ++++++------ | ||
17 | tests/qemu-iotests/082.out | 14 +++++++------- | ||
18 | tests/qemu-iotests/198.out | 4 ++-- | ||
19 | tests/qemu-iotests/287 | 8 ++++---- | ||
20 | tests/qemu-iotests/common.filter | 8 ++++++++ | ||
21 | tests/qemu-iotests/common.rc | 14 +++++++++++++- | ||
22 | 7 files changed, 41 insertions(+), 21 deletions(-) | ||
23 | |||
24 | diff --git a/tests/qemu-iotests/060.out b/tests/qemu-iotests/060.out | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/tests/qemu-iotests/060.out | ||
27 | +++ b/tests/qemu-iotests/060.out | ||
28 | @@ -XXX,XX +XXX,XX @@ virtual size: 64 MiB (67108864 bytes) | ||
29 | cluster_size: 65536 | ||
30 | Format specific information: | ||
31 | compat: 1.1 | ||
32 | - compression type: zlib | ||
33 | + compression type: COMPRESSION_TYPE | ||
34 | lazy refcounts: false | ||
35 | refcount bits: 16 | ||
36 | corrupt: true | ||
37 | diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/tests/qemu-iotests/061.out | ||
40 | +++ b/tests/qemu-iotests/061.out | ||
41 | @@ -XXX,XX +XXX,XX @@ virtual size: 64 MiB (67108864 bytes) | ||
42 | cluster_size: 65536 | ||
43 | Format specific information: | ||
44 | compat: 1.1 | ||
45 | - compression type: zlib | ||
46 | + compression type: COMPRESSION_TYPE | ||
47 | lazy refcounts: false | ||
48 | refcount bits: 16 | ||
49 | data file: TEST_DIR/t.IMGFMT.data | ||
50 | @@ -XXX,XX +XXX,XX @@ virtual size: 64 MiB (67108864 bytes) | ||
51 | cluster_size: 65536 | ||
52 | Format specific information: | ||
53 | compat: 1.1 | ||
54 | - compression type: zlib | ||
55 | + compression type: COMPRESSION_TYPE | ||
56 | lazy refcounts: false | ||
57 | refcount bits: 16 | ||
58 | data file: foo | ||
59 | @@ -XXX,XX +XXX,XX @@ virtual size: 64 MiB (67108864 bytes) | ||
60 | cluster_size: 65536 | ||
61 | Format specific information: | ||
62 | compat: 1.1 | ||
63 | - compression type: zlib | ||
64 | + compression type: COMPRESSION_TYPE | ||
65 | lazy refcounts: false | ||
66 | refcount bits: 16 | ||
67 | data file raw: false | ||
68 | @@ -XXX,XX +XXX,XX @@ virtual size: 64 MiB (67108864 bytes) | ||
69 | cluster_size: 65536 | ||
70 | Format specific information: | ||
71 | compat: 1.1 | ||
72 | - compression type: zlib | ||
73 | + compression type: COMPRESSION_TYPE | ||
74 | lazy refcounts: false | ||
75 | refcount bits: 16 | ||
76 | data file: TEST_DIR/t.IMGFMT.data | ||
77 | @@ -XXX,XX +XXX,XX @@ virtual size: 64 MiB (67108864 bytes) | ||
78 | cluster_size: 65536 | ||
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." | ||
222 | diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter | ||
223 | index XXXXXXX..XXXXXXX 100644 | ||
224 | --- a/tests/qemu-iotests/common.filter | ||
225 | +++ b/tests/qemu-iotests/common.filter | ||
226 | @@ -XXX,XX +XXX,XX @@ _filter_img_info() | ||
227 | -e "/block_state_zero: \\(on\\|off\\)/d" \ | ||
228 | -e "/log_size: [0-9]\\+/d" \ | ||
229 | -e "s/iters: [0-9]\\+/iters: 1024/" \ | ||
230 | + -e 's/\(compression type: \)\(zlib\|zstd\)/\1COMPRESSION_TYPE/' \ | ||
231 | -e "s/uuid: [-a-f0-9]\\+/uuid: 00000000-0000-0000-0000-000000000000/" | \ | ||
232 | while IFS='' read -r line; do | ||
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 | ||
247 | diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc | ||
248 | index XXXXXXX..XXXXXXX 100644 | ||
249 | --- a/tests/qemu-iotests/common.rc | ||
250 | +++ b/tests/qemu-iotests/common.rc | ||
251 | @@ -XXX,XX +XXX,XX @@ _img_info() | ||
252 | -e "s#$TEST_DIR#TEST_DIR#g" \ | ||
253 | -e "s#$SOCK_DIR/fuse-#TEST_DIR/#g" \ | ||
254 | -e "s#$IMGFMT#IMGFMT#g" \ | ||
255 | + -e 's/\(compression type: \)\(zlib\|zstd\)/\1COMPRESSION_TYPE/' \ | ||
256 | -e "/^disk size:/ D" \ | ||
257 | -e "/actual-size/ D" | \ | ||
258 | while IFS='' read -r line; do | ||
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" | ||
273 | fi | ||
274 | |||
275 | - $PYTHON qcow2.py "$img" dump-header | ||
276 | + if [[ $filter_compression == 0 ]]; then | ||
277 | + $PYTHON qcow2.py "$img" dump-header | ||
278 | + else | ||
279 | + $PYTHON qcow2.py "$img" dump-header | _filter_qcow2_compression_type_bit | ||
280 | + fi | ||
281 | } | ||
282 | |||
283 | # make sure this script returns success | ||
284 | -- | ||
285 | 2.34.1 | ||
286 | |||
287 | diff view generated by jsdifflib |
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 1 | Tests should place their files into the test directory. This includes |
---|---|---|---|
2 | Unix sockets. 205 currently fails to do so, which prevents it from | ||
3 | being run concurrently. | ||
2 | 4 | ||
3 | Don't touch other incompatible bits, like compression-type. This makes | 5 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
4 | the test pass with IMGOPTS='compression_type=zstd'. | 6 | Message-id: 20190618210238.9524-1-mreitz@redhat.com |
5 | 7 | Reviewed-by: Eric Blake <eblake@redhat.com> | |
6 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 8 | Signed-off-by: Max Reitz <mreitz@redhat.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> | ||
10 | --- | 9 | --- |
11 | tests/qemu-iotests/060 | 2 +- | 10 | tests/qemu-iotests/205 | 2 +- |
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
13 | 12 | ||
14 | diff --git a/tests/qemu-iotests/060 b/tests/qemu-iotests/060 | 13 | diff --git a/tests/qemu-iotests/205 b/tests/qemu-iotests/205 |
15 | index XXXXXXX..XXXXXXX 100755 | 14 | index XXXXXXX..XXXXXXX 100755 |
16 | --- a/tests/qemu-iotests/060 | 15 | --- a/tests/qemu-iotests/205 |
17 | +++ b/tests/qemu-iotests/060 | 16 | +++ b/tests/qemu-iotests/205 |
18 | @@ -XXX,XX +XXX,XX @@ _make_test_img 64M | 17 | @@ -XXX,XX +XXX,XX @@ import iotests |
19 | # Let the refblock appear unaligned | 18 | import time |
20 | poke_file "$TEST_IMG" "$rt_offset" "\x00\x00\x00\x00\xff\xff\x2a\x00" | 19 | from iotests import qemu_img_create, qemu_io, filter_qemu_io, QemuIoInteractive |
21 | # Mark the image dirty, thus forcing an automatic check when opening it | 20 | |
22 | -poke_file "$TEST_IMG" 72 "\x00\x00\x00\x00\x00\x00\x00\x01" | 21 | -nbd_sock = 'nbd_sock' |
23 | +$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 0 | 22 | +nbd_sock = os.path.join(iotests.test_dir, 'nbd_sock') |
24 | # Open the image (qemu should refuse to do so) | 23 | nbd_uri = 'nbd+unix:///exp?socket=' + nbd_sock |
25 | $QEMU_IO -c close "$TEST_IMG" 2>&1 | _filter_testdir | _filter_imgfmt | 24 | disk = os.path.join(iotests.test_dir, 'disk') |
26 | 25 | ||
27 | -- | 26 | -- |
28 | 2.34.1 | 27 | 2.21.0 |
29 | 28 | ||
30 | 29 | diff view generated by jsdifflib |