1 | The following changes since commit aceeaa69d28e6f08a24395d0aa6915b687d0a681: | 1 | The following changes since commit 16aaacb307ed607b9780c12702c44f0fe52edc7e: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2019-12-17' into staging (2019-12-17 15:55:20 +0000) | 3 | Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20200430' into staging (2020-04-30 14:00:36 +0100) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | git://repo.or.cz/qemu/kevin.git tags/for-upstream | 7 | git://repo.or.cz/qemu/kevin.git tags/for-upstream |
8 | 8 | ||
9 | for you to fetch changes up to f62f08ab7a9d902da70078992248ec5c98f652ad: | 9 | for you to fetch changes up to eaae29ef89d498d0eac553c77b554f310a47f809: |
10 | 10 | ||
11 | iotests: Test external snapshot with VM state (2019-12-19 18:04:25 +0100) | 11 | qemu-storage-daemon: Fix non-string --object properties (2020-04-30 17:51:07 +0200) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Block layer patches: | 14 | Block layer patches: |
15 | 15 | ||
16 | - qemu-img: fix info --backing-chain --image-opts | 16 | - Fix resize (extending) of short overlays |
17 | - Error out on image creation with conflicting size options | 17 | - nvme: introduce PMR support from NVMe 1.4 spec |
18 | - Fix external snapshot with VM state | 18 | - qemu-storage-daemon: Fix non-string --object properties |
19 | - hmp: Allow using qdev ID for qemu-io command | ||
20 | - Misc code cleanup | ||
21 | - Many iotests improvements | ||
22 | 19 | ||
23 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
24 | Alberto Garcia (1): | 21 | Alberto Garcia (1): |
25 | qcow2: Use offset_into_cluster() | 22 | qcow2: Add incompatibility note between backing files and raw external data files |
26 | 23 | ||
27 | Daniel P. Berrangé (1): | 24 | Andrzej Jakowski (1): |
28 | qapi: better document NVMe blockdev @device parameter | 25 | nvme: introduce PMR support from NVMe 1.4 spec |
29 | 26 | ||
30 | Kevin Wolf (19): | 27 | Kevin Wolf (12): |
31 | block: Error out on image creation with conflicting size options | 28 | block: Add flags to BlockDriver.bdrv_co_truncate() |
32 | blockjob: Fix error message for negative speed | 29 | block: Add flags to bdrv(_co)_truncate() |
33 | qcow2: Declare BDRV_REQ_NO_FALLBACK supported | 30 | block-backend: Add flags to blk_truncate() |
34 | iotests: Add qemu_io_log() | 31 | qcow2: Support BDRV_REQ_ZERO_WRITE for truncate |
35 | iotests: Fix timeout in run_job() | 32 | raw-format: Support BDRV_REQ_ZERO_WRITE for truncate |
36 | iotests: Support job-complete in run_job() | 33 | file-posix: Support BDRV_REQ_ZERO_WRITE for truncate |
37 | iotests: Create VM.blockdev_create() | 34 | block: truncate: Don't make backing file data visible |
38 | iotests: 255: Drop blockdev_create() | 35 | iotests: Filter testfiles out in filter_img_info() |
39 | iotests: 206: Convert to VM.blockdev_create() | 36 | iotests: Test committing to short backing file |
40 | iotests: 210: Convert to VM.blockdev_create() | 37 | qcow2: Forward ZERO_WRITE flag for full preallocation |
41 | iotests: 212: Convert to VM.blockdev_create() | 38 | qom: Factor out user_creatable_add_dict() |
42 | iotests: 213: Convert to VM.blockdev_create() | 39 | qemu-storage-daemon: Fix non-string --object properties |
43 | iotests: 237: Convert to VM.blockdev_create() | ||
44 | iotests: 266: Convert to VM.blockdev_create() | ||
45 | iotests: 207: Remove duplication with VM.blockdev_create() | ||
46 | iotests: 211: Remove duplication with VM.blockdev_create() | ||
47 | block: Activate recursively even for already active nodes | ||
48 | hmp: Allow using qdev ID for qemu-io command | ||
49 | iotests: Test external snapshot with VM state | ||
50 | 40 | ||
51 | Max Reitz (2): | 41 | Paolo Bonzini (1): |
52 | iotests/273: Filter format-specific information | 42 | qemu-iotests: allow qcow2 external discarded clusters to contain stale data |
53 | iotests: Fix IMGOPTSSYNTAX for nbd | ||
54 | 43 | ||
55 | Stefan Hajnoczi (1): | 44 | docs/interop/qcow2.txt | 3 + |
56 | qemu-img: fix info --backing-chain --image-opts | 45 | hw/block/nvme.h | 2 + |
57 | 46 | include/block/block.h | 5 +- | |
58 | Thomas Huth (4): | 47 | include/block/block_int.h | 10 +- |
59 | iotests: Provide a function for checking the creation of huge files | 48 | include/block/nvme.h | 172 ++++++++++++++++++++++++++ |
60 | iotests: Skip test 060 if it is not possible to create large files | 49 | include/qom/object_interfaces.h | 16 +++ |
61 | iotests: Skip test 079 if it is not possible to create large files | 50 | include/sysemu/block-backend.h | 2 +- |
62 | iotests: Add more "_require_drivers" checks to the shell-based tests | 51 | block.c | 3 +- |
63 | 52 | block/block-backend.c | 4 +- | |
64 | Tuguoyi (1): | 53 | block/commit.c | 4 +- |
65 | qcow2: Move error check of local_err near its assignment | 54 | block/crypto.c | 7 +- |
66 | 55 | block/file-posix.c | 6 +- | |
67 | Vladimir Sementsov-Ogievskiy (1): | 56 | block/file-win32.c | 2 +- |
68 | MAINTAINERS: fix qcow2-bitmap.c under Dirty Bitmaps header | 57 | block/gluster.c | 1 + |
69 | 58 | block/io.c | 43 ++++++- | |
70 | qapi/block-core.json | 6 +- | 59 | block/iscsi.c | 2 +- |
71 | block.c | 60 ++++++----- | 60 | block/mirror.c | 2 +- |
72 | block/qcow2.c | 21 ++-- | 61 | block/nfs.c | 3 +- |
73 | blockjob.c | 3 +- | 62 | block/parallels.c | 6 +- |
74 | monitor/hmp-cmds.c | 28 +++-- | 63 | block/qcow.c | 4 +- |
75 | qemu-img.c | 3 + | 64 | block/qcow2-cluster.c | 2 +- |
76 | MAINTAINERS | 6 +- | 65 | block/qcow2-refcount.c | 2 +- |
77 | hmp-commands.hx | 8 +- | 66 | block/qcow2.c | 73 +++++++++-- |
78 | tests/qemu-iotests/005 | 5 +- | 67 | block/qed.c | 3 +- |
79 | tests/qemu-iotests/030 | 4 +- | 68 | block/raw-format.c | 6 +- |
80 | tests/qemu-iotests/049 | 5 + | 69 | block/rbd.c | 1 + |
81 | tests/qemu-iotests/049.out | 5 + | 70 | block/sheepdog.c | 4 +- |
82 | tests/qemu-iotests/051 | 1 + | 71 | block/ssh.c | 2 +- |
83 | tests/qemu-iotests/060 | 3 + | 72 | block/vdi.c | 2 +- |
84 | tests/qemu-iotests/079 | 3 + | 73 | block/vhdx-log.c | 2 +- |
85 | tests/qemu-iotests/206 | 232 ++++++++++++++++++++---------------------- | 74 | block/vhdx.c | 6 +- |
86 | tests/qemu-iotests/207 | 8 +- | 75 | block/vmdk.c | 8 +- |
87 | tests/qemu-iotests/210 | 81 +++++++-------- | 76 | block/vpc.c | 2 +- |
88 | tests/qemu-iotests/211 | 12 +-- | 77 | blockdev.c | 2 +- |
89 | tests/qemu-iotests/212 | 101 +++++++++--------- | 78 | hw/block/nvme.c | 109 ++++++++++++++++ |
90 | tests/qemu-iotests/213 | 113 ++++++++++---------- | 79 | qemu-img.c | 2 +- |
91 | tests/qemu-iotests/220 | 6 +- | 80 | qemu-io-cmds.c | 2 +- |
92 | tests/qemu-iotests/237 | 139 ++++++++++++------------- | 81 | qemu-storage-daemon.c | 4 +- |
93 | tests/qemu-iotests/255 | 10 -- | 82 | qom/object_interfaces.c | 31 +++++ |
94 | tests/qemu-iotests/266 | 69 ++++++------- | 83 | qom/qom-qmp-cmds.c | 24 +--- |
95 | tests/qemu-iotests/266.out | 14 +++ | 84 | tests/test-block-iothread.c | 9 +- |
96 | tests/qemu-iotests/267 | 1 + | 85 | tests/qemu-iotests/iotests.py | 5 +- |
97 | tests/qemu-iotests/273 | 3 +- | 86 | hw/block/Makefile.objs | 2 +- |
98 | tests/qemu-iotests/273.out | 27 ----- | 87 | hw/block/trace-events | 4 + |
99 | tests/qemu-iotests/279 | 57 +++++++++++ | 88 | tests/qemu-iotests/244 | 10 +- |
100 | tests/qemu-iotests/279.out | 35 +++++++ | 89 | tests/qemu-iotests/244.out | 9 +- |
101 | tests/qemu-iotests/280 | 83 +++++++++++++++ | 90 | tests/qemu-iotests/274 | 155 +++++++++++++++++++++++ |
102 | tests/qemu-iotests/280.out | 50 +++++++++ | 91 | tests/qemu-iotests/274.out | 268 ++++++++++++++++++++++++++++++++++++++++ |
103 | tests/qemu-iotests/common.rc | 13 ++- | 92 | tests/qemu-iotests/group | 1 + |
104 | tests/qemu-iotests/group | 2 + | 93 | 49 files changed, 951 insertions(+), 96 deletions(-) |
105 | tests/qemu-iotests/iotests.py | 25 ++++- | 94 | create mode 100755 tests/qemu-iotests/274 |
106 | 36 files changed, 724 insertions(+), 518 deletions(-) | 95 | create mode 100644 tests/qemu-iotests/274.out |
107 | create mode 100755 tests/qemu-iotests/279 | ||
108 | create mode 100644 tests/qemu-iotests/279.out | ||
109 | create mode 100755 tests/qemu-iotests/280 | ||
110 | create mode 100644 tests/qemu-iotests/280.out | ||
111 | 96 | ||
112 | 97 | diff view generated by jsdifflib |
1 | From: Daniel P. Berrangé <berrange@redhat.com> | 1 | From: Alberto Garcia <berto@igalia.com> |
---|---|---|---|
2 | 2 | ||
3 | Mention that this is a PCI device address & give the format it is | 3 | Backing files and raw external data files are mutually exclusive. |
4 | expected in. Also mention that it must be first unbound from any | 4 | The documentation of the raw external data bit (in autoclear_features) |
5 | host kernel driver. | 5 | already indicates that, but we should also mention it on the other |
6 | side. | ||
6 | 7 | ||
7 | Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> | 8 | Suggested-by: Eric Blake <eblake@redhat.com> |
8 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | 9 | Signed-off-by: Alberto Garcia <berto@igalia.com> |
10 | Message-Id: <20200410121816.8334-1-berto@igalia.com> | ||
9 | Reviewed-by: Eric Blake <eblake@redhat.com> | 11 | Reviewed-by: Eric Blake <eblake@redhat.com> |
10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 12 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
11 | --- | 13 | --- |
12 | qapi/block-core.json | 6 +++++- | 14 | docs/interop/qcow2.txt | 3 +++ |
13 | 1 file changed, 5 insertions(+), 1 deletion(-) | 15 | 1 file changed, 3 insertions(+) |
14 | 16 | ||
15 | diff --git a/qapi/block-core.json b/qapi/block-core.json | 17 | diff --git a/docs/interop/qcow2.txt b/docs/interop/qcow2.txt |
16 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/qapi/block-core.json | 19 | --- a/docs/interop/qcow2.txt |
18 | +++ b/qapi/block-core.json | 20 | +++ b/docs/interop/qcow2.txt |
19 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ The first cluster of a qcow2 image contains the file header: |
20 | # | 22 | is stored (NB: The string is not null terminated). 0 if the |
21 | # Driver specific block device options for the NVMe backend. | 23 | image doesn't have a backing file. |
22 | # | 24 | |
23 | -# @device: controller address of the NVMe device. | 25 | + Note: backing files are incompatible with raw external data |
24 | +# @device: PCI controller address of the NVMe device in | 26 | + files (auto-clear feature bit 1). |
25 | +# format hhhh:bb:ss.f (host:bus:slot.function) | 27 | + |
26 | # @namespace: namespace number of the device, starting from 1. | 28 | 16 - 19: backing_file_size |
27 | # | 29 | Length of the backing file name in bytes. Must not be |
28 | +# Note that the PCI @device must have been unbound from any host | 30 | longer than 1023 bytes. Undefined if the image doesn't have |
29 | +# kernel driver before instructing QEMU to add the blockdev. | ||
30 | +# | ||
31 | # Since: 2.12 | ||
32 | ## | ||
33 | { 'struct': 'BlockdevOptionsNVMe', | ||
34 | -- | 31 | -- |
35 | 2.20.1 | 32 | 2.25.3 |
36 | 33 | ||
37 | 34 | diff view generated by jsdifflib |
1 | The blockdev_create() function in this test case adds an error check | 1 | From: Paolo Bonzini <pbonzini@redhat.com> |
---|---|---|---|
2 | that skips the test in case of failure because of memory shortage, but | ||
3 | provides otherwise the same functionality as VM.blockdev_create() from | ||
4 | iotests.py. Make it a thin wrapper around the iotests.py function. | ||
5 | 2 | ||
3 | Test 244 checks the expected behavior of qcow2 external data files | ||
4 | with respect to zero and discarded clusters. Filesystems however | ||
5 | are free to ignore discard requests, and this seems to be the | ||
6 | case for overlayfs. Relax the tests to skip checks on the | ||
7 | external data file for discarded areas, which implies not using | ||
8 | qemu-img compare in the data_file_raw=on case. | ||
9 | |||
10 | This fixes docker tests on RHEL8. | ||
11 | |||
12 | Cc: Kevin Wolf <kwolf@redhat.com> | ||
13 | Cc: qemu-block@nongnu.org | ||
14 | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> | ||
15 | Message-Id: <20200409191006.24429-1-pbonzini@redhat.com> | ||
6 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 16 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
7 | --- | 17 | --- |
8 | tests/qemu-iotests/211 | 12 +++--------- | 18 | tests/qemu-iotests/244 | 10 ++++++++-- |
9 | 1 file changed, 3 insertions(+), 9 deletions(-) | 19 | tests/qemu-iotests/244.out | 9 ++++++--- |
20 | 2 files changed, 14 insertions(+), 5 deletions(-) | ||
10 | 21 | ||
11 | diff --git a/tests/qemu-iotests/211 b/tests/qemu-iotests/211 | 22 | diff --git a/tests/qemu-iotests/244 b/tests/qemu-iotests/244 |
12 | index XXXXXXX..XXXXXXX 100755 | 23 | index XXXXXXX..XXXXXXX 100755 |
13 | --- a/tests/qemu-iotests/211 | 24 | --- a/tests/qemu-iotests/244 |
14 | +++ b/tests/qemu-iotests/211 | 25 | +++ b/tests/qemu-iotests/244 |
15 | @@ -XXX,XX +XXX,XX @@ iotests.verify_image_format(supported_fmts=['vdi']) | 26 | @@ -XXX,XX +XXX,XX @@ $QEMU_IO -c 'read -P 0 0 1M' \ |
16 | iotests.verify_protocol(supported=['file']) | 27 | echo |
17 | 28 | $QEMU_IO -c 'read -P 0 0 1M' \ | |
18 | def blockdev_create(vm, options): | 29 | -c 'read -P 0x11 1M 1M' \ |
19 | - result = vm.qmp_log('blockdev-create', job_id='job0', options=options, | 30 | - -c 'read -P 0 2M 2M' \ |
20 | - filters=[iotests.filter_qmp_testfiles]) | 31 | -c 'read -P 0x11 4M 1M' \ |
21 | - | 32 | -c 'read -P 0 5M 1M' \ |
22 | - if 'return' in result: | 33 | -f raw "$TEST_IMG.data" | |
23 | - assert result['return'] == {} | 34 | @@ -XXX,XX +XXX,XX @@ $QEMU_IO -c 'read -P 0 0 1M' \ |
24 | - error = vm.run_job('job0') | 35 | -f $IMGFMT "$TEST_IMG" | |
25 | - if error and 'Could not allocate bmap' in error: | 36 | _filter_qemu_io |
26 | - iotests.notrun('Insufficient memory') | 37 | |
27 | - iotests.log("") | 38 | +# Discarded clusters are only marked as such in the qcow2 metadata, but |
28 | + error = vm.blockdev_create(options) | 39 | +# they can contain stale data in the external data file. Instead, zero |
29 | + if error and 'Could not allocate bmap' in error: | 40 | +# clusters must be zeroed in the external data file too. |
30 | + iotests.notrun('Insufficient memory') | 41 | echo |
31 | 42 | -$QEMU_IMG compare "$TEST_IMG" "$TEST_IMG.data" | |
32 | with iotests.FilePath('t.vdi') as disk_path, \ | 43 | +$QEMU_IO -c 'read -P 0 0 1M' \ |
33 | iotests.VM() as vm: | 44 | + -c 'read -P 0x11 1M 1M' \ |
45 | + -c 'read -P 0 3M 3M' \ | ||
46 | + -f raw "$TEST_IMG".data | | ||
47 | + _filter_qemu_io | ||
48 | |||
49 | echo -n "qcow2 file size after I/O: " | ||
50 | du -b $TEST_IMG | cut -f1 | ||
51 | diff --git a/tests/qemu-iotests/244.out b/tests/qemu-iotests/244.out | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/tests/qemu-iotests/244.out | ||
54 | +++ b/tests/qemu-iotests/244.out | ||
55 | @@ -XXX,XX +XXX,XX @@ read 1048576/1048576 bytes at offset 0 | ||
56 | 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
57 | read 1048576/1048576 bytes at offset 1048576 | ||
58 | 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
59 | -read 2097152/2097152 bytes at offset 2097152 | ||
60 | -2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
61 | read 1048576/1048576 bytes at offset 4194304 | ||
62 | 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
63 | read 1048576/1048576 bytes at offset 5242880 | ||
64 | @@ -XXX,XX +XXX,XX @@ read 1048576/1048576 bytes at offset 1048576 | ||
65 | read 4194304/4194304 bytes at offset 2097152 | ||
66 | 4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
67 | |||
68 | -Images are identical. | ||
69 | +read 1048576/1048576 bytes at offset 0 | ||
70 | +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
71 | +read 1048576/1048576 bytes at offset 1048576 | ||
72 | +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
73 | +read 3145728/3145728 bytes at offset 3145728 | ||
74 | +3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
75 | qcow2 file size after I/O: 327680 | ||
76 | |||
77 | === bdrv_co_block_status test for file and offset=0 === | ||
34 | -- | 78 | -- |
35 | 2.20.1 | 79 | 2.25.3 |
36 | 80 | ||
37 | 81 | diff view generated by jsdifflib |
1 | From: Alberto Garcia <berto@igalia.com> | 1 | This adds a new BdrvRequestFlags parameter to the .bdrv_co_truncate() |
---|---|---|---|
2 | 2 | driver callbacks, and a supported_truncate_flags field in | |
3 | There's a couple of places left in the qcow2 code that still do the | 3 | BlockDriverState that allows drivers to advertise support for request |
4 | calculation manually, so let's replace them. | 4 | flags in the context of truncate. |
5 | 5 | ||
6 | Signed-off-by: Alberto Garcia <berto@igalia.com> | 6 | For now, we always pass 0 and no drivers declare support for any flag. |
7 | Reviewed-by: Eric Blake <eblake@redhat.com> | 7 | |
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
9 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
10 | Reviewed-by: Alberto Garcia <berto@igalia.com> | ||
11 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
12 | Message-Id: <20200424125448.63318-2-kwolf@redhat.com> | ||
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 13 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
9 | --- | 14 | --- |
10 | block/qcow2.c | 8 +++----- | 15 | include/block/block_int.h | 10 +++++++++- |
11 | 1 file changed, 3 insertions(+), 5 deletions(-) | 16 | block/crypto.c | 3 ++- |
12 | 17 | block/file-posix.c | 2 +- | |
18 | block/file-win32.c | 2 +- | ||
19 | block/gluster.c | 1 + | ||
20 | block/io.c | 8 +++++++- | ||
21 | block/iscsi.c | 2 +- | ||
22 | block/nfs.c | 3 ++- | ||
23 | block/qcow2.c | 2 +- | ||
24 | block/qed.c | 1 + | ||
25 | block/raw-format.c | 2 +- | ||
26 | block/rbd.c | 1 + | ||
27 | block/sheepdog.c | 4 ++-- | ||
28 | block/ssh.c | 2 +- | ||
29 | tests/test-block-iothread.c | 3 ++- | ||
30 | 15 files changed, 33 insertions(+), 13 deletions(-) | ||
31 | |||
32 | diff --git a/include/block/block_int.h b/include/block/block_int.h | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/include/block/block_int.h | ||
35 | +++ b/include/block/block_int.h | ||
36 | @@ -XXX,XX +XXX,XX @@ struct BlockDriver { | ||
37 | */ | ||
38 | int coroutine_fn (*bdrv_co_truncate)(BlockDriverState *bs, int64_t offset, | ||
39 | bool exact, PreallocMode prealloc, | ||
40 | - Error **errp); | ||
41 | + BdrvRequestFlags flags, Error **errp); | ||
42 | |||
43 | int64_t (*bdrv_getlength)(BlockDriverState *bs); | ||
44 | bool has_variable_length; | ||
45 | @@ -XXX,XX +XXX,XX @@ struct BlockDriverState { | ||
46 | /* Flags honored during pwrite_zeroes (so far: BDRV_REQ_FUA, | ||
47 | * BDRV_REQ_MAY_UNMAP, BDRV_REQ_WRITE_UNCHANGED) */ | ||
48 | unsigned int supported_zero_flags; | ||
49 | + /* | ||
50 | + * Flags honoured during truncate (so far: BDRV_REQ_ZERO_WRITE). | ||
51 | + * | ||
52 | + * If BDRV_REQ_ZERO_WRITE is given, the truncate operation must make sure | ||
53 | + * that any added space reads as all zeros. If this can't be guaranteed, | ||
54 | + * the operation must fail. | ||
55 | + */ | ||
56 | + unsigned int supported_truncate_flags; | ||
57 | |||
58 | /* the following member gives a name to every node on the bs graph. */ | ||
59 | char node_name[32]; | ||
60 | diff --git a/block/crypto.c b/block/crypto.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/block/crypto.c | ||
63 | +++ b/block/crypto.c | ||
64 | @@ -XXX,XX +XXX,XX @@ static int block_crypto_co_create_generic(BlockDriverState *bs, | ||
65 | |||
66 | static int coroutine_fn | ||
67 | block_crypto_co_truncate(BlockDriverState *bs, int64_t offset, bool exact, | ||
68 | - PreallocMode prealloc, Error **errp) | ||
69 | + PreallocMode prealloc, BdrvRequestFlags flags, | ||
70 | + Error **errp) | ||
71 | { | ||
72 | BlockCrypto *crypto = bs->opaque; | ||
73 | uint64_t payload_offset = | ||
74 | diff --git a/block/file-posix.c b/block/file-posix.c | ||
75 | index XXXXXXX..XXXXXXX 100644 | ||
76 | --- a/block/file-posix.c | ||
77 | +++ b/block/file-posix.c | ||
78 | @@ -XXX,XX +XXX,XX @@ raw_regular_truncate(BlockDriverState *bs, int fd, int64_t offset, | ||
79 | |||
80 | static int coroutine_fn raw_co_truncate(BlockDriverState *bs, int64_t offset, | ||
81 | bool exact, PreallocMode prealloc, | ||
82 | - Error **errp) | ||
83 | + BdrvRequestFlags flags, Error **errp) | ||
84 | { | ||
85 | BDRVRawState *s = bs->opaque; | ||
86 | struct stat st; | ||
87 | diff --git a/block/file-win32.c b/block/file-win32.c | ||
88 | index XXXXXXX..XXXXXXX 100644 | ||
89 | --- a/block/file-win32.c | ||
90 | +++ b/block/file-win32.c | ||
91 | @@ -XXX,XX +XXX,XX @@ static void raw_close(BlockDriverState *bs) | ||
92 | |||
93 | static int coroutine_fn raw_co_truncate(BlockDriverState *bs, int64_t offset, | ||
94 | bool exact, PreallocMode prealloc, | ||
95 | - Error **errp) | ||
96 | + BdrvRequestFlags flags, Error **errp) | ||
97 | { | ||
98 | BDRVRawState *s = bs->opaque; | ||
99 | LONG low, high; | ||
100 | diff --git a/block/gluster.c b/block/gluster.c | ||
101 | index XXXXXXX..XXXXXXX 100644 | ||
102 | --- a/block/gluster.c | ||
103 | +++ b/block/gluster.c | ||
104 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int qemu_gluster_co_truncate(BlockDriverState *bs, | ||
105 | int64_t offset, | ||
106 | bool exact, | ||
107 | PreallocMode prealloc, | ||
108 | + BdrvRequestFlags flags, | ||
109 | Error **errp) | ||
110 | { | ||
111 | BDRVGlusterState *s = bs->opaque; | ||
112 | diff --git a/block/io.c b/block/io.c | ||
113 | index XXXXXXX..XXXXXXX 100644 | ||
114 | --- a/block/io.c | ||
115 | +++ b/block/io.c | ||
116 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact, | ||
117 | BlockDriverState *bs = child->bs; | ||
118 | BlockDriver *drv = bs->drv; | ||
119 | BdrvTrackedRequest req; | ||
120 | + BdrvRequestFlags flags = 0; | ||
121 | int64_t old_size, new_bytes; | ||
122 | int ret; | ||
123 | |||
124 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact, | ||
125 | } | ||
126 | |||
127 | if (drv->bdrv_co_truncate) { | ||
128 | - ret = drv->bdrv_co_truncate(bs, offset, exact, prealloc, errp); | ||
129 | + if (flags & ~bs->supported_truncate_flags) { | ||
130 | + error_setg(errp, "Block driver does not support requested flags"); | ||
131 | + ret = -ENOTSUP; | ||
132 | + goto out; | ||
133 | + } | ||
134 | + ret = drv->bdrv_co_truncate(bs, offset, exact, prealloc, flags, errp); | ||
135 | } else if (bs->file && drv->is_filter) { | ||
136 | ret = bdrv_co_truncate(bs->file, offset, exact, prealloc, errp); | ||
137 | } else { | ||
138 | diff --git a/block/iscsi.c b/block/iscsi.c | ||
139 | index XXXXXXX..XXXXXXX 100644 | ||
140 | --- a/block/iscsi.c | ||
141 | +++ b/block/iscsi.c | ||
142 | @@ -XXX,XX +XXX,XX @@ static void iscsi_reopen_commit(BDRVReopenState *reopen_state) | ||
143 | |||
144 | static int coroutine_fn iscsi_co_truncate(BlockDriverState *bs, int64_t offset, | ||
145 | bool exact, PreallocMode prealloc, | ||
146 | - Error **errp) | ||
147 | + BdrvRequestFlags flags, Error **errp) | ||
148 | { | ||
149 | IscsiLun *iscsilun = bs->opaque; | ||
150 | int64_t cur_length; | ||
151 | diff --git a/block/nfs.c b/block/nfs.c | ||
152 | index XXXXXXX..XXXXXXX 100644 | ||
153 | --- a/block/nfs.c | ||
154 | +++ b/block/nfs.c | ||
155 | @@ -XXX,XX +XXX,XX @@ static int64_t nfs_get_allocated_file_size(BlockDriverState *bs) | ||
156 | |||
157 | static int coroutine_fn | ||
158 | nfs_file_co_truncate(BlockDriverState *bs, int64_t offset, bool exact, | ||
159 | - PreallocMode prealloc, Error **errp) | ||
160 | + PreallocMode prealloc, BdrvRequestFlags flags, | ||
161 | + Error **errp) | ||
162 | { | ||
163 | NFSClient *client = bs->opaque; | ||
164 | int ret; | ||
13 | diff --git a/block/qcow2.c b/block/qcow2.c | 165 | diff --git a/block/qcow2.c b/block/qcow2.c |
14 | index XXXXXXX..XXXXXXX 100644 | 166 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/block/qcow2.c | 167 | --- a/block/qcow2.c |
16 | +++ b/block/qcow2.c | 168 | +++ b/block/qcow2.c |
17 | @@ -XXX,XX +XXX,XX @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, | 169 | @@ -XXX,XX +XXX,XX @@ fail: |
18 | return -EINVAL; | 170 | |
19 | } | 171 | static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset, |
20 | 172 | bool exact, PreallocMode prealloc, | |
21 | - if (bitmaps_ext.bitmap_directory_offset & (s->cluster_size - 1)) { | 173 | - Error **errp) |
22 | + if (offset_into_cluster(s, bitmaps_ext.bitmap_directory_offset)) { | 174 | + BdrvRequestFlags flags, Error **errp) |
23 | error_setg(errp, "bitmaps_ext: " | ||
24 | "invalid bitmap directory offset"); | ||
25 | return -EINVAL; | ||
26 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_co_block_status(BlockDriverState *bs, | ||
27 | { | 175 | { |
28 | BDRVQcow2State *s = bs->opaque; | 176 | BDRVQcow2State *s = bs->opaque; |
29 | uint64_t cluster_offset; | 177 | uint64_t old_length; |
30 | - int index_in_cluster, ret; | 178 | diff --git a/block/qed.c b/block/qed.c |
31 | unsigned int bytes; | 179 | index XXXXXXX..XXXXXXX 100644 |
32 | - int status = 0; | 180 | --- a/block/qed.c |
33 | + int ret, status = 0; | 181 | +++ b/block/qed.c |
34 | 182 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_qed_co_truncate(BlockDriverState *bs, | |
35 | qemu_co_mutex_lock(&s->lock); | 183 | int64_t offset, |
36 | 184 | bool exact, | |
37 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_co_block_status(BlockDriverState *bs, | 185 | PreallocMode prealloc, |
38 | 186 | + BdrvRequestFlags flags, | |
39 | if ((ret == QCOW2_CLUSTER_NORMAL || ret == QCOW2_CLUSTER_ZERO_ALLOC) && | 187 | Error **errp) |
40 | !s->crypto) { | 188 | { |
41 | - index_in_cluster = offset & (s->cluster_size - 1); | 189 | BDRVQEDState *s = bs->opaque; |
42 | - *map = cluster_offset | index_in_cluster; | 190 | diff --git a/block/raw-format.c b/block/raw-format.c |
43 | + *map = cluster_offset | offset_into_cluster(s, offset); | 191 | index XXXXXXX..XXXXXXX 100644 |
44 | *file = s->data_file->bs; | 192 | --- a/block/raw-format.c |
45 | status |= BDRV_BLOCK_OFFSET_VALID; | 193 | +++ b/block/raw-format.c |
46 | } | 194 | @@ -XXX,XX +XXX,XX @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp) |
195 | |||
196 | static int coroutine_fn raw_co_truncate(BlockDriverState *bs, int64_t offset, | ||
197 | bool exact, PreallocMode prealloc, | ||
198 | - Error **errp) | ||
199 | + BdrvRequestFlags flags, Error **errp) | ||
200 | { | ||
201 | BDRVRawState *s = bs->opaque; | ||
202 | |||
203 | diff --git a/block/rbd.c b/block/rbd.c | ||
204 | index XXXXXXX..XXXXXXX 100644 | ||
205 | --- a/block/rbd.c | ||
206 | +++ b/block/rbd.c | ||
207 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qemu_rbd_co_truncate(BlockDriverState *bs, | ||
208 | int64_t offset, | ||
209 | bool exact, | ||
210 | PreallocMode prealloc, | ||
211 | + BdrvRequestFlags flags, | ||
212 | Error **errp) | ||
213 | { | ||
214 | int r; | ||
215 | diff --git a/block/sheepdog.c b/block/sheepdog.c | ||
216 | index XXXXXXX..XXXXXXX 100644 | ||
217 | --- a/block/sheepdog.c | ||
218 | +++ b/block/sheepdog.c | ||
219 | @@ -XXX,XX +XXX,XX @@ static int64_t sd_getlength(BlockDriverState *bs) | ||
220 | |||
221 | static int coroutine_fn sd_co_truncate(BlockDriverState *bs, int64_t offset, | ||
222 | bool exact, PreallocMode prealloc, | ||
223 | - Error **errp) | ||
224 | + BdrvRequestFlags flags, Error **errp) | ||
225 | { | ||
226 | BDRVSheepdogState *s = bs->opaque; | ||
227 | int ret, fd; | ||
228 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int sd_co_writev(BlockDriverState *bs, int64_t sector_num, | ||
229 | |||
230 | assert(!flags); | ||
231 | if (offset > s->inode.vdi_size) { | ||
232 | - ret = sd_co_truncate(bs, offset, false, PREALLOC_MODE_OFF, NULL); | ||
233 | + ret = sd_co_truncate(bs, offset, false, PREALLOC_MODE_OFF, 0, NULL); | ||
234 | if (ret < 0) { | ||
235 | return ret; | ||
236 | } | ||
237 | diff --git a/block/ssh.c b/block/ssh.c | ||
238 | index XXXXXXX..XXXXXXX 100644 | ||
239 | --- a/block/ssh.c | ||
240 | +++ b/block/ssh.c | ||
241 | @@ -XXX,XX +XXX,XX @@ static int64_t ssh_getlength(BlockDriverState *bs) | ||
242 | |||
243 | static int coroutine_fn ssh_co_truncate(BlockDriverState *bs, int64_t offset, | ||
244 | bool exact, PreallocMode prealloc, | ||
245 | - Error **errp) | ||
246 | + BdrvRequestFlags flags, Error **errp) | ||
247 | { | ||
248 | BDRVSSHState *s = bs->opaque; | ||
249 | |||
250 | diff --git a/tests/test-block-iothread.c b/tests/test-block-iothread.c | ||
251 | index XXXXXXX..XXXXXXX 100644 | ||
252 | --- a/tests/test-block-iothread.c | ||
253 | +++ b/tests/test-block-iothread.c | ||
254 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_test_co_pdiscard(BlockDriverState *bs, | ||
255 | |||
256 | static int coroutine_fn | ||
257 | bdrv_test_co_truncate(BlockDriverState *bs, int64_t offset, bool exact, | ||
258 | - PreallocMode prealloc, Error **errp) | ||
259 | + PreallocMode prealloc, BdrvRequestFlags flags, | ||
260 | + Error **errp) | ||
261 | { | ||
262 | return 0; | ||
263 | } | ||
47 | -- | 264 | -- |
48 | 2.20.1 | 265 | 2.25.3 |
49 | 266 | ||
50 | 267 | diff view generated by jsdifflib |
1 | In order to issue requests on an existing BlockBackend with the | 1 | Now that block drivers can support flags for .bdrv_co_truncate, expose |
---|---|---|---|
2 | 'qemu-io' HMP command, allow specifying the BlockBackend not only with a | 2 | the parameter in the node level interfaces bdrv_co_truncate() and |
3 | BlockBackend name, but also with a qdev ID/QOM path for a device that | 3 | bdrv_truncate(). |
4 | owns the (possibly anonymous) BlockBackend. | ||
5 | |||
6 | Because qdev names could be conflicting with BlockBackend and node | ||
7 | names, introduce a -d option to explicitly address a device. If the | ||
8 | option is not given, a BlockBackend or a node is addressed. | ||
9 | 4 | ||
10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
6 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
7 | Reviewed-by: Alberto Garcia <berto@igalia.com> | ||
8 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
9 | Message-Id: <20200424125448.63318-3-kwolf@redhat.com> | ||
10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
11 | --- | 11 | --- |
12 | monitor/hmp-cmds.c | 28 ++++++++++++++++++---------- | 12 | include/block/block.h | 5 +++-- |
13 | hmp-commands.hx | 8 +++++--- | 13 | block/block-backend.c | 2 +- |
14 | 2 files changed, 23 insertions(+), 13 deletions(-) | 14 | block/crypto.c | 2 +- |
15 | block/io.c | 12 +++++++----- | ||
16 | block/parallels.c | 6 +++--- | ||
17 | block/qcow.c | 4 ++-- | ||
18 | block/qcow2-refcount.c | 2 +- | ||
19 | block/qcow2.c | 15 +++++++++------ | ||
20 | block/raw-format.c | 2 +- | ||
21 | block/vhdx-log.c | 2 +- | ||
22 | block/vhdx.c | 2 +- | ||
23 | block/vmdk.c | 2 +- | ||
24 | tests/test-block-iothread.c | 6 +++--- | ||
25 | 13 files changed, 34 insertions(+), 28 deletions(-) | ||
15 | 26 | ||
16 | diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c | 27 | diff --git a/include/block/block.h b/include/block/block.h |
17 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/monitor/hmp-cmds.c | 29 | --- a/include/block/block.h |
19 | +++ b/monitor/hmp-cmds.c | 30 | +++ b/include/block/block.h |
20 | @@ -XXX,XX +XXX,XX @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict) | 31 | @@ -XXX,XX +XXX,XX @@ BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs, |
32 | void bdrv_refresh_filename(BlockDriverState *bs); | ||
33 | |||
34 | int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact, | ||
35 | - PreallocMode prealloc, Error **errp); | ||
36 | + PreallocMode prealloc, BdrvRequestFlags flags, | ||
37 | + Error **errp); | ||
38 | int bdrv_truncate(BdrvChild *child, int64_t offset, bool exact, | ||
39 | - PreallocMode prealloc, Error **errp); | ||
40 | + PreallocMode prealloc, BdrvRequestFlags flags, Error **errp); | ||
41 | |||
42 | int64_t bdrv_nb_sectors(BlockDriverState *bs); | ||
43 | int64_t bdrv_getlength(BlockDriverState *bs); | ||
44 | diff --git a/block/block-backend.c b/block/block-backend.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/block/block-backend.c | ||
47 | +++ b/block/block-backend.c | ||
48 | @@ -XXX,XX +XXX,XX @@ int blk_truncate(BlockBackend *blk, int64_t offset, bool exact, | ||
49 | return -ENOMEDIUM; | ||
50 | } | ||
51 | |||
52 | - return bdrv_truncate(blk->root, offset, exact, prealloc, errp); | ||
53 | + return bdrv_truncate(blk->root, offset, exact, prealloc, 0, errp); | ||
54 | } | ||
55 | |||
56 | int blk_save_vmstate(BlockBackend *blk, const uint8_t *buf, | ||
57 | diff --git a/block/crypto.c b/block/crypto.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/block/crypto.c | ||
60 | +++ b/block/crypto.c | ||
61 | @@ -XXX,XX +XXX,XX @@ block_crypto_co_truncate(BlockDriverState *bs, int64_t offset, bool exact, | ||
62 | |||
63 | offset += payload_offset; | ||
64 | |||
65 | - return bdrv_co_truncate(bs->file, offset, exact, prealloc, errp); | ||
66 | + return bdrv_co_truncate(bs->file, offset, exact, prealloc, 0, errp); | ||
67 | } | ||
68 | |||
69 | static void block_crypto_close(BlockDriverState *bs) | ||
70 | diff --git a/block/io.c b/block/io.c | ||
71 | index XXXXXXX..XXXXXXX 100644 | ||
72 | --- a/block/io.c | ||
73 | +++ b/block/io.c | ||
74 | @@ -XXX,XX +XXX,XX @@ static void bdrv_parent_cb_resize(BlockDriverState *bs) | ||
75 | * 'offset' bytes in length. | ||
76 | */ | ||
77 | int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact, | ||
78 | - PreallocMode prealloc, Error **errp) | ||
79 | + PreallocMode prealloc, BdrvRequestFlags flags, | ||
80 | + Error **errp) | ||
21 | { | 81 | { |
22 | BlockBackend *blk; | 82 | BlockDriverState *bs = child->bs; |
23 | BlockBackend *local_blk = NULL; | 83 | BlockDriver *drv = bs->drv; |
24 | + bool qdev = qdict_get_try_bool(qdict, "qdev", false); | 84 | BdrvTrackedRequest req; |
25 | const char* device = qdict_get_str(qdict, "device"); | 85 | - BdrvRequestFlags flags = 0; |
26 | const char* command = qdict_get_str(qdict, "command"); | 86 | int64_t old_size, new_bytes; |
27 | Error *err = NULL; | ||
28 | int ret; | 87 | int ret; |
29 | 88 | ||
30 | - blk = blk_by_name(device); | 89 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact, |
31 | - if (!blk) { | 90 | } |
32 | - BlockDriverState *bs = bdrv_lookup_bs(NULL, device, &err); | 91 | ret = drv->bdrv_co_truncate(bs, offset, exact, prealloc, flags, errp); |
33 | - if (bs) { | 92 | } else if (bs->file && drv->is_filter) { |
34 | - blk = local_blk = blk_new(bdrv_get_aio_context(bs), | 93 | - ret = bdrv_co_truncate(bs->file, offset, exact, prealloc, errp); |
35 | - 0, BLK_PERM_ALL); | 94 | + ret = bdrv_co_truncate(bs->file, offset, exact, prealloc, flags, errp); |
36 | - ret = blk_insert_bs(blk, bs, &err); | 95 | } else { |
37 | - if (ret < 0) { | 96 | error_setg(errp, "Image format driver does not support resize"); |
38 | + if (qdev) { | 97 | ret = -ENOTSUP; |
39 | + blk = blk_by_qdev_id(device, &err); | 98 | @@ -XXX,XX +XXX,XX @@ typedef struct TruncateCo { |
40 | + if (!blk) { | 99 | int64_t offset; |
41 | + goto fail; | 100 | bool exact; |
42 | + } | 101 | PreallocMode prealloc; |
43 | + } else { | 102 | + BdrvRequestFlags flags; |
44 | + blk = blk_by_name(device); | 103 | Error **errp; |
45 | + if (!blk) { | 104 | int ret; |
46 | + BlockDriverState *bs = bdrv_lookup_bs(NULL, device, &err); | 105 | } TruncateCo; |
47 | + if (bs) { | 106 | @@ -XXX,XX +XXX,XX @@ static void coroutine_fn bdrv_truncate_co_entry(void *opaque) |
48 | + blk = local_blk = blk_new(bdrv_get_aio_context(bs), | 107 | { |
49 | + 0, BLK_PERM_ALL); | 108 | TruncateCo *tco = opaque; |
50 | + ret = blk_insert_bs(blk, bs, &err); | 109 | tco->ret = bdrv_co_truncate(tco->child, tco->offset, tco->exact, |
51 | + if (ret < 0) { | 110 | - tco->prealloc, tco->errp); |
52 | + goto fail; | 111 | + tco->prealloc, tco->flags, tco->errp); |
53 | + } | 112 | aio_wait_kick(); |
54 | + } else { | 113 | } |
114 | |||
115 | int bdrv_truncate(BdrvChild *child, int64_t offset, bool exact, | ||
116 | - PreallocMode prealloc, Error **errp) | ||
117 | + PreallocMode prealloc, BdrvRequestFlags flags, Error **errp) | ||
118 | { | ||
119 | Coroutine *co; | ||
120 | TruncateCo tco = { | ||
121 | @@ -XXX,XX +XXX,XX @@ int bdrv_truncate(BdrvChild *child, int64_t offset, bool exact, | ||
122 | .offset = offset, | ||
123 | .exact = exact, | ||
124 | .prealloc = prealloc, | ||
125 | + .flags = flags, | ||
126 | .errp = errp, | ||
127 | .ret = NOT_DONE, | ||
128 | }; | ||
129 | diff --git a/block/parallels.c b/block/parallels.c | ||
130 | index XXXXXXX..XXXXXXX 100644 | ||
131 | --- a/block/parallels.c | ||
132 | +++ b/block/parallels.c | ||
133 | @@ -XXX,XX +XXX,XX @@ static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num, | ||
134 | } else { | ||
135 | ret = bdrv_truncate(bs->file, | ||
136 | (s->data_end + space) << BDRV_SECTOR_BITS, | ||
137 | - false, PREALLOC_MODE_OFF, NULL); | ||
138 | + false, PREALLOC_MODE_OFF, 0, NULL); | ||
139 | } | ||
140 | if (ret < 0) { | ||
141 | return ret; | ||
142 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, | ||
143 | * That means we have to pass exact=true. | ||
144 | */ | ||
145 | ret = bdrv_truncate(bs->file, res->image_end_offset, true, | ||
146 | - PREALLOC_MODE_OFF, &local_err); | ||
147 | + PREALLOC_MODE_OFF, 0, &local_err); | ||
148 | if (ret < 0) { | ||
149 | error_report_err(local_err); | ||
150 | res->check_errors++; | ||
151 | @@ -XXX,XX +XXX,XX @@ static void parallels_close(BlockDriverState *bs) | ||
152 | |||
153 | /* errors are ignored, so we might as well pass exact=true */ | ||
154 | bdrv_truncate(bs->file, s->data_end << BDRV_SECTOR_BITS, true, | ||
155 | - PREALLOC_MODE_OFF, NULL); | ||
156 | + PREALLOC_MODE_OFF, 0, NULL); | ||
157 | } | ||
158 | |||
159 | g_free(s->bat_dirty_bmap); | ||
160 | diff --git a/block/qcow.c b/block/qcow.c | ||
161 | index XXXXXXX..XXXXXXX 100644 | ||
162 | --- a/block/qcow.c | ||
163 | +++ b/block/qcow.c | ||
164 | @@ -XXX,XX +XXX,XX @@ static int get_cluster_offset(BlockDriverState *bs, | ||
165 | return -E2BIG; | ||
166 | } | ||
167 | ret = bdrv_truncate(bs->file, cluster_offset + s->cluster_size, | ||
168 | - false, PREALLOC_MODE_OFF, NULL); | ||
169 | + false, PREALLOC_MODE_OFF, 0, NULL); | ||
170 | if (ret < 0) { | ||
171 | return ret; | ||
172 | } | ||
173 | @@ -XXX,XX +XXX,XX @@ static int qcow_make_empty(BlockDriverState *bs) | ||
174 | l1_length) < 0) | ||
175 | return -1; | ||
176 | ret = bdrv_truncate(bs->file, s->l1_table_offset + l1_length, false, | ||
177 | - PREALLOC_MODE_OFF, NULL); | ||
178 | + PREALLOC_MODE_OFF, 0, NULL); | ||
179 | if (ret < 0) | ||
180 | return ret; | ||
181 | |||
182 | diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c | ||
183 | index XXXXXXX..XXXXXXX 100644 | ||
184 | --- a/block/qcow2-refcount.c | ||
185 | +++ b/block/qcow2-refcount.c | ||
186 | @@ -XXX,XX +XXX,XX @@ static int check_refblocks(BlockDriverState *bs, BdrvCheckResult *res, | ||
187 | } | ||
188 | |||
189 | ret = bdrv_truncate(bs->file, offset + s->cluster_size, false, | ||
190 | - PREALLOC_MODE_OFF, &local_err); | ||
191 | + PREALLOC_MODE_OFF, 0, &local_err); | ||
192 | if (ret < 0) { | ||
193 | error_report_err(local_err); | ||
194 | goto resize_fail; | ||
195 | diff --git a/block/qcow2.c b/block/qcow2.c | ||
196 | index XXXXXXX..XXXXXXX 100644 | ||
197 | --- a/block/qcow2.c | ||
198 | +++ b/block/qcow2.c | ||
199 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn preallocate_co(BlockDriverState *bs, uint64_t offset, | ||
200 | mode = PREALLOC_MODE_OFF; | ||
201 | } | ||
202 | ret = bdrv_co_truncate(s->data_file, host_offset + cur_bytes, false, | ||
203 | - mode, errp); | ||
204 | + mode, 0, errp); | ||
205 | if (ret < 0) { | ||
206 | return ret; | ||
207 | } | ||
208 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset, | ||
209 | * always fulfilled, so there is no need to pass it on.) | ||
210 | */ | ||
211 | bdrv_co_truncate(bs->file, (last_cluster + 1) * s->cluster_size, | ||
212 | - false, PREALLOC_MODE_OFF, &local_err); | ||
213 | + false, PREALLOC_MODE_OFF, 0, &local_err); | ||
214 | if (local_err) { | ||
215 | warn_reportf_err(local_err, | ||
216 | "Failed to truncate the tail of the image: "); | ||
217 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset, | ||
218 | * file should be resized to the exact target size, too, | ||
219 | * so we pass @exact here. | ||
220 | */ | ||
221 | - ret = bdrv_co_truncate(s->data_file, offset, exact, prealloc, errp); | ||
222 | + ret = bdrv_co_truncate(s->data_file, offset, exact, prealloc, 0, | ||
223 | + errp); | ||
224 | if (ret < 0) { | ||
55 | goto fail; | 225 | goto fail; |
56 | } | 226 | } |
57 | - } else { | 227 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset, |
58 | - goto fail; | 228 | new_file_size = allocation_start + |
59 | } | 229 | nb_new_data_clusters * s->cluster_size; |
60 | } | 230 | /* Image file grows, so @exact does not matter */ |
61 | 231 | - ret = bdrv_co_truncate(bs->file, new_file_size, false, prealloc, errp); | |
62 | diff --git a/hmp-commands.hx b/hmp-commands.hx | 232 | + ret = bdrv_co_truncate(bs->file, new_file_size, false, prealloc, 0, |
63 | index XXXXXXX..XXXXXXX 100644 | 233 | + errp); |
64 | --- a/hmp-commands.hx | 234 | if (ret < 0) { |
65 | +++ b/hmp-commands.hx | 235 | error_prepend(errp, "Failed to resize underlying file: "); |
66 | @@ -XXX,XX +XXX,XX @@ ETEXI | 236 | qcow2_free_clusters(bs, allocation_start, |
67 | 237 | @@ -XXX,XX +XXX,XX @@ qcow2_co_pwritev_compressed_part(BlockDriverState *bs, | |
68 | { | 238 | if (len < 0) { |
69 | .name = "qemu-io", | 239 | return len; |
70 | - .args_type = "device:B,command:s", | 240 | } |
71 | - .params = "[device] \"[command]\"", | 241 | - return bdrv_co_truncate(bs->file, len, false, PREALLOC_MODE_OFF, NULL); |
72 | - .help = "run a qemu-io command on a block device", | 242 | + return bdrv_co_truncate(bs->file, len, false, PREALLOC_MODE_OFF, 0, |
73 | + .args_type = "qdev:-d,device:B,command:s", | 243 | + NULL); |
74 | + .params = "[-d] [device] \"[command]\"", | 244 | } |
75 | + .help = "run a qemu-io command on a block device\n\t\t\t" | 245 | |
76 | + "-d: [device] is a device ID rather than a " | 246 | if (offset_into_cluster(s, offset)) { |
77 | + "drive ID or node name", | 247 | @@ -XXX,XX +XXX,XX @@ static int make_completely_empty(BlockDriverState *bs) |
78 | .cmd = hmp_qemu_io, | 248 | } |
79 | }, | 249 | |
80 | 250 | ret = bdrv_truncate(bs->file, (3 + l1_clusters) * s->cluster_size, false, | |
251 | - PREALLOC_MODE_OFF, &local_err); | ||
252 | + PREALLOC_MODE_OFF, 0, &local_err); | ||
253 | if (ret < 0) { | ||
254 | error_report_err(local_err); | ||
255 | goto fail; | ||
256 | diff --git a/block/raw-format.c b/block/raw-format.c | ||
257 | index XXXXXXX..XXXXXXX 100644 | ||
258 | --- a/block/raw-format.c | ||
259 | +++ b/block/raw-format.c | ||
260 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn raw_co_truncate(BlockDriverState *bs, int64_t offset, | ||
261 | |||
262 | s->size = offset; | ||
263 | offset += s->offset; | ||
264 | - return bdrv_co_truncate(bs->file, offset, exact, prealloc, errp); | ||
265 | + return bdrv_co_truncate(bs->file, offset, exact, prealloc, 0, errp); | ||
266 | } | ||
267 | |||
268 | static void raw_eject(BlockDriverState *bs, bool eject_flag) | ||
269 | diff --git a/block/vhdx-log.c b/block/vhdx-log.c | ||
270 | index XXXXXXX..XXXXXXX 100644 | ||
271 | --- a/block/vhdx-log.c | ||
272 | +++ b/block/vhdx-log.c | ||
273 | @@ -XXX,XX +XXX,XX @@ static int vhdx_log_flush(BlockDriverState *bs, BDRVVHDXState *s, | ||
274 | goto exit; | ||
275 | } | ||
276 | ret = bdrv_truncate(bs->file, new_file_size, false, | ||
277 | - PREALLOC_MODE_OFF, NULL); | ||
278 | + PREALLOC_MODE_OFF, 0, NULL); | ||
279 | if (ret < 0) { | ||
280 | goto exit; | ||
281 | } | ||
282 | diff --git a/block/vhdx.c b/block/vhdx.c | ||
283 | index XXXXXXX..XXXXXXX 100644 | ||
284 | --- a/block/vhdx.c | ||
285 | +++ b/block/vhdx.c | ||
286 | @@ -XXX,XX +XXX,XX @@ static int vhdx_allocate_block(BlockDriverState *bs, BDRVVHDXState *s, | ||
287 | } | ||
288 | |||
289 | return bdrv_truncate(bs->file, *new_offset + s->block_size, false, | ||
290 | - PREALLOC_MODE_OFF, NULL); | ||
291 | + PREALLOC_MODE_OFF, 0, NULL); | ||
292 | } | ||
293 | |||
294 | /* | ||
295 | diff --git a/block/vmdk.c b/block/vmdk.c | ||
296 | index XXXXXXX..XXXXXXX 100644 | ||
297 | --- a/block/vmdk.c | ||
298 | +++ b/block/vmdk.c | ||
299 | @@ -XXX,XX +XXX,XX @@ vmdk_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset, | ||
300 | } | ||
301 | length = QEMU_ALIGN_UP(length, BDRV_SECTOR_SIZE); | ||
302 | ret = bdrv_truncate(s->extents[i].file, length, false, | ||
303 | - PREALLOC_MODE_OFF, NULL); | ||
304 | + PREALLOC_MODE_OFF, 0, NULL); | ||
305 | if (ret < 0) { | ||
306 | return ret; | ||
307 | } | ||
308 | diff --git a/tests/test-block-iothread.c b/tests/test-block-iothread.c | ||
309 | index XXXXXXX..XXXXXXX 100644 | ||
310 | --- a/tests/test-block-iothread.c | ||
311 | +++ b/tests/test-block-iothread.c | ||
312 | @@ -XXX,XX +XXX,XX @@ static void test_sync_op_truncate(BdrvChild *c) | ||
313 | int ret; | ||
314 | |||
315 | /* Normal success path */ | ||
316 | - ret = bdrv_truncate(c, 65536, false, PREALLOC_MODE_OFF, NULL); | ||
317 | + ret = bdrv_truncate(c, 65536, false, PREALLOC_MODE_OFF, 0, NULL); | ||
318 | g_assert_cmpint(ret, ==, 0); | ||
319 | |||
320 | /* Early error: Negative offset */ | ||
321 | - ret = bdrv_truncate(c, -2, false, PREALLOC_MODE_OFF, NULL); | ||
322 | + ret = bdrv_truncate(c, -2, false, PREALLOC_MODE_OFF, 0, NULL); | ||
323 | g_assert_cmpint(ret, ==, -EINVAL); | ||
324 | |||
325 | /* Error: Read-only image */ | ||
326 | c->bs->read_only = true; | ||
327 | c->bs->open_flags &= ~BDRV_O_RDWR; | ||
328 | |||
329 | - ret = bdrv_truncate(c, 65536, false, PREALLOC_MODE_OFF, NULL); | ||
330 | + ret = bdrv_truncate(c, 65536, false, PREALLOC_MODE_OFF, 0, NULL); | ||
331 | g_assert_cmpint(ret, ==, -EACCES); | ||
332 | |||
333 | c->bs->read_only = false; | ||
81 | -- | 334 | -- |
82 | 2.20.1 | 335 | 2.25.3 |
83 | 336 | ||
84 | 337 | diff view generated by jsdifflib |
1 | From: Stefan Hajnoczi <stefanha@redhat.com> | 1 | Now that node level interface bdrv_truncate() supports passing request |
---|---|---|---|
2 | 2 | flags to the block driver, expose this on the BlockBackend level, too. | |
3 | Only apply --image-opts to the topmost image when listing an entire | 3 | |
4 | backing chain. It is incorrect to treat backing filenames as image | 4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
5 | options. Assuming we have the backing chain t.IMGFMT.base <- | 5 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
6 | t.IMGFMT.mid <- t.IMGFMT, qemu-img info fails as follows: | ||
7 | |||
8 | $ qemu-img info --backing-chain --image-opts \ | ||
9 | driver=qcow2,file.driver=file,file.filename=t.IMGFMT | ||
10 | qemu-img: Could not open 'TEST_DIR/t.IMGFMT.mid': Cannot find device=TEST_DIR/t.IMGFMT.mid nor node_name=TEST_DIR/t.IMGFMT.mid | ||
11 | |||
12 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
13 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
14 | Reviewed-by: Alberto Garcia <berto@igalia.com> | 6 | Reviewed-by: Alberto Garcia <berto@igalia.com> |
7 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
8 | Message-Id: <20200424125448.63318-4-kwolf@redhat.com> | ||
15 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
16 | --- | 10 | --- |
17 | qemu-img.c | 3 ++ | 11 | include/sysemu/block-backend.h | 2 +- |
18 | tests/qemu-iotests/279 | 57 ++++++++++++++++++++++++++++++++++++++ | 12 | block.c | 3 ++- |
19 | tests/qemu-iotests/279.out | 35 +++++++++++++++++++++++ | 13 | block/block-backend.c | 4 ++-- |
20 | tests/qemu-iotests/group | 1 + | 14 | block/commit.c | 4 ++-- |
21 | 4 files changed, 96 insertions(+) | 15 | block/crypto.c | 2 +- |
22 | create mode 100755 tests/qemu-iotests/279 | 16 | block/mirror.c | 2 +- |
23 | create mode 100644 tests/qemu-iotests/279.out | 17 | block/qcow2.c | 4 ++-- |
24 | 18 | block/qed.c | 2 +- | |
19 | block/vdi.c | 2 +- | ||
20 | block/vhdx.c | 4 ++-- | ||
21 | block/vmdk.c | 6 +++--- | ||
22 | block/vpc.c | 2 +- | ||
23 | blockdev.c | 2 +- | ||
24 | qemu-img.c | 2 +- | ||
25 | qemu-io-cmds.c | 2 +- | ||
26 | 15 files changed, 22 insertions(+), 21 deletions(-) | ||
27 | |||
28 | diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/include/sysemu/block-backend.h | ||
31 | +++ b/include/sysemu/block-backend.h | ||
32 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn blk_co_pwrite_zeroes(BlockBackend *blk, int64_t offset, | ||
33 | int blk_pwrite_compressed(BlockBackend *blk, int64_t offset, const void *buf, | ||
34 | int bytes); | ||
35 | int blk_truncate(BlockBackend *blk, int64_t offset, bool exact, | ||
36 | - PreallocMode prealloc, Error **errp); | ||
37 | + PreallocMode prealloc, BdrvRequestFlags flags, Error **errp); | ||
38 | int blk_pdiscard(BlockBackend *blk, int64_t offset, int bytes); | ||
39 | int blk_save_vmstate(BlockBackend *blk, const uint8_t *buf, | ||
40 | int64_t pos, int size); | ||
41 | diff --git a/block.c b/block.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/block.c | ||
44 | +++ b/block.c | ||
45 | @@ -XXX,XX +XXX,XX @@ static int64_t create_file_fallback_truncate(BlockBackend *blk, | ||
46 | int64_t size; | ||
47 | int ret; | ||
48 | |||
49 | - ret = blk_truncate(blk, minimum_size, false, PREALLOC_MODE_OFF, &local_err); | ||
50 | + ret = blk_truncate(blk, minimum_size, false, PREALLOC_MODE_OFF, 0, | ||
51 | + &local_err); | ||
52 | if (ret < 0 && ret != -ENOTSUP) { | ||
53 | error_propagate(errp, local_err); | ||
54 | return ret; | ||
55 | diff --git a/block/block-backend.c b/block/block-backend.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/block/block-backend.c | ||
58 | +++ b/block/block-backend.c | ||
59 | @@ -XXX,XX +XXX,XX @@ int blk_pwrite_compressed(BlockBackend *blk, int64_t offset, const void *buf, | ||
60 | } | ||
61 | |||
62 | int blk_truncate(BlockBackend *blk, int64_t offset, bool exact, | ||
63 | - PreallocMode prealloc, Error **errp) | ||
64 | + PreallocMode prealloc, BdrvRequestFlags flags, Error **errp) | ||
65 | { | ||
66 | if (!blk_is_available(blk)) { | ||
67 | error_setg(errp, "No medium inserted"); | ||
68 | return -ENOMEDIUM; | ||
69 | } | ||
70 | |||
71 | - return bdrv_truncate(blk->root, offset, exact, prealloc, 0, errp); | ||
72 | + return bdrv_truncate(blk->root, offset, exact, prealloc, flags, errp); | ||
73 | } | ||
74 | |||
75 | int blk_save_vmstate(BlockBackend *blk, const uint8_t *buf, | ||
76 | diff --git a/block/commit.c b/block/commit.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/block/commit.c | ||
79 | +++ b/block/commit.c | ||
80 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn commit_run(Job *job, Error **errp) | ||
81 | } | ||
82 | |||
83 | if (base_len < len) { | ||
84 | - ret = blk_truncate(s->base, len, false, PREALLOC_MODE_OFF, NULL); | ||
85 | + ret = blk_truncate(s->base, len, false, PREALLOC_MODE_OFF, 0, NULL); | ||
86 | if (ret) { | ||
87 | goto out; | ||
88 | } | ||
89 | @@ -XXX,XX +XXX,XX @@ int bdrv_commit(BlockDriverState *bs) | ||
90 | * grow the backing file image if possible. If not possible, | ||
91 | * we must return an error */ | ||
92 | if (length > backing_length) { | ||
93 | - ret = blk_truncate(backing, length, false, PREALLOC_MODE_OFF, | ||
94 | + ret = blk_truncate(backing, length, false, PREALLOC_MODE_OFF, 0, | ||
95 | &local_err); | ||
96 | if (ret < 0) { | ||
97 | error_report_err(local_err); | ||
98 | diff --git a/block/crypto.c b/block/crypto.c | ||
99 | index XXXXXXX..XXXXXXX 100644 | ||
100 | --- a/block/crypto.c | ||
101 | +++ b/block/crypto.c | ||
102 | @@ -XXX,XX +XXX,XX @@ static ssize_t block_crypto_init_func(QCryptoBlock *block, | ||
103 | * which will be used by the crypto header | ||
104 | */ | ||
105 | return blk_truncate(data->blk, data->size + headerlen, false, | ||
106 | - data->prealloc, errp); | ||
107 | + data->prealloc, 0, errp); | ||
108 | } | ||
109 | |||
110 | |||
111 | diff --git a/block/mirror.c b/block/mirror.c | ||
112 | index XXXXXXX..XXXXXXX 100644 | ||
113 | --- a/block/mirror.c | ||
114 | +++ b/block/mirror.c | ||
115 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn mirror_run(Job *job, Error **errp) | ||
116 | |||
117 | if (s->bdev_length > base_length) { | ||
118 | ret = blk_truncate(s->target, s->bdev_length, false, | ||
119 | - PREALLOC_MODE_OFF, NULL); | ||
120 | + PREALLOC_MODE_OFF, 0, NULL); | ||
121 | if (ret < 0) { | ||
122 | goto immediate_exit; | ||
123 | } | ||
124 | diff --git a/block/qcow2.c b/block/qcow2.c | ||
125 | index XXXXXXX..XXXXXXX 100644 | ||
126 | --- a/block/qcow2.c | ||
127 | +++ b/block/qcow2.c | ||
128 | @@ -XXX,XX +XXX,XX @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp) | ||
129 | |||
130 | /* Okay, now that we have a valid image, let's give it the right size */ | ||
131 | ret = blk_truncate(blk, qcow2_opts->size, false, qcow2_opts->preallocation, | ||
132 | - errp); | ||
133 | + 0, errp); | ||
134 | if (ret < 0) { | ||
135 | error_prepend(errp, "Could not resize image: "); | ||
136 | goto out; | ||
137 | @@ -XXX,XX +XXX,XX @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts, | ||
138 | * Amending image options should ensure that the image has | ||
139 | * exactly the given new values, so pass exact=true here. | ||
140 | */ | ||
141 | - ret = blk_truncate(blk, new_size, true, PREALLOC_MODE_OFF, errp); | ||
142 | + ret = blk_truncate(blk, new_size, true, PREALLOC_MODE_OFF, 0, errp); | ||
143 | blk_unref(blk); | ||
144 | if (ret < 0) { | ||
145 | return ret; | ||
146 | diff --git a/block/qed.c b/block/qed.c | ||
147 | index XXXXXXX..XXXXXXX 100644 | ||
148 | --- a/block/qed.c | ||
149 | +++ b/block/qed.c | ||
150 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_qed_co_create(BlockdevCreateOptions *opts, | ||
151 | * The QED format associates file length with allocation status, | ||
152 | * so a new file (which is empty) must have a length of 0. | ||
153 | */ | ||
154 | - ret = blk_truncate(blk, 0, true, PREALLOC_MODE_OFF, errp); | ||
155 | + ret = blk_truncate(blk, 0, true, PREALLOC_MODE_OFF, 0, errp); | ||
156 | if (ret < 0) { | ||
157 | goto out; | ||
158 | } | ||
159 | diff --git a/block/vdi.c b/block/vdi.c | ||
160 | index XXXXXXX..XXXXXXX 100644 | ||
161 | --- a/block/vdi.c | ||
162 | +++ b/block/vdi.c | ||
163 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn vdi_co_do_create(BlockdevCreateOptions *create_options, | ||
164 | |||
165 | if (image_type == VDI_TYPE_STATIC) { | ||
166 | ret = blk_truncate(blk, offset + blocks * block_size, false, | ||
167 | - PREALLOC_MODE_OFF, errp); | ||
168 | + PREALLOC_MODE_OFF, 0, errp); | ||
169 | if (ret < 0) { | ||
170 | error_prepend(errp, "Failed to statically allocate file"); | ||
171 | goto exit; | ||
172 | diff --git a/block/vhdx.c b/block/vhdx.c | ||
173 | index XXXXXXX..XXXXXXX 100644 | ||
174 | --- a/block/vhdx.c | ||
175 | +++ b/block/vhdx.c | ||
176 | @@ -XXX,XX +XXX,XX @@ static int vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s, | ||
177 | /* All zeroes, so we can just extend the file - the end of the BAT | ||
178 | * is the furthest thing we have written yet */ | ||
179 | ret = blk_truncate(blk, data_file_offset, false, PREALLOC_MODE_OFF, | ||
180 | - errp); | ||
181 | + 0, errp); | ||
182 | if (ret < 0) { | ||
183 | goto exit; | ||
184 | } | ||
185 | } else if (type == VHDX_TYPE_FIXED) { | ||
186 | ret = blk_truncate(blk, data_file_offset + image_size, false, | ||
187 | - PREALLOC_MODE_OFF, errp); | ||
188 | + PREALLOC_MODE_OFF, 0, errp); | ||
189 | if (ret < 0) { | ||
190 | goto exit; | ||
191 | } | ||
192 | diff --git a/block/vmdk.c b/block/vmdk.c | ||
193 | index XXXXXXX..XXXXXXX 100644 | ||
194 | --- a/block/vmdk.c | ||
195 | +++ b/block/vmdk.c | ||
196 | @@ -XXX,XX +XXX,XX @@ static int vmdk_init_extent(BlockBackend *blk, | ||
197 | int gd_buf_size; | ||
198 | |||
199 | if (flat) { | ||
200 | - ret = blk_truncate(blk, filesize, false, PREALLOC_MODE_OFF, errp); | ||
201 | + ret = blk_truncate(blk, filesize, false, PREALLOC_MODE_OFF, 0, errp); | ||
202 | goto exit; | ||
203 | } | ||
204 | magic = cpu_to_be32(VMDK4_MAGIC); | ||
205 | @@ -XXX,XX +XXX,XX @@ static int vmdk_init_extent(BlockBackend *blk, | ||
206 | } | ||
207 | |||
208 | ret = blk_truncate(blk, le64_to_cpu(header.grain_offset) << 9, false, | ||
209 | - PREALLOC_MODE_OFF, errp); | ||
210 | + PREALLOC_MODE_OFF, 0, errp); | ||
211 | if (ret < 0) { | ||
212 | goto exit; | ||
213 | } | ||
214 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn vmdk_co_do_create(int64_t size, | ||
215 | /* bdrv_pwrite write padding zeros to align to sector, we don't need that | ||
216 | * for description file */ | ||
217 | if (desc_offset == 0) { | ||
218 | - ret = blk_truncate(blk, desc_len, false, PREALLOC_MODE_OFF, errp); | ||
219 | + ret = blk_truncate(blk, desc_len, false, PREALLOC_MODE_OFF, 0, errp); | ||
220 | if (ret < 0) { | ||
221 | goto exit; | ||
222 | } | ||
223 | diff --git a/block/vpc.c b/block/vpc.c | ||
224 | index XXXXXXX..XXXXXXX 100644 | ||
225 | --- a/block/vpc.c | ||
226 | +++ b/block/vpc.c | ||
227 | @@ -XXX,XX +XXX,XX @@ static int create_fixed_disk(BlockBackend *blk, uint8_t *buf, | ||
228 | /* Add footer to total size */ | ||
229 | total_size += HEADER_SIZE; | ||
230 | |||
231 | - ret = blk_truncate(blk, total_size, false, PREALLOC_MODE_OFF, errp); | ||
232 | + ret = blk_truncate(blk, total_size, false, PREALLOC_MODE_OFF, 0, errp); | ||
233 | if (ret < 0) { | ||
234 | return ret; | ||
235 | } | ||
236 | diff --git a/blockdev.c b/blockdev.c | ||
237 | index XXXXXXX..XXXXXXX 100644 | ||
238 | --- a/blockdev.c | ||
239 | +++ b/blockdev.c | ||
240 | @@ -XXX,XX +XXX,XX @@ void qmp_block_resize(bool has_device, const char *device, | ||
241 | } | ||
242 | |||
243 | bdrv_drained_begin(bs); | ||
244 | - ret = blk_truncate(blk, size, false, PREALLOC_MODE_OFF, errp); | ||
245 | + ret = blk_truncate(blk, size, false, PREALLOC_MODE_OFF, 0, errp); | ||
246 | bdrv_drained_end(bs); | ||
247 | |||
248 | out: | ||
25 | diff --git a/qemu-img.c b/qemu-img.c | 249 | diff --git a/qemu-img.c b/qemu-img.c |
26 | index XXXXXXX..XXXXXXX 100644 | 250 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/qemu-img.c | 251 | --- a/qemu-img.c |
28 | +++ b/qemu-img.c | 252 | +++ b/qemu-img.c |
29 | @@ -XXX,XX +XXX,XX @@ static ImageInfoList *collect_image_info_list(bool image_opts, | 253 | @@ -XXX,XX +XXX,XX @@ static int img_resize(int argc, char **argv) |
30 | 254 | * resizing, so pass @exact=true. It is of no use to report | |
31 | blk_unref(blk); | 255 | * success when the image has not actually been resized. |
32 | 256 | */ | |
33 | + /* Clear parameters that only apply to the topmost image */ | 257 | - ret = blk_truncate(blk, total_size, true, prealloc, &err); |
34 | filename = fmt = NULL; | 258 | + ret = blk_truncate(blk, total_size, true, prealloc, 0, &err); |
35 | + image_opts = false; | 259 | if (!ret) { |
36 | + | 260 | qprintf(quiet, "Image resized.\n"); |
37 | if (chain) { | 261 | } else { |
38 | if (info->has_full_backing_filename) { | 262 | diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c |
39 | filename = info->full_backing_filename; | 263 | index XXXXXXX..XXXXXXX 100644 |
40 | diff --git a/tests/qemu-iotests/279 b/tests/qemu-iotests/279 | 264 | --- a/qemu-io-cmds.c |
41 | new file mode 100755 | 265 | +++ b/qemu-io-cmds.c |
42 | index XXXXXXX..XXXXXXX | 266 | @@ -XXX,XX +XXX,XX @@ static int truncate_f(BlockBackend *blk, int argc, char **argv) |
43 | --- /dev/null | 267 | * exact=true. It is better to err on the "emit more errors" side |
44 | +++ b/tests/qemu-iotests/279 | 268 | * than to be overly permissive. |
45 | @@ -XXX,XX +XXX,XX @@ | 269 | */ |
46 | +#!/usr/bin/env bash | 270 | - ret = blk_truncate(blk, offset, true, PREALLOC_MODE_OFF, &local_err); |
47 | +# | 271 | + ret = blk_truncate(blk, offset, true, PREALLOC_MODE_OFF, 0, &local_err); |
48 | +# Test qemu-img --backing-chain --image-opts | 272 | if (ret < 0) { |
49 | +# | 273 | error_report_err(local_err); |
50 | +# Copyright (C) 2019 Red Hat, Inc. | 274 | return ret; |
51 | +# | ||
52 | +# This program is free software; you can redistribute it and/or modify | ||
53 | +# it under the terms of the GNU General Public License as published by | ||
54 | +# the Free Software Foundation; either version 2 of the License, or | ||
55 | +# (at your option) any later version. | ||
56 | +# | ||
57 | +# This program is distributed in the hope that it will be useful, | ||
58 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
59 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
60 | +# GNU General Public License for more details. | ||
61 | +# | ||
62 | +# You should have received a copy of the GNU General Public License | ||
63 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
64 | +# | ||
65 | + | ||
66 | +seq=$(basename "$0") | ||
67 | +echo "QA output created by $seq" | ||
68 | + | ||
69 | +status=1 # failure is the default! | ||
70 | + | ||
71 | +_cleanup() | ||
72 | +{ | ||
73 | + _cleanup_test_img | ||
74 | + rm -f "$TEST_IMG.mid" | ||
75 | +} | ||
76 | +trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
77 | + | ||
78 | +# get standard environment, filters and checks | ||
79 | +. ./common.rc | ||
80 | +. ./common.filter | ||
81 | + | ||
82 | +# Backing files are required... | ||
83 | +_supported_fmt qcow qcow2 vmdk qed | ||
84 | +_supported_proto file | ||
85 | +_supported_os Linux | ||
86 | + | ||
87 | +TEST_IMG="$TEST_IMG.base" _make_test_img 64M | ||
88 | +TEST_IMG="$TEST_IMG.mid" _make_test_img -b "$TEST_IMG.base" | ||
89 | +_make_test_img -b "$TEST_IMG.mid" | ||
90 | + | ||
91 | +echo | ||
92 | +echo '== qemu-img info --backing-chain ==' | ||
93 | +_img_info --backing-chain | _filter_img_info | ||
94 | + | ||
95 | +echo | ||
96 | +echo '== qemu-img info --backing-chain --image-opts ==' | ||
97 | +TEST_IMG="driver=qcow2,file.driver=file,file.filename=$TEST_IMG" _img_info --backing-chain --image-opts | _filter_img_info | ||
98 | + | ||
99 | +# success, all done | ||
100 | +echo "*** done" | ||
101 | +rm -f $seq.full | ||
102 | +status=0 | ||
103 | diff --git a/tests/qemu-iotests/279.out b/tests/qemu-iotests/279.out | ||
104 | new file mode 100644 | ||
105 | index XXXXXXX..XXXXXXX | ||
106 | --- /dev/null | ||
107 | +++ b/tests/qemu-iotests/279.out | ||
108 | @@ -XXX,XX +XXX,XX @@ | ||
109 | +QA output created by 279 | ||
110 | +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=67108864 | ||
111 | +Formatting 'TEST_DIR/t.IMGFMT.mid', fmt=IMGFMT size=67108864 backing_file=TEST_DIR/t.IMGFMT.base | ||
112 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 backing_file=TEST_DIR/t.IMGFMT.mid | ||
113 | + | ||
114 | +== qemu-img info --backing-chain == | ||
115 | +image: TEST_DIR/t.IMGFMT | ||
116 | +file format: IMGFMT | ||
117 | +virtual size: 64 MiB (67108864 bytes) | ||
118 | +backing file: TEST_DIR/t.IMGFMT.mid | ||
119 | + | ||
120 | +image: TEST_DIR/t.IMGFMT.mid | ||
121 | +file format: IMGFMT | ||
122 | +virtual size: 64 MiB (67108864 bytes) | ||
123 | +backing file: TEST_DIR/t.IMGFMT.base | ||
124 | + | ||
125 | +image: TEST_DIR/t.IMGFMT.base | ||
126 | +file format: IMGFMT | ||
127 | +virtual size: 64 MiB (67108864 bytes) | ||
128 | + | ||
129 | +== qemu-img info --backing-chain --image-opts == | ||
130 | +image: TEST_DIR/t.IMGFMT | ||
131 | +file format: IMGFMT | ||
132 | +virtual size: 64 MiB (67108864 bytes) | ||
133 | +backing file: TEST_DIR/t.IMGFMT.mid | ||
134 | + | ||
135 | +image: TEST_DIR/t.IMGFMT.mid | ||
136 | +file format: IMGFMT | ||
137 | +virtual size: 64 MiB (67108864 bytes) | ||
138 | +backing file: TEST_DIR/t.IMGFMT.base | ||
139 | + | ||
140 | +image: TEST_DIR/t.IMGFMT.base | ||
141 | +file format: IMGFMT | ||
142 | +virtual size: 64 MiB (67108864 bytes) | ||
143 | +*** done | ||
144 | diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group | ||
145 | index XXXXXXX..XXXXXXX 100644 | ||
146 | --- a/tests/qemu-iotests/group | ||
147 | +++ b/tests/qemu-iotests/group | ||
148 | @@ -XXX,XX +XXX,XX @@ | ||
149 | 272 rw | ||
150 | 273 backing quick | ||
151 | 277 rw quick | ||
152 | +279 rw backing quick | ||
153 | -- | 275 | -- |
154 | 2.20.1 | 276 | 2.25.3 |
155 | 277 | ||
156 | 278 | diff view generated by jsdifflib |
1 | In the common case, qcow2_co_pwrite_zeroes() already only modifies | 1 | If BDRV_REQ_ZERO_WRITE is set and we're extending the image, calling |
---|---|---|---|
2 | metadata case, so we're fine with or without BDRV_REQ_NO_FALLBACK set. | 2 | qcow2_cluster_zeroize() with flags=0 does the right thing: It doesn't |
3 | 3 | undo any previous preallocation, but just adds the zero flag to all | |
4 | The only exception is when using an external data file, where the | 4 | relevant L2 entries. If an external data file is in use, a write_zeroes |
5 | request is passed down to the block driver of the external data file. We | 5 | request to the data file is made instead. |
6 | are forwarding the BDRV_REQ_NO_FALLBACK flag there, though, so this is | ||
7 | fine, too. | ||
8 | |||
9 | Declare the flag supported therefore. | ||
10 | 6 | ||
11 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 7 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
8 | Message-Id: <20200424125448.63318-5-kwolf@redhat.com> | ||
12 | Reviewed-by: Eric Blake <eblake@redhat.com> | 9 | Reviewed-by: Eric Blake <eblake@redhat.com> |
13 | Reviewed-by: Max Reitz <mreitz@redhat.com> | 10 | Reviewed-by: Max Reitz <mreitz@redhat.com> |
14 | Reviewed-by: Alberto Garcia <berto@igalia.com> | 11 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
15 | --- | 12 | --- |
16 | block/qcow2.c | 3 ++- | 13 | block/qcow2-cluster.c | 2 +- |
17 | 1 file changed, 2 insertions(+), 1 deletion(-) | 14 | block/qcow2.c | 34 ++++++++++++++++++++++++++++++++++ |
15 | 2 files changed, 35 insertions(+), 1 deletion(-) | ||
18 | 16 | ||
17 | diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/block/qcow2-cluster.c | ||
20 | +++ b/block/qcow2-cluster.c | ||
21 | @@ -XXX,XX +XXX,XX @@ int qcow2_cluster_zeroize(BlockDriverState *bs, uint64_t offset, | ||
22 | /* Caller must pass aligned values, except at image end */ | ||
23 | assert(QEMU_IS_ALIGNED(offset, s->cluster_size)); | ||
24 | assert(QEMU_IS_ALIGNED(end_offset, s->cluster_size) || | ||
25 | - end_offset == bs->total_sectors << BDRV_SECTOR_BITS); | ||
26 | + end_offset >= bs->total_sectors << BDRV_SECTOR_BITS); | ||
27 | |||
28 | /* The zero flag is only supported by version 3 and newer */ | ||
29 | if (s->qcow_version < 3) { | ||
19 | diff --git a/block/qcow2.c b/block/qcow2.c | 30 | diff --git a/block/qcow2.c b/block/qcow2.c |
20 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/block/qcow2.c | 32 | --- a/block/qcow2.c |
22 | +++ b/block/qcow2.c | 33 | +++ b/block/qcow2.c |
23 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, | 34 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, |
24 | } | 35 | |
25 | } | 36 | bs->supported_zero_flags = header.version >= 3 ? |
26 | 37 | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK : 0; | |
27 | - bs->supported_zero_flags = header.version >= 3 ? BDRV_REQ_MAY_UNMAP : 0; | 38 | + bs->supported_truncate_flags = BDRV_REQ_ZERO_WRITE; |
28 | + bs->supported_zero_flags = header.version >= 3 ? | ||
29 | + BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK : 0; | ||
30 | 39 | ||
31 | /* Repair image if dirty */ | 40 | /* Repair image if dirty */ |
32 | if (!(flags & (BDRV_O_CHECK | BDRV_O_INACTIVE)) && !bs->read_only && | 41 | if (!(flags & (BDRV_O_CHECK | BDRV_O_INACTIVE)) && !bs->read_only && |
42 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset, | ||
43 | g_assert_not_reached(); | ||
44 | } | ||
45 | |||
46 | + if ((flags & BDRV_REQ_ZERO_WRITE) && offset > old_length) { | ||
47 | + uint64_t zero_start = QEMU_ALIGN_UP(old_length, s->cluster_size); | ||
48 | + | ||
49 | + /* | ||
50 | + * Use zero clusters as much as we can. qcow2_cluster_zeroize() | ||
51 | + * requires a cluster-aligned start. The end may be unaligned if it is | ||
52 | + * at the end of the image (which it is here). | ||
53 | + */ | ||
54 | + ret = qcow2_cluster_zeroize(bs, zero_start, offset - zero_start, 0); | ||
55 | + if (ret < 0) { | ||
56 | + error_setg_errno(errp, -ret, "Failed to zero out new clusters"); | ||
57 | + goto fail; | ||
58 | + } | ||
59 | + | ||
60 | + /* Write explicit zeros for the unaligned head */ | ||
61 | + if (zero_start > old_length) { | ||
62 | + uint64_t len = zero_start - old_length; | ||
63 | + uint8_t *buf = qemu_blockalign0(bs, len); | ||
64 | + QEMUIOVector qiov; | ||
65 | + qemu_iovec_init_buf(&qiov, buf, len); | ||
66 | + | ||
67 | + qemu_co_mutex_unlock(&s->lock); | ||
68 | + ret = qcow2_co_pwritev_part(bs, old_length, len, &qiov, 0, 0); | ||
69 | + qemu_co_mutex_lock(&s->lock); | ||
70 | + | ||
71 | + qemu_vfree(buf); | ||
72 | + if (ret < 0) { | ||
73 | + error_setg_errno(errp, -ret, "Failed to zero out the new area"); | ||
74 | + goto fail; | ||
75 | + } | ||
76 | + } | ||
77 | + } | ||
78 | + | ||
79 | if (prealloc != PREALLOC_MODE_OFF) { | ||
80 | /* Flush metadata before actually changing the image size */ | ||
81 | ret = qcow2_write_caches(bs); | ||
33 | -- | 82 | -- |
34 | 2.20.1 | 83 | 2.25.3 |
35 | 84 | ||
36 | 85 | diff view generated by jsdifflib |
1 | Add a function that runs qemu-io and logs the output with the | 1 | The raw format driver can simply forward the flag and let its bs->file |
---|---|---|---|
2 | appropriate filters applied. | 2 | child take care of actually providing the zeros. |
3 | 3 | ||
4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
5 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
5 | Reviewed-by: Eric Blake <eblake@redhat.com> | 6 | Reviewed-by: Eric Blake <eblake@redhat.com> |
6 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 7 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
7 | Reviewed-by: Alberto Garcia <berto@igalia.com> | 8 | Message-Id: <20200424125448.63318-6-kwolf@redhat.com> |
8 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | 9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
9 | --- | 10 | --- |
10 | tests/qemu-iotests/iotests.py | 5 +++++ | 11 | block/raw-format.c | 4 +++- |
11 | 1 file changed, 5 insertions(+) | 12 | 1 file changed, 3 insertions(+), 1 deletion(-) |
12 | 13 | ||
13 | diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py | 14 | diff --git a/block/raw-format.c b/block/raw-format.c |
14 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/tests/qemu-iotests/iotests.py | 16 | --- a/block/raw-format.c |
16 | +++ b/tests/qemu-iotests/iotests.py | 17 | +++ b/block/raw-format.c |
17 | @@ -XXX,XX +XXX,XX @@ def qemu_io(*args): | 18 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn raw_co_truncate(BlockDriverState *bs, int64_t offset, |
18 | sys.stderr.write('qemu-io received signal %i: %s\n' % (-exitcode, ' '.join(args))) | 19 | |
19 | return subp.communicate()[0] | 20 | s->size = offset; |
20 | 21 | offset += s->offset; | |
21 | +def qemu_io_log(*args): | 22 | - return bdrv_co_truncate(bs->file, offset, exact, prealloc, 0, errp); |
22 | + result = qemu_io(*args) | 23 | + return bdrv_co_truncate(bs->file, offset, exact, prealloc, flags, errp); |
23 | + log(result, filters=[filter_testfiles, filter_qemu_io]) | 24 | } |
24 | + return result | 25 | |
25 | + | 26 | static void raw_eject(BlockDriverState *bs, bool eject_flag) |
26 | def qemu_io_silent(*args): | 27 | @@ -XXX,XX +XXX,XX @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags, |
27 | '''Run qemu-io and return the exit code, suppressing stdout''' | 28 | bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED | |
28 | args = qemu_io_args + list(args) | 29 | ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) & |
30 | bs->file->bs->supported_zero_flags); | ||
31 | + bs->supported_truncate_flags = bs->file->bs->supported_truncate_flags & | ||
32 | + BDRV_REQ_ZERO_WRITE; | ||
33 | |||
34 | if (bs->probed && !bdrv_is_read_only(bs)) { | ||
35 | bdrv_refresh_filename(bs->file->bs); | ||
29 | -- | 36 | -- |
30 | 2.20.1 | 37 | 2.25.3 |
31 | 38 | ||
32 | 39 | diff view generated by jsdifflib |
1 | The error message for a negative speed uses QERR_INVALID_PARAMETER, | 1 | For regular files, we always get BDRV_REQ_ZERO_WRITE behaviour from the |
---|---|---|---|
2 | which implies that the 'speed' option doesn't even exist: | 2 | OS, so we can advertise the flag and just ignore it. |
3 | |||
4 | {"error": {"class": "GenericError", "desc": "Invalid parameter 'speed'"}} | ||
5 | |||
6 | Make it use QERR_INVALID_PARAMETER_VALUE instead: | ||
7 | |||
8 | {"error": {"class": "GenericError", "desc": "Parameter 'speed' expects a non-negative value"}} | ||
9 | 3 | ||
10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
5 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
11 | Reviewed-by: Alberto Garcia <berto@igalia.com> | 6 | Reviewed-by: Alberto Garcia <berto@igalia.com> |
12 | Reviewed-by: Max Reitz <mreitz@redhat.com> | 7 | Reviewed-by: Max Reitz <mreitz@redhat.com> |
8 | Message-Id: <20200424125448.63318-7-kwolf@redhat.com> | ||
9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
13 | --- | 10 | --- |
14 | blockjob.c | 3 ++- | 11 | block/file-posix.c | 4 ++++ |
15 | tests/qemu-iotests/030 | 4 ++-- | 12 | 1 file changed, 4 insertions(+) |
16 | 2 files changed, 4 insertions(+), 3 deletions(-) | ||
17 | 13 | ||
18 | diff --git a/blockjob.c b/blockjob.c | 14 | diff --git a/block/file-posix.c b/block/file-posix.c |
19 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/blockjob.c | 16 | --- a/block/file-posix.c |
21 | +++ b/blockjob.c | 17 | +++ b/block/file-posix.c |
22 | @@ -XXX,XX +XXX,XX @@ void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp) | 18 | @@ -XXX,XX +XXX,XX @@ static int raw_open_common(BlockDriverState *bs, QDict *options, |
23 | return; | 19 | #endif |
24 | } | 20 | |
25 | if (speed < 0) { | 21 | bs->supported_zero_flags = BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK; |
26 | - error_setg(errp, QERR_INVALID_PARAMETER, "speed"); | 22 | + if (S_ISREG(st.st_mode)) { |
27 | + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", | 23 | + /* When extending regular files, we get zeros from the OS */ |
28 | + "a non-negative value"); | 24 | + bs->supported_truncate_flags = BDRV_REQ_ZERO_WRITE; |
29 | return; | 25 | + } |
30 | } | 26 | ret = 0; |
31 | 27 | fail: | |
32 | diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030 | 28 | if (filename && (bdrv_flags & BDRV_O_TEMPORARY)) { |
33 | index XXXXXXX..XXXXXXX 100755 | ||
34 | --- a/tests/qemu-iotests/030 | ||
35 | +++ b/tests/qemu-iotests/030 | ||
36 | @@ -XXX,XX +XXX,XX @@ class TestSetSpeed(iotests.QMPTestCase): | ||
37 | self.assert_no_active_block_jobs() | ||
38 | |||
39 | result = self.vm.qmp('block-stream', device='drive0', speed=-1) | ||
40 | - self.assert_qmp(result, 'error/desc', "Invalid parameter 'speed'") | ||
41 | + self.assert_qmp(result, 'error/desc', "Parameter 'speed' expects a non-negative value") | ||
42 | |||
43 | self.assert_no_active_block_jobs() | ||
44 | |||
45 | @@ -XXX,XX +XXX,XX @@ class TestSetSpeed(iotests.QMPTestCase): | ||
46 | self.assert_qmp(result, 'return', {}) | ||
47 | |||
48 | result = self.vm.qmp('block-job-set-speed', device='drive0', speed=-1) | ||
49 | - self.assert_qmp(result, 'error/desc', "Invalid parameter 'speed'") | ||
50 | + self.assert_qmp(result, 'error/desc', "Parameter 'speed' expects a non-negative value") | ||
51 | |||
52 | self.cancel_and_wait(resume=True) | ||
53 | |||
54 | -- | 29 | -- |
55 | 2.20.1 | 30 | 2.25.3 |
56 | 31 | ||
57 | 32 | diff view generated by jsdifflib |
1 | If both the create options (qemu-img create -o ...) and the size | 1 | When extending the size of an image that has a backing file larger than |
---|---|---|---|
2 | parameter were given, the size parameter was silently ignored. Instead, | 2 | its old size, make sure that the backing file data doesn't become |
3 | make specifying two sizes an error. | 3 | visible in the guest, but the added area is properly zeroed out. |
4 | |||
5 | Consider the following scenario where the overlay is shorter than its | ||
6 | backing file: | ||
7 | |||
8 | base.qcow2: AAAAAAAA | ||
9 | overlay.qcow2: BBBB | ||
10 | |||
11 | When resizing (extending) overlay.qcow2, the new blocks should not stay | ||
12 | unallocated and make the additional As from base.qcow2 visible like | ||
13 | before this patch, but zeros should be read. | ||
14 | |||
15 | A similar case happens with the various variants of a commit job when an | ||
16 | intermediate file is short (- for unallocated): | ||
17 | |||
18 | base.qcow2: A-A-AAAA | ||
19 | mid.qcow2: BB-B | ||
20 | top.qcow2: C--C--C- | ||
21 | |||
22 | After commit top.qcow2 to mid.qcow2, the following happens: | ||
23 | |||
24 | mid.qcow2: CB-C00C0 (correct result) | ||
25 | mid.qcow2: CB-C--C- (before this fix) | ||
26 | |||
27 | Without the fix, blocks that previously read as zeros on top.qcow2 | ||
28 | suddenly turn into A. | ||
4 | 29 | ||
5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 30 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
6 | Reviewed-by: Eric Blake <eblake@redhat.com> | 31 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
32 | Message-Id: <20200424125448.63318-8-kwolf@redhat.com> | ||
33 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
34 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
7 | --- | 35 | --- |
8 | block.c | 10 ++++++++-- | 36 | block/io.c | 25 +++++++++++++++++++++++++ |
9 | tests/qemu-iotests/049 | 5 +++++ | 37 | 1 file changed, 25 insertions(+) |
10 | tests/qemu-iotests/049.out | 5 +++++ | ||
11 | 3 files changed, 18 insertions(+), 2 deletions(-) | ||
12 | 38 | ||
13 | diff --git a/block.c b/block.c | 39 | diff --git a/block/io.c b/block/io.c |
14 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/block.c | 41 | --- a/block/io.c |
16 | +++ b/block.c | 42 | +++ b/block/io.c |
17 | @@ -XXX,XX +XXX,XX @@ void bdrv_img_create(const char *filename, const char *fmt, | 43 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact, |
18 | return; | 44 | goto out; |
19 | } | 45 | } |
20 | 46 | ||
21 | + /* Create parameter list */ | 47 | + /* |
22 | create_opts = qemu_opts_append(create_opts, drv->create_opts); | 48 | + * If the image has a backing file that is large enough that it would |
23 | create_opts = qemu_opts_append(create_opts, proto_drv->create_opts); | 49 | + * provide data for the new area, we cannot leave it unallocated because |
24 | 50 | + * then the backing file content would become visible. Instead, zero-fill | |
25 | - /* Create parameter list with default values */ | 51 | + * the new area. |
26 | opts = qemu_opts_create(create_opts, NULL, 0, &error_abort); | 52 | + * |
27 | - qemu_opt_set_number(opts, BLOCK_OPT_SIZE, img_size, &error_abort); | 53 | + * Note that if the image has a backing file, but was opened without the |
28 | 54 | + * backing file, taking care of keeping things consistent with that backing | |
29 | /* Parse -o options */ | 55 | + * file is the user's responsibility. |
30 | if (options) { | 56 | + */ |
31 | @@ -XXX,XX +XXX,XX @@ void bdrv_img_create(const char *filename, const char *fmt, | 57 | + if (new_bytes && bs->backing) { |
32 | } | 58 | + int64_t backing_len; |
33 | } | 59 | + |
34 | 60 | + backing_len = bdrv_getlength(backing_bs(bs)); | |
35 | + if (!qemu_opt_get(opts, BLOCK_OPT_SIZE)) { | 61 | + if (backing_len < 0) { |
36 | + qemu_opt_set_number(opts, BLOCK_OPT_SIZE, img_size, &error_abort); | 62 | + ret = backing_len; |
37 | + } else if (img_size != UINT64_C(-1)) { | 63 | + error_setg_errno(errp, -ret, "Could not get backing file size"); |
38 | + error_setg(errp, "The image size must be specified only once"); | 64 | + goto out; |
39 | + goto out; | 65 | + } |
66 | + | ||
67 | + if (backing_len > old_size) { | ||
68 | + flags |= BDRV_REQ_ZERO_WRITE; | ||
69 | + } | ||
40 | + } | 70 | + } |
41 | + | 71 | + |
42 | if (base_filename) { | 72 | if (drv->bdrv_co_truncate) { |
43 | qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, base_filename, &local_err); | 73 | if (flags & ~bs->supported_truncate_flags) { |
44 | if (local_err) { | 74 | error_setg(errp, "Block driver does not support requested flags"); |
45 | diff --git a/tests/qemu-iotests/049 b/tests/qemu-iotests/049 | ||
46 | index XXXXXXX..XXXXXXX 100755 | ||
47 | --- a/tests/qemu-iotests/049 | ||
48 | +++ b/tests/qemu-iotests/049 | ||
49 | @@ -XXX,XX +XXX,XX @@ for s in $sizes; do | ||
50 | test_qemu_img create -f $IMGFMT -o size=$s "$TEST_IMG" | ||
51 | done | ||
52 | |||
53 | +echo "== 4. Specify size twice (-o and traditional parameter) ==" | ||
54 | +echo | ||
55 | + | ||
56 | +test_qemu_img create -f $IMGFMT -o size=10M "$TEST_IMG" 20M | ||
57 | + | ||
58 | echo "== Check correct interpretation of suffixes for cluster size ==" | ||
59 | echo | ||
60 | sizes="1024 1024b 1k 1K 1M " | ||
61 | diff --git a/tests/qemu-iotests/049.out b/tests/qemu-iotests/049.out | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/tests/qemu-iotests/049.out | ||
64 | +++ b/tests/qemu-iotests/049.out | ||
65 | @@ -XXX,XX +XXX,XX @@ qemu-img: TEST_DIR/t.qcow2: Parameter 'size' expects a non-negative number below | ||
66 | Optional suffix k, M, G, T, P or E means kilo-, mega-, giga-, tera-, peta- | ||
67 | and exabytes, respectively. | ||
68 | |||
69 | +== 4. Specify size twice (-o and traditional parameter) == | ||
70 | + | ||
71 | +qemu-img create -f qcow2 -o size=10M TEST_DIR/t.qcow2 20M | ||
72 | +qemu-img: TEST_DIR/t.qcow2: The image size must be specified only once | ||
73 | + | ||
74 | == Check correct interpretation of suffixes for cluster size == | ||
75 | |||
76 | qemu-img create -f qcow2 -o cluster_size=1024 TEST_DIR/t.qcow2 64M | ||
77 | -- | 75 | -- |
78 | 2.20.1 | 76 | 2.25.3 |
79 | 77 | ||
80 | 78 | diff view generated by jsdifflib |
1 | We have several almost identical copies of a blockdev_create() function | 1 | We want to keep TEST_IMG for the full path of the main test image, but |
---|---|---|---|
2 | in different test cases. Time to create one unified function in | 2 | filter_testfiles() must be called for other test images before replacing |
3 | iotests.py. | 3 | other things like the image format because the test directory path could |
4 | contain the format as a substring. | ||
4 | 5 | ||
5 | To keep the diff managable, this patch only creates the function and | 6 | Insert a filter_testfiles() call between both. |
6 | follow-up patches will convert the individual test cases. | ||
7 | 7 | ||
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
9 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
10 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
11 | Message-Id: <20200424125448.63318-9-kwolf@redhat.com> | ||
12 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
9 | --- | 13 | --- |
10 | tests/qemu-iotests/iotests.py | 16 ++++++++++++++++ | 14 | tests/qemu-iotests/iotests.py | 5 +++-- |
11 | 1 file changed, 16 insertions(+) | 15 | 1 file changed, 3 insertions(+), 2 deletions(-) |
12 | 16 | ||
13 | diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py | 17 | diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py |
14 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/tests/qemu-iotests/iotests.py | 19 | --- a/tests/qemu-iotests/iotests.py |
16 | +++ b/tests/qemu-iotests/iotests.py | 20 | +++ b/tests/qemu-iotests/iotests.py |
17 | @@ -XXX,XX +XXX,XX @@ class VM(qtest.QEMUQtestMachine): | 21 | @@ -XXX,XX +XXX,XX @@ def filter_img_info(output, filename): |
18 | elif status == 'null': | 22 | for line in output.split('\n'): |
19 | return error | 23 | if 'disk size' in line or 'actual-size' in line: |
20 | 24 | continue | |
21 | + # Returns None on success, and an error string on failure | 25 | - line = line.replace(filename, 'TEST_IMG') \ |
22 | + def blockdev_create(self, options, job_id='job0', filters=None): | 26 | - .replace(imgfmt, 'IMGFMT') |
23 | + if filters is None: | 27 | + line = line.replace(filename, 'TEST_IMG') |
24 | + filters = [filter_qmp_testfiles] | 28 | + line = filter_testfiles(line) |
25 | + result = self.qmp_log('blockdev-create', filters=filters, | 29 | + line = line.replace(imgfmt, 'IMGFMT') |
26 | + job_id=job_id, options=options) | 30 | line = re.sub('iters: [0-9]+', 'iters: XXX', line) |
27 | + | 31 | line = re.sub('uuid: [-a-f0-9]+', 'uuid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', line) |
28 | + if 'return' in result: | 32 | line = re.sub('cid: [0-9]+', 'cid: XXXXXXXXXX', line) |
29 | + assert result['return'] == {} | ||
30 | + job_result = self.run_job(job_id) | ||
31 | + else: | ||
32 | + job_result = result['error'] | ||
33 | + | ||
34 | + log("") | ||
35 | + return job_result | ||
36 | + | ||
37 | def enable_migration_events(self, name): | ||
38 | log('Enabling migration QMP events on %s...' % name) | ||
39 | log(self.qmp('migrate-set-capabilities', capabilities=[ | ||
40 | -- | 33 | -- |
41 | 2.20.1 | 34 | 2.25.3 |
42 | 35 | ||
43 | 36 | diff view generated by jsdifflib |
1 | This tests creating an external snapshot with VM state (which results in | 1 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
---|---|---|---|
2 | an active overlay over an inactive backing file, which is also the root | 2 | Message-Id: <20200424125448.63318-10-kwolf@redhat.com> |
3 | node of an inactive BlockBackend), re-activating the images and | 3 | Reviewed-by: Max Reitz <mreitz@redhat.com> |
4 | performing some operations to test that the re-activation worked as | 4 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
5 | intended. | ||
6 | |||
7 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
8 | --- | 6 | --- |
9 | tests/qemu-iotests/280 | 83 ++++++++++++++++++++++++++++++++++++++ | 7 | tests/qemu-iotests/274 | 155 +++++++++++++++++++++ |
10 | tests/qemu-iotests/280.out | 50 +++++++++++++++++++++++ | 8 | tests/qemu-iotests/274.out | 268 +++++++++++++++++++++++++++++++++++++ |
11 | tests/qemu-iotests/group | 1 + | 9 | tests/qemu-iotests/group | 1 + |
12 | 3 files changed, 134 insertions(+) | 10 | 3 files changed, 424 insertions(+) |
13 | create mode 100755 tests/qemu-iotests/280 | 11 | create mode 100755 tests/qemu-iotests/274 |
14 | create mode 100644 tests/qemu-iotests/280.out | 12 | create mode 100644 tests/qemu-iotests/274.out |
15 | 13 | ||
16 | diff --git a/tests/qemu-iotests/280 b/tests/qemu-iotests/280 | 14 | diff --git a/tests/qemu-iotests/274 b/tests/qemu-iotests/274 |
17 | new file mode 100755 | 15 | new file mode 100755 |
18 | index XXXXXXX..XXXXXXX | 16 | index XXXXXXX..XXXXXXX |
19 | --- /dev/null | 17 | --- /dev/null |
20 | +++ b/tests/qemu-iotests/280 | 18 | +++ b/tests/qemu-iotests/274 |
21 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ |
22 | +#!/usr/bin/env python | 20 | +#!/usr/bin/env python3 |
23 | +# | 21 | +# |
24 | +# Copyright (C) 2019 Red Hat, Inc. | 22 | +# Copyright (C) 2019 Red Hat, Inc. |
25 | +# | 23 | +# |
26 | +# This program is free software; you can redistribute it and/or modify | 24 | +# This program is free software; you can redistribute it and/or modify |
27 | +# it under the terms of the GNU General Public License as published by | 25 | +# it under the terms of the GNU General Public License as published by |
... | ... | ||
36 | +# You should have received a copy of the GNU General Public License | 34 | +# You should have received a copy of the GNU General Public License |
37 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | 35 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
38 | +# | 36 | +# |
39 | +# Creator/Owner: Kevin Wolf <kwolf@redhat.com> | 37 | +# Creator/Owner: Kevin Wolf <kwolf@redhat.com> |
40 | +# | 38 | +# |
41 | +# Test migration to file for taking an external snapshot with VM state. | 39 | +# Some tests for short backing files and short overlays |
42 | + | 40 | + |
43 | +import iotests | 41 | +import iotests |
44 | +import os | ||
45 | + | 42 | + |
46 | +iotests.verify_image_format(supported_fmts=['qcow2']) | 43 | +iotests.verify_image_format(supported_fmts=['qcow2']) |
47 | +iotests.verify_protocol(supported=['file']) | ||
48 | +iotests.verify_platform(['linux']) | 44 | +iotests.verify_platform(['linux']) |
49 | + | 45 | + |
50 | +with iotests.FilePath('base') as base_path , \ | 46 | +size_short = 1 * 1024 * 1024 |
51 | + iotests.FilePath('top') as top_path, \ | 47 | +size_long = 2 * 1024 * 1024 |
52 | + iotests.VM() as vm: | 48 | +size_diff = size_long - size_short |
53 | + | 49 | + |
54 | + iotests.qemu_img_log('create', '-f', iotests.imgfmt, base_path, '64M') | 50 | +def create_chain() -> None: |
55 | + | 51 | + iotests.qemu_img_log('create', '-f', iotests.imgfmt, base, |
56 | + iotests.log('=== Launch VM ===') | 52 | + str(size_long)) |
57 | + vm.add_object('iothread,id=iothread0') | 53 | + iotests.qemu_img_log('create', '-f', iotests.imgfmt, '-b', base, mid, |
58 | + vm.add_blockdev('file,filename=%s,node-name=base-file' % (base_path)) | 54 | + str(size_short)) |
59 | + vm.add_blockdev('%s,file=base-file,node-name=base-fmt' % (iotests.imgfmt)) | 55 | + iotests.qemu_img_log('create', '-f', iotests.imgfmt, '-b', mid, top, |
60 | + vm.add_device('virtio-blk,drive=base-fmt,iothread=iothread0,id=vda') | 56 | + str(size_long)) |
61 | + vm.launch() | 57 | + |
62 | + | 58 | + iotests.qemu_io_log('-c', 'write -P 1 0 %d' % size_long, base) |
63 | + vm.enable_migration_events('VM') | 59 | + |
64 | + | 60 | +def create_vm() -> iotests.VM: |
65 | + iotests.log('\n=== Migrate to file ===') | 61 | + vm = iotests.VM() |
66 | + vm.qmp_log('migrate', uri='exec:cat > /dev/null') | 62 | + vm.add_blockdev('file,filename=%s,node-name=base-file' % base) |
67 | + | 63 | + vm.add_blockdev('%s,file=base-file,node-name=base' % iotests.imgfmt) |
68 | + with iotests.Timeout(3, 'Migration does not complete'): | 64 | + vm.add_blockdev('file,filename=%s,node-name=mid-file' % mid) |
69 | + vm.wait_migration() | 65 | + vm.add_blockdev('%s,file=mid-file,node-name=mid,backing=base' |
70 | + | 66 | + % iotests.imgfmt) |
71 | + iotests.log('\nVM is now stopped:') | 67 | + vm.add_drive(top, 'backing=mid,node-name=top') |
72 | + iotests.log(vm.qmp('query-migrate')['return']['status']) | 68 | + return vm |
73 | + vm.qmp_log('query-status') | 69 | + |
74 | + | 70 | +with iotests.FilePath('base') as base, \ |
75 | + iotests.log('\n=== Create a snapshot of the disk image ===') | 71 | + iotests.FilePath('mid') as mid, \ |
76 | + vm.blockdev_create({ | 72 | + iotests.FilePath('top') as top: |
77 | + 'driver': 'file', | 73 | + |
78 | + 'filename': top_path, | 74 | + iotests.log('== Commit tests ==') |
79 | + 'size': 0, | 75 | + |
80 | + }) | 76 | + create_chain() |
81 | + vm.qmp_log('blockdev-add', node_name='top-file', | 77 | + |
82 | + driver='file', filename=top_path, | 78 | + iotests.log('=== Check visible data ===') |
83 | + filters=[iotests.filter_qmp_testfiles]) | 79 | + |
84 | + | 80 | + iotests.qemu_io_log('-c', 'read -P 1 0 %d' % size_short, top) |
85 | + vm.blockdev_create({ | 81 | + iotests.qemu_io_log('-c', 'read -P 0 %d %d' % (size_short, size_diff), top) |
86 | + 'driver': iotests.imgfmt, | 82 | + |
87 | + 'file': 'top-file', | 83 | + iotests.log('=== Checking allocation status ===') |
88 | + 'size': 1024 * 1024, | 84 | + |
89 | + }) | 85 | + iotests.qemu_io_log('-c', 'alloc 0 %d' % size_short, |
90 | + vm.qmp_log('blockdev-add', node_name='top-fmt', | 86 | + '-c', 'alloc %d %d' % (size_short, size_diff), |
91 | + driver=iotests.imgfmt, file='top-file') | 87 | + base) |
92 | + | 88 | + |
93 | + vm.qmp_log('blockdev-snapshot', node='base-fmt', overlay='top-fmt') | 89 | + iotests.qemu_io_log('-c', 'alloc 0 %d' % size_short, |
94 | + | 90 | + '-c', 'alloc %d %d' % (size_short, size_diff), |
95 | + iotests.log('\n=== Resume the VM and simulate a write request ===') | 91 | + mid) |
96 | + vm.qmp_log('cont') | 92 | + |
97 | + iotests.log(vm.hmp_qemu_io('-d vda/virtio-backend', 'write 4k 4k')) | 93 | + iotests.qemu_io_log('-c', 'alloc 0 %d' % size_short, |
98 | + | 94 | + '-c', 'alloc %d %d' % (size_short, size_diff), |
99 | + iotests.log('\n=== Commit it to the backing file ===') | 95 | + top) |
100 | + result = vm.qmp_log('block-commit', job_id='job0', auto_dismiss=False, | 96 | + |
101 | + device='top-fmt', top_node='top-fmt', | 97 | + iotests.log('=== Checking map ===') |
102 | + filters=[iotests.filter_qmp_testfiles]) | 98 | + |
103 | + if 'return' in result: | 99 | + iotests.qemu_img_log('map', '--output=json', base) |
104 | + vm.run_job('job0') | 100 | + iotests.qemu_img_log('map', '--output=human', base) |
105 | diff --git a/tests/qemu-iotests/280.out b/tests/qemu-iotests/280.out | 101 | + iotests.qemu_img_log('map', '--output=json', mid) |
102 | + iotests.qemu_img_log('map', '--output=human', mid) | ||
103 | + iotests.qemu_img_log('map', '--output=json', top) | ||
104 | + iotests.qemu_img_log('map', '--output=human', top) | ||
105 | + | ||
106 | + iotests.log('=== Testing qemu-img commit (top -> mid) ===') | ||
107 | + | ||
108 | + iotests.qemu_img_log('commit', top) | ||
109 | + iotests.img_info_log(mid) | ||
110 | + iotests.qemu_io_log('-c', 'read -P 1 0 %d' % size_short, mid) | ||
111 | + iotests.qemu_io_log('-c', 'read -P 0 %d %d' % (size_short, size_diff), mid) | ||
112 | + | ||
113 | + iotests.log('=== Testing HMP commit (top -> mid) ===') | ||
114 | + | ||
115 | + create_chain() | ||
116 | + with create_vm() as vm: | ||
117 | + vm.launch() | ||
118 | + vm.qmp_log('human-monitor-command', command_line='commit drive0') | ||
119 | + | ||
120 | + iotests.img_info_log(mid) | ||
121 | + iotests.qemu_io_log('-c', 'read -P 1 0 %d' % size_short, mid) | ||
122 | + iotests.qemu_io_log('-c', 'read -P 0 %d %d' % (size_short, size_diff), mid) | ||
123 | + | ||
124 | + iotests.log('=== Testing QMP active commit (top -> mid) ===') | ||
125 | + | ||
126 | + create_chain() | ||
127 | + with create_vm() as vm: | ||
128 | + vm.launch() | ||
129 | + vm.qmp_log('block-commit', device='top', base_node='mid', | ||
130 | + job_id='job0', auto_dismiss=False) | ||
131 | + vm.run_job('job0', wait=5) | ||
132 | + | ||
133 | + iotests.img_info_log(mid) | ||
134 | + iotests.qemu_io_log('-c', 'read -P 1 0 %d' % size_short, mid) | ||
135 | + iotests.qemu_io_log('-c', 'read -P 0 %d %d' % (size_short, size_diff), mid) | ||
136 | + | ||
137 | + | ||
138 | + iotests.log('== Resize tests ==') | ||
139 | + | ||
140 | + # Use different sizes for different allocation modes: | ||
141 | + # | ||
142 | + # We want to have at least one test where 32 bit truncation in the size of | ||
143 | + # the overlapping area becomes visible. This is covered by the | ||
144 | + # prealloc='off' case (1G to 6G is an overlap of 5G). | ||
145 | + # | ||
146 | + # However, we can only do this for modes that don't preallocate data | ||
147 | + # because otherwise we might run out of space on the test host. | ||
148 | + # | ||
149 | + # We also want to test some unaligned combinations. | ||
150 | + for (prealloc, base_size, top_size_old, top_size_new, off) in [ | ||
151 | + ('off', '6G', '1G', '8G', '5G'), | ||
152 | + ('metadata', '32G', '30G', '33G', '31G'), | ||
153 | + ('falloc', '10M', '5M', '15M', '9M'), | ||
154 | + ('full', '16M', '8M', '12M', '11M'), | ||
155 | + ('off', '384k', '253k', '512k', '253k'), | ||
156 | + ('off', '400k', '256k', '512k', '336k'), | ||
157 | + ('off', '512k', '256k', '500k', '436k')]: | ||
158 | + | ||
159 | + iotests.log('=== preallocation=%s ===' % prealloc) | ||
160 | + iotests.qemu_img_log('create', '-f', iotests.imgfmt, base, base_size) | ||
161 | + iotests.qemu_img_log('create', '-f', iotests.imgfmt, '-b', base, top, | ||
162 | + top_size_old) | ||
163 | + iotests.qemu_io_log('-c', 'write -P 1 %s 64k' % off, base) | ||
164 | + | ||
165 | + # After this, top_size_old to base_size should be allocated/zeroed. | ||
166 | + # | ||
167 | + # In theory, leaving base_size to top_size_new unallocated would be | ||
168 | + # correct, but in practice, if we zero out anything, we zero out | ||
169 | + # everything up to top_size_new. | ||
170 | + iotests.qemu_img_log('resize', '-f', iotests.imgfmt, | ||
171 | + '--preallocation', prealloc, top, top_size_new) | ||
172 | + iotests.qemu_io_log('-c', 'read -P 0 %s 64k' % off, top) | ||
173 | + iotests.qemu_io_log('-c', 'map', top) | ||
174 | + iotests.qemu_img_log('map', '--output=json', top) | ||
175 | diff --git a/tests/qemu-iotests/274.out b/tests/qemu-iotests/274.out | ||
106 | new file mode 100644 | 176 | new file mode 100644 |
107 | index XXXXXXX..XXXXXXX | 177 | index XXXXXXX..XXXXXXX |
108 | --- /dev/null | 178 | --- /dev/null |
109 | +++ b/tests/qemu-iotests/280.out | 179 | +++ b/tests/qemu-iotests/274.out |
110 | @@ -XXX,XX +XXX,XX @@ | 180 | @@ -XXX,XX +XXX,XX @@ |
111 | +Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=67108864 cluster_size=65536 lazy_refcounts=off refcount_bits=16 | 181 | +== Commit tests == |
112 | + | 182 | +Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=2097152 cluster_size=65536 lazy_refcounts=off refcount_bits=16 |
113 | +=== Launch VM === | 183 | + |
114 | +Enabling migration QMP events on VM... | 184 | +Formatting 'TEST_DIR/PID-mid', fmt=qcow2 size=1048576 backing_file=TEST_DIR/PID-base cluster_size=65536 lazy_refcounts=off refcount_bits=16 |
115 | +{"return": {}} | 185 | + |
116 | + | 186 | +Formatting 'TEST_DIR/PID-top', fmt=qcow2 size=2097152 backing_file=TEST_DIR/PID-mid cluster_size=65536 lazy_refcounts=off refcount_bits=16 |
117 | +=== Migrate to file === | 187 | + |
118 | +{"execute": "migrate", "arguments": {"uri": "exec:cat > /dev/null"}} | 188 | +wrote 2097152/2097152 bytes at offset 0 |
119 | +{"return": {}} | 189 | +2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
120 | +{"data": {"status": "setup"}, "event": "MIGRATION", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} | 190 | + |
121 | +{"data": {"status": "active"}, "event": "MIGRATION", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} | 191 | +=== Check visible data === |
122 | +{"data": {"status": "completed"}, "event": "MIGRATION", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} | 192 | +read 1048576/1048576 bytes at offset 0 |
123 | + | 193 | +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
124 | +VM is now stopped: | 194 | + |
125 | +completed | 195 | +read 1048576/1048576 bytes at offset 1048576 |
126 | +{"execute": "query-status", "arguments": {}} | 196 | +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
127 | +{"return": {"running": false, "singlestep": false, "status": "postmigrate"}} | 197 | + |
128 | + | 198 | +=== Checking allocation status === |
129 | +=== Create a snapshot of the disk image === | 199 | +1048576/1048576 bytes allocated at offset 0 bytes |
130 | +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "file", "filename": "TEST_DIR/PID-top", "size": 0}}} | 200 | +1048576/1048576 bytes allocated at offset 1 MiB |
131 | +{"return": {}} | 201 | + |
132 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | 202 | +0/1048576 bytes allocated at offset 0 bytes |
133 | +{"return": {}} | 203 | +0/0 bytes allocated at offset 1 MiB |
134 | + | 204 | + |
135 | +{"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-top", "node-name": "top-file"}} | 205 | +0/1048576 bytes allocated at offset 0 bytes |
136 | +{"return": {}} | 206 | +0/1048576 bytes allocated at offset 1 MiB |
137 | +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "qcow2", "file": "top-file", "size": 1048576}}} | 207 | + |
138 | +{"return": {}} | 208 | +=== Checking map === |
139 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | 209 | +[{ "start": 0, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": 327680}] |
140 | +{"return": {}} | 210 | + |
141 | + | 211 | +Offset Length Mapped to File |
142 | +{"execute": "blockdev-add", "arguments": {"driver": "qcow2", "file": "top-file", "node-name": "top-fmt"}} | 212 | +0 0x200000 0x50000 TEST_DIR/PID-base |
143 | +{"return": {}} | 213 | + |
144 | +{"execute": "blockdev-snapshot", "arguments": {"node": "base-fmt", "overlay": "top-fmt"}} | 214 | +[{ "start": 0, "length": 1048576, "depth": 1, "zero": false, "data": true, "offset": 327680}] |
145 | +{"return": {}} | 215 | + |
146 | + | 216 | +Offset Length Mapped to File |
147 | +=== Resume the VM and simulate a write request === | 217 | +0 0x100000 0x50000 TEST_DIR/PID-base |
148 | +{"execute": "cont", "arguments": {}} | 218 | + |
149 | +{"return": {}} | 219 | +[{ "start": 0, "length": 1048576, "depth": 2, "zero": false, "data": true, "offset": 327680}, |
220 | +{ "start": 1048576, "length": 1048576, "depth": 0, "zero": true, "data": false}] | ||
221 | + | ||
222 | +Offset Length Mapped to File | ||
223 | +0 0x100000 0x50000 TEST_DIR/PID-base | ||
224 | + | ||
225 | +=== Testing qemu-img commit (top -> mid) === | ||
226 | +Image committed. | ||
227 | + | ||
228 | +image: TEST_IMG | ||
229 | +file format: IMGFMT | ||
230 | +virtual size: 2 MiB (2097152 bytes) | ||
231 | +cluster_size: 65536 | ||
232 | +backing file: TEST_DIR/PID-base | ||
233 | +Format specific information: | ||
234 | + compat: 1.1 | ||
235 | + lazy refcounts: false | ||
236 | + refcount bits: 16 | ||
237 | + corrupt: false | ||
238 | + | ||
239 | +read 1048576/1048576 bytes at offset 0 | ||
240 | +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
241 | + | ||
242 | +read 1048576/1048576 bytes at offset 1048576 | ||
243 | +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
244 | + | ||
245 | +=== Testing HMP commit (top -> mid) === | ||
246 | +Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=2097152 cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
247 | + | ||
248 | +Formatting 'TEST_DIR/PID-mid', fmt=qcow2 size=1048576 backing_file=TEST_DIR/PID-base cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
249 | + | ||
250 | +Formatting 'TEST_DIR/PID-top', fmt=qcow2 size=2097152 backing_file=TEST_DIR/PID-mid cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
251 | + | ||
252 | +wrote 2097152/2097152 bytes at offset 0 | ||
253 | +2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
254 | + | ||
255 | +{"execute": "human-monitor-command", "arguments": {"command-line": "commit drive0"}} | ||
150 | +{"return": ""} | 256 | +{"return": ""} |
151 | + | 257 | +image: TEST_IMG |
152 | +=== Commit it to the backing file === | 258 | +file format: IMGFMT |
153 | +{"execute": "block-commit", "arguments": {"auto-dismiss": false, "device": "top-fmt", "job-id": "job0", "top-node": "top-fmt"}} | 259 | +virtual size: 2 MiB (2097152 bytes) |
260 | +cluster_size: 65536 | ||
261 | +backing file: TEST_DIR/PID-base | ||
262 | +Format specific information: | ||
263 | + compat: 1.1 | ||
264 | + lazy refcounts: false | ||
265 | + refcount bits: 16 | ||
266 | + corrupt: false | ||
267 | + | ||
268 | +read 1048576/1048576 bytes at offset 0 | ||
269 | +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
270 | + | ||
271 | +read 1048576/1048576 bytes at offset 1048576 | ||
272 | +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
273 | + | ||
274 | +=== Testing QMP active commit (top -> mid) === | ||
275 | +Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=2097152 cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
276 | + | ||
277 | +Formatting 'TEST_DIR/PID-mid', fmt=qcow2 size=1048576 backing_file=TEST_DIR/PID-base cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
278 | + | ||
279 | +Formatting 'TEST_DIR/PID-top', fmt=qcow2 size=2097152 backing_file=TEST_DIR/PID-mid cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
280 | + | ||
281 | +wrote 2097152/2097152 bytes at offset 0 | ||
282 | +2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
283 | + | ||
284 | +{"execute": "block-commit", "arguments": {"auto-dismiss": false, "base-node": "mid", "device": "top", "job-id": "job0"}} | ||
154 | +{"return": {}} | 285 | +{"return": {}} |
155 | +{"execute": "job-complete", "arguments": {"id": "job0"}} | 286 | +{"execute": "job-complete", "arguments": {"id": "job0"}} |
156 | +{"return": {}} | 287 | +{"return": {}} |
157 | +{"data": {"device": "job0", "len": 65536, "offset": 65536, "speed": 0, "type": "commit"}, "event": "BLOCK_JOB_READY", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} | 288 | +{"data": {"device": "job0", "len": 0, "offset": 0, "speed": 0, "type": "commit"}, "event": "BLOCK_JOB_READY", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} |
158 | +{"data": {"device": "job0", "len": 65536, "offset": 65536, "speed": 0, "type": "commit"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} | 289 | +{"data": {"device": "job0", "len": 0, "offset": 0, "speed": 0, "type": "commit"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} |
159 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | 290 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} |
160 | +{"return": {}} | 291 | +{"return": {}} |
292 | +image: TEST_IMG | ||
293 | +file format: IMGFMT | ||
294 | +virtual size: 2 MiB (2097152 bytes) | ||
295 | +cluster_size: 65536 | ||
296 | +backing file: TEST_DIR/PID-base | ||
297 | +Format specific information: | ||
298 | + compat: 1.1 | ||
299 | + lazy refcounts: false | ||
300 | + refcount bits: 16 | ||
301 | + corrupt: false | ||
302 | + | ||
303 | +read 1048576/1048576 bytes at offset 0 | ||
304 | +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
305 | + | ||
306 | +read 1048576/1048576 bytes at offset 1048576 | ||
307 | +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
308 | + | ||
309 | +== Resize tests == | ||
310 | +=== preallocation=off === | ||
311 | +Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=6442450944 cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
312 | + | ||
313 | +Formatting 'TEST_DIR/PID-top', fmt=qcow2 size=1073741824 backing_file=TEST_DIR/PID-base cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
314 | + | ||
315 | +wrote 65536/65536 bytes at offset 5368709120 | ||
316 | +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
317 | + | ||
318 | +Image resized. | ||
319 | + | ||
320 | +read 65536/65536 bytes at offset 5368709120 | ||
321 | +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
322 | + | ||
323 | +1 GiB (0x40000000) bytes not allocated at offset 0 bytes (0x0) | ||
324 | +7 GiB (0x1c0000000) bytes allocated at offset 1 GiB (0x40000000) | ||
325 | + | ||
326 | +[{ "start": 0, "length": 1073741824, "depth": 1, "zero": true, "data": false}, | ||
327 | +{ "start": 1073741824, "length": 7516192768, "depth": 0, "zero": true, "data": false}] | ||
328 | + | ||
329 | +=== preallocation=metadata === | ||
330 | +Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=34359738368 cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
331 | + | ||
332 | +Formatting 'TEST_DIR/PID-top', fmt=qcow2 size=32212254720 backing_file=TEST_DIR/PID-base cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
333 | + | ||
334 | +wrote 65536/65536 bytes at offset 33285996544 | ||
335 | +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
336 | + | ||
337 | +Image resized. | ||
338 | + | ||
339 | +read 65536/65536 bytes at offset 33285996544 | ||
340 | +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
341 | + | ||
342 | +30 GiB (0x780000000) bytes not allocated at offset 0 bytes (0x0) | ||
343 | +3 GiB (0xc0000000) bytes allocated at offset 30 GiB (0x780000000) | ||
344 | + | ||
345 | +[{ "start": 0, "length": 32212254720, "depth": 1, "zero": true, "data": false}, | ||
346 | +{ "start": 32212254720, "length": 536870912, "depth": 0, "zero": true, "data": false, "offset": 327680}, | ||
347 | +{ "start": 32749125632, "length": 536870912, "depth": 0, "zero": true, "data": false, "offset": 537264128}, | ||
348 | +{ "start": 33285996544, "length": 536870912, "depth": 0, "zero": true, "data": false, "offset": 1074200576}, | ||
349 | +{ "start": 33822867456, "length": 536870912, "depth": 0, "zero": true, "data": false, "offset": 1611137024}, | ||
350 | +{ "start": 34359738368, "length": 536870912, "depth": 0, "zero": true, "data": false, "offset": 2148139008}, | ||
351 | +{ "start": 34896609280, "length": 536870912, "depth": 0, "zero": true, "data": false, "offset": 2685075456}] | ||
352 | + | ||
353 | +=== preallocation=falloc === | ||
354 | +Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=10485760 cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
355 | + | ||
356 | +Formatting 'TEST_DIR/PID-top', fmt=qcow2 size=5242880 backing_file=TEST_DIR/PID-base cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
357 | + | ||
358 | +wrote 65536/65536 bytes at offset 9437184 | ||
359 | +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
360 | + | ||
361 | +Image resized. | ||
362 | + | ||
363 | +read 65536/65536 bytes at offset 9437184 | ||
364 | +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
365 | + | ||
366 | +5 MiB (0x500000) bytes not allocated at offset 0 bytes (0x0) | ||
367 | +10 MiB (0xa00000) bytes allocated at offset 5 MiB (0x500000) | ||
368 | + | ||
369 | +[{ "start": 0, "length": 5242880, "depth": 1, "zero": true, "data": false}, | ||
370 | +{ "start": 5242880, "length": 10485760, "depth": 0, "zero": true, "data": false, "offset": 327680}] | ||
371 | + | ||
372 | +=== preallocation=full === | ||
373 | +Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=16777216 cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
374 | + | ||
375 | +Formatting 'TEST_DIR/PID-top', fmt=qcow2 size=8388608 backing_file=TEST_DIR/PID-base cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
376 | + | ||
377 | +wrote 65536/65536 bytes at offset 11534336 | ||
378 | +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
379 | + | ||
380 | +Image resized. | ||
381 | + | ||
382 | +read 65536/65536 bytes at offset 11534336 | ||
383 | +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
384 | + | ||
385 | +8 MiB (0x800000) bytes not allocated at offset 0 bytes (0x0) | ||
386 | +4 MiB (0x400000) bytes allocated at offset 8 MiB (0x800000) | ||
387 | + | ||
388 | +[{ "start": 0, "length": 8388608, "depth": 1, "zero": true, "data": false}, | ||
389 | +{ "start": 8388608, "length": 4194304, "depth": 0, "zero": true, "data": false, "offset": 327680}] | ||
390 | + | ||
391 | +=== preallocation=off === | ||
392 | +Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=393216 cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
393 | + | ||
394 | +Formatting 'TEST_DIR/PID-top', fmt=qcow2 size=259072 backing_file=TEST_DIR/PID-base cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
395 | + | ||
396 | +wrote 65536/65536 bytes at offset 259072 | ||
397 | +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
398 | + | ||
399 | +Image resized. | ||
400 | + | ||
401 | +read 65536/65536 bytes at offset 259072 | ||
402 | +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
403 | + | ||
404 | +192 KiB (0x30000) bytes not allocated at offset 0 bytes (0x0) | ||
405 | +320 KiB (0x50000) bytes allocated at offset 192 KiB (0x30000) | ||
406 | + | ||
407 | +[{ "start": 0, "length": 196608, "depth": 1, "zero": true, "data": false}, | ||
408 | +{ "start": 196608, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": 327680}, | ||
409 | +{ "start": 262144, "length": 262144, "depth": 0, "zero": true, "data": false}] | ||
410 | + | ||
411 | +=== preallocation=off === | ||
412 | +Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=409600 cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
413 | + | ||
414 | +Formatting 'TEST_DIR/PID-top', fmt=qcow2 size=262144 backing_file=TEST_DIR/PID-base cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
415 | + | ||
416 | +wrote 65536/65536 bytes at offset 344064 | ||
417 | +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
418 | + | ||
419 | +Image resized. | ||
420 | + | ||
421 | +read 65536/65536 bytes at offset 344064 | ||
422 | +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
423 | + | ||
424 | +256 KiB (0x40000) bytes not allocated at offset 0 bytes (0x0) | ||
425 | +256 KiB (0x40000) bytes allocated at offset 256 KiB (0x40000) | ||
426 | + | ||
427 | +[{ "start": 0, "length": 262144, "depth": 1, "zero": true, "data": false}, | ||
428 | +{ "start": 262144, "length": 262144, "depth": 0, "zero": true, "data": false}] | ||
429 | + | ||
430 | +=== preallocation=off === | ||
431 | +Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=524288 cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
432 | + | ||
433 | +Formatting 'TEST_DIR/PID-top', fmt=qcow2 size=262144 backing_file=TEST_DIR/PID-base cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
434 | + | ||
435 | +wrote 65536/65536 bytes at offset 446464 | ||
436 | +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
437 | + | ||
438 | +Image resized. | ||
439 | + | ||
440 | +read 65536/65536 bytes at offset 446464 | ||
441 | +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
442 | + | ||
443 | +256 KiB (0x40000) bytes not allocated at offset 0 bytes (0x0) | ||
444 | +244 KiB (0x3d000) bytes allocated at offset 256 KiB (0x40000) | ||
445 | + | ||
446 | +[{ "start": 0, "length": 262144, "depth": 1, "zero": true, "data": false}, | ||
447 | +{ "start": 262144, "length": 249856, "depth": 0, "zero": true, "data": false}] | ||
448 | + | ||
161 | diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group | 449 | diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group |
162 | index XXXXXXX..XXXXXXX 100644 | 450 | index XXXXXXX..XXXXXXX 100644 |
163 | --- a/tests/qemu-iotests/group | 451 | --- a/tests/qemu-iotests/group |
164 | +++ b/tests/qemu-iotests/group | 452 | +++ b/tests/qemu-iotests/group |
165 | @@ -XXX,XX +XXX,XX @@ | 453 | @@ -XXX,XX +XXX,XX @@ |
454 | 270 rw backing quick | ||
455 | 272 rw | ||
166 | 273 backing quick | 456 | 273 backing quick |
457 | +274 rw backing | ||
167 | 277 rw quick | 458 | 277 rw quick |
168 | 279 rw backing quick | 459 | 279 rw backing quick |
169 | +280 rw migration quick | 460 | 280 rw migration quick |
170 | -- | 461 | -- |
171 | 2.20.1 | 462 | 2.25.3 |
172 | 463 | ||
173 | 464 | diff view generated by jsdifflib |
1 | From: Tuguoyi <tu.guoyi@h3c.com> | 1 | The BDRV_REQ_ZERO_WRITE is currently implemented in a way that first the |
---|---|---|---|
2 | image is possibly preallocated and then the zero flag is added to all | ||
3 | clusters. This means that a copy-on-write operation may be needed when | ||
4 | writing to these clusters, despite having used preallocation, negating | ||
5 | one of the major benefits of preallocation. | ||
2 | 6 | ||
3 | The local_err check outside of the if block was necessary | 7 | Instead, try to forward the BDRV_REQ_ZERO_WRITE to the protocol driver, |
4 | when it was introduced in commit d1258dd0c87 because it needed to be | 8 | and if the protocol driver can ensure that the new area reads as zeros, |
5 | executed even if qcow2_load_autoloading_dirty_bitmaps() returned false. | 9 | we can skip setting the zero flag in the qcow2 layer. |
6 | 10 | ||
7 | After some modifications that all required the error check to remain | 11 | Unfortunately, the same approach doesn't work for metadata |
8 | where it is, commit 9c98f145dfb finally moved the | 12 | preallocation, so we'll still set the zero flag there. |
9 | qcow2_load_dirty_bitmaps() call into the if block, so now the error | ||
10 | check should be there, too. | ||
11 | 13 | ||
12 | Signed-off-by: Guoyi Tu <tu.guoyi@h3c.com> | 14 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
15 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
16 | Message-Id: <20200424142701.67053-1-kwolf@redhat.com> | ||
13 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 17 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
14 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 18 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
15 | --- | 19 | --- |
16 | block/qcow2.c | 10 +++++----- | 20 | block/qcow2.c | 22 +++++++++++++++++++--- |
17 | 1 file changed, 5 insertions(+), 5 deletions(-) | 21 | tests/qemu-iotests/274.out | 4 ++-- |
22 | 2 files changed, 21 insertions(+), 5 deletions(-) | ||
18 | 23 | ||
19 | diff --git a/block/qcow2.c b/block/qcow2.c | 24 | diff --git a/block/qcow2.c b/block/qcow2.c |
20 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/block/qcow2.c | 26 | --- a/block/qcow2.c |
22 | +++ b/block/qcow2.c | 27 | +++ b/block/qcow2.c |
23 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, | 28 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset, |
24 | if (!(bdrv_get_flags(bs) & BDRV_O_INACTIVE)) { | 29 | /* Allocate the data area */ |
25 | /* It's case 1, 2 or 3.2. Or 3.1 which is BUG in management layer. */ | 30 | new_file_size = allocation_start + |
26 | bool header_updated = qcow2_load_dirty_bitmaps(bs, &local_err); | 31 | nb_new_data_clusters * s->cluster_size; |
27 | + if (local_err != NULL) { | 32 | - /* Image file grows, so @exact does not matter */ |
28 | + error_propagate(errp, local_err); | 33 | - ret = bdrv_co_truncate(bs->file, new_file_size, false, prealloc, 0, |
29 | + ret = -EINVAL; | 34 | - errp); |
30 | + goto fail; | 35 | + /* |
36 | + * Image file grows, so @exact does not matter. | ||
37 | + * | ||
38 | + * If we need to zero out the new area, try first whether the protocol | ||
39 | + * driver can already take care of this. | ||
40 | + */ | ||
41 | + if (flags & BDRV_REQ_ZERO_WRITE) { | ||
42 | + ret = bdrv_co_truncate(bs->file, new_file_size, false, prealloc, | ||
43 | + BDRV_REQ_ZERO_WRITE, NULL); | ||
44 | + if (ret >= 0) { | ||
45 | + flags &= ~BDRV_REQ_ZERO_WRITE; | ||
46 | + } | ||
47 | + } else { | ||
48 | + ret = -1; | ||
31 | + } | 49 | + } |
32 | 50 | + if (ret < 0) { | |
33 | update_header = update_header && !header_updated; | 51 | + ret = bdrv_co_truncate(bs->file, new_file_size, false, prealloc, 0, |
34 | } | 52 | + errp); |
35 | - if (local_err != NULL) { | 53 | + } |
36 | - error_propagate(errp, local_err); | 54 | if (ret < 0) { |
37 | - ret = -EINVAL; | 55 | error_prepend(errp, "Failed to resize underlying file: "); |
38 | - goto fail; | 56 | qcow2_free_clusters(bs, allocation_start, |
39 | - } | 57 | diff --git a/tests/qemu-iotests/274.out b/tests/qemu-iotests/274.out |
40 | 58 | index XXXXXXX..XXXXXXX 100644 | |
41 | if (update_header) { | 59 | --- a/tests/qemu-iotests/274.out |
42 | ret = qcow2_update_header(bs); | 60 | +++ b/tests/qemu-iotests/274.out |
61 | @@ -XXX,XX +XXX,XX @@ read 65536/65536 bytes at offset 9437184 | ||
62 | 10 MiB (0xa00000) bytes allocated at offset 5 MiB (0x500000) | ||
63 | |||
64 | [{ "start": 0, "length": 5242880, "depth": 1, "zero": true, "data": false}, | ||
65 | -{ "start": 5242880, "length": 10485760, "depth": 0, "zero": true, "data": false, "offset": 327680}] | ||
66 | +{ "start": 5242880, "length": 10485760, "depth": 0, "zero": false, "data": true, "offset": 327680}] | ||
67 | |||
68 | === preallocation=full === | ||
69 | Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=16777216 cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
70 | @@ -XXX,XX +XXX,XX @@ read 65536/65536 bytes at offset 11534336 | ||
71 | 4 MiB (0x400000) bytes allocated at offset 8 MiB (0x800000) | ||
72 | |||
73 | [{ "start": 0, "length": 8388608, "depth": 1, "zero": true, "data": false}, | ||
74 | -{ "start": 8388608, "length": 4194304, "depth": 0, "zero": true, "data": false, "offset": 327680}] | ||
75 | +{ "start": 8388608, "length": 4194304, "depth": 0, "zero": false, "data": true, "offset": 327680}] | ||
76 | |||
77 | === preallocation=off === | ||
78 | Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=393216 cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
43 | -- | 79 | -- |
44 | 2.20.1 | 80 | 2.25.3 |
45 | 81 | ||
46 | 82 | diff view generated by jsdifflib |
1 | bdrv_invalidate_cache_all() assumes that all nodes in a given subtree | 1 | From: Andrzej Jakowski <andrzej.jakowski@linux.intel.com> |
---|---|---|---|
2 | are either active or inactive when it starts. Therefore, as soon as it | ||
3 | arrives at an already active node, it stops. | ||
4 | 2 | ||
5 | However, this assumption is wrong. For example, it's possible to take a | 3 | This patch introduces support for PMR that has been defined as part of NVMe 1.4 |
6 | snapshot of an inactive node, which results in an active overlay over an | 4 | spec. User can now specify a pmrdev option that should point to HostMemoryBackend. |
7 | inactive backing file. The active overlay is probably also the root node | 5 | pmrdev memory region will subsequently be exposed as PCI BAR 2 in emulated NVMe |
8 | of an inactive BlockBackend (blk->disable_perm == true). | 6 | device. Guest OS can perform mmio read and writes to the PMR region that will stay |
7 | persistent across system reboot. | ||
9 | 8 | ||
10 | In this case, bdrv_invalidate_cache_all() does not need to do anything | 9 | Signed-off-by: Andrzej Jakowski <andrzej.jakowski@linux.intel.com> |
11 | to activate the overlay node, but it still needs to recurse into the | 10 | Reviewed-by: Klaus Jensen <k.jensen@samsung.com> |
12 | children and the parents to make sure that after returning success, | 11 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> |
13 | really everything is activated. | 12 | Message-Id: <20200330164656.9348-1-andrzej.jakowski@linux.intel.com> |
13 | Reviewed-by: Keith Busch <kbusch@kernel.org> | ||
14 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
15 | --- | ||
16 | hw/block/nvme.h | 2 + | ||
17 | include/block/nvme.h | 172 +++++++++++++++++++++++++++++++++++++++++ | ||
18 | hw/block/nvme.c | 109 ++++++++++++++++++++++++++ | ||
19 | hw/block/Makefile.objs | 2 +- | ||
20 | hw/block/trace-events | 4 + | ||
21 | 5 files changed, 288 insertions(+), 1 deletion(-) | ||
14 | 22 | ||
15 | Cc: qemu-stable@nongnu.org | 23 | diff --git a/hw/block/nvme.h b/hw/block/nvme.h |
16 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
17 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
18 | --- | ||
19 | block.c | 50 ++++++++++++++++++++++++-------------------------- | ||
20 | 1 file changed, 24 insertions(+), 26 deletions(-) | ||
21 | |||
22 | diff --git a/block.c b/block.c | ||
23 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/block.c | 25 | --- a/hw/block/nvme.h |
25 | +++ b/block.c | 26 | +++ b/hw/block/nvme.h |
26 | @@ -XXX,XX +XXX,XX @@ static void coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs, | 27 | @@ -XXX,XX +XXX,XX @@ typedef struct NvmeCtrl { |
28 | uint64_t timestamp_set_qemu_clock_ms; /* QEMU clock time */ | ||
29 | |||
30 | char *serial; | ||
31 | + HostMemoryBackend *pmrdev; | ||
32 | + | ||
33 | NvmeNamespace *namespaces; | ||
34 | NvmeSQueue **sq; | ||
35 | NvmeCQueue **cq; | ||
36 | diff --git a/include/block/nvme.h b/include/block/nvme.h | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/include/block/nvme.h | ||
39 | +++ b/include/block/nvme.h | ||
40 | @@ -XXX,XX +XXX,XX @@ typedef struct NvmeBar { | ||
41 | uint64_t acq; | ||
42 | uint32_t cmbloc; | ||
43 | uint32_t cmbsz; | ||
44 | + uint8_t padding[3520]; /* not used by QEMU */ | ||
45 | + uint32_t pmrcap; | ||
46 | + uint32_t pmrctl; | ||
47 | + uint32_t pmrsts; | ||
48 | + uint32_t pmrebs; | ||
49 | + uint32_t pmrswtp; | ||
50 | + uint32_t pmrmsc; | ||
51 | } NvmeBar; | ||
52 | |||
53 | enum NvmeCapShift { | ||
54 | @@ -XXX,XX +XXX,XX @@ enum NvmeCapShift { | ||
55 | CAP_CSS_SHIFT = 37, | ||
56 | CAP_MPSMIN_SHIFT = 48, | ||
57 | CAP_MPSMAX_SHIFT = 52, | ||
58 | + CAP_PMR_SHIFT = 56, | ||
59 | }; | ||
60 | |||
61 | enum NvmeCapMask { | ||
62 | @@ -XXX,XX +XXX,XX @@ enum NvmeCapMask { | ||
63 | CAP_CSS_MASK = 0xff, | ||
64 | CAP_MPSMIN_MASK = 0xf, | ||
65 | CAP_MPSMAX_MASK = 0xf, | ||
66 | + CAP_PMR_MASK = 0x1, | ||
67 | }; | ||
68 | |||
69 | #define NVME_CAP_MQES(cap) (((cap) >> CAP_MQES_SHIFT) & CAP_MQES_MASK) | ||
70 | @@ -XXX,XX +XXX,XX @@ enum NvmeCapMask { | ||
71 | << CAP_MPSMIN_SHIFT) | ||
72 | #define NVME_CAP_SET_MPSMAX(cap, val) (cap |= (uint64_t)(val & CAP_MPSMAX_MASK)\ | ||
73 | << CAP_MPSMAX_SHIFT) | ||
74 | +#define NVME_CAP_SET_PMRS(cap, val) (cap |= (uint64_t)(val & CAP_PMR_MASK)\ | ||
75 | + << CAP_PMR_SHIFT) | ||
76 | |||
77 | enum NvmeCcShift { | ||
78 | CC_EN_SHIFT = 0, | ||
79 | @@ -XXX,XX +XXX,XX @@ enum NvmeCmbszMask { | ||
80 | #define NVME_CMBSZ_GETSIZE(cmbsz) \ | ||
81 | (NVME_CMBSZ_SZ(cmbsz) * (1 << (12 + 4 * NVME_CMBSZ_SZU(cmbsz)))) | ||
82 | |||
83 | +enum NvmePmrcapShift { | ||
84 | + PMRCAP_RDS_SHIFT = 3, | ||
85 | + PMRCAP_WDS_SHIFT = 4, | ||
86 | + PMRCAP_BIR_SHIFT = 5, | ||
87 | + PMRCAP_PMRTU_SHIFT = 8, | ||
88 | + PMRCAP_PMRWBM_SHIFT = 10, | ||
89 | + PMRCAP_PMRTO_SHIFT = 16, | ||
90 | + PMRCAP_CMSS_SHIFT = 24, | ||
91 | +}; | ||
92 | + | ||
93 | +enum NvmePmrcapMask { | ||
94 | + PMRCAP_RDS_MASK = 0x1, | ||
95 | + PMRCAP_WDS_MASK = 0x1, | ||
96 | + PMRCAP_BIR_MASK = 0x7, | ||
97 | + PMRCAP_PMRTU_MASK = 0x3, | ||
98 | + PMRCAP_PMRWBM_MASK = 0xf, | ||
99 | + PMRCAP_PMRTO_MASK = 0xff, | ||
100 | + PMRCAP_CMSS_MASK = 0x1, | ||
101 | +}; | ||
102 | + | ||
103 | +#define NVME_PMRCAP_RDS(pmrcap) \ | ||
104 | + ((pmrcap >> PMRCAP_RDS_SHIFT) & PMRCAP_RDS_MASK) | ||
105 | +#define NVME_PMRCAP_WDS(pmrcap) \ | ||
106 | + ((pmrcap >> PMRCAP_WDS_SHIFT) & PMRCAP_WDS_MASK) | ||
107 | +#define NVME_PMRCAP_BIR(pmrcap) \ | ||
108 | + ((pmrcap >> PMRCAP_BIR_SHIFT) & PMRCAP_BIR_MASK) | ||
109 | +#define NVME_PMRCAP_PMRTU(pmrcap) \ | ||
110 | + ((pmrcap >> PMRCAP_PMRTU_SHIFT) & PMRCAP_PMRTU_MASK) | ||
111 | +#define NVME_PMRCAP_PMRWBM(pmrcap) \ | ||
112 | + ((pmrcap >> PMRCAP_PMRWBM_SHIFT) & PMRCAP_PMRWBM_MASK) | ||
113 | +#define NVME_PMRCAP_PMRTO(pmrcap) \ | ||
114 | + ((pmrcap >> PMRCAP_PMRTO_SHIFT) & PMRCAP_PMRTO_MASK) | ||
115 | +#define NVME_PMRCAP_CMSS(pmrcap) \ | ||
116 | + ((pmrcap >> PMRCAP_CMSS_SHIFT) & PMRCAP_CMSS_MASK) | ||
117 | + | ||
118 | +#define NVME_PMRCAP_SET_RDS(pmrcap, val) \ | ||
119 | + (pmrcap |= (uint64_t)(val & PMRCAP_RDS_MASK) << PMRCAP_RDS_SHIFT) | ||
120 | +#define NVME_PMRCAP_SET_WDS(pmrcap, val) \ | ||
121 | + (pmrcap |= (uint64_t)(val & PMRCAP_WDS_MASK) << PMRCAP_WDS_SHIFT) | ||
122 | +#define NVME_PMRCAP_SET_BIR(pmrcap, val) \ | ||
123 | + (pmrcap |= (uint64_t)(val & PMRCAP_BIR_MASK) << PMRCAP_BIR_SHIFT) | ||
124 | +#define NVME_PMRCAP_SET_PMRTU(pmrcap, val) \ | ||
125 | + (pmrcap |= (uint64_t)(val & PMRCAP_PMRTU_MASK) << PMRCAP_PMRTU_SHIFT) | ||
126 | +#define NVME_PMRCAP_SET_PMRWBM(pmrcap, val) \ | ||
127 | + (pmrcap |= (uint64_t)(val & PMRCAP_PMRWBM_MASK) << PMRCAP_PMRWBM_SHIFT) | ||
128 | +#define NVME_PMRCAP_SET_PMRTO(pmrcap, val) \ | ||
129 | + (pmrcap |= (uint64_t)(val & PMRCAP_PMRTO_MASK) << PMRCAP_PMRTO_SHIFT) | ||
130 | +#define NVME_PMRCAP_SET_CMSS(pmrcap, val) \ | ||
131 | + (pmrcap |= (uint64_t)(val & PMRCAP_CMSS_MASK) << PMRCAP_CMSS_SHIFT) | ||
132 | + | ||
133 | +enum NvmePmrctlShift { | ||
134 | + PMRCTL_EN_SHIFT = 0, | ||
135 | +}; | ||
136 | + | ||
137 | +enum NvmePmrctlMask { | ||
138 | + PMRCTL_EN_MASK = 0x1, | ||
139 | +}; | ||
140 | + | ||
141 | +#define NVME_PMRCTL_EN(pmrctl) ((pmrctl >> PMRCTL_EN_SHIFT) & PMRCTL_EN_MASK) | ||
142 | + | ||
143 | +#define NVME_PMRCTL_SET_EN(pmrctl, val) \ | ||
144 | + (pmrctl |= (uint64_t)(val & PMRCTL_EN_MASK) << PMRCTL_EN_SHIFT) | ||
145 | + | ||
146 | +enum NvmePmrstsShift { | ||
147 | + PMRSTS_ERR_SHIFT = 0, | ||
148 | + PMRSTS_NRDY_SHIFT = 8, | ||
149 | + PMRSTS_HSTS_SHIFT = 9, | ||
150 | + PMRSTS_CBAI_SHIFT = 12, | ||
151 | +}; | ||
152 | + | ||
153 | +enum NvmePmrstsMask { | ||
154 | + PMRSTS_ERR_MASK = 0xff, | ||
155 | + PMRSTS_NRDY_MASK = 0x1, | ||
156 | + PMRSTS_HSTS_MASK = 0x7, | ||
157 | + PMRSTS_CBAI_MASK = 0x1, | ||
158 | +}; | ||
159 | + | ||
160 | +#define NVME_PMRSTS_ERR(pmrsts) \ | ||
161 | + ((pmrsts >> PMRSTS_ERR_SHIFT) & PMRSTS_ERR_MASK) | ||
162 | +#define NVME_PMRSTS_NRDY(pmrsts) \ | ||
163 | + ((pmrsts >> PMRSTS_NRDY_SHIFT) & PMRSTS_NRDY_MASK) | ||
164 | +#define NVME_PMRSTS_HSTS(pmrsts) \ | ||
165 | + ((pmrsts >> PMRSTS_HSTS_SHIFT) & PMRSTS_HSTS_MASK) | ||
166 | +#define NVME_PMRSTS_CBAI(pmrsts) \ | ||
167 | + ((pmrsts >> PMRSTS_CBAI_SHIFT) & PMRSTS_CBAI_MASK) | ||
168 | + | ||
169 | +#define NVME_PMRSTS_SET_ERR(pmrsts, val) \ | ||
170 | + (pmrsts |= (uint64_t)(val & PMRSTS_ERR_MASK) << PMRSTS_ERR_SHIFT) | ||
171 | +#define NVME_PMRSTS_SET_NRDY(pmrsts, val) \ | ||
172 | + (pmrsts |= (uint64_t)(val & PMRSTS_NRDY_MASK) << PMRSTS_NRDY_SHIFT) | ||
173 | +#define NVME_PMRSTS_SET_HSTS(pmrsts, val) \ | ||
174 | + (pmrsts |= (uint64_t)(val & PMRSTS_HSTS_MASK) << PMRSTS_HSTS_SHIFT) | ||
175 | +#define NVME_PMRSTS_SET_CBAI(pmrsts, val) \ | ||
176 | + (pmrsts |= (uint64_t)(val & PMRSTS_CBAI_MASK) << PMRSTS_CBAI_SHIFT) | ||
177 | + | ||
178 | +enum NvmePmrebsShift { | ||
179 | + PMREBS_PMRSZU_SHIFT = 0, | ||
180 | + PMREBS_RBB_SHIFT = 4, | ||
181 | + PMREBS_PMRWBZ_SHIFT = 8, | ||
182 | +}; | ||
183 | + | ||
184 | +enum NvmePmrebsMask { | ||
185 | + PMREBS_PMRSZU_MASK = 0xf, | ||
186 | + PMREBS_RBB_MASK = 0x1, | ||
187 | + PMREBS_PMRWBZ_MASK = 0xffffff, | ||
188 | +}; | ||
189 | + | ||
190 | +#define NVME_PMREBS_PMRSZU(pmrebs) \ | ||
191 | + ((pmrebs >> PMREBS_PMRSZU_SHIFT) & PMREBS_PMRSZU_MASK) | ||
192 | +#define NVME_PMREBS_RBB(pmrebs) \ | ||
193 | + ((pmrebs >> PMREBS_RBB_SHIFT) & PMREBS_RBB_MASK) | ||
194 | +#define NVME_PMREBS_PMRWBZ(pmrebs) \ | ||
195 | + ((pmrebs >> PMREBS_PMRWBZ_SHIFT) & PMREBS_PMRWBZ_MASK) | ||
196 | + | ||
197 | +#define NVME_PMREBS_SET_PMRSZU(pmrebs, val) \ | ||
198 | + (pmrebs |= (uint64_t)(val & PMREBS_PMRSZU_MASK) << PMREBS_PMRSZU_SHIFT) | ||
199 | +#define NVME_PMREBS_SET_RBB(pmrebs, val) \ | ||
200 | + (pmrebs |= (uint64_t)(val & PMREBS_RBB_MASK) << PMREBS_RBB_SHIFT) | ||
201 | +#define NVME_PMREBS_SET_PMRWBZ(pmrebs, val) \ | ||
202 | + (pmrebs |= (uint64_t)(val & PMREBS_PMRWBZ_MASK) << PMREBS_PMRWBZ_SHIFT) | ||
203 | + | ||
204 | +enum NvmePmrswtpShift { | ||
205 | + PMRSWTP_PMRSWTU_SHIFT = 0, | ||
206 | + PMRSWTP_PMRSWTV_SHIFT = 8, | ||
207 | +}; | ||
208 | + | ||
209 | +enum NvmePmrswtpMask { | ||
210 | + PMRSWTP_PMRSWTU_MASK = 0xf, | ||
211 | + PMRSWTP_PMRSWTV_MASK = 0xffffff, | ||
212 | +}; | ||
213 | + | ||
214 | +#define NVME_PMRSWTP_PMRSWTU(pmrswtp) \ | ||
215 | + ((pmrswtp >> PMRSWTP_PMRSWTU_SHIFT) & PMRSWTP_PMRSWTU_MASK) | ||
216 | +#define NVME_PMRSWTP_PMRSWTV(pmrswtp) \ | ||
217 | + ((pmrswtp >> PMRSWTP_PMRSWTV_SHIFT) & PMRSWTP_PMRSWTV_MASK) | ||
218 | + | ||
219 | +#define NVME_PMRSWTP_SET_PMRSWTU(pmrswtp, val) \ | ||
220 | + (pmrswtp |= (uint64_t)(val & PMRSWTP_PMRSWTU_MASK) << PMRSWTP_PMRSWTU_SHIFT) | ||
221 | +#define NVME_PMRSWTP_SET_PMRSWTV(pmrswtp, val) \ | ||
222 | + (pmrswtp |= (uint64_t)(val & PMRSWTP_PMRSWTV_MASK) << PMRSWTP_PMRSWTV_SHIFT) | ||
223 | + | ||
224 | +enum NvmePmrmscShift { | ||
225 | + PMRMSC_CMSE_SHIFT = 1, | ||
226 | + PMRMSC_CBA_SHIFT = 12, | ||
227 | +}; | ||
228 | + | ||
229 | +enum NvmePmrmscMask { | ||
230 | + PMRMSC_CMSE_MASK = 0x1, | ||
231 | + PMRMSC_CBA_MASK = 0xfffffffffffff, | ||
232 | +}; | ||
233 | + | ||
234 | +#define NVME_PMRMSC_CMSE(pmrmsc) \ | ||
235 | + ((pmrmsc >> PMRMSC_CMSE_SHIFT) & PMRMSC_CMSE_MASK) | ||
236 | +#define NVME_PMRMSC_CBA(pmrmsc) \ | ||
237 | + ((pmrmsc >> PMRMSC_CBA_SHIFT) & PMRMSC_CBA_MASK) | ||
238 | + | ||
239 | +#define NVME_PMRMSC_SET_CMSE(pmrmsc, val) \ | ||
240 | + (pmrmsc |= (uint64_t)(val & PMRMSC_CMSE_MASK) << PMRMSC_CMSE_SHIFT) | ||
241 | +#define NVME_PMRMSC_SET_CBA(pmrmsc, val) \ | ||
242 | + (pmrmsc |= (uint64_t)(val & PMRMSC_CBA_MASK) << PMRMSC_CBA_SHIFT) | ||
243 | + | ||
244 | typedef struct NvmeCmd { | ||
245 | uint8_t opcode; | ||
246 | uint8_t fuse; | ||
247 | diff --git a/hw/block/nvme.c b/hw/block/nvme.c | ||
248 | index XXXXXXX..XXXXXXX 100644 | ||
249 | --- a/hw/block/nvme.c | ||
250 | +++ b/hw/block/nvme.c | ||
251 | @@ -XXX,XX +XXX,XX @@ | ||
252 | * -drive file=<file>,if=none,id=<drive_id> | ||
253 | * -device nvme,drive=<drive_id>,serial=<serial>,id=<id[optional]>, \ | ||
254 | * cmb_size_mb=<cmb_size_mb[optional]>, \ | ||
255 | + * [pmrdev=<mem_backend_file_id>,] \ | ||
256 | * num_queues=<N[optional]> | ||
257 | * | ||
258 | * Note cmb_size_mb denotes size of CMB in MB. CMB is assumed to be at | ||
259 | * offset 0 in BAR2 and supports only WDS, RDS and SQS for now. | ||
260 | + * | ||
261 | + * cmb_size_mb= and pmrdev= options are mutually exclusive due to limitation | ||
262 | + * in available BAR's. cmb_size_mb= will take precedence over pmrdev= when | ||
263 | + * both provided. | ||
264 | + * Enabling pmr emulation can be achieved by pointing to memory-backend-file. | ||
265 | + * For example: | ||
266 | + * -object memory-backend-file,id=<mem_id>,share=on,mem-path=<file_path>, \ | ||
267 | + * size=<size> .... -device nvme,...,pmrdev=<mem_id> | ||
268 | */ | ||
269 | |||
270 | #include "qemu/osdep.h" | ||
271 | @@ -XXX,XX +XXX,XX @@ | ||
272 | #include "sysemu/sysemu.h" | ||
273 | #include "qapi/error.h" | ||
274 | #include "qapi/visitor.h" | ||
275 | +#include "sysemu/hostmem.h" | ||
276 | #include "sysemu/block-backend.h" | ||
277 | +#include "exec/ram_addr.h" | ||
278 | |||
279 | #include "qemu/log.h" | ||
280 | #include "qemu/module.h" | ||
281 | @@ -XXX,XX +XXX,XX @@ static void nvme_write_bar(NvmeCtrl *n, hwaddr offset, uint64_t data, | ||
282 | NVME_GUEST_ERR(nvme_ub_mmiowr_cmbsz_readonly, | ||
283 | "invalid write to read only CMBSZ, ignored"); | ||
284 | return; | ||
285 | + case 0xE00: /* PMRCAP */ | ||
286 | + NVME_GUEST_ERR(nvme_ub_mmiowr_pmrcap_readonly, | ||
287 | + "invalid write to PMRCAP register, ignored"); | ||
288 | + return; | ||
289 | + case 0xE04: /* TODO PMRCTL */ | ||
290 | + break; | ||
291 | + case 0xE08: /* PMRSTS */ | ||
292 | + NVME_GUEST_ERR(nvme_ub_mmiowr_pmrsts_readonly, | ||
293 | + "invalid write to PMRSTS register, ignored"); | ||
294 | + return; | ||
295 | + case 0xE0C: /* PMREBS */ | ||
296 | + NVME_GUEST_ERR(nvme_ub_mmiowr_pmrebs_readonly, | ||
297 | + "invalid write to PMREBS register, ignored"); | ||
298 | + return; | ||
299 | + case 0xE10: /* PMRSWTP */ | ||
300 | + NVME_GUEST_ERR(nvme_ub_mmiowr_pmrswtp_readonly, | ||
301 | + "invalid write to PMRSWTP register, ignored"); | ||
302 | + return; | ||
303 | + case 0xE14: /* TODO PMRMSC */ | ||
304 | + break; | ||
305 | default: | ||
306 | NVME_GUEST_ERR(nvme_ub_mmiowr_invalid, | ||
307 | "invalid MMIO write," | ||
308 | @@ -XXX,XX +XXX,XX @@ static uint64_t nvme_mmio_read(void *opaque, hwaddr addr, unsigned size) | ||
309 | } | ||
310 | |||
311 | if (addr < sizeof(n->bar)) { | ||
312 | + /* | ||
313 | + * When PMRWBM bit 1 is set then read from | ||
314 | + * from PMRSTS should ensure prior writes | ||
315 | + * made it to persistent media | ||
316 | + */ | ||
317 | + if (addr == 0xE08 && | ||
318 | + (NVME_PMRCAP_PMRWBM(n->bar.pmrcap) & 0x02)) { | ||
319 | + qemu_ram_writeback(n->pmrdev->mr.ram_block, | ||
320 | + 0, n->pmrdev->size); | ||
321 | + } | ||
322 | memcpy(&val, ptr + addr, size); | ||
323 | } else { | ||
324 | NVME_GUEST_ERR(nvme_ub_mmiord_invalid_ofs, | ||
325 | @@ -XXX,XX +XXX,XX @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) | ||
326 | error_setg(errp, "serial property not set"); | ||
27 | return; | 327 | return; |
28 | } | 328 | } |
29 | 329 | + | |
30 | - if (!(bs->open_flags & BDRV_O_INACTIVE)) { | 330 | + if (!n->cmb_size_mb && n->pmrdev) { |
31 | - return; | 331 | + if (host_memory_backend_is_mapped(n->pmrdev)) { |
32 | - } | 332 | + char *path = object_get_canonical_path_component(OBJECT(n->pmrdev)); |
33 | - | 333 | + error_setg(errp, "can't use already busy memdev: %s", path); |
34 | QLIST_FOREACH(child, &bs->children, next) { | 334 | + g_free(path); |
35 | bdrv_co_invalidate_cache(child->bs, &local_err); | ||
36 | if (local_err) { | ||
37 | @@ -XXX,XX +XXX,XX @@ static void coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs, | ||
38 | * just keep the extended permissions for the next time that an activation | ||
39 | * of the image is tried. | ||
40 | */ | ||
41 | - bs->open_flags &= ~BDRV_O_INACTIVE; | ||
42 | - bdrv_get_cumulative_perm(bs, &perm, &shared_perm); | ||
43 | - ret = bdrv_check_perm(bs, NULL, perm, shared_perm, NULL, NULL, &local_err); | ||
44 | - if (ret < 0) { | ||
45 | - bs->open_flags |= BDRV_O_INACTIVE; | ||
46 | - error_propagate(errp, local_err); | ||
47 | - return; | ||
48 | - } | ||
49 | - bdrv_set_perm(bs, perm, shared_perm); | ||
50 | - | ||
51 | - if (bs->drv->bdrv_co_invalidate_cache) { | ||
52 | - bs->drv->bdrv_co_invalidate_cache(bs, &local_err); | ||
53 | - if (local_err) { | ||
54 | + if (bs->open_flags & BDRV_O_INACTIVE) { | ||
55 | + bs->open_flags &= ~BDRV_O_INACTIVE; | ||
56 | + bdrv_get_cumulative_perm(bs, &perm, &shared_perm); | ||
57 | + ret = bdrv_check_perm(bs, NULL, perm, shared_perm, NULL, NULL, &local_err); | ||
58 | + if (ret < 0) { | ||
59 | bs->open_flags |= BDRV_O_INACTIVE; | ||
60 | error_propagate(errp, local_err); | ||
61 | return; | ||
62 | } | ||
63 | - } | ||
64 | + bdrv_set_perm(bs, perm, shared_perm); | ||
65 | |||
66 | - FOR_EACH_DIRTY_BITMAP(bs, bm) { | ||
67 | - bdrv_dirty_bitmap_skip_store(bm, false); | ||
68 | - } | ||
69 | + if (bs->drv->bdrv_co_invalidate_cache) { | ||
70 | + bs->drv->bdrv_co_invalidate_cache(bs, &local_err); | ||
71 | + if (local_err) { | ||
72 | + bs->open_flags |= BDRV_O_INACTIVE; | ||
73 | + error_propagate(errp, local_err); | ||
74 | + return; | ||
75 | + } | ||
76 | + } | ||
77 | |||
78 | - ret = refresh_total_sectors(bs, bs->total_sectors); | ||
79 | - if (ret < 0) { | ||
80 | - bs->open_flags |= BDRV_O_INACTIVE; | ||
81 | - error_setg_errno(errp, -ret, "Could not refresh total sector count"); | ||
82 | - return; | ||
83 | + FOR_EACH_DIRTY_BITMAP(bs, bm) { | ||
84 | + bdrv_dirty_bitmap_skip_store(bm, false); | ||
85 | + } | ||
86 | + | ||
87 | + ret = refresh_total_sectors(bs, bs->total_sectors); | ||
88 | + if (ret < 0) { | ||
89 | + bs->open_flags |= BDRV_O_INACTIVE; | ||
90 | + error_setg_errno(errp, -ret, "Could not refresh total sector count"); | ||
91 | + return; | 335 | + return; |
92 | + } | 336 | + } |
337 | + | ||
338 | + if (!is_power_of_2(n->pmrdev->size)) { | ||
339 | + error_setg(errp, "pmr backend size needs to be power of 2 in size"); | ||
340 | + return; | ||
341 | + } | ||
342 | + | ||
343 | + host_memory_backend_set_mapped(n->pmrdev, true); | ||
344 | + } | ||
345 | + | ||
346 | blkconf_blocksizes(&n->conf); | ||
347 | if (!blkconf_apply_backend_options(&n->conf, blk_is_read_only(n->conf.blk), | ||
348 | false, errp)) { | ||
349 | @@ -XXX,XX +XXX,XX @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) | ||
350 | PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64 | | ||
351 | PCI_BASE_ADDRESS_MEM_PREFETCH, &n->ctrl_mem); | ||
352 | |||
353 | + } else if (n->pmrdev) { | ||
354 | + /* Controller Capabilities register */ | ||
355 | + NVME_CAP_SET_PMRS(n->bar.cap, 1); | ||
356 | + | ||
357 | + /* PMR Capabities register */ | ||
358 | + n->bar.pmrcap = 0; | ||
359 | + NVME_PMRCAP_SET_RDS(n->bar.pmrcap, 0); | ||
360 | + NVME_PMRCAP_SET_WDS(n->bar.pmrcap, 0); | ||
361 | + NVME_PMRCAP_SET_BIR(n->bar.pmrcap, 2); | ||
362 | + NVME_PMRCAP_SET_PMRTU(n->bar.pmrcap, 0); | ||
363 | + /* Turn on bit 1 support */ | ||
364 | + NVME_PMRCAP_SET_PMRWBM(n->bar.pmrcap, 0x02); | ||
365 | + NVME_PMRCAP_SET_PMRTO(n->bar.pmrcap, 0); | ||
366 | + NVME_PMRCAP_SET_CMSS(n->bar.pmrcap, 0); | ||
367 | + | ||
368 | + /* PMR Control register */ | ||
369 | + n->bar.pmrctl = 0; | ||
370 | + NVME_PMRCTL_SET_EN(n->bar.pmrctl, 0); | ||
371 | + | ||
372 | + /* PMR Status register */ | ||
373 | + n->bar.pmrsts = 0; | ||
374 | + NVME_PMRSTS_SET_ERR(n->bar.pmrsts, 0); | ||
375 | + NVME_PMRSTS_SET_NRDY(n->bar.pmrsts, 0); | ||
376 | + NVME_PMRSTS_SET_HSTS(n->bar.pmrsts, 0); | ||
377 | + NVME_PMRSTS_SET_CBAI(n->bar.pmrsts, 0); | ||
378 | + | ||
379 | + /* PMR Elasticity Buffer Size register */ | ||
380 | + n->bar.pmrebs = 0; | ||
381 | + NVME_PMREBS_SET_PMRSZU(n->bar.pmrebs, 0); | ||
382 | + NVME_PMREBS_SET_RBB(n->bar.pmrebs, 0); | ||
383 | + NVME_PMREBS_SET_PMRWBZ(n->bar.pmrebs, 0); | ||
384 | + | ||
385 | + /* PMR Sustained Write Throughput register */ | ||
386 | + n->bar.pmrswtp = 0; | ||
387 | + NVME_PMRSWTP_SET_PMRSWTU(n->bar.pmrswtp, 0); | ||
388 | + NVME_PMRSWTP_SET_PMRSWTV(n->bar.pmrswtp, 0); | ||
389 | + | ||
390 | + /* PMR Memory Space Control register */ | ||
391 | + n->bar.pmrmsc = 0; | ||
392 | + NVME_PMRMSC_SET_CMSE(n->bar.pmrmsc, 0); | ||
393 | + NVME_PMRMSC_SET_CBA(n->bar.pmrmsc, 0); | ||
394 | + | ||
395 | + pci_register_bar(pci_dev, NVME_PMRCAP_BIR(n->bar.pmrcap), | ||
396 | + PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64 | | ||
397 | + PCI_BASE_ADDRESS_MEM_PREFETCH, &n->pmrdev->mr); | ||
93 | } | 398 | } |
94 | 399 | ||
95 | QLIST_FOREACH(parent, &bs->parents, next_parent) { | 400 | for (i = 0; i < n->num_namespaces; i++) { |
401 | @@ -XXX,XX +XXX,XX @@ static void nvme_exit(PCIDevice *pci_dev) | ||
402 | if (n->cmb_size_mb) { | ||
403 | g_free(n->cmbuf); | ||
404 | } | ||
405 | + | ||
406 | + if (n->pmrdev) { | ||
407 | + host_memory_backend_set_mapped(n->pmrdev, false); | ||
408 | + } | ||
409 | msix_uninit_exclusive_bar(pci_dev); | ||
410 | } | ||
411 | |||
412 | static Property nvme_props[] = { | ||
413 | DEFINE_BLOCK_PROPERTIES(NvmeCtrl, conf), | ||
414 | + DEFINE_PROP_LINK("pmrdev", NvmeCtrl, pmrdev, TYPE_MEMORY_BACKEND, | ||
415 | + HostMemoryBackend *), | ||
416 | DEFINE_PROP_STRING("serial", NvmeCtrl, serial), | ||
417 | DEFINE_PROP_UINT32("cmb_size_mb", NvmeCtrl, cmb_size_mb, 0), | ||
418 | DEFINE_PROP_UINT32("num_queues", NvmeCtrl, num_queues, 64), | ||
419 | diff --git a/hw/block/Makefile.objs b/hw/block/Makefile.objs | ||
420 | index XXXXXXX..XXXXXXX 100644 | ||
421 | --- a/hw/block/Makefile.objs | ||
422 | +++ b/hw/block/Makefile.objs | ||
423 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_PFLASH_CFI02) += pflash_cfi02.o | ||
424 | common-obj-$(CONFIG_XEN) += xen-block.o | ||
425 | common-obj-$(CONFIG_ECC) += ecc.o | ||
426 | common-obj-$(CONFIG_ONENAND) += onenand.o | ||
427 | -common-obj-$(CONFIG_NVME_PCI) += nvme.o | ||
428 | common-obj-$(CONFIG_SWIM) += swim.o | ||
429 | |||
430 | common-obj-$(CONFIG_SH4) += tc58128.o | ||
431 | |||
432 | obj-$(CONFIG_VIRTIO_BLK) += virtio-blk.o | ||
433 | obj-$(CONFIG_VHOST_USER_BLK) += vhost-user-blk.o | ||
434 | +obj-$(CONFIG_NVME_PCI) += nvme.o | ||
435 | |||
436 | obj-y += dataplane/ | ||
437 | diff --git a/hw/block/trace-events b/hw/block/trace-events | ||
438 | index XXXXXXX..XXXXXXX 100644 | ||
439 | --- a/hw/block/trace-events | ||
440 | +++ b/hw/block/trace-events | ||
441 | @@ -XXX,XX +XXX,XX @@ nvme_ub_mmiowr_ssreset_w1c_unsupported(void) "attempted to W1C CSTS.NSSRO but CA | ||
442 | nvme_ub_mmiowr_ssreset_unsupported(void) "attempted NVM subsystem reset but CAP.NSSRS is zero (not supported)" | ||
443 | nvme_ub_mmiowr_cmbloc_reserved(void) "invalid write to reserved CMBLOC when CMBSZ is zero, ignored" | ||
444 | nvme_ub_mmiowr_cmbsz_readonly(void) "invalid write to read only CMBSZ, ignored" | ||
445 | +nvme_ub_mmiowr_pmrcap_readonly(void) "invalid write to read only PMRCAP, ignored" | ||
446 | +nvme_ub_mmiowr_pmrsts_readonly(void) "invalid write to read only PMRSTS, ignored" | ||
447 | +nvme_ub_mmiowr_pmrebs_readonly(void) "invalid write to read only PMREBS, ignored" | ||
448 | +nvme_ub_mmiowr_pmrswtp_readonly(void) "invalid write to read only PMRSWTP, ignored" | ||
449 | nvme_ub_mmiowr_invalid(uint64_t offset, uint64_t data) "invalid MMIO write, offset=0x%"PRIx64", data=0x%"PRIx64"" | ||
450 | nvme_ub_mmiord_misaligned32(uint64_t offset) "MMIO read not 32-bit aligned, offset=0x%"PRIx64"" | ||
451 | nvme_ub_mmiord_toosmall(uint64_t offset) "MMIO read smaller than 32-bits, offset=0x%"PRIx64"" | ||
96 | -- | 452 | -- |
97 | 2.20.1 | 453 | 2.25.3 |
98 | 454 | ||
99 | 455 | diff view generated by jsdifflib |
1 | The blockdev_create() function in this test case adds another filter to | 1 | The QMP handler qmp_object_add() and the implementation of --object in |
---|---|---|---|
2 | the logging, but provides otherwise the same functionality as | 2 | qemu-storage-daemon can share most of the code. Currently, |
3 | VM.blockdev_create() from iotests.py. Make it a thin wrapper around the | 3 | qemu-storage-daemon calls qmp_object_add(), but this is not correct |
4 | iotests.py function. | 4 | because different visitors need to be used. |
5 | |||
6 | As a first step towards a fix, make qmp_object_add() a wrapper around a | ||
7 | new function user_creatable_add_dict() that can get an additional | ||
8 | parameter. The handling of "props" is only required for compatibility | ||
9 | and not required for the qemu-storage-daemon command line, so it stays | ||
10 | in qmp_object_add(). | ||
5 | 11 | ||
6 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 12 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
7 | --- | 13 | --- |
8 | tests/qemu-iotests/207 | 8 +------- | 14 | include/qom/object_interfaces.h | 12 ++++++++++++ |
9 | 1 file changed, 1 insertion(+), 7 deletions(-) | 15 | qom/object_interfaces.c | 27 +++++++++++++++++++++++++++ |
16 | qom/qom-qmp-cmds.c | 24 +----------------------- | ||
17 | 3 files changed, 40 insertions(+), 23 deletions(-) | ||
10 | 18 | ||
11 | diff --git a/tests/qemu-iotests/207 b/tests/qemu-iotests/207 | 19 | diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h |
12 | index XXXXXXX..XXXXXXX 100755 | 20 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/tests/qemu-iotests/207 | 21 | --- a/include/qom/object_interfaces.h |
14 | +++ b/tests/qemu-iotests/207 | 22 | +++ b/include/qom/object_interfaces.h |
15 | @@ -XXX,XX +XXX,XX @@ def filter_hash(qmsg): | 23 | @@ -XXX,XX +XXX,XX @@ Object *user_creatable_add_type(const char *type, const char *id, |
16 | return iotests.filter_qmp(qmsg, _filter) | 24 | const QDict *qdict, |
17 | 25 | Visitor *v, Error **errp); | |
18 | def blockdev_create(vm, options): | 26 | |
19 | - result = vm.qmp_log('blockdev-create', job_id='job0', options=options, | 27 | +/** |
20 | - filters=[iotests.filter_qmp_testfiles, filter_hash]) | 28 | + * user_creatable_add_dict: |
29 | + * @qdict: the object definition | ||
30 | + * @errp: if an error occurs, a pointer to an area to store the error | ||
31 | + * | ||
32 | + * Create an instance of the user creatable object that is defined by | ||
33 | + * @qdict. The object type is taken from the QDict key 'qom-type', its | ||
34 | + * ID from the key 'id'. The remaining entries in @qdict are used to | ||
35 | + * initialize the object properties. | ||
36 | + */ | ||
37 | +void user_creatable_add_dict(QDict *qdict, Error **errp); | ||
38 | + | ||
39 | /** | ||
40 | * user_creatable_add_opts: | ||
41 | * @opts: the object definition | ||
42 | diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/qom/object_interfaces.c | ||
45 | +++ b/qom/object_interfaces.c | ||
46 | @@ -XXX,XX +XXX,XX @@ | ||
47 | #include "qapi/qmp/qerror.h" | ||
48 | #include "qapi/qmp/qjson.h" | ||
49 | #include "qapi/qmp/qstring.h" | ||
50 | +#include "qapi/qobject-input-visitor.h" | ||
51 | #include "qom/object_interfaces.h" | ||
52 | #include "qemu/help_option.h" | ||
53 | #include "qemu/module.h" | ||
54 | @@ -XXX,XX +XXX,XX @@ out: | ||
55 | return obj; | ||
56 | } | ||
57 | |||
58 | +void user_creatable_add_dict(QDict *qdict, Error **errp) | ||
59 | +{ | ||
60 | + Visitor *v; | ||
61 | + Object *obj; | ||
62 | + g_autofree char *type = NULL; | ||
63 | + g_autofree char *id = NULL; | ||
64 | + | ||
65 | + type = g_strdup(qdict_get_try_str(qdict, "qom-type")); | ||
66 | + if (!type) { | ||
67 | + error_setg(errp, QERR_MISSING_PARAMETER, "qom-type"); | ||
68 | + return; | ||
69 | + } | ||
70 | + qdict_del(qdict, "qom-type"); | ||
71 | + | ||
72 | + id = g_strdup(qdict_get_try_str(qdict, "id")); | ||
73 | + if (!id) { | ||
74 | + error_setg(errp, QERR_MISSING_PARAMETER, "id"); | ||
75 | + return; | ||
76 | + } | ||
77 | + qdict_del(qdict, "id"); | ||
78 | + | ||
79 | + v = qobject_input_visitor_new(QOBJECT(qdict)); | ||
80 | + obj = user_creatable_add_type(type, id, qdict, v, errp); | ||
81 | + visit_free(v); | ||
82 | + object_unref(obj); | ||
83 | +} | ||
84 | |||
85 | Object *user_creatable_add_opts(QemuOpts *opts, Error **errp) | ||
86 | { | ||
87 | diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c | ||
88 | index XXXXXXX..XXXXXXX 100644 | ||
89 | --- a/qom/qom-qmp-cmds.c | ||
90 | +++ b/qom/qom-qmp-cmds.c | ||
91 | @@ -XXX,XX +XXX,XX @@ | ||
92 | #include "qapi/qapi-commands-qom.h" | ||
93 | #include "qapi/qmp/qdict.h" | ||
94 | #include "qapi/qmp/qerror.h" | ||
95 | -#include "qapi/qobject-input-visitor.h" | ||
96 | #include "qemu/cutils.h" | ||
97 | #include "qom/object_interfaces.h" | ||
98 | #include "qom/qom-qobject.h" | ||
99 | @@ -XXX,XX +XXX,XX @@ void qmp_object_add(QDict *qdict, QObject **ret_data, Error **errp) | ||
100 | { | ||
101 | QObject *props; | ||
102 | QDict *pdict; | ||
103 | - Visitor *v; | ||
104 | - Object *obj; | ||
105 | - g_autofree char *type = NULL; | ||
106 | - g_autofree char *id = NULL; | ||
21 | - | 107 | - |
22 | - if 'return' in result: | 108 | - type = g_strdup(qdict_get_try_str(qdict, "qom-type")); |
23 | - assert result['return'] == {} | 109 | - if (!type) { |
24 | - vm.run_job('job0') | 110 | - error_setg(errp, QERR_MISSING_PARAMETER, "qom-type"); |
25 | - iotests.log("") | 111 | - return; |
26 | + vm.blockdev_create(options, filters=[iotests.filter_qmp_testfiles, filter_hash]) | 112 | - } |
27 | 113 | - qdict_del(qdict, "qom-type"); | |
28 | with iotests.FilePath('t.img') as disk_path, \ | 114 | - |
29 | iotests.VM() as vm: | 115 | - id = g_strdup(qdict_get_try_str(qdict, "id")); |
116 | - if (!id) { | ||
117 | - error_setg(errp, QERR_MISSING_PARAMETER, "id"); | ||
118 | - return; | ||
119 | - } | ||
120 | - qdict_del(qdict, "id"); | ||
121 | |||
122 | props = qdict_get(qdict, "props"); | ||
123 | if (props) { | ||
124 | @@ -XXX,XX +XXX,XX @@ void qmp_object_add(QDict *qdict, QObject **ret_data, Error **errp) | ||
125 | qobject_unref(pdict); | ||
126 | } | ||
127 | |||
128 | - v = qobject_input_visitor_new(QOBJECT(qdict)); | ||
129 | - obj = user_creatable_add_type(type, id, qdict, v, errp); | ||
130 | - visit_free(v); | ||
131 | - object_unref(obj); | ||
132 | + user_creatable_add_dict(qdict, errp); | ||
133 | } | ||
134 | |||
135 | void qmp_object_del(const char *id, Error **errp) | ||
30 | -- | 136 | -- |
31 | 2.20.1 | 137 | 2.25.3 |
32 | 138 | ||
33 | 139 | diff view generated by jsdifflib |
1 | From: Thomas Huth <thuth@redhat.com> | 1 | After processing the option string with the keyval parser, we get a |
---|---|---|---|
2 | QDict that contains only strings. This QDict must be fed to a keyval | ||
3 | visitor which converts the strings into the right data types. | ||
2 | 4 | ||
3 | Some tests create huge (but sparse) files, and to be able to run those | 5 | qmp_object_add(), however, uses the normal QObject input visitor, which |
4 | tests in certain limited environments (like CI containers), we have to | 6 | expects a QDict where all properties already have the QType that matches |
5 | check for the possibility to create such files first. Thus let's introduce | 7 | the data type required by the QOM object type. |
6 | a common function to check for large files, and replace the already | ||
7 | existing checks in the iotests 005 and 220 with this function. | ||
8 | 8 | ||
9 | Signed-off-by: Thomas Huth <thuth@redhat.com> | 9 | Change the --object implementation in qemu-storage-daemon so that it |
10 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 10 | doesn't call qmp_object_add(), but calls user_creatable_add_dict() |
11 | directly instead and pass it a new keyval boolean that decides which | ||
12 | visitor must be used. | ||
13 | |||
14 | Reported-by: Coiby Xu <coiby.xu@gmail.com> | ||
11 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 15 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
12 | --- | 16 | --- |
13 | tests/qemu-iotests/005 | 5 +---- | 17 | include/qom/object_interfaces.h | 6 +++++- |
14 | tests/qemu-iotests/220 | 6 ++---- | 18 | qemu-storage-daemon.c | 4 +--- |
15 | tests/qemu-iotests/common.rc | 10 ++++++++++ | 19 | qom/object_interfaces.c | 8 ++++++-- |
16 | 3 files changed, 13 insertions(+), 8 deletions(-) | 20 | qom/qom-qmp-cmds.c | 2 +- |
21 | 4 files changed, 13 insertions(+), 7 deletions(-) | ||
17 | 22 | ||
18 | diff --git a/tests/qemu-iotests/005 b/tests/qemu-iotests/005 | 23 | diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h |
19 | index XXXXXXX..XXXXXXX 100755 | ||
20 | --- a/tests/qemu-iotests/005 | ||
21 | +++ b/tests/qemu-iotests/005 | ||
22 | @@ -XXX,XX +XXX,XX @@ fi | ||
23 | # Sanity check: For raw, we require a file system that permits the creation | ||
24 | # of a HUGE (but very sparse) file. Check we can create it before continuing. | ||
25 | if [ "$IMGFMT" = "raw" ]; then | ||
26 | - if ! truncate --size=5T "$TEST_IMG"; then | ||
27 | - _notrun "file system on $TEST_DIR does not support large enough files" | ||
28 | - fi | ||
29 | - rm "$TEST_IMG" | ||
30 | + _require_large_file 5T | ||
31 | fi | ||
32 | |||
33 | echo | ||
34 | diff --git a/tests/qemu-iotests/220 b/tests/qemu-iotests/220 | ||
35 | index XXXXXXX..XXXXXXX 100755 | ||
36 | --- a/tests/qemu-iotests/220 | ||
37 | +++ b/tests/qemu-iotests/220 | ||
38 | @@ -XXX,XX +XXX,XX @@ echo "== Creating huge file ==" | ||
39 | |||
40 | # Sanity check: We require a file system that permits the creation | ||
41 | # of a HUGE (but very sparse) file. tmpfs works, ext4 does not. | ||
42 | -if ! truncate --size=513T "$TEST_IMG"; then | ||
43 | - _notrun "file system on $TEST_DIR does not support large enough files" | ||
44 | -fi | ||
45 | -rm "$TEST_IMG" | ||
46 | +_require_large_file 513T | ||
47 | + | ||
48 | IMGOPTS='cluster_size=2M,refcount_bits=1' _make_test_img 513T | ||
49 | |||
50 | echo "== Populating refcounts ==" | ||
51 | diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc | ||
52 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
53 | --- a/tests/qemu-iotests/common.rc | 25 | --- a/include/qom/object_interfaces.h |
54 | +++ b/tests/qemu-iotests/common.rc | 26 | +++ b/include/qom/object_interfaces.h |
55 | @@ -XXX,XX +XXX,XX @@ _require_drivers() | 27 | @@ -XXX,XX +XXX,XX @@ Object *user_creatable_add_type(const char *type, const char *id, |
56 | done | 28 | /** |
29 | * user_creatable_add_dict: | ||
30 | * @qdict: the object definition | ||
31 | + * @keyval: if true, use a keyval visitor for processing @qdict (i.e. | ||
32 | + * assume that all @qdict values are strings); otherwise, use | ||
33 | + * the normal QObject visitor (i.e. assume all @qdict values | ||
34 | + * have the QType expected by the QOM object type) | ||
35 | * @errp: if an error occurs, a pointer to an area to store the error | ||
36 | * | ||
37 | * Create an instance of the user creatable object that is defined by | ||
38 | @@ -XXX,XX +XXX,XX @@ Object *user_creatable_add_type(const char *type, const char *id, | ||
39 | * ID from the key 'id'. The remaining entries in @qdict are used to | ||
40 | * initialize the object properties. | ||
41 | */ | ||
42 | -void user_creatable_add_dict(QDict *qdict, Error **errp); | ||
43 | +void user_creatable_add_dict(QDict *qdict, bool keyval, Error **errp); | ||
44 | |||
45 | /** | ||
46 | * user_creatable_add_opts: | ||
47 | diff --git a/qemu-storage-daemon.c b/qemu-storage-daemon.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/qemu-storage-daemon.c | ||
50 | +++ b/qemu-storage-daemon.c | ||
51 | @@ -XXX,XX +XXX,XX @@ static void process_options(int argc, char *argv[]) | ||
52 | QemuOpts *opts; | ||
53 | const char *type; | ||
54 | QDict *args; | ||
55 | - QObject *ret_data = NULL; | ||
56 | |||
57 | /* FIXME The keyval parser rejects 'help' arguments, so we must | ||
58 | * unconditionall try QemuOpts first. */ | ||
59 | @@ -XXX,XX +XXX,XX @@ static void process_options(int argc, char *argv[]) | ||
60 | qemu_opts_del(opts); | ||
61 | |||
62 | args = keyval_parse(optarg, "qom-type", &error_fatal); | ||
63 | - qmp_object_add(args, &ret_data, &error_fatal); | ||
64 | + user_creatable_add_dict(args, true, &error_fatal); | ||
65 | qobject_unref(args); | ||
66 | - qobject_unref(ret_data); | ||
67 | break; | ||
68 | } | ||
69 | default: | ||
70 | diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c | ||
71 | index XXXXXXX..XXXXXXX 100644 | ||
72 | --- a/qom/object_interfaces.c | ||
73 | +++ b/qom/object_interfaces.c | ||
74 | @@ -XXX,XX +XXX,XX @@ out: | ||
75 | return obj; | ||
57 | } | 76 | } |
58 | 77 | ||
59 | +# Check that we have a file system that allows huge (but very sparse) files | 78 | -void user_creatable_add_dict(QDict *qdict, Error **errp) |
60 | +# | 79 | +void user_creatable_add_dict(QDict *qdict, bool keyval, Error **errp) |
61 | +_require_large_file() | 80 | { |
62 | +{ | 81 | Visitor *v; |
63 | + if ! truncate --size="$1" "$TEST_IMG"; then | 82 | Object *obj; |
64 | + _notrun "file system on $TEST_DIR does not support large enough files" | 83 | @@ -XXX,XX +XXX,XX @@ void user_creatable_add_dict(QDict *qdict, Error **errp) |
65 | + fi | 84 | } |
66 | + rm "$TEST_IMG" | 85 | qdict_del(qdict, "id"); |
67 | +} | 86 | |
68 | + | 87 | - v = qobject_input_visitor_new(QOBJECT(qdict)); |
69 | # make sure this script returns success | 88 | + if (keyval) { |
70 | true | 89 | + v = qobject_input_visitor_new_keyval(QOBJECT(qdict)); |
90 | + } else { | ||
91 | + v = qobject_input_visitor_new(QOBJECT(qdict)); | ||
92 | + } | ||
93 | obj = user_creatable_add_type(type, id, qdict, v, errp); | ||
94 | visit_free(v); | ||
95 | object_unref(obj); | ||
96 | diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/qom/qom-qmp-cmds.c | ||
99 | +++ b/qom/qom-qmp-cmds.c | ||
100 | @@ -XXX,XX +XXX,XX @@ void qmp_object_add(QDict *qdict, QObject **ret_data, Error **errp) | ||
101 | qobject_unref(pdict); | ||
102 | } | ||
103 | |||
104 | - user_creatable_add_dict(qdict, errp); | ||
105 | + user_creatable_add_dict(qdict, false, errp); | ||
106 | } | ||
107 | |||
108 | void qmp_object_del(const char *id, Error **errp) | ||
71 | -- | 109 | -- |
72 | 2.20.1 | 110 | 2.25.3 |
73 | 111 | ||
74 | 112 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Thomas Huth <thuth@redhat.com> | ||
2 | 1 | ||
3 | Test 060 fails in the arm64, s390x and ppc64le LXD containers on Travis | ||
4 | (which we will hopefully enable in our CI soon). These containers | ||
5 | apparently do not allow large files to be created. The repair process | ||
6 | in test 060 creates a file of 64 GiB, so test first whether such large | ||
7 | files are possible and skip the test if that's not the case. | ||
8 | |||
9 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
11 | --- | ||
12 | tests/qemu-iotests/060 | 3 +++ | ||
13 | 1 file changed, 3 insertions(+) | ||
14 | |||
15 | diff --git a/tests/qemu-iotests/060 b/tests/qemu-iotests/060 | ||
16 | index XXXXXXX..XXXXXXX 100755 | ||
17 | --- a/tests/qemu-iotests/060 | ||
18 | +++ b/tests/qemu-iotests/060 | ||
19 | @@ -XXX,XX +XXX,XX @@ _supported_fmt qcow2 | ||
20 | _supported_proto file | ||
21 | _supported_os Linux | ||
22 | |||
23 | +# The repair process will create a large file - so check for availability first | ||
24 | +_require_large_file 64G | ||
25 | + | ||
26 | rt_offset=65536 # 0x10000 (XXX: just an assumption) | ||
27 | rb_offset=131072 # 0x20000 (XXX: just an assumption) | ||
28 | l1_offset=196608 # 0x30000 (XXX: just an assumption) | ||
29 | -- | ||
30 | 2.20.1 | ||
31 | |||
32 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Thomas Huth <thuth@redhat.com> | ||
2 | 1 | ||
3 | Test 079 fails in the arm64, s390x and ppc64le LXD containers on Travis | ||
4 | (which we will hopefully enable in our CI soon). These containers | ||
5 | apparently do not allow large files to be created. Test 079 tries to | ||
6 | create a 4G sparse file, which is apparently already too big for these | ||
7 | containers, so check first whether we can really create such files before | ||
8 | executing the test. | ||
9 | |||
10 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
11 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
12 | --- | ||
13 | tests/qemu-iotests/079 | 3 +++ | ||
14 | 1 file changed, 3 insertions(+) | ||
15 | |||
16 | diff --git a/tests/qemu-iotests/079 b/tests/qemu-iotests/079 | ||
17 | index XXXXXXX..XXXXXXX 100755 | ||
18 | --- a/tests/qemu-iotests/079 | ||
19 | +++ b/tests/qemu-iotests/079 | ||
20 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
21 | _supported_fmt qcow2 | ||
22 | _supported_proto file nfs | ||
23 | |||
24 | +# Some containers (e.g. non-x86 on Travis) do not allow large files | ||
25 | +_require_large_file 4G | ||
26 | + | ||
27 | echo "=== Check option preallocation and cluster_size ===" | ||
28 | echo | ||
29 | cluster_sizes="16384 32768 65536 131072 262144 524288 1048576 2097152 4194304" | ||
30 | -- | ||
31 | 2.20.1 | ||
32 | |||
33 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | run_job() accepts a wait parameter for a timeout, but it doesn't | ||
2 | actually use it. The only thing that is missing is passing it to | ||
3 | events_wait(), so do that now. | ||
4 | 1 | ||
5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
6 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
7 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
8 | Reviewed-by: Alberto Garcia <berto@igalia.com> | ||
9 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
10 | --- | ||
11 | tests/qemu-iotests/iotests.py | 2 +- | ||
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/tests/qemu-iotests/iotests.py | ||
17 | +++ b/tests/qemu-iotests/iotests.py | ||
18 | @@ -XXX,XX +XXX,XX @@ class VM(qtest.QEMUQtestMachine): | ||
19 | ] | ||
20 | error = None | ||
21 | while True: | ||
22 | - ev = filter_qmp_event(self.events_wait(events)) | ||
23 | + ev = filter_qmp_event(self.events_wait(events, timeout=wait)) | ||
24 | if ev['event'] != 'JOB_STATUS_CHANGE': | ||
25 | if use_log: | ||
26 | log(ev) | ||
27 | -- | ||
28 | 2.20.1 | ||
29 | |||
30 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Automatically complete jobs that have a 'ready' state and need an | ||
2 | explicit job-complete. Without this, run_job() would hang for such | ||
3 | jobs. | ||
4 | 1 | ||
5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
6 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
7 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
8 | Reviewed-by: Alberto Garcia <berto@igalia.com> | ||
9 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
10 | --- | ||
11 | tests/qemu-iotests/iotests.py | 2 ++ | ||
12 | 1 file changed, 2 insertions(+) | ||
13 | |||
14 | diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/tests/qemu-iotests/iotests.py | ||
17 | +++ b/tests/qemu-iotests/iotests.py | ||
18 | @@ -XXX,XX +XXX,XX @@ class VM(qtest.QEMUQtestMachine): | ||
19 | error = j['error'] | ||
20 | if use_log: | ||
21 | log('Job failed: %s' % (j['error'])) | ||
22 | + elif status == 'ready': | ||
23 | + self.qmp_log('job-complete', id=job) | ||
24 | elif status == 'pending' and not auto_finalize: | ||
25 | if pre_finalize: | ||
26 | pre_finalize() | ||
27 | -- | ||
28 | 2.20.1 | ||
29 | |||
30 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
3 | Somehow I wrote not full path to the file. Fix that. | ||
4 | |||
5 | Also, while being here, rearrange entries, so that includes go first, | ||
6 | then block, than migration, than util. | ||
7 | |||
8 | Fixes: 052db8e71444d | ||
9 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
11 | --- | ||
12 | MAINTAINERS | 6 +++--- | ||
13 | 1 file changed, 3 insertions(+), 3 deletions(-) | ||
14 | |||
15 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/MAINTAINERS | ||
18 | +++ b/MAINTAINERS | ||
19 | @@ -XXX,XX +XXX,XX @@ M: John Snow <jsnow@redhat.com> | ||
20 | R: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
21 | L: qemu-block@nongnu.org | ||
22 | S: Supported | ||
23 | -F: util/hbitmap.c | ||
24 | -F: block/dirty-bitmap.c | ||
25 | F: include/qemu/hbitmap.h | ||
26 | F: include/block/dirty-bitmap.h | ||
27 | -F: qcow2-bitmap.c | ||
28 | +F: block/dirty-bitmap.c | ||
29 | +F: block/qcow2-bitmap.c | ||
30 | F: migration/block-dirty-bitmap.c | ||
31 | +F: util/hbitmap.c | ||
32 | F: tests/test-hbitmap.c | ||
33 | F: docs/interop/bitmaps.rst | ||
34 | T: git https://github.com/jnsnow/qemu.git bitmaps | ||
35 | -- | ||
36 | 2.20.1 | ||
37 | |||
38 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Thomas Huth <thuth@redhat.com> | ||
2 | 1 | ||
3 | Test 051 should be skipped if nbd is not available, and 267 should | ||
4 | be skipped if copy-on-read is not enabled. | ||
5 | |||
6 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
7 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
9 | --- | ||
10 | tests/qemu-iotests/051 | 1 + | ||
11 | tests/qemu-iotests/267 | 1 + | ||
12 | 2 files changed, 2 insertions(+) | ||
13 | |||
14 | diff --git a/tests/qemu-iotests/051 b/tests/qemu-iotests/051 | ||
15 | index XXXXXXX..XXXXXXX 100755 | ||
16 | --- a/tests/qemu-iotests/051 | ||
17 | +++ b/tests/qemu-iotests/051 | ||
18 | @@ -XXX,XX +XXX,XX @@ _supported_proto file | ||
19 | # A compat=0.10 image is created in this test which does not support anything | ||
20 | # other than refcount_bits=16 | ||
21 | _unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' | ||
22 | +_require_drivers nbd | ||
23 | |||
24 | do_run_qemu() | ||
25 | { | ||
26 | diff --git a/tests/qemu-iotests/267 b/tests/qemu-iotests/267 | ||
27 | index XXXXXXX..XXXXXXX 100755 | ||
28 | --- a/tests/qemu-iotests/267 | ||
29 | +++ b/tests/qemu-iotests/267 | ||
30 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
31 | _supported_fmt qcow2 | ||
32 | _supported_proto file | ||
33 | _supported_os Linux | ||
34 | +_require_drivers copy-on-read | ||
35 | |||
36 | # Internal snapshots are (currently) impossible with refcount_bits=1 | ||
37 | _unsupported_imgopts 'refcount_bits=1[^0-9]' | ||
38 | -- | ||
39 | 2.20.1 | ||
40 | |||
41 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Max Reitz <mreitz@redhat.com> | ||
2 | 1 | ||
3 | Doing this allows running this test with e.g. -o compat=0.10 or | ||
4 | -o compat=refcount_bits=1. | ||
5 | |||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
7 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
8 | --- | ||
9 | tests/qemu-iotests/273 | 3 ++- | ||
10 | tests/qemu-iotests/273.out | 27 --------------------------- | ||
11 | 2 files changed, 2 insertions(+), 28 deletions(-) | ||
12 | |||
13 | diff --git a/tests/qemu-iotests/273 b/tests/qemu-iotests/273 | ||
14 | index XXXXXXX..XXXXXXX 100755 | ||
15 | --- a/tests/qemu-iotests/273 | ||
16 | +++ b/tests/qemu-iotests/273 | ||
17 | @@ -XXX,XX +XXX,XX @@ do_run_qemu() | ||
18 | run_qemu() | ||
19 | { | ||
20 | do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp | | ||
21 | - _filter_generated_node_ids | _filter_imgfmt | _filter_actual_image_size | ||
22 | + _filter_generated_node_ids | _filter_imgfmt | | ||
23 | + _filter_actual_image_size | _filter_img_info | ||
24 | } | ||
25 | |||
26 | TEST_IMG="$TEST_IMG.base" _make_test_img 64M | ||
27 | diff --git a/tests/qemu-iotests/273.out b/tests/qemu-iotests/273.out | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/tests/qemu-iotests/273.out | ||
30 | +++ b/tests/qemu-iotests/273.out | ||
31 | @@ -XXX,XX +XXX,XX @@ Testing: -blockdev file,node-name=base,filename=TEST_DIR/t.IMGFMT.base -blockdev | ||
32 | "cluster-size": 65536, | ||
33 | "format": "IMGFMT", | ||
34 | "actual-size": SIZE, | ||
35 | - "format-specific": { | ||
36 | - "type": "IMGFMT", | ||
37 | - "data": { | ||
38 | - "compat": "1.1", | ||
39 | - "lazy-refcounts": false, | ||
40 | - "refcount-bits": 16, | ||
41 | - "corrupt": false | ||
42 | - } | ||
43 | - }, | ||
44 | "full-backing-filename": "TEST_DIR/t.IMGFMT.base", | ||
45 | "backing-filename": "TEST_DIR/t.IMGFMT.base", | ||
46 | "dirty-flag": false | ||
47 | @@ -XXX,XX +XXX,XX @@ Testing: -blockdev file,node-name=base,filename=TEST_DIR/t.IMGFMT.base -blockdev | ||
48 | "cluster-size": 65536, | ||
49 | "format": "IMGFMT", | ||
50 | "actual-size": SIZE, | ||
51 | - "format-specific": { | ||
52 | - "type": "IMGFMT", | ||
53 | - "data": { | ||
54 | - "compat": "1.1", | ||
55 | - "lazy-refcounts": false, | ||
56 | - "refcount-bits": 16, | ||
57 | - "corrupt": false | ||
58 | - } | ||
59 | - }, | ||
60 | "full-backing-filename": "TEST_DIR/t.IMGFMT.mid", | ||
61 | "backing-filename": "TEST_DIR/t.IMGFMT.mid", | ||
62 | "dirty-flag": false | ||
63 | @@ -XXX,XX +XXX,XX @@ Testing: -blockdev file,node-name=base,filename=TEST_DIR/t.IMGFMT.base -blockdev | ||
64 | "cluster-size": 65536, | ||
65 | "format": "IMGFMT", | ||
66 | "actual-size": SIZE, | ||
67 | - "format-specific": { | ||
68 | - "type": "IMGFMT", | ||
69 | - "data": { | ||
70 | - "compat": "1.1", | ||
71 | - "lazy-refcounts": false, | ||
72 | - "refcount-bits": 16, | ||
73 | - "corrupt": false | ||
74 | - } | ||
75 | - }, | ||
76 | "full-backing-filename": "TEST_DIR/t.IMGFMT.base", | ||
77 | "backing-filename": "TEST_DIR/t.IMGFMT.base", | ||
78 | "dirty-flag": false | ||
79 | -- | ||
80 | 2.20.1 | ||
81 | |||
82 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Max Reitz <mreitz@redhat.com> | ||
2 | 1 | ||
3 | There is no $SOCKDIR, only $SOCK_DIR. | ||
4 | |||
5 | Fixes: f3923a72f199b2c63747a7032db74730546f55c6 | ||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
9 | --- | ||
10 | tests/qemu-iotests/common.rc | 3 ++- | ||
11 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/tests/qemu-iotests/common.rc | ||
16 | +++ b/tests/qemu-iotests/common.rc | ||
17 | @@ -XXX,XX +XXX,XX @@ if [ "$IMGOPTSSYNTAX" = "true" ]; then | ||
18 | TEST_IMG="$DRIVER,file.filename=$TEST_DIR/t.$IMGFMT" | ||
19 | elif [ "$IMGPROTO" = "nbd" ]; then | ||
20 | TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT | ||
21 | - TEST_IMG="$DRIVER,file.driver=nbd,file.type=unix,file.path=$SOCKDIR/nbd" | ||
22 | + TEST_IMG="$DRIVER,file.driver=nbd,file.type=unix" | ||
23 | + TEST_IMG="$TEST_IMG,file.path=$SOCK_DIR/nbd" | ||
24 | elif [ "$IMGPROTO" = "ssh" ]; then | ||
25 | TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT | ||
26 | TEST_IMG="$DRIVER,file.driver=ssh,file.host=127.0.0.1,file.path=$TEST_IMG_FILE" | ||
27 | -- | ||
28 | 2.20.1 | ||
29 | |||
30 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | blockdev_create() is completely unused in this test case, so we can just | ||
2 | drop it. | ||
3 | 1 | ||
4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
5 | --- | ||
6 | tests/qemu-iotests/255 | 10 ---------- | ||
7 | 1 file changed, 10 deletions(-) | ||
8 | |||
9 | diff --git a/tests/qemu-iotests/255 b/tests/qemu-iotests/255 | ||
10 | index XXXXXXX..XXXXXXX 100755 | ||
11 | --- a/tests/qemu-iotests/255 | ||
12 | +++ b/tests/qemu-iotests/255 | ||
13 | @@ -XXX,XX +XXX,XX @@ from iotests import imgfmt | ||
14 | |||
15 | iotests.verify_image_format(supported_fmts=['qcow2']) | ||
16 | |||
17 | -def blockdev_create(vm, options): | ||
18 | - result = vm.qmp_log('blockdev-create', | ||
19 | - filters=[iotests.filter_qmp_testfiles], | ||
20 | - job_id='job0', options=options) | ||
21 | - | ||
22 | - if 'return' in result: | ||
23 | - assert result['return'] == {} | ||
24 | - vm.run_job('job0') | ||
25 | - iotests.log("") | ||
26 | - | ||
27 | iotests.log('Finishing a commit job with background reads') | ||
28 | iotests.log('============================================') | ||
29 | iotests.log('') | ||
30 | -- | ||
31 | 2.20.1 | ||
32 | |||
33 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Instead of having a separate blockdev_create() function, make use of the | ||
2 | VM.blockdev_create() offered by iotests.py. | ||
3 | 1 | ||
4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
5 | --- | ||
6 | tests/qemu-iotests/206 | 232 ++++++++++++++++++++--------------------- | ||
7 | 1 file changed, 111 insertions(+), 121 deletions(-) | ||
8 | |||
9 | diff --git a/tests/qemu-iotests/206 b/tests/qemu-iotests/206 | ||
10 | index XXXXXXX..XXXXXXX 100755 | ||
11 | --- a/tests/qemu-iotests/206 | ||
12 | +++ b/tests/qemu-iotests/206 | ||
13 | @@ -XXX,XX +XXX,XX @@ from iotests import imgfmt | ||
14 | |||
15 | iotests.verify_image_format(supported_fmts=['qcow2']) | ||
16 | |||
17 | -def blockdev_create(vm, options): | ||
18 | - result = vm.qmp_log('blockdev-create', | ||
19 | - filters=[iotests.filter_qmp_testfiles], | ||
20 | - job_id='job0', options=options) | ||
21 | - | ||
22 | - if 'return' in result: | ||
23 | - assert result['return'] == {} | ||
24 | - vm.run_job('job0') | ||
25 | - iotests.log("") | ||
26 | - | ||
27 | with iotests.FilePath('t.qcow2') as disk_path, \ | ||
28 | iotests.FilePath('t.qcow2.base') as backing_path, \ | ||
29 | iotests.VM() as vm: | ||
30 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.qcow2') as disk_path, \ | ||
31 | size = 128 * 1024 * 1024 | ||
32 | |||
33 | vm.launch() | ||
34 | - blockdev_create(vm, { 'driver': 'file', | ||
35 | - 'filename': disk_path, | ||
36 | - 'size': 0 }) | ||
37 | + vm.blockdev_create({ 'driver': 'file', | ||
38 | + 'filename': disk_path, | ||
39 | + 'size': 0 }) | ||
40 | |||
41 | vm.qmp_log('blockdev-add', | ||
42 | filters=[iotests.filter_qmp_testfiles], | ||
43 | driver='file', filename=disk_path, | ||
44 | node_name='imgfile') | ||
45 | |||
46 | - blockdev_create(vm, { 'driver': imgfmt, | ||
47 | - 'file': 'imgfile', | ||
48 | - 'size': size }) | ||
49 | + vm.blockdev_create({ 'driver': imgfmt, | ||
50 | + 'file': 'imgfile', | ||
51 | + 'size': size }) | ||
52 | vm.shutdown() | ||
53 | |||
54 | iotests.img_info_log(disk_path) | ||
55 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.qcow2') as disk_path, \ | ||
56 | size = 64 * 1024 * 1024 | ||
57 | |||
58 | vm.launch() | ||
59 | - blockdev_create(vm, { 'driver': 'file', | ||
60 | - 'filename': disk_path, | ||
61 | - 'size': 0, | ||
62 | - 'preallocation': 'off', | ||
63 | - 'nocow': False }) | ||
64 | - | ||
65 | - blockdev_create(vm, { 'driver': imgfmt, | ||
66 | - 'file': { | ||
67 | - 'driver': 'file', | ||
68 | - 'filename': disk_path, | ||
69 | - }, | ||
70 | - 'size': size, | ||
71 | - 'version': 'v3', | ||
72 | - 'cluster-size': 65536, | ||
73 | - 'preallocation': 'off', | ||
74 | - 'lazy-refcounts': False, | ||
75 | - 'refcount-bits': 16 }) | ||
76 | + vm.blockdev_create({ 'driver': 'file', | ||
77 | + 'filename': disk_path, | ||
78 | + 'size': 0, | ||
79 | + 'preallocation': 'off', | ||
80 | + 'nocow': False }) | ||
81 | + | ||
82 | + vm.blockdev_create({ 'driver': imgfmt, | ||
83 | + 'file': { | ||
84 | + 'driver': 'file', | ||
85 | + 'filename': disk_path, | ||
86 | + }, | ||
87 | + 'size': size, | ||
88 | + 'version': 'v3', | ||
89 | + 'cluster-size': 65536, | ||
90 | + 'preallocation': 'off', | ||
91 | + 'lazy-refcounts': False, | ||
92 | + 'refcount-bits': 16 }) | ||
93 | vm.shutdown() | ||
94 | |||
95 | iotests.img_info_log(disk_path) | ||
96 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.qcow2') as disk_path, \ | ||
97 | size = 32 * 1024 * 1024 | ||
98 | |||
99 | vm.launch() | ||
100 | - blockdev_create(vm, { 'driver': 'file', | ||
101 | - 'filename': disk_path, | ||
102 | - 'size': 0, | ||
103 | - 'preallocation': 'falloc', | ||
104 | - 'nocow': True }) | ||
105 | - | ||
106 | - blockdev_create(vm, { 'driver': imgfmt, | ||
107 | - 'file': { | ||
108 | - 'driver': 'file', | ||
109 | - 'filename': disk_path, | ||
110 | - }, | ||
111 | - 'size': size, | ||
112 | - 'version': 'v3', | ||
113 | - 'cluster-size': 2097152, | ||
114 | - 'preallocation': 'metadata', | ||
115 | - 'lazy-refcounts': True, | ||
116 | - 'refcount-bits': 1 }) | ||
117 | + vm.blockdev_create({ 'driver': 'file', | ||
118 | + 'filename': disk_path, | ||
119 | + 'size': 0, | ||
120 | + 'preallocation': 'falloc', | ||
121 | + 'nocow': True }) | ||
122 | + | ||
123 | + vm.blockdev_create({ 'driver': imgfmt, | ||
124 | + 'file': { | ||
125 | + 'driver': 'file', | ||
126 | + 'filename': disk_path, | ||
127 | + }, | ||
128 | + 'size': size, | ||
129 | + 'version': 'v3', | ||
130 | + 'cluster-size': 2097152, | ||
131 | + 'preallocation': 'metadata', | ||
132 | + 'lazy-refcounts': True, | ||
133 | + 'refcount-bits': 1 }) | ||
134 | vm.shutdown() | ||
135 | |||
136 | iotests.img_info_log(disk_path) | ||
137 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.qcow2') as disk_path, \ | ||
138 | iotests.log("") | ||
139 | |||
140 | vm.launch() | ||
141 | - blockdev_create(vm, { 'driver': 'file', | ||
142 | - 'filename': disk_path, | ||
143 | - 'size': 0 }) | ||
144 | - | ||
145 | - blockdev_create(vm, { 'driver': imgfmt, | ||
146 | - 'file': { | ||
147 | - 'driver': 'file', | ||
148 | - 'filename': disk_path, | ||
149 | - }, | ||
150 | - 'size': size, | ||
151 | - 'backing-file': backing_path, | ||
152 | - 'backing-fmt': 'qcow2', | ||
153 | - 'version': 'v2', | ||
154 | - 'cluster-size': 512 }) | ||
155 | + vm.blockdev_create({ 'driver': 'file', | ||
156 | + 'filename': disk_path, | ||
157 | + 'size': 0 }) | ||
158 | + | ||
159 | + vm.blockdev_create({ 'driver': imgfmt, | ||
160 | + 'file': { | ||
161 | + 'driver': 'file', | ||
162 | + 'filename': disk_path, | ||
163 | + }, | ||
164 | + 'size': size, | ||
165 | + 'backing-file': backing_path, | ||
166 | + 'backing-fmt': 'qcow2', | ||
167 | + 'version': 'v2', | ||
168 | + 'cluster-size': 512 }) | ||
169 | vm.shutdown() | ||
170 | |||
171 | iotests.img_info_log(disk_path) | ||
172 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.qcow2') as disk_path, \ | ||
173 | iotests.log("") | ||
174 | |||
175 | vm.launch() | ||
176 | - blockdev_create(vm, { 'driver': imgfmt, | ||
177 | - 'file': { | ||
178 | - 'driver': 'file', | ||
179 | - 'filename': disk_path, | ||
180 | - }, | ||
181 | - 'size': size, | ||
182 | - 'encrypt': { | ||
183 | - 'format': 'luks', | ||
184 | - 'key-secret': 'keysec0', | ||
185 | - 'cipher-alg': 'twofish-128', | ||
186 | - 'cipher-mode': 'ctr', | ||
187 | - 'ivgen-alg': 'plain64', | ||
188 | - 'ivgen-hash-alg': 'md5', | ||
189 | - 'hash-alg': 'sha1', | ||
190 | - 'iter-time': 10, | ||
191 | - }}) | ||
192 | + vm.blockdev_create({ 'driver': imgfmt, | ||
193 | + 'file': { | ||
194 | + 'driver': 'file', | ||
195 | + 'filename': disk_path, | ||
196 | + }, | ||
197 | + 'size': size, | ||
198 | + 'encrypt': { | ||
199 | + 'format': 'luks', | ||
200 | + 'key-secret': 'keysec0', | ||
201 | + 'cipher-alg': 'twofish-128', | ||
202 | + 'cipher-mode': 'ctr', | ||
203 | + 'ivgen-alg': 'plain64', | ||
204 | + 'ivgen-hash-alg': 'md5', | ||
205 | + 'hash-alg': 'sha1', | ||
206 | + 'iter-time': 10, | ||
207 | + }}) | ||
208 | vm.shutdown() | ||
209 | |||
210 | iotests.img_info_log(disk_path) | ||
211 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.qcow2') as disk_path, \ | ||
212 | iotests.log("") | ||
213 | |||
214 | vm.launch() | ||
215 | - blockdev_create(vm, { 'driver': imgfmt, | ||
216 | - 'file': "this doesn't exist", | ||
217 | - 'size': size }) | ||
218 | + vm.blockdev_create({ 'driver': imgfmt, | ||
219 | + 'file': "this doesn't exist", | ||
220 | + 'size': size }) | ||
221 | vm.shutdown() | ||
222 | |||
223 | # | ||
224 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.qcow2') as disk_path, \ | ||
225 | vm.launch() | ||
226 | for size in [ 1234, 18446744073709551104, 9223372036854775808, | ||
227 | 9223372036854775296 ]: | ||
228 | - blockdev_create(vm, { 'driver': imgfmt, | ||
229 | - 'file': 'node0', | ||
230 | - 'size': size }) | ||
231 | + vm.blockdev_create({ 'driver': imgfmt, | ||
232 | + 'file': 'node0', | ||
233 | + 'size': size }) | ||
234 | vm.shutdown() | ||
235 | |||
236 | # | ||
237 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.qcow2') as disk_path, \ | ||
238 | iotests.log("=== Invalid version ===") | ||
239 | |||
240 | vm.launch() | ||
241 | - blockdev_create(vm, { 'driver': imgfmt, | ||
242 | - 'file': 'node0', | ||
243 | - 'size': 67108864, | ||
244 | - 'version': 'v1' }) | ||
245 | - blockdev_create(vm, { 'driver': imgfmt, | ||
246 | - 'file': 'node0', | ||
247 | - 'size': 67108864, | ||
248 | - 'version': 'v2', | ||
249 | - 'lazy-refcounts': True }) | ||
250 | - blockdev_create(vm, { 'driver': imgfmt, | ||
251 | - 'file': 'node0', | ||
252 | - 'size': 67108864, | ||
253 | - 'version': 'v2', | ||
254 | - 'refcount-bits': 8 }) | ||
255 | + vm.blockdev_create({ 'driver': imgfmt, | ||
256 | + 'file': 'node0', | ||
257 | + 'size': 67108864, | ||
258 | + 'version': 'v1' }) | ||
259 | + vm.blockdev_create({ 'driver': imgfmt, | ||
260 | + 'file': 'node0', | ||
261 | + 'size': 67108864, | ||
262 | + 'version': 'v2', | ||
263 | + 'lazy-refcounts': True }) | ||
264 | + vm.blockdev_create({ 'driver': imgfmt, | ||
265 | + 'file': 'node0', | ||
266 | + 'size': 67108864, | ||
267 | + 'version': 'v2', | ||
268 | + 'refcount-bits': 8 }) | ||
269 | vm.shutdown() | ||
270 | |||
271 | # | ||
272 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.qcow2') as disk_path, \ | ||
273 | iotests.log("=== Invalid backing file options ===") | ||
274 | |||
275 | vm.launch() | ||
276 | - blockdev_create(vm, { 'driver': imgfmt, | ||
277 | - 'file': 'node0', | ||
278 | - 'size': 67108864, | ||
279 | - 'backing-file': '/dev/null', | ||
280 | - 'preallocation': 'full' }) | ||
281 | - blockdev_create(vm, { 'driver': imgfmt, | ||
282 | - 'file': 'node0', | ||
283 | - 'size': 67108864, | ||
284 | - 'backing-fmt': imgfmt }) | ||
285 | + vm.blockdev_create({ 'driver': imgfmt, | ||
286 | + 'file': 'node0', | ||
287 | + 'size': 67108864, | ||
288 | + 'backing-file': '/dev/null', | ||
289 | + 'preallocation': 'full' }) | ||
290 | + vm.blockdev_create({ 'driver': imgfmt, | ||
291 | + 'file': 'node0', | ||
292 | + 'size': 67108864, | ||
293 | + 'backing-fmt': imgfmt }) | ||
294 | vm.shutdown() | ||
295 | |||
296 | # | ||
297 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.qcow2') as disk_path, \ | ||
298 | |||
299 | vm.launch() | ||
300 | for csize in [ 1234, 128, 4194304, 0 ]: | ||
301 | - blockdev_create(vm, { 'driver': imgfmt, | ||
302 | - 'file': 'node0', | ||
303 | - 'size': 67108864, | ||
304 | - 'cluster-size': csize }) | ||
305 | - blockdev_create(vm, { 'driver': imgfmt, | ||
306 | - 'file': 'node0', | ||
307 | - 'size': 281474976710656, | ||
308 | - 'cluster-size': 512 }) | ||
309 | + vm.blockdev_create({ 'driver': imgfmt, | ||
310 | + 'file': 'node0', | ||
311 | + 'size': 67108864, | ||
312 | + 'cluster-size': csize }) | ||
313 | + vm.blockdev_create({ 'driver': imgfmt, | ||
314 | + 'file': 'node0', | ||
315 | + 'size': 281474976710656, | ||
316 | + 'cluster-size': 512 }) | ||
317 | vm.shutdown() | ||
318 | |||
319 | # | ||
320 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.qcow2') as disk_path, \ | ||
321 | |||
322 | vm.launch() | ||
323 | for refcount_bits in [ 128, 0, 7 ]: | ||
324 | - blockdev_create(vm, { 'driver': imgfmt, | ||
325 | - 'file': 'node0', | ||
326 | - 'size': 67108864, | ||
327 | - 'refcount-bits': refcount_bits }) | ||
328 | + vm.blockdev_create({ 'driver': imgfmt, | ||
329 | + 'file': 'node0', | ||
330 | + 'size': 67108864, | ||
331 | + 'refcount-bits': refcount_bits }) | ||
332 | vm.shutdown() | ||
333 | -- | ||
334 | 2.20.1 | ||
335 | |||
336 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Instead of having a separate blockdev_create() function, make use of the | ||
2 | VM.blockdev_create() offered by iotests.py. | ||
3 | 1 | ||
4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
5 | --- | ||
6 | tests/qemu-iotests/210 | 81 +++++++++++++++++++----------------------- | ||
7 | 1 file changed, 36 insertions(+), 45 deletions(-) | ||
8 | |||
9 | diff --git a/tests/qemu-iotests/210 b/tests/qemu-iotests/210 | ||
10 | index XXXXXXX..XXXXXXX 100755 | ||
11 | --- a/tests/qemu-iotests/210 | ||
12 | +++ b/tests/qemu-iotests/210 | ||
13 | @@ -XXX,XX +XXX,XX @@ from iotests import imgfmt | ||
14 | iotests.verify_image_format(supported_fmts=['luks']) | ||
15 | iotests.verify_protocol(supported=['file']) | ||
16 | |||
17 | -def blockdev_create(vm, options): | ||
18 | - result = vm.qmp_log('blockdev-create', job_id='job0', options=options, | ||
19 | - filters=[iotests.filter_qmp_testfiles]) | ||
20 | - | ||
21 | - if 'return' in result: | ||
22 | - assert result['return'] == {} | ||
23 | - vm.run_job('job0') | ||
24 | - iotests.log("") | ||
25 | - | ||
26 | with iotests.FilePath('t.luks') as disk_path, \ | ||
27 | iotests.VM() as vm: | ||
28 | |||
29 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.luks') as disk_path, \ | ||
30 | size = 128 * 1024 * 1024 | ||
31 | |||
32 | vm.launch() | ||
33 | - blockdev_create(vm, { 'driver': 'file', | ||
34 | - 'filename': disk_path, | ||
35 | - 'size': 0 }) | ||
36 | + vm.blockdev_create({ 'driver': 'file', | ||
37 | + 'filename': disk_path, | ||
38 | + 'size': 0 }) | ||
39 | |||
40 | vm.qmp_log('blockdev-add', driver='file', filename=disk_path, | ||
41 | node_name='imgfile', filters=[iotests.filter_qmp_testfiles]) | ||
42 | |||
43 | - blockdev_create(vm, { 'driver': imgfmt, | ||
44 | - 'file': 'imgfile', | ||
45 | - 'key-secret': 'keysec0', | ||
46 | - 'size': size, | ||
47 | - 'iter-time': 10 }) | ||
48 | + vm.blockdev_create({ 'driver': imgfmt, | ||
49 | + 'file': 'imgfile', | ||
50 | + 'key-secret': 'keysec0', | ||
51 | + 'size': size, | ||
52 | + 'iter-time': 10 }) | ||
53 | vm.shutdown() | ||
54 | |||
55 | # TODO Proper support for images to be used with imgopts and/or protocols | ||
56 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.luks') as disk_path, \ | ||
57 | size = 64 * 1024 * 1024 | ||
58 | |||
59 | vm.launch() | ||
60 | - blockdev_create(vm, { 'driver': 'file', | ||
61 | - 'filename': disk_path, | ||
62 | - 'size': 0 }) | ||
63 | - blockdev_create(vm, { 'driver': imgfmt, | ||
64 | - 'file': { | ||
65 | - 'driver': 'file', | ||
66 | - 'filename': disk_path, | ||
67 | - }, | ||
68 | - 'size': size, | ||
69 | - 'key-secret': 'keysec0', | ||
70 | - 'cipher-alg': 'twofish-128', | ||
71 | - 'cipher-mode': 'ctr', | ||
72 | - 'ivgen-alg': 'plain64', | ||
73 | - 'ivgen-hash-alg': 'md5', | ||
74 | - 'hash-alg': 'sha1', | ||
75 | - 'iter-time': 10 }) | ||
76 | + vm.blockdev_create({ 'driver': 'file', | ||
77 | + 'filename': disk_path, | ||
78 | + 'size': 0 }) | ||
79 | + vm.blockdev_create({ 'driver': imgfmt, | ||
80 | + 'file': { | ||
81 | + 'driver': 'file', | ||
82 | + 'filename': disk_path, | ||
83 | + }, | ||
84 | + 'size': size, | ||
85 | + 'key-secret': 'keysec0', | ||
86 | + 'cipher-alg': 'twofish-128', | ||
87 | + 'cipher-mode': 'ctr', | ||
88 | + 'ivgen-alg': 'plain64', | ||
89 | + 'ivgen-hash-alg': 'md5', | ||
90 | + 'hash-alg': 'sha1', | ||
91 | + 'iter-time': 10 }) | ||
92 | vm.shutdown() | ||
93 | |||
94 | # TODO Proper support for images to be used with imgopts and/or protocols | ||
95 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.luks') as disk_path, \ | ||
96 | size = 64 * 1024 * 1024 | ||
97 | |||
98 | vm.launch() | ||
99 | - blockdev_create(vm, { 'driver': imgfmt, | ||
100 | - 'file': "this doesn't exist", | ||
101 | - 'size': size }) | ||
102 | + vm.blockdev_create({ 'driver': imgfmt, | ||
103 | + 'file': "this doesn't exist", | ||
104 | + 'size': size }) | ||
105 | vm.shutdown() | ||
106 | |||
107 | # | ||
108 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.luks') as disk_path, \ | ||
109 | |||
110 | vm.add_blockdev('driver=file,filename=%s,node-name=node0' % (disk_path)) | ||
111 | vm.launch() | ||
112 | - blockdev_create(vm, { 'driver': imgfmt, | ||
113 | - 'file': 'node0', | ||
114 | - 'key-secret': 'keysec0', | ||
115 | - 'size': 0, | ||
116 | - 'iter-time': 10 }) | ||
117 | + vm.blockdev_create({ 'driver': imgfmt, | ||
118 | + 'file': 'node0', | ||
119 | + 'key-secret': 'keysec0', | ||
120 | + 'size': 0, | ||
121 | + 'iter-time': 10 }) | ||
122 | vm.shutdown() | ||
123 | |||
124 | # TODO Proper support for images to be used with imgopts and/or protocols | ||
125 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.luks') as disk_path, \ | ||
126 | |||
127 | vm.launch() | ||
128 | for size in [ 18446744073709551104, 9223372036854775808, 9223372036854775296 ]: | ||
129 | - blockdev_create(vm, { 'driver': imgfmt, | ||
130 | - 'file': 'node0', | ||
131 | - 'key-secret': 'keysec0', | ||
132 | - 'size': size }) | ||
133 | + vm.blockdev_create({ 'driver': imgfmt, | ||
134 | + 'file': 'node0', | ||
135 | + 'key-secret': 'keysec0', | ||
136 | + 'size': size }) | ||
137 | vm.shutdown() | ||
138 | |||
139 | # | ||
140 | -- | ||
141 | 2.20.1 | ||
142 | |||
143 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Instead of having a separate blockdev_create() function, make use of the | ||
2 | VM.blockdev_create() offered by iotests.py. | ||
3 | 1 | ||
4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
5 | --- | ||
6 | tests/qemu-iotests/212 | 101 +++++++++++++++++++---------------------- | ||
7 | 1 file changed, 46 insertions(+), 55 deletions(-) | ||
8 | |||
9 | diff --git a/tests/qemu-iotests/212 b/tests/qemu-iotests/212 | ||
10 | index XXXXXXX..XXXXXXX 100755 | ||
11 | --- a/tests/qemu-iotests/212 | ||
12 | +++ b/tests/qemu-iotests/212 | ||
13 | @@ -XXX,XX +XXX,XX @@ from iotests import imgfmt | ||
14 | iotests.verify_image_format(supported_fmts=['parallels']) | ||
15 | iotests.verify_protocol(supported=['file']) | ||
16 | |||
17 | -def blockdev_create(vm, options): | ||
18 | - result = vm.qmp_log('blockdev-create', job_id='job0', options=options, | ||
19 | - filters=[iotests.filter_qmp_testfiles]) | ||
20 | - | ||
21 | - if 'return' in result: | ||
22 | - assert result['return'] == {} | ||
23 | - vm.run_job('job0') | ||
24 | - iotests.log("") | ||
25 | - | ||
26 | with iotests.FilePath('t.parallels') as disk_path, \ | ||
27 | iotests.VM() as vm: | ||
28 | |||
29 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.parallels') as disk_path, \ | ||
30 | size = 128 * 1024 * 1024 | ||
31 | |||
32 | vm.launch() | ||
33 | - blockdev_create(vm, { 'driver': 'file', | ||
34 | - 'filename': disk_path, | ||
35 | - 'size': 0 }) | ||
36 | + vm.blockdev_create({ 'driver': 'file', | ||
37 | + 'filename': disk_path, | ||
38 | + 'size': 0 }) | ||
39 | |||
40 | vm.qmp_log('blockdev-add', driver='file', filename=disk_path, | ||
41 | node_name='imgfile', filters=[iotests.filter_qmp_testfiles]) | ||
42 | |||
43 | - blockdev_create(vm, { 'driver': imgfmt, | ||
44 | - 'file': 'imgfile', | ||
45 | - 'size': size }) | ||
46 | + vm.blockdev_create({ 'driver': imgfmt, | ||
47 | + 'file': 'imgfile', | ||
48 | + 'size': size }) | ||
49 | vm.shutdown() | ||
50 | |||
51 | iotests.img_info_log(disk_path) | ||
52 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.parallels') as disk_path, \ | ||
53 | size = 64 * 1024 * 1024 | ||
54 | |||
55 | vm.launch() | ||
56 | - blockdev_create(vm, { 'driver': 'file', | ||
57 | - 'filename': disk_path, | ||
58 | - 'size': 0 }) | ||
59 | - blockdev_create(vm, { 'driver': imgfmt, | ||
60 | - 'file': { | ||
61 | - 'driver': 'file', | ||
62 | - 'filename': disk_path, | ||
63 | - }, | ||
64 | - 'size': size, | ||
65 | - 'cluster-size': 1048576 }) | ||
66 | + vm.blockdev_create({ 'driver': 'file', | ||
67 | + 'filename': disk_path, | ||
68 | + 'size': 0 }) | ||
69 | + vm.blockdev_create({ 'driver': imgfmt, | ||
70 | + 'file': { | ||
71 | + 'driver': 'file', | ||
72 | + 'filename': disk_path, | ||
73 | + }, | ||
74 | + 'size': size, | ||
75 | + 'cluster-size': 1048576 }) | ||
76 | vm.shutdown() | ||
77 | |||
78 | iotests.img_info_log(disk_path) | ||
79 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.parallels') as disk_path, \ | ||
80 | size = 32 * 1024 * 1024 | ||
81 | |||
82 | vm.launch() | ||
83 | - blockdev_create(vm, { 'driver': 'file', | ||
84 | - 'filename': disk_path, | ||
85 | - 'size': 0 }) | ||
86 | - blockdev_create(vm, { 'driver': imgfmt, | ||
87 | - 'file': { | ||
88 | - 'driver': 'file', | ||
89 | - 'filename': disk_path, | ||
90 | - }, | ||
91 | - 'size': size, | ||
92 | - 'cluster-size': 65536 }) | ||
93 | + vm.blockdev_create({ 'driver': 'file', | ||
94 | + 'filename': disk_path, | ||
95 | + 'size': 0 }) | ||
96 | + vm.blockdev_create({ 'driver': imgfmt, | ||
97 | + 'file': { | ||
98 | + 'driver': 'file', | ||
99 | + 'filename': disk_path, | ||
100 | + }, | ||
101 | + 'size': size, | ||
102 | + 'cluster-size': 65536 }) | ||
103 | vm.shutdown() | ||
104 | |||
105 | iotests.img_info_log(disk_path) | ||
106 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.parallels') as disk_path, \ | ||
107 | iotests.log("") | ||
108 | |||
109 | vm.launch() | ||
110 | - blockdev_create(vm, { 'driver': imgfmt, | ||
111 | - 'file': "this doesn't exist", | ||
112 | - 'size': size }) | ||
113 | + vm.blockdev_create({ 'driver': imgfmt, | ||
114 | + 'file': "this doesn't exist", | ||
115 | + 'size': size }) | ||
116 | vm.shutdown() | ||
117 | |||
118 | # | ||
119 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.parallels') as disk_path, \ | ||
120 | |||
121 | vm.add_blockdev('driver=file,filename=%s,node-name=node0' % (disk_path)) | ||
122 | vm.launch() | ||
123 | - blockdev_create(vm, { 'driver': imgfmt, | ||
124 | - 'file': 'node0', | ||
125 | - 'size': 0 }) | ||
126 | + vm.blockdev_create({ 'driver': imgfmt, | ||
127 | + 'file': 'node0', | ||
128 | + 'size': 0 }) | ||
129 | vm.shutdown() | ||
130 | |||
131 | iotests.img_info_log(disk_path) | ||
132 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.parallels') as disk_path, \ | ||
133 | iotests.log("") | ||
134 | |||
135 | vm.launch() | ||
136 | - blockdev_create(vm, { 'driver': imgfmt, | ||
137 | - 'file': 'node0', | ||
138 | - 'size': 4503599627369984}) | ||
139 | + vm.blockdev_create({ 'driver': imgfmt, | ||
140 | + 'file': 'node0', | ||
141 | + 'size': 4503599627369984}) | ||
142 | vm.shutdown() | ||
143 | |||
144 | iotests.img_info_log(disk_path) | ||
145 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.parallels') as disk_path, \ | ||
146 | vm.launch() | ||
147 | for size in [ 1234, 18446744073709551104, 9223372036854775808, | ||
148 | 9223372036854775296, 4503599627370497 ]: | ||
149 | - blockdev_create(vm, { 'driver': imgfmt, | ||
150 | - 'file': 'node0', | ||
151 | - 'size': size }) | ||
152 | + vm.blockdev_create({ 'driver': imgfmt, | ||
153 | + 'file': 'node0', | ||
154 | + 'size': size }) | ||
155 | vm.shutdown() | ||
156 | |||
157 | # | ||
158 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.parallels') as disk_path, \ | ||
159 | vm.launch() | ||
160 | for csize in [ 1234, 128, 4294967296, 9223372036854775808, | ||
161 | 18446744073709551104, 0 ]: | ||
162 | - blockdev_create(vm, { 'driver': imgfmt, | ||
163 | - 'file': 'node0', | ||
164 | - 'size': 67108864, | ||
165 | - 'cluster-size': csize }) | ||
166 | - blockdev_create(vm, { 'driver': imgfmt, | ||
167 | - 'file': 'node0', | ||
168 | - 'size': 281474976710656, | ||
169 | - 'cluster-size': 512 }) | ||
170 | + vm.blockdev_create({ 'driver': imgfmt, | ||
171 | + 'file': 'node0', | ||
172 | + 'size': 67108864, | ||
173 | + 'cluster-size': csize }) | ||
174 | + vm.blockdev_create({ 'driver': imgfmt, | ||
175 | + 'file': 'node0', | ||
176 | + 'size': 281474976710656, | ||
177 | + 'cluster-size': 512 }) | ||
178 | vm.shutdown() | ||
179 | -- | ||
180 | 2.20.1 | ||
181 | |||
182 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Instead of having a separate blockdev_create() function, make use of the | ||
2 | VM.blockdev_create() offered by iotests.py. | ||
3 | 1 | ||
4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
5 | --- | ||
6 | tests/qemu-iotests/213 | 113 +++++++++++++++++++---------------------- | ||
7 | 1 file changed, 52 insertions(+), 61 deletions(-) | ||
8 | |||
9 | diff --git a/tests/qemu-iotests/213 b/tests/qemu-iotests/213 | ||
10 | index XXXXXXX..XXXXXXX 100755 | ||
11 | --- a/tests/qemu-iotests/213 | ||
12 | +++ b/tests/qemu-iotests/213 | ||
13 | @@ -XXX,XX +XXX,XX @@ from iotests import imgfmt | ||
14 | iotests.verify_image_format(supported_fmts=['vhdx']) | ||
15 | iotests.verify_protocol(supported=['file']) | ||
16 | |||
17 | -def blockdev_create(vm, options): | ||
18 | - result = vm.qmp_log('blockdev-create', job_id='job0', options=options, | ||
19 | - filters=[iotests.filter_qmp_testfiles]) | ||
20 | - | ||
21 | - if 'return' in result: | ||
22 | - assert result['return'] == {} | ||
23 | - vm.run_job('job0') | ||
24 | - iotests.log("") | ||
25 | - | ||
26 | with iotests.FilePath('t.vhdx') as disk_path, \ | ||
27 | iotests.VM() as vm: | ||
28 | |||
29 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.vhdx') as disk_path, \ | ||
30 | size = 128 * 1024 * 1024 | ||
31 | |||
32 | vm.launch() | ||
33 | - blockdev_create(vm, { 'driver': 'file', | ||
34 | - 'filename': disk_path, | ||
35 | - 'size': 0 }) | ||
36 | + vm.blockdev_create({ 'driver': 'file', | ||
37 | + 'filename': disk_path, | ||
38 | + 'size': 0 }) | ||
39 | |||
40 | vm.qmp_log('blockdev-add', driver='file', filename=disk_path, | ||
41 | node_name='imgfile', filters=[iotests.filter_qmp_testfiles]) | ||
42 | |||
43 | - blockdev_create(vm, { 'driver': imgfmt, | ||
44 | - 'file': 'imgfile', | ||
45 | - 'size': size }) | ||
46 | + vm.blockdev_create({ 'driver': imgfmt, | ||
47 | + 'file': 'imgfile', | ||
48 | + 'size': size }) | ||
49 | vm.shutdown() | ||
50 | |||
51 | iotests.img_info_log(disk_path) | ||
52 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.vhdx') as disk_path, \ | ||
53 | size = 64 * 1024 * 1024 | ||
54 | |||
55 | vm.launch() | ||
56 | - blockdev_create(vm, { 'driver': 'file', | ||
57 | - 'filename': disk_path, | ||
58 | - 'size': 0 }) | ||
59 | - blockdev_create(vm, { 'driver': imgfmt, | ||
60 | - 'file': { | ||
61 | - 'driver': 'file', | ||
62 | - 'filename': disk_path, | ||
63 | - }, | ||
64 | - 'size': size, | ||
65 | - 'log-size': 1048576, | ||
66 | - 'block-size': 8388608, | ||
67 | - 'subformat': 'dynamic', | ||
68 | - 'block-state-zero': True }) | ||
69 | + vm.blockdev_create({ 'driver': 'file', | ||
70 | + 'filename': disk_path, | ||
71 | + 'size': 0 }) | ||
72 | + vm.blockdev_create({ 'driver': imgfmt, | ||
73 | + 'file': { | ||
74 | + 'driver': 'file', | ||
75 | + 'filename': disk_path, | ||
76 | + }, | ||
77 | + 'size': size, | ||
78 | + 'log-size': 1048576, | ||
79 | + 'block-size': 8388608, | ||
80 | + 'subformat': 'dynamic', | ||
81 | + 'block-state-zero': True }) | ||
82 | vm.shutdown() | ||
83 | |||
84 | iotests.img_info_log(disk_path) | ||
85 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.vhdx') as disk_path, \ | ||
86 | size = 32 * 1024 * 1024 | ||
87 | |||
88 | vm.launch() | ||
89 | - blockdev_create(vm, { 'driver': 'file', | ||
90 | - 'filename': disk_path, | ||
91 | - 'size': 0 }) | ||
92 | - blockdev_create(vm, { 'driver': imgfmt, | ||
93 | - 'file': { | ||
94 | - 'driver': 'file', | ||
95 | - 'filename': disk_path, | ||
96 | - }, | ||
97 | - 'size': size, | ||
98 | - 'log-size': 8388608, | ||
99 | - 'block-size': 268435456, | ||
100 | - 'subformat': 'fixed', | ||
101 | - 'block-state-zero': False }) | ||
102 | + vm.blockdev_create({ 'driver': 'file', | ||
103 | + 'filename': disk_path, | ||
104 | + 'size': 0 }) | ||
105 | + vm.blockdev_create({ 'driver': imgfmt, | ||
106 | + 'file': { | ||
107 | + 'driver': 'file', | ||
108 | + 'filename': disk_path, | ||
109 | + }, | ||
110 | + 'size': size, | ||
111 | + 'log-size': 8388608, | ||
112 | + 'block-size': 268435456, | ||
113 | + 'subformat': 'fixed', | ||
114 | + 'block-state-zero': False }) | ||
115 | vm.shutdown() | ||
116 | |||
117 | iotests.img_info_log(disk_path) | ||
118 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.vhdx') as disk_path, \ | ||
119 | iotests.log("") | ||
120 | |||
121 | vm.launch() | ||
122 | - blockdev_create(vm, { 'driver': imgfmt, | ||
123 | - 'file': "this doesn't exist", | ||
124 | - 'size': size }) | ||
125 | + vm.blockdev_create({ 'driver': imgfmt, | ||
126 | + 'file': "this doesn't exist", | ||
127 | + 'size': size }) | ||
128 | vm.shutdown() | ||
129 | |||
130 | # | ||
131 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.vhdx') as disk_path, \ | ||
132 | |||
133 | vm.add_blockdev('driver=file,filename=%s,node-name=node0' % (disk_path)) | ||
134 | vm.launch() | ||
135 | - blockdev_create(vm, { 'driver': imgfmt, | ||
136 | - 'file': 'node0', | ||
137 | - 'size': 0 }) | ||
138 | + vm.blockdev_create({ 'driver': imgfmt, | ||
139 | + 'file': 'node0', | ||
140 | + 'size': 0 }) | ||
141 | vm.shutdown() | ||
142 | |||
143 | iotests.img_info_log(disk_path) | ||
144 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.vhdx') as disk_path, \ | ||
145 | iotests.log("") | ||
146 | |||
147 | vm.launch() | ||
148 | - blockdev_create(vm, { 'driver': imgfmt, | ||
149 | - 'file': 'node0', | ||
150 | - 'size': 70368744177664 }) | ||
151 | + vm.blockdev_create({ 'driver': imgfmt, | ||
152 | + 'file': 'node0', | ||
153 | + 'size': 70368744177664 }) | ||
154 | vm.shutdown() | ||
155 | |||
156 | iotests.img_info_log(disk_path) | ||
157 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.vhdx') as disk_path, \ | ||
158 | vm.launch() | ||
159 | for size in [ 18446744073709551104, 9223372036854775808, | ||
160 | 9223372036854775296, 70368744177665 ]: | ||
161 | - blockdev_create(vm, { 'driver': imgfmt, | ||
162 | - 'file': 'node0', | ||
163 | - 'size': size }) | ||
164 | + vm.blockdev_create({ 'driver': imgfmt, | ||
165 | + 'file': 'node0', | ||
166 | + 'size': size }) | ||
167 | vm.shutdown() | ||
168 | |||
169 | # | ||
170 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.vhdx') as disk_path, \ | ||
171 | |||
172 | vm.launch() | ||
173 | for bsize in [ 1234567, 128, 3145728, 536870912, 0 ]: | ||
174 | - blockdev_create(vm, { 'driver': imgfmt, | ||
175 | - 'file': 'node0', | ||
176 | - 'size': 67108864, | ||
177 | - 'block-size': bsize }) | ||
178 | + vm.blockdev_create({ 'driver': imgfmt, | ||
179 | + 'file': 'node0', | ||
180 | + 'size': 67108864, | ||
181 | + 'block-size': bsize }) | ||
182 | vm.shutdown() | ||
183 | |||
184 | # | ||
185 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.vhdx') as disk_path, \ | ||
186 | |||
187 | vm.launch() | ||
188 | for lsize in [ 1234567, 128, 4294967296, 0 ]: | ||
189 | - blockdev_create(vm, { 'driver': imgfmt, | ||
190 | - 'file': 'node0', | ||
191 | - 'size': 67108864, | ||
192 | - 'log-size': lsize }) | ||
193 | + vm.blockdev_create({ 'driver': imgfmt, | ||
194 | + 'file': 'node0', | ||
195 | + 'size': 67108864, | ||
196 | + 'log-size': lsize }) | ||
197 | vm.shutdown() | ||
198 | -- | ||
199 | 2.20.1 | ||
200 | |||
201 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Instead of having a separate blockdev_create() function, make use of the | ||
2 | VM.blockdev_create() offered by iotests.py. | ||
3 | 1 | ||
4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
5 | --- | ||
6 | tests/qemu-iotests/237 | 139 +++++++++++++++++++---------------------- | ||
7 | 1 file changed, 65 insertions(+), 74 deletions(-) | ||
8 | |||
9 | diff --git a/tests/qemu-iotests/237 b/tests/qemu-iotests/237 | ||
10 | index XXXXXXX..XXXXXXX 100755 | ||
11 | --- a/tests/qemu-iotests/237 | ||
12 | +++ b/tests/qemu-iotests/237 | ||
13 | @@ -XXX,XX +XXX,XX @@ from iotests import imgfmt | ||
14 | |||
15 | iotests.verify_image_format(supported_fmts=['vmdk']) | ||
16 | |||
17 | -def blockdev_create(vm, options): | ||
18 | - result = vm.qmp_log('blockdev-create', job_id='job0', options=options, | ||
19 | - filters=[iotests.filter_qmp_testfiles]) | ||
20 | - | ||
21 | - if 'return' in result: | ||
22 | - assert result['return'] == {} | ||
23 | - vm.run_job('job0') | ||
24 | - iotests.log("") | ||
25 | - | ||
26 | with iotests.FilePath('t.vmdk') as disk_path, \ | ||
27 | iotests.FilePath('t.vmdk.1') as extent1_path, \ | ||
28 | iotests.FilePath('t.vmdk.2') as extent2_path, \ | ||
29 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.vmdk') as disk_path, \ | ||
30 | size = 5 * 1024 * 1024 * 1024 | ||
31 | |||
32 | vm.launch() | ||
33 | - blockdev_create(vm, { 'driver': 'file', | ||
34 | - 'filename': disk_path, | ||
35 | - 'size': 0 }) | ||
36 | + vm.blockdev_create({ 'driver': 'file', | ||
37 | + 'filename': disk_path, | ||
38 | + 'size': 0 }) | ||
39 | |||
40 | vm.qmp_log('blockdev-add', driver='file', filename=disk_path, | ||
41 | node_name='imgfile', filters=[iotests.filter_qmp_testfiles]) | ||
42 | |||
43 | - blockdev_create(vm, { 'driver': imgfmt, | ||
44 | - 'file': 'imgfile', | ||
45 | - 'size': size }) | ||
46 | + vm.blockdev_create({ 'driver': imgfmt, | ||
47 | + 'file': 'imgfile', | ||
48 | + 'size': size }) | ||
49 | vm.shutdown() | ||
50 | |||
51 | iotests.img_info_log(disk_path) | ||
52 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.vmdk') as disk_path, \ | ||
53 | size = 64 * 1024 * 1024 | ||
54 | |||
55 | vm.launch() | ||
56 | - blockdev_create(vm, { 'driver': 'file', | ||
57 | - 'filename': disk_path, | ||
58 | - 'size': 0 }) | ||
59 | - | ||
60 | - blockdev_create(vm, { 'driver': imgfmt, | ||
61 | - 'file': { | ||
62 | - 'driver': 'file', | ||
63 | - 'filename': disk_path, | ||
64 | - }, | ||
65 | - 'size': size, | ||
66 | - 'extents': [], | ||
67 | - 'subformat': 'monolithicSparse', | ||
68 | - 'adapter-type': 'ide', | ||
69 | - 'hwversion': '4', | ||
70 | - 'zeroed-grain': False }) | ||
71 | + vm.blockdev_create({ 'driver': 'file', | ||
72 | + 'filename': disk_path, | ||
73 | + 'size': 0 }) | ||
74 | + | ||
75 | + vm.blockdev_create({ 'driver': imgfmt, | ||
76 | + 'file': { | ||
77 | + 'driver': 'file', | ||
78 | + 'filename': disk_path, | ||
79 | + }, | ||
80 | + 'size': size, | ||
81 | + 'extents': [], | ||
82 | + 'subformat': 'monolithicSparse', | ||
83 | + 'adapter-type': 'ide', | ||
84 | + 'hwversion': '4', | ||
85 | + 'zeroed-grain': False }) | ||
86 | vm.shutdown() | ||
87 | |||
88 | iotests.img_info_log(disk_path) | ||
89 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.vmdk') as disk_path, \ | ||
90 | size = 32 * 1024 * 1024 | ||
91 | |||
92 | vm.launch() | ||
93 | - blockdev_create(vm, { 'driver': 'file', | ||
94 | - 'filename': disk_path, | ||
95 | - 'size': 0 }) | ||
96 | - | ||
97 | - blockdev_create(vm, { 'driver': imgfmt, | ||
98 | - 'file': { | ||
99 | - 'driver': 'file', | ||
100 | - 'filename': disk_path, | ||
101 | - }, | ||
102 | - 'size': size, | ||
103 | - 'extents': [], | ||
104 | - 'subformat': 'monolithicSparse', | ||
105 | - 'adapter-type': 'buslogic', | ||
106 | - 'zeroed-grain': True }) | ||
107 | + vm.blockdev_create({ 'driver': 'file', | ||
108 | + 'filename': disk_path, | ||
109 | + 'size': 0 }) | ||
110 | + | ||
111 | + vm.blockdev_create({ 'driver': imgfmt, | ||
112 | + 'file': { | ||
113 | + 'driver': 'file', | ||
114 | + 'filename': disk_path, | ||
115 | + }, | ||
116 | + 'size': size, | ||
117 | + 'extents': [], | ||
118 | + 'subformat': 'monolithicSparse', | ||
119 | + 'adapter-type': 'buslogic', | ||
120 | + 'zeroed-grain': True }) | ||
121 | vm.shutdown() | ||
122 | |||
123 | iotests.img_info_log(disk_path) | ||
124 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.vmdk') as disk_path, \ | ||
125 | iotests.log("") | ||
126 | |||
127 | vm.launch() | ||
128 | - blockdev_create(vm, { 'driver': imgfmt, | ||
129 | - 'file': "this doesn't exist", | ||
130 | - 'size': size }) | ||
131 | + vm.blockdev_create({ 'driver': imgfmt, | ||
132 | + 'file': "this doesn't exist", | ||
133 | + 'size': size }) | ||
134 | vm.shutdown() | ||
135 | |||
136 | # | ||
137 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.vmdk') as disk_path, \ | ||
138 | |||
139 | vm.launch() | ||
140 | for adapter_type in [ 'ide', 'buslogic', 'lsilogic', 'legacyESX' ]: | ||
141 | - blockdev_create(vm, { 'driver': imgfmt, | ||
142 | - 'file': 'node0', | ||
143 | - 'size': size, | ||
144 | - 'adapter-type': adapter_type }) | ||
145 | + vm.blockdev_create({ 'driver': imgfmt, | ||
146 | + 'file': 'node0', | ||
147 | + 'size': size, | ||
148 | + 'adapter-type': adapter_type }) | ||
149 | vm.shutdown() | ||
150 | |||
151 | # Invalid | ||
152 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.vmdk') as disk_path, \ | ||
153 | |||
154 | vm.launch() | ||
155 | for adapter_type in [ 'foo', 'IDE', 'legacyesx', 1 ]: | ||
156 | - blockdev_create(vm, { 'driver': imgfmt, | ||
157 | - 'file': 'node0', | ||
158 | - 'size': size, | ||
159 | - 'adapter-type': adapter_type }) | ||
160 | + vm.blockdev_create({ 'driver': imgfmt, | ||
161 | + 'file': 'node0', | ||
162 | + 'size': size, | ||
163 | + 'adapter-type': adapter_type }) | ||
164 | vm.shutdown() | ||
165 | |||
166 | # | ||
167 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.vmdk') as disk_path, \ | ||
168 | iotests.log("") | ||
169 | |||
170 | vm.launch() | ||
171 | - blockdev_create(vm, { 'driver': imgfmt, | ||
172 | - 'file': 'node0', | ||
173 | - 'size': size, | ||
174 | - 'subformat': 'monolithicFlat' }) | ||
175 | + vm.blockdev_create({ 'driver': imgfmt, | ||
176 | + 'file': 'node0', | ||
177 | + 'size': size, | ||
178 | + 'subformat': 'monolithicFlat' }) | ||
179 | vm.shutdown() | ||
180 | |||
181 | # Correct extent | ||
182 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.vmdk') as disk_path, \ | ||
183 | iotests.log("") | ||
184 | |||
185 | vm.launch() | ||
186 | - blockdev_create(vm, { 'driver': imgfmt, | ||
187 | - 'file': 'node0', | ||
188 | - 'size': size, | ||
189 | - 'subformat': 'monolithicFlat', | ||
190 | - 'extents': ['ext1'] }) | ||
191 | + vm.blockdev_create({ 'driver': imgfmt, | ||
192 | + 'file': 'node0', | ||
193 | + 'size': size, | ||
194 | + 'subformat': 'monolithicFlat', | ||
195 | + 'extents': ['ext1'] }) | ||
196 | vm.shutdown() | ||
197 | |||
198 | # Extra extent | ||
199 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.vmdk') as disk_path, \ | ||
200 | iotests.log("") | ||
201 | |||
202 | vm.launch() | ||
203 | - blockdev_create(vm, { 'driver': imgfmt, | ||
204 | - 'file': 'node0', | ||
205 | - 'size': 512, | ||
206 | - 'subformat': 'monolithicFlat', | ||
207 | - 'extents': ['ext1', 'ext2', 'ext3'] }) | ||
208 | + vm.blockdev_create({ 'driver': imgfmt, | ||
209 | + 'file': 'node0', | ||
210 | + 'size': 512, | ||
211 | + 'subformat': 'monolithicFlat', | ||
212 | + 'extents': ['ext1', 'ext2', 'ext3'] }) | ||
213 | vm.shutdown() | ||
214 | |||
215 | # Split formats | ||
216 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.vmdk') as disk_path, \ | ||
217 | extents = [ "ext%d" % (i) for i in range(1, num_extents + 1) ] | ||
218 | |||
219 | vm.launch() | ||
220 | - blockdev_create(vm, { 'driver': imgfmt, | ||
221 | - 'file': 'node0', | ||
222 | - 'size': size, | ||
223 | - 'subformat': subfmt, | ||
224 | - 'extents': extents }) | ||
225 | + vm.blockdev_create({ 'driver': imgfmt, | ||
226 | + 'file': 'node0', | ||
227 | + 'size': size, | ||
228 | + 'subformat': subfmt, | ||
229 | + 'extents': extents }) | ||
230 | vm.shutdown() | ||
231 | |||
232 | iotests.img_info_log(disk_path) | ||
233 | -- | ||
234 | 2.20.1 | ||
235 | |||
236 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Instead of having a separate blockdev_create() function, make use of the | ||
2 | VM.blockdev_create() offered by iotests.py. | ||
3 | 1 | ||
4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
5 | --- | ||
6 | tests/qemu-iotests/266 | 69 +++++++++++++++++--------------------- | ||
7 | tests/qemu-iotests/266.out | 14 ++++++++ | ||
8 | 2 files changed, 44 insertions(+), 39 deletions(-) | ||
9 | |||
10 | diff --git a/tests/qemu-iotests/266 b/tests/qemu-iotests/266 | ||
11 | index XXXXXXX..XXXXXXX 100755 | ||
12 | --- a/tests/qemu-iotests/266 | ||
13 | +++ b/tests/qemu-iotests/266 | ||
14 | @@ -XXX,XX +XXX,XX @@ import iotests | ||
15 | from iotests import imgfmt | ||
16 | |||
17 | |||
18 | -def blockdev_create(vm, options): | ||
19 | - result = vm.qmp_log('blockdev-create', job_id='job0', options=options, | ||
20 | - filters=[iotests.filter_qmp_testfiles]) | ||
21 | - | ||
22 | - if 'return' in result: | ||
23 | - assert result['return'] == {} | ||
24 | - vm.run_job('job0') | ||
25 | - | ||
26 | - | ||
27 | # Successful image creation (defaults) | ||
28 | def implicit_defaults(vm, file_path): | ||
29 | iotests.log("=== Successful image creation (defaults) ===") | ||
30 | @@ -XXX,XX +XXX,XX @@ def implicit_defaults(vm, file_path): | ||
31 | # (Close to 64 MB) | ||
32 | size = 8 * 964 * 17 * 512 | ||
33 | |||
34 | - blockdev_create(vm, { 'driver': imgfmt, | ||
35 | - 'file': 'protocol-node', | ||
36 | - 'size': size }) | ||
37 | + vm.blockdev_create({ 'driver': imgfmt, | ||
38 | + 'file': 'protocol-node', | ||
39 | + 'size': size }) | ||
40 | |||
41 | |||
42 | # Successful image creation (explicit defaults) | ||
43 | @@ -XXX,XX +XXX,XX @@ def explicit_defaults(vm, file_path): | ||
44 | # (Close to 128 MB) | ||
45 | size = 16 * 964 * 17 * 512 | ||
46 | |||
47 | - blockdev_create(vm, { 'driver': imgfmt, | ||
48 | - 'file': 'protocol-node', | ||
49 | - 'size': size, | ||
50 | - 'subformat': 'dynamic', | ||
51 | - 'force-size': False }) | ||
52 | + vm.blockdev_create({ 'driver': imgfmt, | ||
53 | + 'file': 'protocol-node', | ||
54 | + 'size': size, | ||
55 | + 'subformat': 'dynamic', | ||
56 | + 'force-size': False }) | ||
57 | |||
58 | |||
59 | # Successful image creation (non-default options) | ||
60 | @@ -XXX,XX +XXX,XX @@ def non_defaults(vm, file_path): | ||
61 | # Not representable in CHS (fine with force-size=True) | ||
62 | size = 1048576 | ||
63 | |||
64 | - blockdev_create(vm, { 'driver': imgfmt, | ||
65 | - 'file': 'protocol-node', | ||
66 | - 'size': size, | ||
67 | - 'subformat': 'fixed', | ||
68 | - 'force-size': True }) | ||
69 | + vm.blockdev_create({ 'driver': imgfmt, | ||
70 | + 'file': 'protocol-node', | ||
71 | + 'size': size, | ||
72 | + 'subformat': 'fixed', | ||
73 | + 'force-size': True }) | ||
74 | |||
75 | |||
76 | # Size not representable in CHS with force-size=False | ||
77 | @@ -XXX,XX +XXX,XX @@ def non_chs_size_without_force(vm, file_path): | ||
78 | # Not representable in CHS (will not work with force-size=False) | ||
79 | size = 1048576 | ||
80 | |||
81 | - blockdev_create(vm, { 'driver': imgfmt, | ||
82 | - 'file': 'protocol-node', | ||
83 | - 'size': size, | ||
84 | - 'force-size': False }) | ||
85 | + vm.blockdev_create({ 'driver': imgfmt, | ||
86 | + 'file': 'protocol-node', | ||
87 | + 'size': size, | ||
88 | + 'force-size': False }) | ||
89 | |||
90 | |||
91 | # Zero size | ||
92 | @@ -XXX,XX +XXX,XX @@ def zero_size(vm, file_path): | ||
93 | iotests.log("=== Zero size===") | ||
94 | iotests.log("") | ||
95 | |||
96 | - blockdev_create(vm, { 'driver': imgfmt, | ||
97 | - 'file': 'protocol-node', | ||
98 | - 'size': 0 }) | ||
99 | + vm.blockdev_create({ 'driver': imgfmt, | ||
100 | + 'file': 'protocol-node', | ||
101 | + 'size': 0 }) | ||
102 | |||
103 | |||
104 | # Maximum CHS size | ||
105 | @@ -XXX,XX +XXX,XX @@ def maximum_chs_size(vm, file_path): | ||
106 | iotests.log("=== Maximum CHS size===") | ||
107 | iotests.log("") | ||
108 | |||
109 | - blockdev_create(vm, { 'driver': imgfmt, | ||
110 | - 'file': 'protocol-node', | ||
111 | - 'size': 16 * 65535 * 255 * 512 }) | ||
112 | + vm.blockdev_create({ 'driver': imgfmt, | ||
113 | + 'file': 'protocol-node', | ||
114 | + 'size': 16 * 65535 * 255 * 512 }) | ||
115 | |||
116 | |||
117 | # Actual maximum size | ||
118 | @@ -XXX,XX +XXX,XX @@ def maximum_size(vm, file_path): | ||
119 | iotests.log("=== Actual maximum size===") | ||
120 | iotests.log("") | ||
121 | |||
122 | - blockdev_create(vm, { 'driver': imgfmt, | ||
123 | - 'file': 'protocol-node', | ||
124 | - 'size': 0xff000000 * 512, | ||
125 | - 'force-size': True }) | ||
126 | + vm.blockdev_create({ 'driver': imgfmt, | ||
127 | + 'file': 'protocol-node', | ||
128 | + 'size': 0xff000000 * 512, | ||
129 | + 'force-size': True }) | ||
130 | |||
131 | |||
132 | def main(): | ||
133 | @@ -XXX,XX +XXX,XX @@ def main(): | ||
134 | vm.launch() | ||
135 | |||
136 | iotests.log('--- Creating empty file ---') | ||
137 | - blockdev_create(vm, { 'driver': 'file', | ||
138 | - 'filename': file_path, | ||
139 | - 'size': 0 }) | ||
140 | + vm.blockdev_create({ 'driver': 'file', | ||
141 | + 'filename': file_path, | ||
142 | + 'size': 0 }) | ||
143 | |||
144 | vm.qmp_log('blockdev-add', driver='file', filename=file_path, | ||
145 | node_name='protocol-node', | ||
146 | diff --git a/tests/qemu-iotests/266.out b/tests/qemu-iotests/266.out | ||
147 | index XXXXXXX..XXXXXXX 100644 | ||
148 | --- a/tests/qemu-iotests/266.out | ||
149 | +++ b/tests/qemu-iotests/266.out | ||
150 | @@ -XXX,XX +XXX,XX @@ | ||
151 | {"return": {}} | ||
152 | {"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
153 | {"return": {}} | ||
154 | + | ||
155 | {"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}} | ||
156 | {"return": {}} | ||
157 | |||
158 | @@ -XXX,XX +XXX,XX @@ | ||
159 | {"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
160 | {"return": {}} | ||
161 | |||
162 | + | ||
163 | image: TEST_IMG | ||
164 | file format: IMGFMT | ||
165 | virtual size: 64 MiB (67125248 bytes) | ||
166 | @@ -XXX,XX +XXX,XX @@ cluster_size: 2097152 | ||
167 | {"return": {}} | ||
168 | {"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
169 | {"return": {}} | ||
170 | + | ||
171 | {"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}} | ||
172 | {"return": {}} | ||
173 | |||
174 | @@ -XXX,XX +XXX,XX @@ cluster_size: 2097152 | ||
175 | {"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
176 | {"return": {}} | ||
177 | |||
178 | + | ||
179 | image: TEST_IMG | ||
180 | file format: IMGFMT | ||
181 | virtual size: 128 MiB (134250496 bytes) | ||
182 | @@ -XXX,XX +XXX,XX @@ cluster_size: 2097152 | ||
183 | {"return": {}} | ||
184 | {"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
185 | {"return": {}} | ||
186 | + | ||
187 | {"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}} | ||
188 | {"return": {}} | ||
189 | |||
190 | @@ -XXX,XX +XXX,XX @@ cluster_size: 2097152 | ||
191 | {"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
192 | {"return": {}} | ||
193 | |||
194 | + | ||
195 | image: TEST_IMG | ||
196 | file format: IMGFMT | ||
197 | virtual size: 1 MiB (1048576 bytes) | ||
198 | @@ -XXX,XX +XXX,XX @@ virtual size: 1 MiB (1048576 bytes) | ||
199 | {"return": {}} | ||
200 | {"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
201 | {"return": {}} | ||
202 | + | ||
203 | {"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}} | ||
204 | {"return": {}} | ||
205 | |||
206 | @@ -XXX,XX +XXX,XX @@ Job failed: The requested image size cannot be represented in CHS geometry | ||
207 | {"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
208 | {"return": {}} | ||
209 | |||
210 | + | ||
211 | qemu-img: Could not open 'TEST_IMG': File too small for a VHD header | ||
212 | |||
213 | --- Creating empty file --- | ||
214 | @@ -XXX,XX +XXX,XX @@ qemu-img: Could not open 'TEST_IMG': File too small for a VHD header | ||
215 | {"return": {}} | ||
216 | {"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
217 | {"return": {}} | ||
218 | + | ||
219 | {"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}} | ||
220 | {"return": {}} | ||
221 | |||
222 | @@ -XXX,XX +XXX,XX @@ qemu-img: Could not open 'TEST_IMG': File too small for a VHD header | ||
223 | {"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
224 | {"return": {}} | ||
225 | |||
226 | + | ||
227 | image: TEST_IMG | ||
228 | file format: IMGFMT | ||
229 | virtual size: 0 B (0 bytes) | ||
230 | @@ -XXX,XX +XXX,XX @@ cluster_size: 2097152 | ||
231 | {"return": {}} | ||
232 | {"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
233 | {"return": {}} | ||
234 | + | ||
235 | {"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}} | ||
236 | {"return": {}} | ||
237 | |||
238 | @@ -XXX,XX +XXX,XX @@ cluster_size: 2097152 | ||
239 | {"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
240 | {"return": {}} | ||
241 | |||
242 | + | ||
243 | image: TEST_IMG | ||
244 | file format: IMGFMT | ||
245 | virtual size: 127 GiB (136899993600 bytes) | ||
246 | @@ -XXX,XX +XXX,XX @@ cluster_size: 2097152 | ||
247 | {"return": {}} | ||
248 | {"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
249 | {"return": {}} | ||
250 | + | ||
251 | {"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}} | ||
252 | {"return": {}} | ||
253 | |||
254 | @@ -XXX,XX +XXX,XX @@ cluster_size: 2097152 | ||
255 | {"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
256 | {"return": {}} | ||
257 | |||
258 | + | ||
259 | image: TEST_IMG | ||
260 | file format: IMGFMT | ||
261 | virtual size: 1.99 TiB (2190433320960 bytes) | ||
262 | -- | ||
263 | 2.20.1 | ||
264 | |||
265 | diff view generated by jsdifflib |