1 | The following changes since commit 4871b51b9241b10f4fd8e04bbb21577886795e25: | 1 | The following changes since commit 754f756cc4c6d9d14b7230c62b5bb20f9d655888: |
---|---|---|---|
2 | 2 | ||
3 | vmgenid-test: use boot-sector infrastructure (2017-07-14 17:03:03 +0100) | 3 | Merge tag 'pull-target-arm-20220422-1' of https://git.linaro.org/people/pmaydell/qemu-arm into staging (2022-04-22 08:03:18 -0700) |
4 | 4 | ||
5 | are available in the git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | git://github.com/stefanha/qemu.git tags/block-pull-request | 7 | https://gitlab.com/hreitz/qemu.git tags/pull-block-2022-04-25 |
8 | 8 | ||
9 | for you to fetch changes up to 593ed6f0a3c827a13a274e47f6fa980344234f9c: | 9 | for you to fetch changes up to 348a0740afc5b313599533eb69bbb2b95d2f1bba: |
10 | 10 | ||
11 | block: fix shadowed variable in bdrv_co_pdiscard (2017-07-17 15:58:37 +0100) | 11 | iotests/108: Fix when missing user_allow_other (2022-04-25 14:46:45 +0200) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Block patches: | ||
15 | - New @force parameter for blockdev-change-medium | ||
16 | - Improvements to the iotests to help with debugging | ||
17 | - Fix iotest 108 on systems without user_allow_other in fuse.conf | ||
14 | 18 | ||
15 | ---------------------------------------------------------------- | 19 | ---------------------------------------------------------------- |
20 | Denis V. Lunev (1): | ||
21 | block: add 'force' parameter to 'blockdev-change-medium' command | ||
16 | 22 | ||
17 | Alistair Francis (1): | 23 | Hanna Reitz (1): |
18 | util/aio-win32: Only select on what we are actually waiting for | 24 | iotests/108: Fix when missing user_allow_other |
19 | 25 | ||
20 | Denis V. Lunev (1): | 26 | John Snow (12): |
21 | block: fix shadowed variable in bdrv_co_pdiscard | 27 | iotests: replace calls to log(qemu_io(...)) with qemu_io_log() |
28 | iotests/163: Fix broken qemu-io invocation | ||
29 | iotests: Don't check qemu_io() output for specific error strings | ||
30 | iotests/040: Don't check image pattern on zero-length image | ||
31 | iotests/040: Fix TestCommitWithFilters test | ||
32 | iotests: create generic qemu_tool() function | ||
33 | iotests: rebase qemu_io() on top of qemu_tool() | ||
34 | iotests/migration-permissions: use assertRaises() for qemu_io() | ||
35 | negative test | ||
36 | iotests/image-fleecing: switch to qemu_io() | ||
37 | iotests: remove qemu_io_pipe_and_status() | ||
38 | iotests: remove qemu_io_silent() and qemu_io_silent_check(). | ||
39 | iotests: make qemu_io_log() check return codes by default | ||
22 | 40 | ||
23 | block/io.c | 1 - | 41 | qapi/block.json | 6 ++ |
24 | util/aio-win32.c | 13 ++++++++++--- | 42 | block/qapi-sysemu.c | 3 +- |
25 | 2 files changed, 10 insertions(+), 4 deletions(-) | 43 | monitor/hmp-cmds.c | 4 +- |
44 | hmp-commands.hx | 11 ++- | ||
45 | tests/qemu-iotests/030 | 85 +++++++++++-------- | ||
46 | tests/qemu-iotests/040 | 53 +++++++----- | ||
47 | tests/qemu-iotests/056 | 2 +- | ||
48 | tests/qemu-iotests/108 | 2 +- | ||
49 | tests/qemu-iotests/149 | 6 +- | ||
50 | tests/qemu-iotests/163 | 5 +- | ||
51 | tests/qemu-iotests/205 | 4 +- | ||
52 | tests/qemu-iotests/216 | 12 +-- | ||
53 | tests/qemu-iotests/218 | 5 +- | ||
54 | tests/qemu-iotests/224 | 4 +- | ||
55 | tests/qemu-iotests/242 | 6 +- | ||
56 | tests/qemu-iotests/245 | 17 ++-- | ||
57 | tests/qemu-iotests/255 | 4 +- | ||
58 | tests/qemu-iotests/258 | 11 ++- | ||
59 | tests/qemu-iotests/298 | 17 ++-- | ||
60 | tests/qemu-iotests/303 | 4 +- | ||
61 | tests/qemu-iotests/310 | 22 ++--- | ||
62 | tests/qemu-iotests/iotests.py | 69 ++++++++------- | ||
63 | tests/qemu-iotests/tests/image-fleecing | 30 ++++--- | ||
64 | .../qemu-iotests/tests/migration-permissions | 28 +++--- | ||
65 | .../tests/mirror-ready-cancel-error | 2 +- | ||
66 | .../qemu-iotests/tests/nbd-reconnect-on-open | 2 +- | ||
67 | .../qemu-iotests/tests/stream-error-on-reset | 4 +- | ||
68 | ui/cocoa.m | 1 + | ||
69 | 28 files changed, 231 insertions(+), 188 deletions(-) | ||
26 | 70 | ||
27 | -- | 71 | -- |
28 | 2.9.4 | 72 | 2.35.1 |
29 | |||
30 | diff view generated by jsdifflib |
1 | From: "Denis V. Lunev" <den@openvz.org> | 1 | From: "Denis V. Lunev" <den@openvz.org> |
---|---|---|---|
2 | 2 | ||
3 | We've had a shadowed 'ret' variable, which risks returning the wrong | 3 | 'blockdev-change-medium' is a convinient wrapper for the following |
4 | value, introduced in commit b9c64947. | 4 | sequence of commands: |
5 | * blockdev-open-tray | ||
6 | * blockdev-remove-medium | ||
7 | * blockdev-insert-medium | ||
8 | * blockdev-close-tray | ||
9 | and should be used f.e. to change ISO image inside the CD-ROM tray. | ||
10 | Though the guest could lock the tray and some linux guests like | ||
11 | CentOS 8.5 actually does that. In this case the execution if this | ||
12 | command results in the error like the following: | ||
13 | Device 'scsi0-0-1-0' is locked and force was not specified, | ||
14 | wait for tray to open and try again. | ||
15 | |||
16 | This situation is could be resolved 'blockdev-open-tray' by passing | ||
17 | flag 'force' inside. Thus is seems reasonable to add the same | ||
18 | capability for 'blockdev-change-medium' too. | ||
5 | 19 | ||
6 | Signed-off-by: Denis V. Lunev <den@openvz.org> | 20 | Signed-off-by: Denis V. Lunev <den@openvz.org> |
7 | Reviewed-by: Fam Zheng <famz@redhat.com> | 21 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org> |
8 | Reviewed-by: Eric Blake <eblake@redhat.com> | 22 | Acked-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com> |
9 | Message-id: 20170710150559.30163-1-den@openvz.org | ||
10 | CC: Stefan Hajnoczi <stefanha@redhat.com> | ||
11 | CC: Kevin Wolf <kwolf@redhat.com> | 23 | CC: Kevin Wolf <kwolf@redhat.com> |
24 | CC: Hanna Reitz <hreitz@redhat.com> | ||
12 | CC: Eric Blake <eblake@redhat.com> | 25 | CC: Eric Blake <eblake@redhat.com> |
13 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 26 | CC: Markus Armbruster <armbru@redhat.com> |
27 | Message-Id: <20220412221846.280723-1-den@openvz.org> | ||
28 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
29 | Signed-off-by: Hanna Reitz <hreitz@redhat.com> | ||
14 | --- | 30 | --- |
15 | block/io.c | 1 - | 31 | qapi/block.json | 6 ++++++ |
16 | 1 file changed, 1 deletion(-) | 32 | block/qapi-sysemu.c | 3 ++- |
33 | monitor/hmp-cmds.c | 4 +++- | ||
34 | hmp-commands.hx | 11 +++++++---- | ||
35 | ui/cocoa.m | 1 + | ||
36 | 5 files changed, 19 insertions(+), 6 deletions(-) | ||
17 | 37 | ||
18 | diff --git a/block/io.c b/block/io.c | 38 | diff --git a/qapi/block.json b/qapi/block.json |
19 | index XXXXXXX..XXXXXXX 100644 | 39 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/block/io.c | 40 | --- a/qapi/block.json |
21 | +++ b/block/io.c | 41 | +++ b/qapi/block.json |
22 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset, | 42 | @@ -XXX,XX +XXX,XX @@ |
23 | assert(max_pdiscard >= bs->bl.request_alignment); | 43 | # @read-only-mode: change the read-only mode of the device; defaults |
24 | 44 | # to 'retain' | |
25 | while (bytes > 0) { | 45 | # |
26 | - int ret; | 46 | +# @force: if false (the default), an eject request through blockdev-open-tray |
27 | int num = bytes; | 47 | +# will be sent to the guest if it has locked the tray (and the tray |
28 | 48 | +# will not be opened immediately); if true, the tray will be opened | |
29 | if (head) { | 49 | +# regardless of whether it is locked. (since 7.1) |
50 | +# | ||
51 | # Features: | ||
52 | # @deprecated: Member @device is deprecated. Use @id instead. | ||
53 | # | ||
54 | @@ -XXX,XX +XXX,XX @@ | ||
55 | '*id': 'str', | ||
56 | 'filename': 'str', | ||
57 | '*format': 'str', | ||
58 | + '*force': 'bool', | ||
59 | '*read-only-mode': 'BlockdevChangeReadOnlyMode' } } | ||
60 | |||
61 | |||
62 | diff --git a/block/qapi-sysemu.c b/block/qapi-sysemu.c | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/block/qapi-sysemu.c | ||
65 | +++ b/block/qapi-sysemu.c | ||
66 | @@ -XXX,XX +XXX,XX @@ void qmp_blockdev_change_medium(bool has_device, const char *device, | ||
67 | bool has_id, const char *id, | ||
68 | const char *filename, | ||
69 | bool has_format, const char *format, | ||
70 | + bool has_force, bool force, | ||
71 | bool has_read_only, | ||
72 | BlockdevChangeReadOnlyMode read_only, | ||
73 | Error **errp) | ||
74 | @@ -XXX,XX +XXX,XX @@ void qmp_blockdev_change_medium(bool has_device, const char *device, | ||
75 | |||
76 | rc = do_open_tray(has_device ? device : NULL, | ||
77 | has_id ? id : NULL, | ||
78 | - false, &err); | ||
79 | + force, &err); | ||
80 | if (rc && rc != -ENOSYS) { | ||
81 | error_propagate(errp, err); | ||
82 | goto fail; | ||
83 | diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c | ||
84 | index XXXXXXX..XXXXXXX 100644 | ||
85 | --- a/monitor/hmp-cmds.c | ||
86 | +++ b/monitor/hmp-cmds.c | ||
87 | @@ -XXX,XX +XXX,XX @@ void hmp_change(Monitor *mon, const QDict *qdict) | ||
88 | const char *target = qdict_get_str(qdict, "target"); | ||
89 | const char *arg = qdict_get_try_str(qdict, "arg"); | ||
90 | const char *read_only = qdict_get_try_str(qdict, "read-only-mode"); | ||
91 | + bool force = qdict_get_try_bool(qdict, "force", false); | ||
92 | BlockdevChangeReadOnlyMode read_only_mode = 0; | ||
93 | Error *err = NULL; | ||
94 | |||
95 | @@ -XXX,XX +XXX,XX @@ void hmp_change(Monitor *mon, const QDict *qdict) | ||
96 | } | ||
97 | |||
98 | qmp_blockdev_change_medium(true, device, false, NULL, target, | ||
99 | - !!arg, arg, !!read_only, read_only_mode, | ||
100 | + !!arg, arg, true, force, | ||
101 | + !!read_only, read_only_mode, | ||
102 | &err); | ||
103 | } | ||
104 | |||
105 | diff --git a/hmp-commands.hx b/hmp-commands.hx | ||
106 | index XXXXXXX..XXXXXXX 100644 | ||
107 | --- a/hmp-commands.hx | ||
108 | +++ b/hmp-commands.hx | ||
109 | @@ -XXX,XX +XXX,XX @@ ERST | ||
110 | |||
111 | { | ||
112 | .name = "change", | ||
113 | - .args_type = "device:B,target:F,arg:s?,read-only-mode:s?", | ||
114 | - .params = "device filename [format [read-only-mode]]", | ||
115 | - .help = "change a removable medium, optional format", | ||
116 | + .args_type = "device:B,force:-f,target:F,arg:s?,read-only-mode:s?", | ||
117 | + .params = "device [-f] filename [format [read-only-mode]]", | ||
118 | + .help = "change a removable medium, optional format, use -f to force the operation", | ||
119 | .cmd = hmp_change, | ||
120 | }, | ||
121 | |||
122 | @@ -XXX,XX +XXX,XX @@ SRST | ||
123 | ``change`` *device* *setting* | ||
124 | Change the configuration of a device. | ||
125 | |||
126 | - ``change`` *diskdevice* *filename* [*format* [*read-only-mode*]] | ||
127 | + ``change`` *diskdevice* [-f] *filename* [*format* [*read-only-mode*]] | ||
128 | Change the medium for a removable disk device to point to *filename*. eg:: | ||
129 | |||
130 | (qemu) change ide1-cd0 /path/to/some.iso | ||
131 | |||
132 | + ``-f`` | ||
133 | + forces the operation even if the guest has locked the tray. | ||
134 | + | ||
135 | *format* is optional. | ||
136 | |||
137 | *read-only-mode* may be used to change the read-only status of the device. | ||
138 | diff --git a/ui/cocoa.m b/ui/cocoa.m | ||
139 | index XXXXXXX..XXXXXXX 100644 | ||
140 | --- a/ui/cocoa.m | ||
141 | +++ b/ui/cocoa.m | ||
142 | @@ -XXX,XX +XXX,XX @@ - (void)changeDeviceMedia:(id)sender | ||
143 | [file cStringUsingEncoding: | ||
144 | NSASCIIStringEncoding], | ||
145 | true, "raw", | ||
146 | + true, false, | ||
147 | false, 0, | ||
148 | &err); | ||
149 | }); | ||
30 | -- | 150 | -- |
31 | 2.9.4 | 151 | 2.35.1 |
32 | 152 | ||
33 | 153 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: John Snow <jsnow@redhat.com> | ||
1 | 2 | ||
3 | This makes these callsites a little simpler, but the real motivation is | ||
4 | a forthcoming commit will change the return type of qemu_io(), so removing | ||
5 | users of the return value now is helpful. | ||
6 | |||
7 | Signed-off-by: John Snow <jsnow@redhat.com> | ||
8 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
9 | Reviewed-by: Hanna Reitz <hreitz@redhat.com> | ||
10 | Message-Id: <20220418211504.943969-2-jsnow@redhat.com> | ||
11 | Signed-off-by: Hanna Reitz <hreitz@redhat.com> | ||
12 | --- | ||
13 | tests/qemu-iotests/242 | 6 +++--- | ||
14 | tests/qemu-iotests/255 | 4 +--- | ||
15 | tests/qemu-iotests/303 | 4 ++-- | ||
16 | 3 files changed, 6 insertions(+), 8 deletions(-) | ||
17 | |||
18 | diff --git a/tests/qemu-iotests/242 b/tests/qemu-iotests/242 | ||
19 | index XXXXXXX..XXXXXXX 100755 | ||
20 | --- a/tests/qemu-iotests/242 | ||
21 | +++ b/tests/qemu-iotests/242 | ||
22 | @@ -XXX,XX +XXX,XX @@ | ||
23 | import iotests | ||
24 | import json | ||
25 | import struct | ||
26 | -from iotests import qemu_img_create, qemu_io, qemu_img_info, \ | ||
27 | - file_path, img_info_log, log, filter_qemu_io | ||
28 | +from iotests import qemu_img_create, qemu_io_log, qemu_img_info, \ | ||
29 | + file_path, img_info_log, log | ||
30 | |||
31 | iotests.script_initialize(supported_fmts=['qcow2'], | ||
32 | supported_protocols=['file'], | ||
33 | @@ -XXX,XX +XXX,XX @@ def add_bitmap(bitmap_number, persistent, disabled): | ||
34 | |||
35 | def write_to_disk(offset, size): | ||
36 | write = 'write {} {}'.format(offset, size) | ||
37 | - log(qemu_io('-c', write, disk), filters=[filter_qemu_io]) | ||
38 | + qemu_io_log('-c', write, disk) | ||
39 | |||
40 | |||
41 | def toggle_flag(offset): | ||
42 | diff --git a/tests/qemu-iotests/255 b/tests/qemu-iotests/255 | ||
43 | index XXXXXXX..XXXXXXX 100755 | ||
44 | --- a/tests/qemu-iotests/255 | ||
45 | +++ b/tests/qemu-iotests/255 | ||
46 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('src.qcow2') as src_path, \ | ||
47 | iotests.qemu_img_create('-f', iotests.imgfmt, src_path, size_str) | ||
48 | iotests.qemu_img_create('-f', iotests.imgfmt, dst_path, size_str) | ||
49 | |||
50 | - iotests.log(iotests.qemu_io('-f', iotests.imgfmt, '-c', 'write 0 1M', | ||
51 | - src_path), | ||
52 | - filters=[iotests.filter_test_dir, iotests.filter_qemu_io]) | ||
53 | + iotests.qemu_io_log('-f', iotests.imgfmt, '-c', 'write 0 1M', src_path), | ||
54 | |||
55 | vm.add_object('throttle-group,x-bps-read=4096,id=throttle0') | ||
56 | |||
57 | diff --git a/tests/qemu-iotests/303 b/tests/qemu-iotests/303 | ||
58 | index XXXXXXX..XXXXXXX 100755 | ||
59 | --- a/tests/qemu-iotests/303 | ||
60 | +++ b/tests/qemu-iotests/303 | ||
61 | @@ -XXX,XX +XXX,XX @@ | ||
62 | |||
63 | import iotests | ||
64 | import subprocess | ||
65 | -from iotests import qemu_img_create, qemu_io, file_path, log, filter_qemu_io, \ | ||
66 | +from iotests import qemu_img_create, qemu_io_log, file_path, log, \ | ||
67 | verify_qcow2_zstd_compression | ||
68 | |||
69 | iotests.script_initialize(supported_fmts=['qcow2'], | ||
70 | @@ -XXX,XX +XXX,XX @@ def create_bitmap(bitmap_number, disabled): | ||
71 | |||
72 | def write_to_disk(offset, size): | ||
73 | write = f'write {offset} {size}' | ||
74 | - log(qemu_io('-c', write, disk), filters=[filter_qemu_io]) | ||
75 | + qemu_io_log('-c', write, disk) | ||
76 | |||
77 | |||
78 | def add_bitmap(num, begin, end, disabled): | ||
79 | -- | ||
80 | 2.35.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: John Snow <jsnow@redhat.com> | ||
1 | 2 | ||
3 | The 'read' commands to qemu-io were malformed, and this invocation only | ||
4 | worked by coincidence because the error messages were identical. Oops. | ||
5 | |||
6 | There's no point in checking the patterning of the reference image, so | ||
7 | just check the empty image by itself instead. | ||
8 | |||
9 | (Note: as of this commit, nothing actually enforces that this command | ||
10 | completes successfully, but a forthcoming commit in this series will | ||
11 | enforce that qemu_io() must have a zero status code.) | ||
12 | |||
13 | Signed-off-by: John Snow <jsnow@redhat.com> | ||
14 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
15 | Reviewed-by: Hanna Reitz <hreitz@redhat.com> | ||
16 | Message-Id: <20220418211504.943969-3-jsnow@redhat.com> | ||
17 | Signed-off-by: Hanna Reitz <hreitz@redhat.com> | ||
18 | --- | ||
19 | tests/qemu-iotests/163 | 5 +---- | ||
20 | 1 file changed, 1 insertion(+), 4 deletions(-) | ||
21 | |||
22 | diff --git a/tests/qemu-iotests/163 b/tests/qemu-iotests/163 | ||
23 | index XXXXXXX..XXXXXXX 100755 | ||
24 | --- a/tests/qemu-iotests/163 | ||
25 | +++ b/tests/qemu-iotests/163 | ||
26 | @@ -XXX,XX +XXX,XX @@ class ShrinkBaseClass(iotests.QMPTestCase): | ||
27 | qemu_img('resize', '-f', iotests.imgfmt, '--shrink', test_img, | ||
28 | self.shrink_size) | ||
29 | |||
30 | - self.assertEqual( | ||
31 | - qemu_io('-c', 'read -P 0x00 %s'%self.shrink_size, test_img), | ||
32 | - qemu_io('-c', 'read -P 0x00 %s'%self.shrink_size, check_img), | ||
33 | - "Verifying image content") | ||
34 | + qemu_io('-c', f"read -P 0x00 0 {self.shrink_size}", test_img) | ||
35 | |||
36 | self.image_verify() | ||
37 | |||
38 | -- | ||
39 | 2.35.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: John Snow <jsnow@redhat.com> | ||
1 | 2 | ||
3 | A forthcoming commit updates qemu_io() to raise an exception on non-zero | ||
4 | return by default, and changes its return type. | ||
5 | |||
6 | In preparation, simplify some calls to qemu_io() that assert that | ||
7 | specific error message strings do not appear in qemu-io's | ||
8 | output. Asserting that all of these calls return a status code of zero | ||
9 | will be a more robust way to guard against failure. | ||
10 | |||
11 | Signed-off-by: John Snow <jsnow@redhat.com> | ||
12 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
13 | Reviewed-by: Hanna Reitz <hreitz@redhat.com> | ||
14 | Message-Id: <20220418211504.943969-4-jsnow@redhat.com> | ||
15 | Signed-off-by: Hanna Reitz <hreitz@redhat.com> | ||
16 | --- | ||
17 | tests/qemu-iotests/040 | 33 ++++++++++++++++----------------- | ||
18 | tests/qemu-iotests/056 | 2 +- | ||
19 | 2 files changed, 17 insertions(+), 18 deletions(-) | ||
20 | |||
21 | diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040 | ||
22 | index XXXXXXX..XXXXXXX 100755 | ||
23 | --- a/tests/qemu-iotests/040 | ||
24 | +++ b/tests/qemu-iotests/040 | ||
25 | @@ -XXX,XX +XXX,XX @@ class TestSingleDrive(ImageCommitTestCase): | ||
26 | |||
27 | def test_commit(self): | ||
28 | self.run_commit_test(mid_img, backing_img) | ||
29 | - self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img).find("verification failed")) | ||
30 | - self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img).find("verification failed")) | ||
31 | + qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img) | ||
32 | + qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img) | ||
33 | |||
34 | def test_commit_node(self): | ||
35 | self.run_commit_test("mid", "base", node_names=True) | ||
36 | - self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img).find("verification failed")) | ||
37 | - self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img).find("verification failed")) | ||
38 | + qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img) | ||
39 | + qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img) | ||
40 | |||
41 | @iotests.skip_if_unsupported(['throttle']) | ||
42 | def test_commit_with_filter_and_quit(self): | ||
43 | @@ -XXX,XX +XXX,XX @@ class TestSingleDrive(ImageCommitTestCase): | ||
44 | |||
45 | def test_top_is_active(self): | ||
46 | self.run_commit_test(test_img, backing_img, need_ready=True) | ||
47 | - self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img).find("verification failed")) | ||
48 | - self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img).find("verification failed")) | ||
49 | + qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img) | ||
50 | + qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img) | ||
51 | |||
52 | def test_top_is_default_active(self): | ||
53 | self.run_default_commit_test() | ||
54 | - self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img).find("verification failed")) | ||
55 | - self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img).find("verification failed")) | ||
56 | + qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img) | ||
57 | + qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img) | ||
58 | |||
59 | def test_top_and_base_reversed(self): | ||
60 | self.assert_no_active_block_jobs() | ||
61 | @@ -XXX,XX +XXX,XX @@ class TestRelativePaths(ImageCommitTestCase): | ||
62 | |||
63 | def test_commit(self): | ||
64 | self.run_commit_test(self.mid_img, self.backing_img) | ||
65 | - self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', self.backing_img_abs).find("verification failed")) | ||
66 | - self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', self.backing_img_abs).find("verification failed")) | ||
67 | + qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', self.backing_img_abs) | ||
68 | + qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', self.backing_img_abs) | ||
69 | |||
70 | def test_device_not_found(self): | ||
71 | result = self.vm.qmp('block-commit', device='nonexistent', top='%s' % self.mid_img) | ||
72 | @@ -XXX,XX +XXX,XX @@ class TestRelativePaths(ImageCommitTestCase): | ||
73 | |||
74 | def test_top_is_active(self): | ||
75 | self.run_commit_test(self.test_img, self.backing_img) | ||
76 | - self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', self.backing_img_abs).find("verification failed")) | ||
77 | - self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', self.backing_img_abs).find("verification failed")) | ||
78 | + qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', self.backing_img_abs) | ||
79 | + qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', self.backing_img_abs) | ||
80 | |||
81 | def test_top_and_base_reversed(self): | ||
82 | self.assert_no_active_block_jobs() | ||
83 | @@ -XXX,XX +XXX,XX @@ class TestCommitWithFilters(iotests.QMPTestCase): | ||
84 | |||
85 | def do_test_io(self, read_or_write): | ||
86 | for index, pattern_file in enumerate(self.pattern_files): | ||
87 | - result = qemu_io('-f', iotests.imgfmt, | ||
88 | - '-c', | ||
89 | - f'{read_or_write} -P {index + 1} {index}M 1M', | ||
90 | - pattern_file) | ||
91 | - self.assertFalse('Pattern verification failed' in result) | ||
92 | + qemu_io('-f', iotests.imgfmt, | ||
93 | + '-c', | ||
94 | + f'{read_or_write} -P {index + 1} {index}M 1M', | ||
95 | + pattern_file) | ||
96 | |||
97 | @iotests.skip_if_unsupported(['throttle']) | ||
98 | def setUp(self): | ||
99 | diff --git a/tests/qemu-iotests/056 b/tests/qemu-iotests/056 | ||
100 | index XXXXXXX..XXXXXXX 100755 | ||
101 | --- a/tests/qemu-iotests/056 | ||
102 | +++ b/tests/qemu-iotests/056 | ||
103 | @@ -XXX,XX +XXX,XX @@ class TestSyncModesNoneAndTop(iotests.QMPTestCase): | ||
104 | |||
105 | self.vm.shutdown() | ||
106 | time.sleep(1) | ||
107 | - self.assertEqual(-1, qemu_io('-c', 'read -P0x41 0 512', target_img).find("verification failed")) | ||
108 | + qemu_io('-c', 'read -P0x41 0 512', target_img) | ||
109 | |||
110 | class TestBeforeWriteNotifier(iotests.QMPTestCase): | ||
111 | def setUp(self): | ||
112 | -- | ||
113 | 2.35.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: John Snow <jsnow@redhat.com> | ||
1 | 2 | ||
3 | qemu-io fails on read/write beyond end-of-file on raw images, so skip | ||
4 | these invocations when running the zero-length image tests. | ||
5 | |||
6 | Signed-off-by: John Snow <jsnow@redhat.com> | ||
7 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
8 | Reviewed-by: Hanna Reitz <hreitz@redhat.com> | ||
9 | Message-Id: <20220418211504.943969-5-jsnow@redhat.com> | ||
10 | Signed-off-by: Hanna Reitz <hreitz@redhat.com> | ||
11 | --- | ||
12 | tests/qemu-iotests/040 | 14 ++++++++++++-- | ||
13 | 1 file changed, 12 insertions(+), 2 deletions(-) | ||
14 | |||
15 | diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040 | ||
16 | index XXXXXXX..XXXXXXX 100755 | ||
17 | --- a/tests/qemu-iotests/040 | ||
18 | +++ b/tests/qemu-iotests/040 | ||
19 | @@ -XXX,XX +XXX,XX @@ class TestSingleDrive(ImageCommitTestCase): | ||
20 | qemu_img('create', '-f', iotests.imgfmt, | ||
21 | '-o', 'backing_file=%s' % mid_img, | ||
22 | '-F', iotests.imgfmt, test_img) | ||
23 | - qemu_io('-f', 'raw', '-c', 'write -P 0xab 0 524288', backing_img) | ||
24 | - qemu_io('-f', iotests.imgfmt, '-c', 'write -P 0xef 524288 524288', mid_img) | ||
25 | + if self.image_len: | ||
26 | + qemu_io('-f', 'raw', '-c', 'write -P 0xab 0 524288', backing_img) | ||
27 | + qemu_io('-f', iotests.imgfmt, '-c', 'write -P 0xef 524288 524288', | ||
28 | + mid_img) | ||
29 | self.vm = iotests.VM().add_drive(test_img, "node-name=top,backing.node-name=mid,backing.backing.node-name=base", interface="none") | ||
30 | self.vm.add_device('virtio-scsi') | ||
31 | self.vm.add_device("scsi-hd,id=scsi0,drive=drive0") | ||
32 | @@ -XXX,XX +XXX,XX @@ class TestSingleDrive(ImageCommitTestCase): | ||
33 | |||
34 | def test_commit(self): | ||
35 | self.run_commit_test(mid_img, backing_img) | ||
36 | + if not self.image_len: | ||
37 | + return | ||
38 | qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img) | ||
39 | qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img) | ||
40 | |||
41 | def test_commit_node(self): | ||
42 | self.run_commit_test("mid", "base", node_names=True) | ||
43 | + if not self.image_len: | ||
44 | + return | ||
45 | qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img) | ||
46 | qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img) | ||
47 | |||
48 | @@ -XXX,XX +XXX,XX @@ class TestSingleDrive(ImageCommitTestCase): | ||
49 | |||
50 | def test_top_is_active(self): | ||
51 | self.run_commit_test(test_img, backing_img, need_ready=True) | ||
52 | + if not self.image_len: | ||
53 | + return | ||
54 | qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img) | ||
55 | qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img) | ||
56 | |||
57 | def test_top_is_default_active(self): | ||
58 | self.run_default_commit_test() | ||
59 | + if not self.image_len: | ||
60 | + return | ||
61 | qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img) | ||
62 | qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img) | ||
63 | |||
64 | -- | ||
65 | 2.35.1 | diff view generated by jsdifflib |
1 | From: Alistair Francis <alistair.francis@xilinx.com> | 1 | From: John Snow <jsnow@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Alistair Francis <alistair.francis@xilinx.com> | 3 | Without this change, asserting that qemu_io always returns 0 causes this |
4 | Acked-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 4 | test to fail in a way we happened not to be catching previously: |
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 5 | |
6 | Message-id: 9307b70e9876c4e9e3c4478524a32a23a3d5dd05.1499368180.git.alistair.francis@xilinx.com | 6 | qemu.utils.VerboseProcessError: Command |
7 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 7 | '('/home/jsnow/src/qemu/bin/git/tests/qemu-iotests/../../qemu-io', |
8 | '--cache', 'writeback', '--aio', 'threads', '-f', 'qcow2', '-c', | ||
9 | 'read -P 4 3M 1M', | ||
10 | '/home/jsnow/src/qemu/bin/git/tests/qemu-iotests/scratch/3.img')' | ||
11 | returned non-zero exit status 1. | ||
12 | ┏━ output ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
13 | ┃ qemu-io: can't open device | ||
14 | ┃ /home/jsnow/src/qemu/bin/git/tests/qemu-iotests/scratch/3.img: | ||
15 | ┃ Could not open backing file: Could not open backing file: Throttle | ||
16 | ┃ group 'tg' does not exist | ||
17 | ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
18 | |||
19 | The commit jobs changes the backing file string stored in the image file | ||
20 | header belonging to the node above the commit’s top node to point to the | ||
21 | commit target (the base node). QEMU tries to be as accurate as | ||
22 | possible, and so in these test cases will include the filter that is | ||
23 | part of the block graph in that backing file string (by virtue of making | ||
24 | it a json:{} description of the post-commit subgraph). This makes | ||
25 | little sense outside of QEMU, though: Specifically, the throttle node in | ||
26 | that subgraph will dearly miss its supposedly associated throttle group | ||
27 | object. | ||
28 | |||
29 | When starting the commit job, we can specify a custom backing file | ||
30 | string to write into said image file, so let’s use that feature to write | ||
31 | the plain filename of the backing chain’s next actual image file there. | ||
32 | |||
33 | Explicitly provide the backing file so that opening the file outside of | ||
34 | QEMU (Where we will not have throttle groups) will succeed. | ||
35 | |||
36 | Signed-off-by: Hanna Reitz <hreitz@redhat.com> | ||
37 | Signed-off-by: John Snow <jsnow@redhat.com> | ||
38 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
39 | Message-Id: <20220418211504.943969-6-jsnow@redhat.com> | ||
8 | --- | 40 | --- |
9 | util/aio-win32.c | 13 ++++++++++--- | 41 | tests/qemu-iotests/040 | 6 ++++-- |
10 | 1 file changed, 10 insertions(+), 3 deletions(-) | 42 | 1 file changed, 4 insertions(+), 2 deletions(-) |
11 | 43 | ||
12 | diff --git a/util/aio-win32.c b/util/aio-win32.c | 44 | diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040 |
13 | index XXXXXXX..XXXXXXX 100644 | 45 | index XXXXXXX..XXXXXXX 100755 |
14 | --- a/util/aio-win32.c | 46 | --- a/tests/qemu-iotests/040 |
15 | +++ b/util/aio-win32.c | 47 | +++ b/tests/qemu-iotests/040 |
16 | @@ -XXX,XX +XXX,XX @@ void aio_set_fd_handler(AioContext *ctx, | 48 | @@ -XXX,XX +XXX,XX @@ class TestCommitWithFilters(iotests.QMPTestCase): |
17 | } | 49 | job_id='commit', |
18 | } else { | 50 | device='top-filter', |
19 | HANDLE event; | 51 | top_node='cow-2', |
20 | + long bitmask = 0; | 52 | - base_node='cow-1') |
21 | 53 | + base_node='cow-1', | |
22 | if (node == NULL) { | 54 | + backing_file=self.img1) |
23 | /* Alloc and insert if it's not already there */ | 55 | self.assert_qmp(result, 'return', {}) |
24 | @@ -XXX,XX +XXX,XX @@ void aio_set_fd_handler(AioContext *ctx, | 56 | self.wait_until_completed(drive='commit') |
25 | node->io_write = io_write; | 57 | |
26 | node->is_external = is_external; | 58 | @@ -XXX,XX +XXX,XX @@ class TestCommitWithFilters(iotests.QMPTestCase): |
27 | 59 | job_id='commit', | |
28 | + if (io_read) { | 60 | device='top-filter', |
29 | + bitmask |= FD_READ | FD_ACCEPT | FD_CLOSE; | 61 | top_node='cow-1', |
30 | + } | 62 | - base_node='cow-0') |
31 | + | 63 | + base_node='cow-0', |
32 | + if (io_write) { | 64 | + backing_file=self.img0) |
33 | + bitmask |= FD_WRITE | FD_CONNECT; | 65 | self.assert_qmp(result, 'return', {}) |
34 | + } | 66 | self.wait_until_completed(drive='commit') |
35 | + | 67 | |
36 | event = event_notifier_get_handle(&ctx->notifier); | ||
37 | - WSAEventSelect(node->pfd.fd, event, | ||
38 | - FD_READ | FD_ACCEPT | FD_CLOSE | | ||
39 | - FD_CONNECT | FD_WRITE | FD_OOB); | ||
40 | + WSAEventSelect(node->pfd.fd, event, bitmask); | ||
41 | } | ||
42 | |||
43 | qemu_lockcnt_unlock(&ctx->list_lock); | ||
44 | -- | 68 | -- |
45 | 2.9.4 | 69 | 2.35.1 |
46 | 70 | ||
47 | 71 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: John Snow <jsnow@redhat.com> | ||
1 | 2 | ||
3 | reimplement qemu_img() in terms of qemu_tool() in preparation for doing | ||
4 | the same with qemu_io(). | ||
5 | |||
6 | Signed-off-by: John Snow <jsnow@redhat.com> | ||
7 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
8 | Reviewed-by: Hanna Reitz <hreitz@redhat.com> | ||
9 | Message-Id: <20220418211504.943969-7-jsnow@redhat.com> | ||
10 | Signed-off-by: Hanna Reitz <hreitz@redhat.com> | ||
11 | --- | ||
12 | tests/qemu-iotests/iotests.py | 32 +++++++++++++++++++++----------- | ||
13 | 1 file changed, 21 insertions(+), 11 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 | |||
21 | return result | ||
22 | |||
23 | -def qemu_img(*args: str, check: bool = True, combine_stdio: bool = True | ||
24 | - ) -> 'subprocess.CompletedProcess[str]': | ||
25 | - """ | ||
26 | - Run qemu_img and return the status code and console output. | ||
27 | |||
28 | - This function always prepends QEMU_IMG_OPTIONS and may further alter | ||
29 | - the args for 'create' commands. | ||
30 | +def qemu_tool(*args: str, check: bool = True, combine_stdio: bool = True | ||
31 | + ) -> 'subprocess.CompletedProcess[str]': | ||
32 | + """ | ||
33 | + Run a qemu tool and return its status code and console output. | ||
34 | |||
35 | - :param args: command-line arguments to qemu-img. | ||
36 | + :param args: full command line to run. | ||
37 | :param check: Enforce a return code of zero. | ||
38 | :param combine_stdio: set to False to keep stdout/stderr separated. | ||
39 | |||
40 | @@ -XXX,XX +XXX,XX @@ def qemu_img(*args: str, check: bool = True, combine_stdio: bool = True | ||
41 | properties. If streams are not combined, it will also have a | ||
42 | stderr property. | ||
43 | """ | ||
44 | - full_args = qemu_img_args + qemu_img_create_prepare_args(list(args)) | ||
45 | - | ||
46 | subp = subprocess.run( | ||
47 | - full_args, | ||
48 | + args, | ||
49 | stdout=subprocess.PIPE, | ||
50 | stderr=subprocess.STDOUT if combine_stdio else subprocess.PIPE, | ||
51 | universal_newlines=True, | ||
52 | @@ -XXX,XX +XXX,XX @@ def qemu_img(*args: str, check: bool = True, combine_stdio: bool = True | ||
53 | |||
54 | if check and subp.returncode or (subp.returncode < 0): | ||
55 | raise VerboseProcessError( | ||
56 | - subp.returncode, full_args, | ||
57 | + subp.returncode, args, | ||
58 | output=subp.stdout, | ||
59 | stderr=subp.stderr, | ||
60 | ) | ||
61 | @@ -XXX,XX +XXX,XX @@ def qemu_img(*args: str, check: bool = True, combine_stdio: bool = True | ||
62 | return subp | ||
63 | |||
64 | |||
65 | +def qemu_img(*args: str, check: bool = True, combine_stdio: bool = True | ||
66 | + ) -> 'subprocess.CompletedProcess[str]': | ||
67 | + """ | ||
68 | + Run QEMU_IMG_PROG and return its status code and console output. | ||
69 | + | ||
70 | + This function always prepends QEMU_IMG_OPTIONS and may further alter | ||
71 | + the args for 'create' commands. | ||
72 | + | ||
73 | + See `qemu_tool()` for greater detail. | ||
74 | + """ | ||
75 | + full_args = qemu_img_args + qemu_img_create_prepare_args(list(args)) | ||
76 | + return qemu_tool(*full_args, check=check, combine_stdio=combine_stdio) | ||
77 | + | ||
78 | + | ||
79 | def ordered_qmp(qmsg, conv_keys=True): | ||
80 | # Dictionaries are not ordered prior to 3.6, therefore: | ||
81 | if isinstance(qmsg, list): | ||
82 | -- | ||
83 | 2.35.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: John Snow <jsnow@redhat.com> | |
2 | |||
3 | Rework qemu_io() to be analogous to qemu_img(); a function that requires | ||
4 | a return code of zero by default unless disabled explicitly. | ||
5 | |||
6 | Tests that use qemu_io(): | ||
7 | 030 040 041 044 055 056 093 124 129 132 136 148 149 151 152 163 165 205 | ||
8 | 209 219 236 245 248 254 255 257 260 264 280 298 300 302 304 | ||
9 | image-fleecing migrate-bitmaps-postcopy-test migrate-bitmaps-test | ||
10 | migrate-during-backup migration-permissions | ||
11 | |||
12 | Test that use qemu_io_log(): | ||
13 | 242 245 255 274 303 307 nbd-reconnect-on-open | ||
14 | |||
15 | Copy-pastables for testing/verification: | ||
16 | |||
17 | ./check -qcow2 030 040 041 044 055 056 124 129 132 151 152 163 165 209 \ | ||
18 | 219 236 242 245 248 254 255 257 260 264 274 \ | ||
19 | 280 298 300 302 303 304 307 image-fleecing \ | ||
20 | migrate-bitmaps-postcopy-test migrate-bitmaps-test \ | ||
21 | migrate-during-backup nbd-reconnect-on-open | ||
22 | ./check -raw 093 136 148 migration-permissions | ||
23 | ./check -nbd 205 | ||
24 | |||
25 | # ./configure configure --disable-gnutls --enable-gcrypt | ||
26 | # this ALSO requires passwordless sudo. | ||
27 | ./check -luks 149 | ||
28 | |||
29 | # Just the tests that were edited in this commit: | ||
30 | ./check -qcow2 030 040 242 245 | ||
31 | ./check -raw migration-permissions | ||
32 | ./check -nbd 205 | ||
33 | ./check -luks 149 | ||
34 | |||
35 | Signed-off-by: John Snow <jsnow@redhat.com> | ||
36 | Message-Id: <20220418211504.943969-8-jsnow@redhat.com> | ||
37 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
38 | Signed-off-by: Hanna Reitz <hreitz@redhat.com> | ||
39 | --- | ||
40 | tests/qemu-iotests/030 | 85 +++++++++++-------- | ||
41 | tests/qemu-iotests/149 | 6 +- | ||
42 | tests/qemu-iotests/205 | 4 +- | ||
43 | tests/qemu-iotests/245 | 17 ++-- | ||
44 | tests/qemu-iotests/iotests.py | 19 +++-- | ||
45 | .../qemu-iotests/tests/migration-permissions | 4 +- | ||
46 | 6 files changed, 81 insertions(+), 54 deletions(-) | ||
47 | |||
48 | diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030 | ||
49 | index XXXXXXX..XXXXXXX 100755 | ||
50 | --- a/tests/qemu-iotests/030 | ||
51 | +++ b/tests/qemu-iotests/030 | ||
52 | @@ -XXX,XX +XXX,XX @@ class TestSingleDrive(iotests.QMPTestCase): | ||
53 | self.assert_no_active_block_jobs() | ||
54 | self.vm.shutdown() | ||
55 | |||
56 | - self.assertEqual(qemu_io('-f', 'raw', '-c', 'map', backing_img), | ||
57 | - qemu_io('-f', iotests.imgfmt, '-c', 'map', test_img), | ||
58 | - 'image file map does not match backing file after streaming') | ||
59 | + self.assertEqual( | ||
60 | + qemu_io('-f', 'raw', '-c', 'map', backing_img).stdout, | ||
61 | + qemu_io('-f', iotests.imgfmt, '-c', 'map', test_img).stdout, | ||
62 | + 'image file map does not match backing file after streaming') | ||
63 | |||
64 | def test_stream_intermediate(self): | ||
65 | self.assert_no_active_block_jobs() | ||
66 | |||
67 | - self.assertNotEqual(qemu_io('-f', 'raw', '-rU', '-c', 'map', backing_img), | ||
68 | - qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', mid_img), | ||
69 | - 'image file map matches backing file before streaming') | ||
70 | + self.assertNotEqual( | ||
71 | + qemu_io('-f', 'raw', '-rU', '-c', 'map', backing_img).stdout, | ||
72 | + qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', mid_img).stdout, | ||
73 | + 'image file map matches backing file before streaming') | ||
74 | |||
75 | result = self.vm.qmp('block-stream', device='mid', job_id='stream-mid') | ||
76 | self.assert_qmp(result, 'return', {}) | ||
77 | @@ -XXX,XX +XXX,XX @@ class TestSingleDrive(iotests.QMPTestCase): | ||
78 | self.assert_no_active_block_jobs() | ||
79 | self.vm.shutdown() | ||
80 | |||
81 | - self.assertEqual(qemu_io('-f', 'raw', '-c', 'map', backing_img), | ||
82 | - qemu_io('-f', iotests.imgfmt, '-c', 'map', mid_img), | ||
83 | - 'image file map does not match backing file after streaming') | ||
84 | + self.assertEqual( | ||
85 | + qemu_io('-f', 'raw', '-c', 'map', backing_img).stdout, | ||
86 | + qemu_io('-f', iotests.imgfmt, '-c', 'map', mid_img).stdout, | ||
87 | + 'image file map does not match backing file after streaming') | ||
88 | |||
89 | def test_stream_pause(self): | ||
90 | self.assert_no_active_block_jobs() | ||
91 | @@ -XXX,XX +XXX,XX @@ class TestSingleDrive(iotests.QMPTestCase): | ||
92 | self.assert_no_active_block_jobs() | ||
93 | self.vm.shutdown() | ||
94 | |||
95 | - self.assertEqual(qemu_io('-f', 'raw', '-c', 'map', backing_img), | ||
96 | - qemu_io('-f', iotests.imgfmt, '-c', 'map', test_img), | ||
97 | - 'image file map does not match backing file after streaming') | ||
98 | + self.assertEqual( | ||
99 | + qemu_io('-f', 'raw', '-c', 'map', backing_img).stdout, | ||
100 | + qemu_io('-f', iotests.imgfmt, '-c', 'map', test_img).stdout, | ||
101 | + 'image file map does not match backing file after streaming') | ||
102 | |||
103 | def test_stream_no_op(self): | ||
104 | self.assert_no_active_block_jobs() | ||
105 | |||
106 | # The image map is empty before the operation | ||
107 | - empty_map = qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', test_img) | ||
108 | + empty_map = qemu_io( | ||
109 | + '-f', iotests.imgfmt, '-rU', '-c', 'map', test_img).stdout | ||
110 | |||
111 | # This is a no-op: no data should ever be copied from the base image | ||
112 | result = self.vm.qmp('block-stream', device='drive0', base=mid_img) | ||
113 | @@ -XXX,XX +XXX,XX @@ class TestSingleDrive(iotests.QMPTestCase): | ||
114 | self.assert_no_active_block_jobs() | ||
115 | self.vm.shutdown() | ||
116 | |||
117 | - self.assertEqual(qemu_io('-f', iotests.imgfmt, '-c', 'map', test_img), | ||
118 | - empty_map, 'image file map changed after a no-op') | ||
119 | + self.assertEqual( | ||
120 | + qemu_io('-f', iotests.imgfmt, '-c', 'map', test_img).stdout, | ||
121 | + empty_map, 'image file map changed after a no-op') | ||
122 | |||
123 | def test_stream_partial(self): | ||
124 | self.assert_no_active_block_jobs() | ||
125 | @@ -XXX,XX +XXX,XX @@ class TestSingleDrive(iotests.QMPTestCase): | ||
126 | self.assert_no_active_block_jobs() | ||
127 | self.vm.shutdown() | ||
128 | |||
129 | - self.assertEqual(qemu_io('-f', iotests.imgfmt, '-c', 'map', mid_img), | ||
130 | - qemu_io('-f', iotests.imgfmt, '-c', 'map', test_img), | ||
131 | - 'image file map does not match backing file after streaming') | ||
132 | + self.assertEqual( | ||
133 | + qemu_io('-f', iotests.imgfmt, '-c', 'map', mid_img).stdout, | ||
134 | + qemu_io('-f', iotests.imgfmt, '-c', 'map', test_img).stdout, | ||
135 | + 'image file map does not match backing file after streaming') | ||
136 | |||
137 | def test_device_not_found(self): | ||
138 | result = self.vm.qmp('block-stream', device='nonexistent') | ||
139 | @@ -XXX,XX +XXX,XX @@ class TestParallelOps(iotests.QMPTestCase): | ||
140 | |||
141 | # Check that the maps don't match before the streaming operations | ||
142 | for i in range(2, self.num_imgs, 2): | ||
143 | - self.assertNotEqual(qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.imgs[i]), | ||
144 | - qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.imgs[i-1]), | ||
145 | - 'image file map matches backing file before streaming') | ||
146 | + self.assertNotEqual( | ||
147 | + qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.imgs[i]).stdout, | ||
148 | + qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.imgs[i-1]).stdout, | ||
149 | + 'image file map matches backing file before streaming') | ||
150 | |||
151 | # Create all streaming jobs | ||
152 | pending_jobs = [] | ||
153 | @@ -XXX,XX +XXX,XX @@ class TestParallelOps(iotests.QMPTestCase): | ||
154 | |||
155 | # Check that all maps match now | ||
156 | for i in range(2, self.num_imgs, 2): | ||
157 | - self.assertEqual(qemu_io('-f', iotests.imgfmt, '-c', 'map', self.imgs[i]), | ||
158 | - qemu_io('-f', iotests.imgfmt, '-c', 'map', self.imgs[i-1]), | ||
159 | - 'image file map does not match backing file after streaming') | ||
160 | + self.assertEqual( | ||
161 | + qemu_io('-f', iotests.imgfmt, '-c', 'map', self.imgs[i]).stdout, | ||
162 | + qemu_io('-f', iotests.imgfmt, '-c', 'map', self.imgs[i-1]).stdout, | ||
163 | + 'image file map does not match backing file after streaming') | ||
164 | |||
165 | # Test that it's not possible to perform two block-stream | ||
166 | # operations if there are nodes involved in both. | ||
167 | @@ -XXX,XX +XXX,XX @@ class TestParallelOps(iotests.QMPTestCase): | ||
168 | def test_stream_base_node_name(self): | ||
169 | self.assert_no_active_block_jobs() | ||
170 | |||
171 | - self.assertNotEqual(qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.imgs[4]), | ||
172 | - qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.imgs[3]), | ||
173 | - 'image file map matches backing file before streaming') | ||
174 | + self.assertNotEqual( | ||
175 | + qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.imgs[4]).stdout, | ||
176 | + qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.imgs[3]).stdout, | ||
177 | + 'image file map matches backing file before streaming') | ||
178 | |||
179 | # Error: the base node does not exist | ||
180 | result = self.vm.qmp('block-stream', device='node4', base_node='none', job_id='stream') | ||
181 | @@ -XXX,XX +XXX,XX @@ class TestParallelOps(iotests.QMPTestCase): | ||
182 | self.assert_no_active_block_jobs() | ||
183 | self.vm.shutdown() | ||
184 | |||
185 | - self.assertEqual(qemu_io('-f', iotests.imgfmt, '-c', 'map', self.imgs[4]), | ||
186 | - qemu_io('-f', iotests.imgfmt, '-c', 'map', self.imgs[3]), | ||
187 | - 'image file map matches backing file after streaming') | ||
188 | + self.assertEqual( | ||
189 | + qemu_io('-f', iotests.imgfmt, '-c', 'map', self.imgs[4]).stdout, | ||
190 | + qemu_io('-f', iotests.imgfmt, '-c', 'map', self.imgs[3]).stdout, | ||
191 | + 'image file map matches backing file after streaming') | ||
192 | |||
193 | class TestQuorum(iotests.QMPTestCase): | ||
194 | num_children = 3 | ||
195 | @@ -XXX,XX +XXX,XX @@ class TestQuorum(iotests.QMPTestCase): | ||
196 | os.remove(img) | ||
197 | |||
198 | def test_stream_quorum(self): | ||
199 | - self.assertNotEqual(qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.children[0]), | ||
200 | - qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.backing[0]), | ||
201 | - 'image file map matches backing file before streaming') | ||
202 | + self.assertNotEqual( | ||
203 | + qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.children[0]).stdout, | ||
204 | + qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', self.backing[0]).stdout, | ||
205 | + 'image file map matches backing file before streaming') | ||
206 | |||
207 | self.assert_no_active_block_jobs() | ||
208 | |||
209 | @@ -XXX,XX +XXX,XX @@ class TestQuorum(iotests.QMPTestCase): | ||
210 | self.assert_no_active_block_jobs() | ||
211 | self.vm.shutdown() | ||
212 | |||
213 | - self.assertEqual(qemu_io('-f', iotests.imgfmt, '-c', 'map', self.children[0]), | ||
214 | - qemu_io('-f', iotests.imgfmt, '-c', 'map', self.backing[0]), | ||
215 | - 'image file map does not match backing file after streaming') | ||
216 | + self.assertEqual( | ||
217 | + qemu_io('-f', iotests.imgfmt, '-c', 'map', self.children[0]).stdout, | ||
218 | + qemu_io('-f', iotests.imgfmt, '-c', 'map', self.backing[0]).stdout, | ||
219 | + 'image file map does not match backing file after streaming') | ||
220 | |||
221 | class TestSmallerBackingFile(iotests.QMPTestCase): | ||
222 | backing_len = 1 * 1024 * 1024 # MB | ||
223 | diff --git a/tests/qemu-iotests/149 b/tests/qemu-iotests/149 | ||
224 | index XXXXXXX..XXXXXXX 100755 | ||
225 | --- a/tests/qemu-iotests/149 | ||
226 | +++ b/tests/qemu-iotests/149 | ||
227 | @@ -XXX,XX +XXX,XX @@ def qemu_io_write_pattern(config, pattern, offset_mb, size_mb, dev=False): | ||
228 | args = ["-c", "write -P 0x%x %dM %dM" % (pattern, offset_mb, size_mb)] | ||
229 | args.extend(qemu_io_image_args(config, dev)) | ||
230 | iotests.log("qemu-io " + " ".join(args), filters=[iotests.filter_test_dir]) | ||
231 | - iotests.log(check_cipher_support(config, iotests.qemu_io(*args)), | ||
232 | + output = iotests.qemu_io(*args, check=False).stdout | ||
233 | + iotests.log(check_cipher_support(config, output), | ||
234 | filters=[iotests.filter_test_dir, iotests.filter_qemu_io]) | ||
235 | |||
236 | |||
237 | @@ -XXX,XX +XXX,XX @@ def qemu_io_read_pattern(config, pattern, offset_mb, size_mb, dev=False): | ||
238 | args = ["-c", "read -P 0x%x %dM %dM" % (pattern, offset_mb, size_mb)] | ||
239 | args.extend(qemu_io_image_args(config, dev)) | ||
240 | iotests.log("qemu-io " + " ".join(args), filters=[iotests.filter_test_dir]) | ||
241 | - iotests.log(check_cipher_support(config, iotests.qemu_io(*args)), | ||
242 | + output = iotests.qemu_io(*args, check=False).stdout | ||
243 | + iotests.log(check_cipher_support(config, output), | ||
244 | filters=[iotests.filter_test_dir, iotests.filter_qemu_io]) | ||
245 | |||
246 | |||
247 | diff --git a/tests/qemu-iotests/205 b/tests/qemu-iotests/205 | ||
248 | index XXXXXXX..XXXXXXX 100755 | ||
249 | --- a/tests/qemu-iotests/205 | ||
250 | +++ b/tests/qemu-iotests/205 | ||
251 | @@ -XXX,XX +XXX,XX @@ class TestNbdServerRemove(iotests.QMPTestCase): | ||
252 | |||
253 | def do_test_connect_after_remove(self, mode=None): | ||
254 | args = ('-r', '-f', 'raw', '-c', 'read 0 512', nbd_uri) | ||
255 | - self.assertReadOk(qemu_io(*args)) | ||
256 | + self.assertReadOk(qemu_io(*args).stdout) | ||
257 | |||
258 | result = self.remove_export('exp', mode) | ||
259 | self.assert_qmp(result, 'return', {}) | ||
260 | |||
261 | self.assertExportNotFound('exp') | ||
262 | - self.assertConnectFailed(qemu_io(*args)) | ||
263 | + self.assertConnectFailed(qemu_io(*args, check=False).stdout) | ||
264 | |||
265 | def test_connect_after_remove_default(self): | ||
266 | self.do_test_connect_after_remove() | ||
267 | diff --git a/tests/qemu-iotests/245 b/tests/qemu-iotests/245 | ||
268 | index XXXXXXX..XXXXXXX 100755 | ||
269 | --- a/tests/qemu-iotests/245 | ||
270 | +++ b/tests/qemu-iotests/245 | ||
271 | @@ -XXX,XX +XXX,XX @@ | ||
272 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
273 | # | ||
274 | |||
275 | +import copy | ||
276 | +import json | ||
277 | import os | ||
278 | import re | ||
279 | +from subprocess import CalledProcessError | ||
280 | + | ||
281 | import iotests | ||
282 | -import copy | ||
283 | -import json | ||
284 | from iotests import qemu_img, qemu_io | ||
285 | |||
286 | hd_path = [ | ||
287 | @@ -XXX,XX +XXX,XX @@ class TestBlockdevReopen(iotests.QMPTestCase): | ||
288 | |||
289 | # Reopen an image several times changing some of its options | ||
290 | def test_reopen(self): | ||
291 | - # Check whether the filesystem supports O_DIRECT | ||
292 | - if 'O_DIRECT' in qemu_io('-f', 'raw', '-t', 'none', '-c', 'quit', hd_path[0]): | ||
293 | - supports_direct = False | ||
294 | - else: | ||
295 | + try: | ||
296 | + qemu_io('-f', 'raw', '-t', 'none', '-c', 'quit', hd_path[0]) | ||
297 | supports_direct = True | ||
298 | + except CalledProcessError as exc: | ||
299 | + if 'O_DIRECT' in exc.stdout: | ||
300 | + supports_direct = False | ||
301 | + else: | ||
302 | + raise | ||
303 | |||
304 | # Open the hd1 image passing all backing options | ||
305 | opts = hd_opts(1) | ||
306 | diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py | ||
307 | index XXXXXXX..XXXXXXX 100644 | ||
308 | --- a/tests/qemu-iotests/iotests.py | ||
309 | +++ b/tests/qemu-iotests/iotests.py | ||
310 | @@ -XXX,XX +XXX,XX @@ def qemu_io_wrap_args(args: Sequence[str]) -> List[str]: | ||
311 | def qemu_io_popen(*args): | ||
312 | return qemu_tool_popen(qemu_io_wrap_args(args)) | ||
313 | |||
314 | -def qemu_io(*args): | ||
315 | - '''Run qemu-io and return the stdout data''' | ||
316 | - return qemu_tool_pipe_and_status('qemu-io', qemu_io_wrap_args(args))[0] | ||
317 | +def qemu_io(*args: str, check: bool = True, combine_stdio: bool = True | ||
318 | + ) -> 'subprocess.CompletedProcess[str]': | ||
319 | + """ | ||
320 | + Run QEMU_IO_PROG and return the status code and console output. | ||
321 | + | ||
322 | + This function always prepends either QEMU_IO_OPTIONS or | ||
323 | + QEMU_IO_OPTIONS_NO_FMT. | ||
324 | + """ | ||
325 | + return qemu_tool(*qemu_io_wrap_args(args), | ||
326 | + check=check, combine_stdio=combine_stdio) | ||
327 | |||
328 | def qemu_io_pipe_and_status(*args): | ||
329 | return qemu_tool_pipe_and_status('qemu-io', qemu_io_wrap_args(args)) | ||
330 | |||
331 | -def qemu_io_log(*args): | ||
332 | - result = qemu_io(*args) | ||
333 | - log(result, filters=[filter_testfiles, filter_qemu_io]) | ||
334 | +def qemu_io_log(*args: str) -> 'subprocess.CompletedProcess[str]': | ||
335 | + result = qemu_io(*args, check=False) | ||
336 | + log(result.stdout, filters=[filter_testfiles, filter_qemu_io]) | ||
337 | return result | ||
338 | |||
339 | def qemu_io_silent(*args): | ||
340 | diff --git a/tests/qemu-iotests/tests/migration-permissions b/tests/qemu-iotests/tests/migration-permissions | ||
341 | index XXXXXXX..XXXXXXX 100755 | ||
342 | --- a/tests/qemu-iotests/tests/migration-permissions | ||
343 | +++ b/tests/qemu-iotests/tests/migration-permissions | ||
344 | @@ -XXX,XX +XXX,XX @@ class TestMigrationPermissions(iotests.QMPTestCase): | ||
345 | def test_post_migration_permissions(self): | ||
346 | # Try to access the image R/W, which should fail because virtio-blk | ||
347 | # has not been configured with share-rw=on | ||
348 | - log = qemu_io('-f', imgfmt, '-c', 'quit', test_img) | ||
349 | + log = qemu_io('-f', imgfmt, '-c', 'quit', test_img, check=False).stdout | ||
350 | if not log.strip(): | ||
351 | print('ERROR (pre-migration): qemu-io should not be able to ' | ||
352 | 'access this image, but it reported no error') | ||
353 | @@ -XXX,XX +XXX,XX @@ class TestMigrationPermissions(iotests.QMPTestCase): | ||
354 | |||
355 | # Try the same qemu-io access again, verifying that the WRITE | ||
356 | # permission remains unshared | ||
357 | - log = qemu_io('-f', imgfmt, '-c', 'quit', test_img) | ||
358 | + log = qemu_io('-f', imgfmt, '-c', 'quit', test_img, check=False).stdout | ||
359 | if not log.strip(): | ||
360 | print('ERROR (post-migration): qemu-io should not be able to ' | ||
361 | 'access this image, but it reported no error') | ||
362 | -- | ||
363 | 2.35.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: John Snow <jsnow@redhat.com> | ||
1 | 2 | ||
3 | Modify this test to use assertRaises for its negative testing of | ||
4 | qemu_io. If the exception raised does not match the one we tell it to | ||
5 | expect, we get *that* exception unhandled. If we get no exception, we | ||
6 | get a unittest assertion failure and the provided emsg printed to | ||
7 | screen. | ||
8 | |||
9 | If we get the CalledProcessError exception but the output is not what we | ||
10 | expect, we re-raise the original CalledProcessError. | ||
11 | |||
12 | Tidy. | ||
13 | |||
14 | (Note: Yes, you can reference "with" objects after that block ends; it | ||
15 | just means that ctx.__exit__(...) will have been called on it. It does | ||
16 | not *actually* go out of scope. unittests expects you to want to inspect | ||
17 | the Exception object, so they leave it defined post-exit.) | ||
18 | |||
19 | Signed-off-by: John Snow <jsnow@redhat.com> | ||
20 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
21 | Tested-by: Eric Blake <eblake@redhat.com> | ||
22 | Reviewed-by: Hanna Reitz <hreitz@redhat.com> | ||
23 | Message-Id: <20220418211504.943969-9-jsnow@redhat.com> | ||
24 | Signed-off-by: Hanna Reitz <hreitz@redhat.com> | ||
25 | --- | ||
26 | .../qemu-iotests/tests/migration-permissions | 28 +++++++++---------- | ||
27 | 1 file changed, 14 insertions(+), 14 deletions(-) | ||
28 | |||
29 | diff --git a/tests/qemu-iotests/tests/migration-permissions b/tests/qemu-iotests/tests/migration-permissions | ||
30 | index XXXXXXX..XXXXXXX 100755 | ||
31 | --- a/tests/qemu-iotests/tests/migration-permissions | ||
32 | +++ b/tests/qemu-iotests/tests/migration-permissions | ||
33 | @@ -XXX,XX +XXX,XX @@ | ||
34 | # | ||
35 | |||
36 | import os | ||
37 | +from subprocess import CalledProcessError | ||
38 | + | ||
39 | import iotests | ||
40 | from iotests import imgfmt, qemu_img_create, qemu_io | ||
41 | |||
42 | @@ -XXX,XX +XXX,XX @@ class TestMigrationPermissions(iotests.QMPTestCase): | ||
43 | def test_post_migration_permissions(self): | ||
44 | # Try to access the image R/W, which should fail because virtio-blk | ||
45 | # has not been configured with share-rw=on | ||
46 | - log = qemu_io('-f', imgfmt, '-c', 'quit', test_img, check=False).stdout | ||
47 | - if not log.strip(): | ||
48 | - print('ERROR (pre-migration): qemu-io should not be able to ' | ||
49 | - 'access this image, but it reported no error') | ||
50 | - else: | ||
51 | - # This is the expected output | ||
52 | - assert 'Is another process using the image' in log | ||
53 | + emsg = ('ERROR (pre-migration): qemu-io should not be able to ' | ||
54 | + 'access this image, but it reported no error') | ||
55 | + with self.assertRaises(CalledProcessError, msg=emsg) as ctx: | ||
56 | + qemu_io('-f', imgfmt, '-c', 'quit', test_img) | ||
57 | + if 'Is another process using the image' not in ctx.exception.stdout: | ||
58 | + raise ctx.exception | ||
59 | |||
60 | # Now migrate the VM | ||
61 | self.vm_s.qmp('migrate', uri=f'unix:{mig_sock}') | ||
62 | @@ -XXX,XX +XXX,XX @@ class TestMigrationPermissions(iotests.QMPTestCase): | ||
63 | |||
64 | # Try the same qemu-io access again, verifying that the WRITE | ||
65 | # permission remains unshared | ||
66 | - log = qemu_io('-f', imgfmt, '-c', 'quit', test_img, check=False).stdout | ||
67 | - if not log.strip(): | ||
68 | - print('ERROR (post-migration): qemu-io should not be able to ' | ||
69 | - 'access this image, but it reported no error') | ||
70 | - else: | ||
71 | - # This is the expected output | ||
72 | - assert 'Is another process using the image' in log | ||
73 | + emsg = ('ERROR (post-migration): qemu-io should not be able to ' | ||
74 | + 'access this image, but it reported no error') | ||
75 | + with self.assertRaises(CalledProcessError, msg=emsg) as ctx: | ||
76 | + qemu_io('-f', imgfmt, '-c', 'quit', test_img) | ||
77 | + if 'Is another process using the image' not in ctx.exception.stdout: | ||
78 | + raise ctx.exception | ||
79 | |||
80 | |||
81 | if __name__ == '__main__': | ||
82 | -- | ||
83 | 2.35.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: John Snow <jsnow@redhat.com> | ||
1 | 2 | ||
3 | This test expects failure ... but only sometimes. When? Why? | ||
4 | |||
5 | It's for reads of a region not defined by a bitmap. Adjust the test to | ||
6 | be more explicit about what it expects to fail and why. | ||
7 | |||
8 | Signed-off-by: John Snow <jsnow@redhat.com> | ||
9 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
10 | Reviewed-by: Hanna Reitz <hreitz@redhat.com> | ||
11 | Message-Id: <20220418211504.943969-10-jsnow@redhat.com> | ||
12 | Signed-off-by: Hanna Reitz <hreitz@redhat.com> | ||
13 | --- | ||
14 | tests/qemu-iotests/tests/image-fleecing | 28 +++++++++++++++++-------- | ||
15 | 1 file changed, 19 insertions(+), 9 deletions(-) | ||
16 | |||
17 | diff --git a/tests/qemu-iotests/tests/image-fleecing b/tests/qemu-iotests/tests/image-fleecing | ||
18 | index XXXXXXX..XXXXXXX 100755 | ||
19 | --- a/tests/qemu-iotests/tests/image-fleecing | ||
20 | +++ b/tests/qemu-iotests/tests/image-fleecing | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | # | ||
23 | # Creator/Owner: John Snow <jsnow@redhat.com> | ||
24 | |||
25 | +from subprocess import CalledProcessError | ||
26 | + | ||
27 | import iotests | ||
28 | -from iotests import log, qemu_img, qemu_io, qemu_io_silent, \ | ||
29 | - qemu_io_pipe_and_status | ||
30 | +from iotests import log, qemu_img, qemu_io, qemu_io_silent | ||
31 | |||
32 | iotests.script_initialize( | ||
33 | supported_fmts=['qcow2'], | ||
34 | @@ -XXX,XX +XXX,XX @@ def do_test(vm, use_cbw, use_snapshot_access_filter, base_img_path, | ||
35 | for p in patterns + zeroes: | ||
36 | cmd = 'read -P%s %s %s' % p | ||
37 | log(cmd) | ||
38 | - out, ret = qemu_io_pipe_and_status('-r', '-f', 'raw', '-c', cmd, | ||
39 | - nbd_uri) | ||
40 | - if ret != 0: | ||
41 | - print(out) | ||
42 | + | ||
43 | + try: | ||
44 | + qemu_io('-r', '-f', 'raw', '-c', cmd, nbd_uri) | ||
45 | + except CalledProcessError as exc: | ||
46 | + if bitmap and p in zeroes: | ||
47 | + log(exc.stdout) | ||
48 | + else: | ||
49 | + raise | ||
50 | |||
51 | log('') | ||
52 | log('--- Testing COW ---') | ||
53 | @@ -XXX,XX +XXX,XX @@ def do_test(vm, use_cbw, use_snapshot_access_filter, base_img_path, | ||
54 | args += [target_img_path] | ||
55 | else: | ||
56 | args += ['-f', 'raw', nbd_uri] | ||
57 | - out, ret = qemu_io_pipe_and_status(*args) | ||
58 | - if ret != 0: | ||
59 | - print(out) | ||
60 | + | ||
61 | + try: | ||
62 | + qemu_io(*args) | ||
63 | + except CalledProcessError as exc: | ||
64 | + if bitmap and p in zeroes: | ||
65 | + log(exc.stdout) | ||
66 | + else: | ||
67 | + raise | ||
68 | |||
69 | log('') | ||
70 | log('--- Cleanup ---') | ||
71 | -- | ||
72 | 2.35.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: John Snow <jsnow@redhat.com> | ||
1 | 2 | ||
3 | I know we just added it, sorry. This is done in favor of qemu_io() which | ||
4 | *also* returns the console output and status, but with more robust error | ||
5 | handling on failure. | ||
6 | |||
7 | Signed-off-by: John Snow <jsnow@redhat.com> | ||
8 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
9 | Reviewed-by: Hanna Reitz <hreitz@redhat.com> | ||
10 | Message-Id: <20220418211504.943969-11-jsnow@redhat.com> | ||
11 | Signed-off-by: Hanna Reitz <hreitz@redhat.com> | ||
12 | --- | ||
13 | tests/qemu-iotests/iotests.py | 3 --- | ||
14 | 1 file changed, 3 deletions(-) | ||
15 | |||
16 | diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/tests/qemu-iotests/iotests.py | ||
19 | +++ b/tests/qemu-iotests/iotests.py | ||
20 | @@ -XXX,XX +XXX,XX @@ def qemu_io(*args: str, check: bool = True, combine_stdio: bool = True | ||
21 | return qemu_tool(*qemu_io_wrap_args(args), | ||
22 | check=check, combine_stdio=combine_stdio) | ||
23 | |||
24 | -def qemu_io_pipe_and_status(*args): | ||
25 | - return qemu_tool_pipe_and_status('qemu-io', qemu_io_wrap_args(args)) | ||
26 | - | ||
27 | def qemu_io_log(*args: str) -> 'subprocess.CompletedProcess[str]': | ||
28 | result = qemu_io(*args, check=False) | ||
29 | log(result.stdout, filters=[filter_testfiles, filter_qemu_io]) | ||
30 | -- | ||
31 | 2.35.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: John Snow <jsnow@redhat.com> | ||
1 | 2 | ||
3 | Like qemu-img, qemu-io returning 0 should be the norm and not the | ||
4 | exception. Remove all calls to qemu_io_silent that just assert the | ||
5 | return code is zero (That's every last call, as it turns out), and | ||
6 | replace them with a normal qemu_io() call. | ||
7 | |||
8 | qemu_io_silent_check() appeared to have been unused already. | ||
9 | |||
10 | Signed-off-by: John Snow <jsnow@redhat.com> | ||
11 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
12 | Reviewed-by: Hanna Reitz <hreitz@redhat.com> | ||
13 | Message-Id: <20220418211504.943969-12-jsnow@redhat.com> | ||
14 | Signed-off-by: Hanna Reitz <hreitz@redhat.com> | ||
15 | --- | ||
16 | tests/qemu-iotests/216 | 12 +++++----- | ||
17 | tests/qemu-iotests/218 | 5 ++--- | ||
18 | tests/qemu-iotests/224 | 4 ++-- | ||
19 | tests/qemu-iotests/258 | 11 +++++----- | ||
20 | tests/qemu-iotests/298 | 17 ++++++-------- | ||
21 | tests/qemu-iotests/310 | 22 +++++++++---------- | ||
22 | tests/qemu-iotests/iotests.py | 16 -------------- | ||
23 | tests/qemu-iotests/tests/image-fleecing | 4 ++-- | ||
24 | .../tests/mirror-ready-cancel-error | 2 +- | ||
25 | .../qemu-iotests/tests/stream-error-on-reset | 4 ++-- | ||
26 | 10 files changed, 38 insertions(+), 59 deletions(-) | ||
27 | |||
28 | diff --git a/tests/qemu-iotests/216 b/tests/qemu-iotests/216 | ||
29 | index XXXXXXX..XXXXXXX 100755 | ||
30 | --- a/tests/qemu-iotests/216 | ||
31 | +++ b/tests/qemu-iotests/216 | ||
32 | @@ -XXX,XX +XXX,XX @@ | ||
33 | # Creator/Owner: Hanna Reitz <hreitz@redhat.com> | ||
34 | |||
35 | import iotests | ||
36 | -from iotests import log, qemu_img, qemu_io_silent | ||
37 | +from iotests import log, qemu_img, qemu_io | ||
38 | |||
39 | # Need backing file support | ||
40 | iotests.script_initialize(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk'], | ||
41 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('base.img') as base_img_path, \ | ||
42 | log('') | ||
43 | |||
44 | qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') | ||
45 | - assert qemu_io_silent(base_img_path, '-c', 'write -P 1 0M 1M') == 0 | ||
46 | + qemu_io(base_img_path, '-c', 'write -P 1 0M 1M') | ||
47 | qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path, | ||
48 | '-F', iotests.imgfmt, top_img_path) | ||
49 | - assert qemu_io_silent(top_img_path, '-c', 'write -P 2 1M 1M') == 0 | ||
50 | + qemu_io(top_img_path, '-c', 'write -P 2 1M 1M') | ||
51 | |||
52 | log('Done') | ||
53 | |||
54 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('base.img') as base_img_path, \ | ||
55 | log('--- Checking COR result ---') | ||
56 | log('') | ||
57 | |||
58 | - assert qemu_io_silent(base_img_path, '-c', 'discard 0 64M') == 0 | ||
59 | - assert qemu_io_silent(top_img_path, '-c', 'read -P 1 0M 1M') == 0 | ||
60 | - assert qemu_io_silent(top_img_path, '-c', 'read -P 2 1M 1M') == 0 | ||
61 | + qemu_io(base_img_path, '-c', 'discard 0 64M') | ||
62 | + qemu_io(top_img_path, '-c', 'read -P 1 0M 1M') | ||
63 | + qemu_io(top_img_path, '-c', 'read -P 2 1M 1M') | ||
64 | |||
65 | log('Done') | ||
66 | diff --git a/tests/qemu-iotests/218 b/tests/qemu-iotests/218 | ||
67 | index XXXXXXX..XXXXXXX 100755 | ||
68 | --- a/tests/qemu-iotests/218 | ||
69 | +++ b/tests/qemu-iotests/218 | ||
70 | @@ -XXX,XX +XXX,XX @@ | ||
71 | # Creator/Owner: Hanna Reitz <hreitz@redhat.com> | ||
72 | |||
73 | import iotests | ||
74 | -from iotests import log, qemu_img, qemu_io_silent | ||
75 | +from iotests import log, qemu_img, qemu_io | ||
76 | |||
77 | iotests.script_initialize(supported_fmts=['qcow2', 'raw']) | ||
78 | |||
79 | @@ -XXX,XX +XXX,XX @@ with iotests.VM() as vm, \ | ||
80 | iotests.FilePath('src.img') as src_img_path: | ||
81 | |||
82 | qemu_img('create', '-f', iotests.imgfmt, src_img_path, '64M') | ||
83 | - assert qemu_io_silent('-f', iotests.imgfmt, src_img_path, | ||
84 | - '-c', 'write -P 42 0M 64M') == 0 | ||
85 | + qemu_io('-f', iotests.imgfmt, src_img_path, '-c', 'write -P 42 0M 64M') | ||
86 | |||
87 | vm.launch() | ||
88 | |||
89 | diff --git a/tests/qemu-iotests/224 b/tests/qemu-iotests/224 | ||
90 | index XXXXXXX..XXXXXXX 100755 | ||
91 | --- a/tests/qemu-iotests/224 | ||
92 | +++ b/tests/qemu-iotests/224 | ||
93 | @@ -XXX,XX +XXX,XX @@ | ||
94 | # Creator/Owner: Hanna Reitz <hreitz@redhat.com> | ||
95 | |||
96 | import iotests | ||
97 | -from iotests import log, qemu_img, qemu_io_silent, filter_qmp_testfiles, \ | ||
98 | +from iotests import log, qemu_img, qemu_io, filter_qmp_testfiles, \ | ||
99 | filter_qmp_imgfmt | ||
100 | import json | ||
101 | |||
102 | @@ -XXX,XX +XXX,XX @@ for filter_node_name in False, True: | ||
103 | '-F', iotests.imgfmt, top_img_path) | ||
104 | |||
105 | # Something to commit | ||
106 | - assert qemu_io_silent(mid_img_path, '-c', 'write -P 1 0 1M') == 0 | ||
107 | + qemu_io(mid_img_path, '-c', 'write -P 1 0 1M') | ||
108 | |||
109 | vm.launch() | ||
110 | |||
111 | diff --git a/tests/qemu-iotests/258 b/tests/qemu-iotests/258 | ||
112 | index XXXXXXX..XXXXXXX 100755 | ||
113 | --- a/tests/qemu-iotests/258 | ||
114 | +++ b/tests/qemu-iotests/258 | ||
115 | @@ -XXX,XX +XXX,XX @@ | ||
116 | # Creator/Owner: Hanna Reitz <hreitz@redhat.com> | ||
117 | |||
118 | import iotests | ||
119 | -from iotests import log, qemu_img, qemu_io_silent, \ | ||
120 | +from iotests import log, qemu_img, qemu_io, \ | ||
121 | filter_qmp_testfiles, filter_qmp_imgfmt | ||
122 | |||
123 | # Returns a node for blockdev-add | ||
124 | @@ -XXX,XX +XXX,XX @@ def test_concurrent_finish(write_to_stream_node): | ||
125 | if write_to_stream_node: | ||
126 | # This is what (most of the time) makes commit finish | ||
127 | # earlier and then pull in stream | ||
128 | - assert qemu_io_silent(node2_path, | ||
129 | - '-c', 'write %iK 64K' % (65536 - 192), | ||
130 | - '-c', 'write %iK 64K' % (65536 - 64)) == 0 | ||
131 | + qemu_io(node2_path, | ||
132 | + '-c', 'write %iK 64K' % (65536 - 192), | ||
133 | + '-c', 'write %iK 64K' % (65536 - 64)) | ||
134 | |||
135 | stream_throttle='tg' | ||
136 | else: | ||
137 | # And this makes stream finish earlier | ||
138 | - assert qemu_io_silent(node1_path, | ||
139 | - '-c', 'write %iK 64K' % (65536 - 64)) == 0 | ||
140 | + qemu_io(node1_path, '-c', 'write %iK 64K' % (65536 - 64)) | ||
141 | |||
142 | commit_throttle='tg' | ||
143 | |||
144 | diff --git a/tests/qemu-iotests/298 b/tests/qemu-iotests/298 | ||
145 | index XXXXXXX..XXXXXXX 100755 | ||
146 | --- a/tests/qemu-iotests/298 | ||
147 | +++ b/tests/qemu-iotests/298 | ||
148 | @@ -XXX,XX +XXX,XX @@ class TestTruncate(iotests.QMPTestCase): | ||
149 | os.remove(refdisk) | ||
150 | |||
151 | def do_test(self, prealloc_mode, new_size): | ||
152 | - ret = iotests.qemu_io_silent('--image-opts', '-c', 'write 0 10M', '-c', | ||
153 | - f'truncate -m {prealloc_mode} {new_size}', | ||
154 | - drive_opts) | ||
155 | - self.assertEqual(ret, 0) | ||
156 | - | ||
157 | - ret = iotests.qemu_io_silent('-f', iotests.imgfmt, '-c', 'write 0 10M', | ||
158 | - '-c', | ||
159 | - f'truncate -m {prealloc_mode} {new_size}', | ||
160 | - refdisk) | ||
161 | - self.assertEqual(ret, 0) | ||
162 | + iotests.qemu_io('--image-opts', '-c', 'write 0 10M', '-c', | ||
163 | + f'truncate -m {prealloc_mode} {new_size}', | ||
164 | + drive_opts) | ||
165 | + | ||
166 | + iotests.qemu_io('-f', iotests.imgfmt, '-c', 'write 0 10M', | ||
167 | + '-c', f'truncate -m {prealloc_mode} {new_size}', | ||
168 | + refdisk) | ||
169 | |||
170 | stat = os.stat(disk) | ||
171 | refstat = os.stat(refdisk) | ||
172 | diff --git a/tests/qemu-iotests/310 b/tests/qemu-iotests/310 | ||
173 | index XXXXXXX..XXXXXXX 100755 | ||
174 | --- a/tests/qemu-iotests/310 | ||
175 | +++ b/tests/qemu-iotests/310 | ||
176 | @@ -XXX,XX +XXX,XX @@ | ||
177 | # | ||
178 | |||
179 | import iotests | ||
180 | -from iotests import log, qemu_img, qemu_io_silent | ||
181 | +from iotests import log, qemu_img, qemu_io | ||
182 | |||
183 | # Need backing file support | ||
184 | iotests.script_initialize(supported_fmts=['qcow2'], | ||
185 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('base.img') as base_img_path, \ | ||
186 | log('') | ||
187 | |||
188 | qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') | ||
189 | - assert qemu_io_silent(base_img_path, '-c', 'write -P 1 0M 1M') == 0 | ||
190 | - assert qemu_io_silent(base_img_path, '-c', 'write -P 1 3M 1M') == 0 | ||
191 | + qemu_io(base_img_path, '-c', 'write -P 1 0M 1M') | ||
192 | + qemu_io(base_img_path, '-c', 'write -P 1 3M 1M') | ||
193 | qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path, | ||
194 | '-F', iotests.imgfmt, mid_img_path) | ||
195 | - assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 2M 1M') == 0 | ||
196 | - assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 4M 1M') == 0 | ||
197 | + qemu_io(mid_img_path, '-c', 'write -P 3 2M 1M') | ||
198 | + qemu_io(mid_img_path, '-c', 'write -P 3 4M 1M') | ||
199 | qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path, | ||
200 | '-F', iotests.imgfmt, top_img_path) | ||
201 | - assert qemu_io_silent(top_img_path, '-c', 'write -P 2 1M 1M') == 0 | ||
202 | + qemu_io(top_img_path, '-c', 'write -P 2 1M 1M') | ||
203 | |||
204 | # 0 1 2 3 4 | ||
205 | # top 2 | ||
206 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('base.img') as base_img_path, \ | ||
207 | # Detach backing to check that we can read the data from the top level now | ||
208 | qemu_img('rebase', '-u', '-b', '', '-f', iotests.imgfmt, top_img_path) | ||
209 | |||
210 | - assert qemu_io_silent(top_img_path, '-c', 'read -P 0 0 1M') == 0 | ||
211 | - assert qemu_io_silent(top_img_path, '-c', 'read -P 2 1M 1M') == 0 | ||
212 | - assert qemu_io_silent(top_img_path, '-c', 'read -P 3 2M 1M') == 0 | ||
213 | - assert qemu_io_silent(top_img_path, '-c', 'read -P 0 3M 1M') == 0 | ||
214 | - assert qemu_io_silent(top_img_path, '-c', 'read -P 3 4M 1M') == 0 | ||
215 | + qemu_io(top_img_path, '-c', 'read -P 0 0 1M') | ||
216 | + qemu_io(top_img_path, '-c', 'read -P 2 1M 1M') | ||
217 | + qemu_io(top_img_path, '-c', 'read -P 3 2M 1M') | ||
218 | + qemu_io(top_img_path, '-c', 'read -P 0 3M 1M') | ||
219 | + qemu_io(top_img_path, '-c', 'read -P 3 4M 1M') | ||
220 | |||
221 | log('Done') | ||
222 | diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py | ||
223 | index XXXXXXX..XXXXXXX 100644 | ||
224 | --- a/tests/qemu-iotests/iotests.py | ||
225 | +++ b/tests/qemu-iotests/iotests.py | ||
226 | @@ -XXX,XX +XXX,XX @@ def qemu_io_log(*args: str) -> 'subprocess.CompletedProcess[str]': | ||
227 | log(result.stdout, filters=[filter_testfiles, filter_qemu_io]) | ||
228 | return result | ||
229 | |||
230 | -def qemu_io_silent(*args): | ||
231 | - '''Run qemu-io and return the exit code, suppressing stdout''' | ||
232 | - args = qemu_io_wrap_args(args) | ||
233 | - result = subprocess.run(args, stdout=subprocess.DEVNULL, check=False) | ||
234 | - if result.returncode < 0: | ||
235 | - sys.stderr.write('qemu-io received signal %i: %s\n' % | ||
236 | - (-result.returncode, ' '.join(args))) | ||
237 | - return result.returncode | ||
238 | - | ||
239 | -def qemu_io_silent_check(*args): | ||
240 | - '''Run qemu-io and return the true if subprocess returned 0''' | ||
241 | - args = qemu_io_wrap_args(args) | ||
242 | - result = subprocess.run(args, stdout=subprocess.DEVNULL, | ||
243 | - stderr=subprocess.STDOUT, check=False) | ||
244 | - return result.returncode == 0 | ||
245 | - | ||
246 | class QemuIoInteractive: | ||
247 | def __init__(self, *args): | ||
248 | self.args = qemu_io_wrap_args(args) | ||
249 | diff --git a/tests/qemu-iotests/tests/image-fleecing b/tests/qemu-iotests/tests/image-fleecing | ||
250 | index XXXXXXX..XXXXXXX 100755 | ||
251 | --- a/tests/qemu-iotests/tests/image-fleecing | ||
252 | +++ b/tests/qemu-iotests/tests/image-fleecing | ||
253 | @@ -XXX,XX +XXX,XX @@ | ||
254 | from subprocess import CalledProcessError | ||
255 | |||
256 | import iotests | ||
257 | -from iotests import log, qemu_img, qemu_io, qemu_io_silent | ||
258 | +from iotests import log, qemu_img, qemu_io | ||
259 | |||
260 | iotests.script_initialize( | ||
261 | supported_fmts=['qcow2'], | ||
262 | @@ -XXX,XX +XXX,XX @@ def do_test(vm, use_cbw, use_snapshot_access_filter, base_img_path, | ||
263 | for p in overwrite + remainder: | ||
264 | cmd = 'read -P%s %s %s' % p | ||
265 | log(cmd) | ||
266 | - assert qemu_io_silent(base_img_path, '-c', cmd) == 0 | ||
267 | + qemu_io(base_img_path, '-c', cmd) | ||
268 | |||
269 | log('') | ||
270 | log('Done') | ||
271 | diff --git a/tests/qemu-iotests/tests/mirror-ready-cancel-error b/tests/qemu-iotests/tests/mirror-ready-cancel-error | ||
272 | index XXXXXXX..XXXXXXX 100755 | ||
273 | --- a/tests/qemu-iotests/tests/mirror-ready-cancel-error | ||
274 | +++ b/tests/qemu-iotests/tests/mirror-ready-cancel-error | ||
275 | @@ -XXX,XX +XXX,XX @@ class TestMirrorReadyCancelError(iotests.QMPTestCase): | ||
276 | # Ensure that mirror will copy something before READY so the | ||
277 | # target format layer will forward the pre-READY flush to its | ||
278 | # file child | ||
279 | - assert iotests.qemu_io_silent('-c', 'write -P 1 0 64k', source) == 0 | ||
280 | + iotests.qemu_io('-c', 'write -P 1 0 64k', source) | ||
281 | |||
282 | self.vm = iotests.VM() | ||
283 | self.vm.launch() | ||
284 | diff --git a/tests/qemu-iotests/tests/stream-error-on-reset b/tests/qemu-iotests/tests/stream-error-on-reset | ||
285 | index XXXXXXX..XXXXXXX 100755 | ||
286 | --- a/tests/qemu-iotests/tests/stream-error-on-reset | ||
287 | +++ b/tests/qemu-iotests/tests/stream-error-on-reset | ||
288 | @@ -XXX,XX +XXX,XX @@ | ||
289 | |||
290 | import os | ||
291 | import iotests | ||
292 | -from iotests import imgfmt, qemu_img_create, qemu_io_silent, QMPTestCase | ||
293 | +from iotests import imgfmt, qemu_img_create, qemu_io, QMPTestCase | ||
294 | |||
295 | |||
296 | image_size = 1 * 1024 * 1024 | ||
297 | @@ -XXX,XX +XXX,XX @@ class TestStreamErrorOnReset(QMPTestCase): | ||
298 | - top image is attached to a virtio-scsi device | ||
299 | """ | ||
300 | qemu_img_create('-f', imgfmt, base, str(image_size)) | ||
301 | - assert qemu_io_silent('-c', f'write 0 {data_size}', base) == 0 | ||
302 | + qemu_io('-c', f'write 0 {data_size}', base) | ||
303 | qemu_img_create('-f', imgfmt, top, str(image_size)) | ||
304 | |||
305 | self.vm = iotests.VM() | ||
306 | -- | ||
307 | 2.35.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: John Snow <jsnow@redhat.com> | ||
1 | 2 | ||
3 | Just like qemu_img_log(), upgrade qemu_io_log() to enforce a return code | ||
4 | of zero by default. | ||
5 | |||
6 | Tests that use qemu_io_log(): 242 245 255 274 303 307 nbd-reconnect-on-open | ||
7 | |||
8 | Signed-off-by: John Snow <jsnow@redhat.com> | ||
9 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
10 | Reviewed-by: Hanna Reitz <hreitz@redhat.com> | ||
11 | Message-Id: <20220418211504.943969-13-jsnow@redhat.com> | ||
12 | Signed-off-by: Hanna Reitz <hreitz@redhat.com> | ||
13 | --- | ||
14 | tests/qemu-iotests/iotests.py | 5 +++-- | ||
15 | tests/qemu-iotests/tests/nbd-reconnect-on-open | 2 +- | ||
16 | 2 files changed, 4 insertions(+), 3 deletions(-) | ||
17 | |||
18 | diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/tests/qemu-iotests/iotests.py | ||
21 | +++ b/tests/qemu-iotests/iotests.py | ||
22 | @@ -XXX,XX +XXX,XX @@ def qemu_io(*args: str, check: bool = True, combine_stdio: bool = True | ||
23 | return qemu_tool(*qemu_io_wrap_args(args), | ||
24 | check=check, combine_stdio=combine_stdio) | ||
25 | |||
26 | -def qemu_io_log(*args: str) -> 'subprocess.CompletedProcess[str]': | ||
27 | - result = qemu_io(*args, check=False) | ||
28 | +def qemu_io_log(*args: str, check: bool = True | ||
29 | + ) -> 'subprocess.CompletedProcess[str]': | ||
30 | + result = qemu_io(*args, check=check) | ||
31 | log(result.stdout, filters=[filter_testfiles, filter_qemu_io]) | ||
32 | return result | ||
33 | |||
34 | diff --git a/tests/qemu-iotests/tests/nbd-reconnect-on-open b/tests/qemu-iotests/tests/nbd-reconnect-on-open | ||
35 | index XXXXXXX..XXXXXXX 100755 | ||
36 | --- a/tests/qemu-iotests/tests/nbd-reconnect-on-open | ||
37 | +++ b/tests/qemu-iotests/tests/nbd-reconnect-on-open | ||
38 | @@ -XXX,XX +XXX,XX @@ def check_fail_to_connect(open_timeout): | ||
39 | log(f'Check fail to connect with {open_timeout} seconds of timeout') | ||
40 | |||
41 | start_t = time.time() | ||
42 | - qemu_io_log(*create_args(open_timeout)) | ||
43 | + qemu_io_log(*create_args(open_timeout), check=False) | ||
44 | delta_t = time.time() - start_t | ||
45 | |||
46 | max_delta = open_timeout + 0.2 | ||
47 | -- | ||
48 | 2.35.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | FUSE exports' allow-other option defaults to "auto", which means that it | ||
2 | will try passing allow_other as a mount option, and fall back to not | ||
3 | using it when an error occurs. We make no effort to hide fusermount's | ||
4 | error message (because it would be difficult, and because users might | ||
5 | want to know about the fallback occurring), and so when allow_other does | ||
6 | not work (primarily when /etc/fuse.conf does not contain | ||
7 | user_allow_other), this error message will appear and break the | ||
8 | reference output. | ||
1 | 9 | ||
10 | We do not need allow_other here, though, so we can just pass | ||
11 | allow-other=off to fix that. | ||
12 | |||
13 | Reported-by: Markus Armbruster <armbru@redhat.com> | ||
14 | Signed-off-by: Hanna Reitz <hreitz@redhat.com> | ||
15 | Message-Id: <20220421142435.569600-1-hreitz@redhat.com> | ||
16 | Tested-by: Markus Armbruster <armbru@redhat.com> | ||
17 | Tested-by: Eric Blake <eblake@redhat.com> | ||
18 | --- | ||
19 | tests/qemu-iotests/108 | 2 +- | ||
20 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
21 | |||
22 | diff --git a/tests/qemu-iotests/108 b/tests/qemu-iotests/108 | ||
23 | index XXXXXXX..XXXXXXX 100755 | ||
24 | --- a/tests/qemu-iotests/108 | ||
25 | +++ b/tests/qemu-iotests/108 | ||
26 | @@ -XXX,XX +XXX,XX @@ else | ||
27 | |||
28 | $QSD \ | ||
29 | --blockdev file,node-name=export-node,filename="$TEST_IMG" \ | ||
30 | - --export fuse,id=fuse-export,node-name=export-node,mountpoint="$export_mp",writable=on,growable=off \ | ||
31 | + --export fuse,id=fuse-export,node-name=export-node,mountpoint="$export_mp",writable=on,growable=off,allow-other=off \ | ||
32 | --pidfile "$TEST_DIR/qsd.pid" \ | ||
33 | --daemonize | ||
34 | fi | ||
35 | -- | ||
36 | 2.35.1 | diff view generated by jsdifflib |