1 | The following changes since commit b2f7a038bb4c4fc5ce6b8486e8513dfd97665e2a: | 1 | The following changes since commit 9e06029aea3b2eca1d5261352e695edc1e7d7b8b: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/rth/tags/pull-softfloat-20181104' into staging (2018-11-05 10:32:49 +0000) | 3 | Update version for v4.1.0 release (2019-08-15 13:03:37 +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 1240ac558d348f6c7a5752b1a57c1da58e4efe3e: | 9 | for you to fetch changes up to a6b257a08e3d72219f03e461a52152672fec0612: |
10 | 10 | ||
11 | include: Add a comment to explain the origin of sizes' lookup table (2018-11-05 15:29:59 +0100) | 11 | file-posix: Handle undetectable alignment (2019-08-16 11:29:11 +0200) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Block layer patches: | 14 | Block layer patches: |
15 | 15 | ||
16 | - auto-read-only option to fix commit job when used with -blockdev | 16 | - file-posix: Fix O_DIRECT alignment detection |
17 | - Fix help text related qemu-iotests failure (by improving the help text | 17 | - Fixes for concurrent block jobs |
18 | and updating the reference output) | 18 | - block-backend: Queue requests while drained (fix IDE vs. job crashes) |
19 | - quorum: Add missing checks when adding/removing child nodes | 19 | - qemu-img convert: Deprecate using -n and -o together |
20 | - Don't take address of fields in packed structs | 20 | - iotests: Migration tests with filter nodes |
21 | - vvfat: Fix crash when reporting error about too many files in directory | 21 | - iotests: More media change tests |
22 | 22 | ||
23 | ---------------------------------------------------------------- | 23 | ---------------------------------------------------------------- |
24 | Alberto Garcia (7): | 24 | Kevin Wolf (10): |
25 | block: replace "discard" literal with BDRV_OPT_DISCARD macro | 25 | iotests/118: Test media change for scsi-cd |
26 | qcow2: Get the request alignment for encrypted images from QCryptoBlock | 26 | iotests/118: Create test classes dynamically |
27 | quorum: Remove quorum_err() | 27 | iotests/118: Add -blockdev based tests |
28 | quorum: Return an error if the blkverify mode has invalid settings | 28 | iotests: Move migration helpers to iotests.py |
29 | iotest: Test the blkverify mode of the Quorum driver | 29 | iotests: Test migration with all kinds of filter nodes |
30 | quorum: Forbid adding children in blkverify mode | 30 | block: Simplify bdrv_filter_default_perms() |
31 | iotest: Test x-blockdev-change on a Quorum | 31 | block: Remove blk_pread_unthrottled() |
32 | 32 | mirror: Keep mirror_top_bs drained after dropping permissions | |
33 | Cleber Rosa (1): | 33 | block-backend: Queue requests while drained |
34 | iotests: make 083 specific to raw | 34 | qemu-img convert: Deprecate using -n and -o together |
35 | |||
36 | Daniel P. Berrangé (1): | ||
37 | crypto: initialize sector size even when opening with no IO flag | ||
38 | |||
39 | Kevin Wolf (12): | ||
40 | vpc: Don't leak opts in vpc_open() | ||
41 | block: Update flags in bdrv_set_read_only() | ||
42 | block: Add auto-read-only option | ||
43 | rbd: Close image in qemu_rbd_open() error path | ||
44 | block: Require auto-read-only for existing fallbacks | ||
45 | nbd: Support auto-read-only option | ||
46 | file-posix: Support auto-read-only option | ||
47 | curl: Support auto-read-only option | ||
48 | gluster: Support auto-read-only option | ||
49 | iscsi: Support auto-read-only option | ||
50 | block: Make auto-read-only=on default for -drive | ||
51 | qemu-iotests: Test auto-read-only with -drive and -blockdev | ||
52 | |||
53 | Leonid Bloch (2): | ||
54 | vdi: Use a literal number of bytes for DEFAULT_CLUSTER_SIZE | ||
55 | include: Add a comment to explain the origin of sizes' lookup table | ||
56 | |||
57 | Li Qiang (1): | ||
58 | block: change some function return type to bool | ||
59 | 35 | ||
60 | Max Reitz (5): | 36 | Max Reitz (5): |
61 | option: Make option help nicer to read | 37 | block: Keep subtree drained in drop_intermediate |
62 | chardev: Indent list of chardevs | 38 | block: Reduce (un)drains when replacing a child |
63 | qdev-monitor: Make device options help nicer | 39 | tests: Test polling in bdrv_drop_intermediate() |
64 | object: Make option help nicer to read | 40 | tests: Test mid-drain bdrv_replace_child_noperm() |
65 | fw_cfg: Drop newline in @file description | 41 | iotests: Add test for concurrent stream/commit |
66 | 42 | ||
67 | Peter Maydell (5): | 43 | Nir Soffer (1): |
68 | block/qcow2: Don't take address of fields in packed structs | 44 | file-posix: Handle undetectable alignment |
69 | block/qcow: Don't take address of fields in packed structs | ||
70 | block/qcow2-bitmap: Don't take address of fields in packed structs | ||
71 | block/vhdx: Don't take address of fields in packed structs | ||
72 | block/vdi: Don't take address of fields in packed structs | ||
73 | 45 | ||
74 | Stefan Weil (1): | 46 | include/sysemu/block-backend.h | 3 +- |
75 | qemu-io-cmds: Fix two format strings | 47 | block.c | 63 +++--- |
48 | block/backup.c | 1 + | ||
49 | block/block-backend.c | 69 ++++-- | ||
50 | block/commit.c | 2 + | ||
51 | block/file-posix.c | 36 +++- | ||
52 | block/mirror.c | 7 +- | ||
53 | blockjob.c | 3 + | ||
54 | hw/block/hd-geometry.c | 7 +- | ||
55 | qemu-img.c | 5 + | ||
56 | tests/test-bdrv-drain.c | 476 +++++++++++++++++++++++++++++++++++++++++ | ||
57 | qemu-deprecated.texi | 7 + | ||
58 | tests/qemu-iotests/118 | 84 ++++---- | ||
59 | tests/qemu-iotests/118.out | 4 +- | ||
60 | tests/qemu-iotests/234 | 30 +-- | ||
61 | tests/qemu-iotests/258 | 163 ++++++++++++++ | ||
62 | tests/qemu-iotests/258.out | 33 +++ | ||
63 | tests/qemu-iotests/262 | 82 +++++++ | ||
64 | tests/qemu-iotests/262.out | 17 ++ | ||
65 | tests/qemu-iotests/group | 2 + | ||
66 | tests/qemu-iotests/iotests.py | 16 ++ | ||
67 | 21 files changed, 983 insertions(+), 127 deletions(-) | ||
68 | create mode 100755 tests/qemu-iotests/258 | ||
69 | create mode 100644 tests/qemu-iotests/258.out | ||
70 | create mode 100755 tests/qemu-iotests/262 | ||
71 | create mode 100644 tests/qemu-iotests/262.out | ||
76 | 72 | ||
77 | Thomas Huth (1): | ||
78 | block/vvfat: Fix crash when reporting error about too many files in directory | ||
79 | |||
80 | qapi/block-core.json | 7 + | ||
81 | block/vhdx.h | 12 +- | ||
82 | include/block/block.h | 5 +- | ||
83 | include/qemu/option.h | 2 +- | ||
84 | include/qemu/units.h | 18 + | ||
85 | include/sysemu/block-backend.h | 6 +- | ||
86 | block.c | 60 ++- | ||
87 | block/block-backend.c | 8 +- | ||
88 | block/bochs.c | 17 +- | ||
89 | block/cloop.c | 16 +- | ||
90 | block/curl.c | 8 +- | ||
91 | block/dmg.c | 16 +- | ||
92 | block/file-posix.c | 19 +- | ||
93 | block/gluster.c | 12 +- | ||
94 | block/iscsi.c | 8 +- | ||
95 | block/nbd-client.c | 10 +- | ||
96 | block/qcow.c | 18 +- | ||
97 | block/qcow2-bitmap.c | 24 +- | ||
98 | block/qcow2.c | 66 +-- | ||
99 | block/quorum.c | 45 +- | ||
100 | block/rbd.c | 14 +- | ||
101 | block/vdi.c | 68 +-- | ||
102 | block/vhdx-endian.c | 118 ++--- | ||
103 | block/vhdx-log.c | 4 +- | ||
104 | block/vhdx.c | 18 +- | ||
105 | block/vpc.c | 2 + | ||
106 | block/vvfat.c | 15 +- | ||
107 | blockdev.c | 3 +- | ||
108 | chardev/char.c | 2 +- | ||
109 | crypto/block-qcow.c | 2 + | ||
110 | qdev-monitor.c | 13 +- | ||
111 | qemu-img.c | 4 +- | ||
112 | qemu-io-cmds.c | 4 +- | ||
113 | util/qemu-option.c | 32 +- | ||
114 | vl.c | 15 +- | ||
115 | tests/qemu-iotests/081 | 116 +++++ | ||
116 | tests/qemu-iotests/081.out | 70 +++ | ||
117 | tests/qemu-iotests/082.out | 956 ++++++++++++++++++++--------------------- | ||
118 | tests/qemu-iotests/083 | 2 +- | ||
119 | tests/qemu-iotests/232 | 147 +++++++ | ||
120 | tests/qemu-iotests/232.out | 59 +++ | ||
121 | tests/qemu-iotests/group | 1 + | ||
122 | 42 files changed, 1266 insertions(+), 776 deletions(-) | ||
123 | create mode 100755 tests/qemu-iotests/232 | ||
124 | create mode 100644 tests/qemu-iotests/232.out | ||
125 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Thomas Huth <thuth@redhat.com> | ||
2 | 1 | ||
3 | When using the vvfat driver with a directory that contains too many files, | ||
4 | QEMU currently crashes. This can be triggered like this for example: | ||
5 | |||
6 | mkdir /tmp/vvfattest | ||
7 | cd /tmp/vvfattest | ||
8 | for ((x=0;x<=513;x++)); do mkdir $x; done | ||
9 | qemu-system-x86_64 -drive \ | ||
10 | file.driver=vvfat,file.dir=.,read-only=on,media=cdrom | ||
11 | |||
12 | Seems like read_directory() is changing the mapping->path variable. Make | ||
13 | sure we use the right pointer instead. | ||
14 | |||
15 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
16 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
17 | --- | ||
18 | block/vvfat.c | 4 ++-- | ||
19 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
20 | |||
21 | diff --git a/block/vvfat.c b/block/vvfat.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/block/vvfat.c | ||
24 | +++ b/block/vvfat.c | ||
25 | @@ -XXX,XX +XXX,XX @@ static int init_directories(BDRVVVFATState* s, | ||
26 | mapping = array_get(&(s->mapping), i); | ||
27 | |||
28 | if (mapping->mode & MODE_DIRECTORY) { | ||
29 | + char *path = mapping->path; | ||
30 | mapping->begin = cluster; | ||
31 | if(read_directory(s, i)) { | ||
32 | - error_setg(errp, "Could not read directory %s", | ||
33 | - mapping->path); | ||
34 | + error_setg(errp, "Could not read directory %s", path); | ||
35 | return -1; | ||
36 | } | ||
37 | mapping = array_get(&(s->mapping), i); | ||
38 | -- | ||
39 | 2.19.1 | ||
40 | |||
41 | diff view generated by jsdifflib |
1 | While we want machine interfaces like -blockdev and QMP blockdev-add to | 1 | The test covered only floppy and ide-cd. Add scsi-cd as well. |
---|---|---|---|
2 | add as little auto-detection as possible so that management tools are | ||
3 | explicit about their needs, -drive is a convenience option for human | ||
4 | users. Enabling auto-read-only=on by default there enables users to use | ||
5 | read-only images for read-only guest devices without having to specify | ||
6 | read-only=on explicitly. If they try to attach the image to a read-write | ||
7 | device, they will still get an error message. | ||
8 | 2 | ||
9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 3 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
10 | Reviewed-by: Eric Blake <eblake@redhat.com> | 4 | Reviewed-by: Max Reitz <mreitz@redhat.com> |
11 | --- | 5 | --- |
12 | blockdev.c | 1 + | 6 | tests/qemu-iotests/118 | 20 ++++++++++++++++++++ |
13 | 1 file changed, 1 insertion(+) | 7 | tests/qemu-iotests/118.out | 4 ++-- |
8 | 2 files changed, 22 insertions(+), 2 deletions(-) | ||
14 | 9 | ||
15 | diff --git a/blockdev.c b/blockdev.c | 10 | diff --git a/tests/qemu-iotests/118 b/tests/qemu-iotests/118 |
11 | index XXXXXXX..XXXXXXX 100755 | ||
12 | --- a/tests/qemu-iotests/118 | ||
13 | +++ b/tests/qemu-iotests/118 | ||
14 | @@ -XXX,XX +XXX,XX @@ def interface_to_device_name(interface): | ||
15 | return 'ide-cd' | ||
16 | elif interface == 'floppy': | ||
17 | return 'floppy' | ||
18 | + elif interface == 'scsi': | ||
19 | + return 'scsi-cd' | ||
20 | else: | ||
21 | return None | ||
22 | |||
23 | @@ -XXX,XX +XXX,XX @@ class TestInitiallyFilled(GeneralChangeTestsBaseClass): | ||
24 | qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k') | ||
25 | self.vm = iotests.VM() | ||
26 | self.vm.add_drive(old_img, 'media=%s' % media, 'none') | ||
27 | + if interface == 'scsi': | ||
28 | + self.vm.add_device('virtio-scsi-pci') | ||
29 | self.vm.add_device('%s,drive=drive0,id=%s' % | ||
30 | (interface_to_device_name(interface), | ||
31 | self.device_name)) | ||
32 | @@ -XXX,XX +XXX,XX @@ class TestInitiallyEmpty(GeneralChangeTestsBaseClass): | ||
33 | def setUp(self, media, interface): | ||
34 | qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k') | ||
35 | self.vm = iotests.VM().add_drive(None, 'media=%s' % media, 'none') | ||
36 | + if interface == 'scsi': | ||
37 | + self.vm.add_device('virtio-scsi-pci') | ||
38 | self.vm.add_device('%s,drive=drive0,id=%s' % | ||
39 | (interface_to_device_name(interface), | ||
40 | self.device_name)) | ||
41 | @@ -XXX,XX +XXX,XX @@ class TestCDInitiallyEmpty(TestInitiallyEmpty): | ||
42 | def setUp(self): | ||
43 | self.TestInitiallyEmpty.setUp(self, 'cdrom', 'ide') | ||
44 | |||
45 | +class TestSCSICDInitiallyFilled(TestInitiallyFilled): | ||
46 | + TestInitiallyFilled = TestInitiallyFilled | ||
47 | + has_real_tray = True | ||
48 | + | ||
49 | + def setUp(self): | ||
50 | + self.TestInitiallyFilled.setUp(self, 'cdrom', 'scsi') | ||
51 | + | ||
52 | +class TestSCSICDInitiallyEmpty(TestInitiallyEmpty): | ||
53 | + TestInitiallyEmpty = TestInitiallyEmpty | ||
54 | + has_real_tray = True | ||
55 | + | ||
56 | + def setUp(self): | ||
57 | + self.TestInitiallyEmpty.setUp(self, 'cdrom', 'scsi') | ||
58 | + | ||
59 | class TestFloppyInitiallyFilled(TestInitiallyFilled): | ||
60 | TestInitiallyFilled = TestInitiallyFilled | ||
61 | has_real_tray = False | ||
62 | diff --git a/tests/qemu-iotests/118.out b/tests/qemu-iotests/118.out | ||
16 | index XXXXXXX..XXXXXXX 100644 | 63 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/blockdev.c | 64 | --- a/tests/qemu-iotests/118.out |
18 | +++ b/blockdev.c | 65 | +++ b/tests/qemu-iotests/118.out |
19 | @@ -XXX,XX +XXX,XX @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, | 66 | @@ -XXX,XX +XXX,XX @@ |
20 | qdict_set_default_str(bs_opts, BDRV_OPT_CACHE_NO_FLUSH, "off"); | 67 | -............................................................... |
21 | qdict_set_default_str(bs_opts, BDRV_OPT_READ_ONLY, | 68 | +......................................................................................... |
22 | read_only ? "on" : "off"); | 69 | ---------------------------------------------------------------------- |
23 | + qdict_set_default_str(bs_opts, BDRV_OPT_AUTO_READ_ONLY, "on"); | 70 | -Ran 63 tests |
24 | assert((bdrv_flags & BDRV_O_CACHE_MASK) == 0); | 71 | +Ran 89 tests |
25 | 72 | ||
26 | if (runstate_check(RUN_STATE_INMIGRATE)) { | 73 | OK |
27 | -- | 74 | -- |
28 | 2.19.1 | 75 | 2.20.1 |
29 | 76 | ||
30 | 77 | diff view generated by jsdifflib |
1 | If read-only=off, but auto-read-only=on is given, just degrade to | 1 | We're getting a ridiculous number of child classes of |
---|---|---|---|
2 | read-only. | 2 | TestInitiallyFilled and TestInitiallyEmpty that differ only in a few |
3 | attributes that we want to test in all combinations. | ||
4 | |||
5 | Instead of explicitly writing down every combination, let's use a loop | ||
6 | and create those classes dynamically. | ||
3 | 7 | ||
4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
5 | Reviewed-by: Eric Blake <eblake@redhat.com> | 9 | Reviewed-by: Max Reitz <mreitz@redhat.com> |
6 | --- | 10 | --- |
7 | block/curl.c | 8 ++++---- | 11 | tests/qemu-iotests/118 | 69 +++++++++++++----------------------------- |
8 | 1 file changed, 4 insertions(+), 4 deletions(-) | 12 | 1 file changed, 21 insertions(+), 48 deletions(-) |
9 | 13 | ||
10 | diff --git a/block/curl.c b/block/curl.c | 14 | diff --git a/tests/qemu-iotests/118 b/tests/qemu-iotests/118 |
11 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100755 |
12 | --- a/block/curl.c | 16 | --- a/tests/qemu-iotests/118 |
13 | +++ b/block/curl.c | 17 | +++ b/tests/qemu-iotests/118 |
14 | @@ -XXX,XX +XXX,XX @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags, | 18 | @@ -XXX,XX +XXX,XX @@ class GeneralChangeTestsBaseClass(ChangeBaseClass): |
15 | const char *protocol_delimiter; | 19 | class TestInitiallyFilled(GeneralChangeTestsBaseClass): |
16 | int ret; | 20 | was_empty = False |
17 | 21 | ||
22 | - def setUp(self, media, interface): | ||
23 | + def setUp(self): | ||
24 | qemu_img('create', '-f', iotests.imgfmt, old_img, '1440k') | ||
25 | qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k') | ||
26 | self.vm = iotests.VM() | ||
27 | - self.vm.add_drive(old_img, 'media=%s' % media, 'none') | ||
28 | - if interface == 'scsi': | ||
29 | + self.vm.add_drive(old_img, 'media=%s' % self.media, 'none') | ||
30 | + if self.interface == 'scsi': | ||
31 | self.vm.add_device('virtio-scsi-pci') | ||
32 | self.vm.add_device('%s,drive=drive0,id=%s' % | ||
33 | - (interface_to_device_name(interface), | ||
34 | + (interface_to_device_name(self.interface), | ||
35 | self.device_name)) | ||
36 | self.vm.launch() | ||
37 | |||
38 | @@ -XXX,XX +XXX,XX @@ class TestInitiallyFilled(GeneralChangeTestsBaseClass): | ||
39 | class TestInitiallyEmpty(GeneralChangeTestsBaseClass): | ||
40 | was_empty = True | ||
41 | |||
42 | - def setUp(self, media, interface): | ||
43 | + def setUp(self): | ||
44 | qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k') | ||
45 | - self.vm = iotests.VM().add_drive(None, 'media=%s' % media, 'none') | ||
46 | - if interface == 'scsi': | ||
47 | + self.vm = iotests.VM().add_drive(None, 'media=%s' % self.media, 'none') | ||
48 | + if self.interface == 'scsi': | ||
49 | self.vm.add_device('virtio-scsi-pci') | ||
50 | self.vm.add_device('%s,drive=drive0,id=%s' % | ||
51 | - (interface_to_device_name(interface), | ||
52 | + (interface_to_device_name(self.interface), | ||
53 | self.device_name)) | ||
54 | self.vm.launch() | ||
55 | |||
56 | @@ -XXX,XX +XXX,XX @@ class TestInitiallyEmpty(GeneralChangeTestsBaseClass): | ||
57 | # Should be a no-op | ||
58 | self.assert_qmp(result, 'return', {}) | ||
59 | |||
60 | -class TestCDInitiallyFilled(TestInitiallyFilled): | ||
61 | - TestInitiallyFilled = TestInitiallyFilled | ||
62 | - has_real_tray = True | ||
18 | - | 63 | - |
19 | - if (flags & BDRV_O_RDWR) { | 64 | - def setUp(self): |
20 | - error_setg(errp, "curl block device does not support writes"); | 65 | - self.TestInitiallyFilled.setUp(self, 'cdrom', 'ide') |
21 | - return -EROFS; | 66 | - |
22 | + ret = bdrv_apply_auto_read_only(bs, "curl driver does not support writes", | 67 | -class TestCDInitiallyEmpty(TestInitiallyEmpty): |
23 | + errp); | 68 | - TestInitiallyEmpty = TestInitiallyEmpty |
24 | + if (ret < 0) { | 69 | - has_real_tray = True |
25 | + return ret; | 70 | - |
26 | } | 71 | - def setUp(self): |
27 | 72 | - self.TestInitiallyEmpty.setUp(self, 'cdrom', 'ide') | |
28 | if (!libcurl_initialized) { | 73 | +# Do this in a function to avoid leaking variables like case into the global |
74 | +# name space (otherwise tests would be run for the abstract base classes) | ||
75 | +def create_basic_test_classes(): | ||
76 | + for (media, interface, has_real_tray) in [ ('cdrom', 'ide', True), | ||
77 | + ('cdrom', 'scsi', True), | ||
78 | + ('disk', 'floppy', False) ]: | ||
79 | |||
80 | -class TestSCSICDInitiallyFilled(TestInitiallyFilled): | ||
81 | - TestInitiallyFilled = TestInitiallyFilled | ||
82 | - has_real_tray = True | ||
83 | + for case in [ TestInitiallyFilled, TestInitiallyEmpty ]: | ||
84 | |||
85 | - def setUp(self): | ||
86 | - self.TestInitiallyFilled.setUp(self, 'cdrom', 'scsi') | ||
87 | + attr = { 'media': media, | ||
88 | + 'interface': interface, | ||
89 | + 'has_real_tray': has_real_tray } | ||
90 | |||
91 | -class TestSCSICDInitiallyEmpty(TestInitiallyEmpty): | ||
92 | - TestInitiallyEmpty = TestInitiallyEmpty | ||
93 | - has_real_tray = True | ||
94 | + name = '%s_%s_%s' % (case.__name__, media, interface) | ||
95 | + globals()[name] = type(name, (case, ), attr) | ||
96 | |||
97 | - def setUp(self): | ||
98 | - self.TestInitiallyEmpty.setUp(self, 'cdrom', 'scsi') | ||
99 | - | ||
100 | -class TestFloppyInitiallyFilled(TestInitiallyFilled): | ||
101 | - TestInitiallyFilled = TestInitiallyFilled | ||
102 | - has_real_tray = False | ||
103 | - | ||
104 | - def setUp(self): | ||
105 | - self.TestInitiallyFilled.setUp(self, 'disk', 'floppy') | ||
106 | - | ||
107 | -class TestFloppyInitiallyEmpty(TestInitiallyEmpty): | ||
108 | - TestInitiallyEmpty = TestInitiallyEmpty | ||
109 | - has_real_tray = False | ||
110 | - | ||
111 | - def setUp(self): | ||
112 | - self.TestInitiallyEmpty.setUp(self, 'disk', 'floppy') | ||
113 | - # FDDs not having a real tray and there not being a medium inside the | ||
114 | - # tray at startup means the tray will be considered open | ||
115 | - self.has_opened = True | ||
116 | +create_basic_test_classes() | ||
117 | |||
118 | class TestChangeReadOnly(ChangeBaseClass): | ||
119 | device_name = 'qdev0' | ||
29 | -- | 120 | -- |
30 | 2.19.1 | 121 | 2.20.1 |
31 | 122 | ||
32 | 123 | diff view generated by jsdifflib |
1 | If read-only=off, but auto-read-only=on is given, open the volume | 1 | The code path for -device drive=<node-name> or without a drive=... |
---|---|---|---|
2 | read-write if we have the permissions, but instead of erroring out for | 2 | option for empty drives, which is supposed to be used with -blockdev |
3 | read-only volumes, just degrade to read-only. | 3 | differs enough from the -drive based path with a user-owned |
4 | BlockBackend, so we want to test both paths at least for the basic tests | ||
5 | implemented by TestInitiallyFilled and TestInitiallyEmpty. | ||
6 | |||
7 | This would have caught the bug recently fixed for inserting read-only | ||
8 | nodes into a scsi-cd created without a drive=... option. | ||
4 | 9 | ||
5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
6 | Reviewed-by: Eric Blake <eblake@redhat.com> | 11 | Reviewed-by: Max Reitz <mreitz@redhat.com> |
7 | --- | 12 | --- |
8 | block/iscsi.c | 8 +++++--- | 13 | tests/qemu-iotests/118 | 43 ++++++++++++++++++++++++++------------ |
9 | 1 file changed, 5 insertions(+), 3 deletions(-) | 14 | tests/qemu-iotests/118.out | 4 ++-- |
15 | 2 files changed, 32 insertions(+), 15 deletions(-) | ||
10 | 16 | ||
11 | diff --git a/block/iscsi.c b/block/iscsi.c | 17 | diff --git a/tests/qemu-iotests/118 b/tests/qemu-iotests/118 |
18 | index XXXXXXX..XXXXXXX 100755 | ||
19 | --- a/tests/qemu-iotests/118 | ||
20 | +++ b/tests/qemu-iotests/118 | ||
21 | @@ -XXX,XX +XXX,XX @@ class ChangeBaseClass(iotests.QMPTestCase): | ||
22 | has_opened = False | ||
23 | has_closed = False | ||
24 | |||
25 | + device_name = 'qdev0' | ||
26 | + use_drive = False | ||
27 | + | ||
28 | def process_events(self): | ||
29 | for event in self.vm.get_qmp_events(wait=False): | ||
30 | if (event['event'] == 'DEVICE_TRAY_MOVED' and | ||
31 | - event['data']['device'] == 'drive0'): | ||
32 | + (event['data']['device'] == 'drive0' or | ||
33 | + event['data']['id'] == self.device_name)): | ||
34 | if event['data']['tray-open'] == False: | ||
35 | self.has_closed = True | ||
36 | else: | ||
37 | @@ -XXX,XX +XXX,XX @@ class ChangeBaseClass(iotests.QMPTestCase): | ||
38 | |||
39 | class GeneralChangeTestsBaseClass(ChangeBaseClass): | ||
40 | |||
41 | - device_name = 'qdev0' | ||
42 | - | ||
43 | def test_change(self): | ||
44 | + # 'change' requires a drive name, so skip the test for blockdev | ||
45 | + if not self.use_drive: | ||
46 | + return | ||
47 | + | ||
48 | result = self.vm.qmp('change', device='drive0', target=new_img, | ||
49 | arg=iotests.imgfmt) | ||
50 | self.assert_qmp(result, 'return', {}) | ||
51 | @@ -XXX,XX +XXX,XX @@ class TestInitiallyFilled(GeneralChangeTestsBaseClass): | ||
52 | qemu_img('create', '-f', iotests.imgfmt, old_img, '1440k') | ||
53 | qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k') | ||
54 | self.vm = iotests.VM() | ||
55 | - self.vm.add_drive(old_img, 'media=%s' % self.media, 'none') | ||
56 | + if self.use_drive: | ||
57 | + self.vm.add_drive(old_img, 'media=%s' % self.media, 'none') | ||
58 | + else: | ||
59 | + self.vm.add_blockdev([ 'node-name=drive0', | ||
60 | + 'driver=%s' % iotests.imgfmt, | ||
61 | + 'file.driver=file', | ||
62 | + 'file.filename=%s' % old_img ]) | ||
63 | if self.interface == 'scsi': | ||
64 | self.vm.add_device('virtio-scsi-pci') | ||
65 | self.vm.add_device('%s,drive=drive0,id=%s' % | ||
66 | @@ -XXX,XX +XXX,XX @@ class TestInitiallyEmpty(GeneralChangeTestsBaseClass): | ||
67 | |||
68 | def setUp(self): | ||
69 | qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k') | ||
70 | - self.vm = iotests.VM().add_drive(None, 'media=%s' % self.media, 'none') | ||
71 | + self.vm = iotests.VM() | ||
72 | + if self.use_drive: | ||
73 | + self.vm.add_drive(None, 'media=%s' % self.media, 'none') | ||
74 | if self.interface == 'scsi': | ||
75 | self.vm.add_device('virtio-scsi-pci') | ||
76 | - self.vm.add_device('%s,drive=drive0,id=%s' % | ||
77 | + self.vm.add_device('%s,%sid=%s' % | ||
78 | (interface_to_device_name(self.interface), | ||
79 | + 'drive=drive0,' if self.use_drive else '', | ||
80 | self.device_name)) | ||
81 | self.vm.launch() | ||
82 | |||
83 | @@ -XXX,XX +XXX,XX @@ def create_basic_test_classes(): | ||
84 | ('disk', 'floppy', False) ]: | ||
85 | |||
86 | for case in [ TestInitiallyFilled, TestInitiallyEmpty ]: | ||
87 | - | ||
88 | - attr = { 'media': media, | ||
89 | - 'interface': interface, | ||
90 | - 'has_real_tray': has_real_tray } | ||
91 | - | ||
92 | - name = '%s_%s_%s' % (case.__name__, media, interface) | ||
93 | - globals()[name] = type(name, (case, ), attr) | ||
94 | + for use_drive in [ True, False ]: | ||
95 | + attr = { 'media': media, | ||
96 | + 'interface': interface, | ||
97 | + 'has_real_tray': has_real_tray, | ||
98 | + 'use_drive': use_drive } | ||
99 | + | ||
100 | + name = '%s_%s_%s_%s' % (case.__name__, media, interface, | ||
101 | + 'drive' if use_drive else 'blockdev') | ||
102 | + globals()[name] = type(name, (case, ), attr) | ||
103 | |||
104 | create_basic_test_classes() | ||
105 | |||
106 | diff --git a/tests/qemu-iotests/118.out b/tests/qemu-iotests/118.out | ||
12 | index XXXXXXX..XXXXXXX 100644 | 107 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/block/iscsi.c | 108 | --- a/tests/qemu-iotests/118.out |
14 | +++ b/block/iscsi.c | 109 | +++ b/tests/qemu-iotests/118.out |
15 | @@ -XXX,XX +XXX,XX @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags, | 110 | @@ -XXX,XX +XXX,XX @@ |
16 | /* Check the write protect flag of the LUN if we want to write */ | 111 | -......................................................................................... |
17 | if (iscsilun->type == TYPE_DISK && (flags & BDRV_O_RDWR) && | 112 | +....................................................................................................................................................................... |
18 | iscsilun->write_protected) { | 113 | ---------------------------------------------------------------------- |
19 | - error_setg(errp, "Cannot open a write protected LUN as read-write"); | 114 | -Ran 89 tests |
20 | - ret = -EACCES; | 115 | +Ran 167 tests |
21 | - goto out; | 116 | |
22 | + ret = bdrv_apply_auto_read_only(bs, "LUN is write protected", errp); | 117 | OK |
23 | + if (ret < 0) { | ||
24 | + goto out; | ||
25 | + } | ||
26 | + flags &= ~BDRV_O_RDWR; | ||
27 | } | ||
28 | |||
29 | iscsi_readcapacity_sync(iscsilun, &local_err); | ||
30 | -- | 118 | -- |
31 | 2.19.1 | 119 | 2.20.1 |
32 | 120 | ||
33 | 121 | diff view generated by jsdifflib |
1 | If read-only=off, but auto-read-only=on is given, open the file | 1 | 234 implements functions that are useful for doing migration between two |
---|---|---|---|
2 | read-write if we have the permissions, but instead of erroring out for | 2 | VMs. Move them to iotests.py so that other test cases can use them, too. |
3 | read-only files, just degrade to read-only. | ||
4 | 3 | ||
5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
6 | Reviewed-by: Niels de Vos <ndevos@redhat.com> | 5 | Reviewed-by: Max Reitz <mreitz@redhat.com> |
7 | --- | 6 | --- |
8 | block/gluster.c | 12 ++++++++++-- | 7 | tests/qemu-iotests/234 | 30 +++++++----------------------- |
9 | 1 file changed, 10 insertions(+), 2 deletions(-) | 8 | tests/qemu-iotests/iotests.py | 16 ++++++++++++++++ |
9 | 2 files changed, 23 insertions(+), 23 deletions(-) | ||
10 | 10 | ||
11 | diff --git a/block/gluster.c b/block/gluster.c | 11 | diff --git a/tests/qemu-iotests/234 b/tests/qemu-iotests/234 |
12 | index XXXXXXX..XXXXXXX 100755 | ||
13 | --- a/tests/qemu-iotests/234 | ||
14 | +++ b/tests/qemu-iotests/234 | ||
15 | @@ -XXX,XX +XXX,XX @@ import os | ||
16 | iotests.verify_image_format(supported_fmts=['qcow2']) | ||
17 | iotests.verify_platform(['linux']) | ||
18 | |||
19 | -def enable_migration_events(vm, name): | ||
20 | - iotests.log('Enabling migration QMP events on %s...' % name) | ||
21 | - iotests.log(vm.qmp('migrate-set-capabilities', capabilities=[ | ||
22 | - { | ||
23 | - 'capability': 'events', | ||
24 | - 'state': True | ||
25 | - } | ||
26 | - ])) | ||
27 | - | ||
28 | -def wait_migration(vm): | ||
29 | - while True: | ||
30 | - event = vm.event_wait('MIGRATION') | ||
31 | - iotests.log(event, filters=[iotests.filter_qmp_event]) | ||
32 | - if event['data']['status'] == 'completed': | ||
33 | - break | ||
34 | - | ||
35 | with iotests.FilePath('img') as img_path, \ | ||
36 | iotests.FilePath('backing') as backing_path, \ | ||
37 | iotests.FilePath('mig_fifo_a') as fifo_a, \ | ||
38 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('img') as img_path, \ | ||
39 | .add_blockdev('%s,file=drive0-backing-file,node-name=drive0-backing' % (iotests.imgfmt)) | ||
40 | .launch()) | ||
41 | |||
42 | - enable_migration_events(vm_a, 'A') | ||
43 | + vm_a.enable_migration_events('A') | ||
44 | |||
45 | iotests.log('Launching destination VM...') | ||
46 | (vm_b.add_blockdev('file,filename=%s,node-name=drive0-file' % (img_path)) | ||
47 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('img') as img_path, \ | ||
48 | .add_incoming("exec: cat '%s'" % (fifo_a)) | ||
49 | .launch()) | ||
50 | |||
51 | - enable_migration_events(vm_b, 'B') | ||
52 | + vm_b.enable_migration_events('B') | ||
53 | |||
54 | # Add a child node that was created after the parent node. The reverse case | ||
55 | # is covered by the -blockdev options above. | ||
56 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('img') as img_path, \ | ||
57 | iotests.log(vm_a.qmp('migrate', uri='exec:cat >%s' % (fifo_a))) | ||
58 | with iotests.Timeout(3, 'Migration does not complete'): | ||
59 | # Wait for the source first (which includes setup=setup) | ||
60 | - wait_migration(vm_a) | ||
61 | + vm_a.wait_migration() | ||
62 | # Wait for the destination second (which does not) | ||
63 | - wait_migration(vm_b) | ||
64 | + vm_b.wait_migration() | ||
65 | |||
66 | iotests.log(vm_a.qmp('query-migrate')['return']['status']) | ||
67 | iotests.log(vm_b.qmp('query-migrate')['return']['status']) | ||
68 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('img') as img_path, \ | ||
69 | .add_incoming("exec: cat '%s'" % (fifo_b)) | ||
70 | .launch()) | ||
71 | |||
72 | - enable_migration_events(vm_a, 'A') | ||
73 | + vm_a.enable_migration_events('A') | ||
74 | |||
75 | iotests.log(vm_a.qmp('blockdev-snapshot', node='drive0-backing', | ||
76 | overlay='drive0')) | ||
77 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('img') as img_path, \ | ||
78 | iotests.log(vm_b.qmp('migrate', uri='exec:cat >%s' % (fifo_b))) | ||
79 | with iotests.Timeout(3, 'Migration does not complete'): | ||
80 | # Wait for the source first (which includes setup=setup) | ||
81 | - wait_migration(vm_b) | ||
82 | + vm_b.wait_migration() | ||
83 | # Wait for the destination second (which does not) | ||
84 | - wait_migration(vm_a) | ||
85 | + vm_a.wait_migration() | ||
86 | |||
87 | iotests.log(vm_a.qmp('query-migrate')['return']['status']) | ||
88 | iotests.log(vm_b.qmp('query-migrate')['return']['status']) | ||
89 | diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py | ||
12 | index XXXXXXX..XXXXXXX 100644 | 90 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/block/gluster.c | 91 | --- a/tests/qemu-iotests/iotests.py |
14 | +++ b/block/gluster.c | 92 | +++ b/tests/qemu-iotests/iotests.py |
15 | @@ -XXX,XX +XXX,XX @@ static int qemu_gluster_open(BlockDriverState *bs, QDict *options, | 93 | @@ -XXX,XX +XXX,XX @@ class VM(qtest.QEMUQtestMachine): |
16 | qemu_gluster_parse_flags(bdrv_flags, &open_flags); | 94 | elif status == 'null': |
17 | 95 | return error | |
18 | s->fd = glfs_open(s->glfs, gconf->path, open_flags); | 96 | |
19 | - if (!s->fd) { | 97 | + def enable_migration_events(self, name): |
20 | - ret = -errno; | 98 | + log('Enabling migration QMP events on %s...' % name) |
21 | + ret = s->fd ? 0 : -errno; | 99 | + log(self.qmp('migrate-set-capabilities', capabilities=[ |
100 | + { | ||
101 | + 'capability': 'events', | ||
102 | + 'state': True | ||
103 | + } | ||
104 | + ])) | ||
22 | + | 105 | + |
23 | + if (ret == -EACCES || ret == -EROFS) { | 106 | + def wait_migration(self): |
24 | + /* Try to degrade to read-only, but if it doesn't work, still use the | 107 | + while True: |
25 | + * normal error message. */ | 108 | + event = self.event_wait('MIGRATION') |
26 | + if (bdrv_apply_auto_read_only(bs, NULL, NULL) == 0) { | 109 | + log(event, filters=[filter_qmp_event]) |
27 | + open_flags = (open_flags & ~O_RDWR) | O_RDONLY; | 110 | + if event['data']['status'] == 'completed': |
28 | + s->fd = glfs_open(s->glfs, gconf->path, open_flags); | 111 | + break |
29 | + ret = s->fd ? 0 : -errno; | 112 | + |
30 | + } | 113 | def node_info(self, node_name): |
31 | } | 114 | nodes = self.qmp('query-named-block-nodes') |
32 | 115 | for x in nodes['return']: | |
33 | s->supports_seek_data = qemu_gluster_test_seek(s->fd); | ||
34 | -- | 116 | -- |
35 | 2.19.1 | 117 | 2.20.1 |
36 | 118 | ||
37 | 119 | diff view generated by jsdifflib |
1 | This test case is motivated by commit 2b23f28639 ('block/copy-on-read: | ||
---|---|---|---|
2 | Fix permissions for inactive node'). Instead of just testing | ||
3 | copy-on-read on migration, let's stack all sorts of filter nodes on top | ||
4 | of each other and try if the resulting VM can still migrate | ||
5 | successfully. For good measure, put everything into an iothread, because | ||
6 | why not? | ||
7 | |||
1 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
2 | Reviewed-by: Eric Blake <eblake@redhat.com> | 9 | Reviewed-by: Max Reitz <mreitz@redhat.com> |
3 | --- | 10 | --- |
4 | tests/qemu-iotests/232 | 147 +++++++++++++++++++++++++++++++++++++ | 11 | tests/qemu-iotests/262 | 82 ++++++++++++++++++++++++++++++++++++++ |
5 | tests/qemu-iotests/232.out | 59 +++++++++++++++ | 12 | tests/qemu-iotests/262.out | 17 ++++++++ |
6 | tests/qemu-iotests/group | 1 + | 13 | tests/qemu-iotests/group | 1 + |
7 | 3 files changed, 207 insertions(+) | 14 | 3 files changed, 100 insertions(+) |
8 | create mode 100755 tests/qemu-iotests/232 | 15 | create mode 100755 tests/qemu-iotests/262 |
9 | create mode 100644 tests/qemu-iotests/232.out | 16 | create mode 100644 tests/qemu-iotests/262.out |
10 | 17 | ||
11 | diff --git a/tests/qemu-iotests/232 b/tests/qemu-iotests/232 | 18 | diff --git a/tests/qemu-iotests/262 b/tests/qemu-iotests/262 |
12 | new file mode 100755 | 19 | new file mode 100755 |
13 | index XXXXXXX..XXXXXXX | 20 | index XXXXXXX..XXXXXXX |
14 | --- /dev/null | 21 | --- /dev/null |
15 | +++ b/tests/qemu-iotests/232 | 22 | +++ b/tests/qemu-iotests/262 |
16 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ |
17 | +#!/bin/bash | 24 | +#!/usr/bin/env python |
18 | +# | 25 | +# |
19 | +# Test for auto-read-only | 26 | +# Copyright (C) 2019 Red Hat, Inc. |
20 | +# | ||
21 | +# Copyright (C) 2018 Red Hat, Inc. | ||
22 | +# | 27 | +# |
23 | +# This program is free software; you can redistribute it and/or modify | 28 | +# This program is free software; you can redistribute it and/or modify |
24 | +# it under the terms of the GNU General Public License as published by | 29 | +# it under the terms of the GNU General Public License as published by |
25 | +# the Free Software Foundation; either version 2 of the License, or | 30 | +# the Free Software Foundation; either version 2 of the License, or |
26 | +# (at your option) any later version. | 31 | +# (at your option) any later version. |
... | ... | ||
31 | +# GNU General Public License for more details. | 36 | +# GNU General Public License for more details. |
32 | +# | 37 | +# |
33 | +# You should have received a copy of the GNU General Public License | 38 | +# You should have received a copy of the GNU General Public License |
34 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | 39 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
35 | +# | 40 | +# |
41 | +# Creator/Owner: Kevin Wolf <kwolf@redhat.com> | ||
42 | +# | ||
43 | +# Test migration with filter drivers present. Keep everything in an | ||
44 | +# iothread just for fun. | ||
36 | + | 45 | + |
37 | +# creator | 46 | +import iotests |
38 | +owner=kwolf@redhat.com | 47 | +import os |
39 | + | 48 | + |
40 | +seq=`basename $0` | 49 | +iotests.verify_image_format(supported_fmts=['qcow2']) |
41 | +echo "QA output created by $seq" | 50 | +iotests.verify_platform(['linux']) |
42 | + | 51 | + |
43 | +here=`pwd` | 52 | +with iotests.FilePath('img') as img_path, \ |
44 | +status=1 # failure is the default! | 53 | + iotests.FilePath('mig_fifo') as fifo, \ |
54 | + iotests.VM(path_suffix='a') as vm_a, \ | ||
55 | + iotests.VM(path_suffix='b') as vm_b: | ||
45 | + | 56 | + |
46 | +_cleanup() | 57 | + def add_opts(vm): |
47 | +{ | 58 | + vm.add_object('iothread,id=iothread0') |
48 | + _cleanup_test_img | 59 | + vm.add_object('throttle-group,id=tg0,x-bps-total=65536') |
49 | + rm -f $TEST_IMG.snap | 60 | + vm.add_blockdev('file,filename=%s,node-name=drive0-file' % (img_path)) |
50 | +} | 61 | + vm.add_blockdev('%s,file=drive0-file,node-name=drive0-fmt' % (iotests.imgfmt)) |
51 | +trap "_cleanup; exit \$status" 0 1 2 3 15 | 62 | + vm.add_blockdev('copy-on-read,file=drive0-fmt,node-name=drive0-cor') |
63 | + vm.add_blockdev('throttle,file=drive0-cor,node-name=drive0-throttle,throttle-group=tg0') | ||
64 | + vm.add_blockdev('blkdebug,image=drive0-throttle,node-name=drive0-dbg') | ||
65 | + vm.add_blockdev('null-co,node-name=null,read-zeroes=on') | ||
66 | + vm.add_blockdev('blkverify,test=drive0-dbg,raw=null,node-name=drive0-verify') | ||
52 | + | 67 | + |
53 | +# get standard environment, filters and checks | 68 | + if iotests.supports_quorum(): |
54 | +. ./common.rc | 69 | + vm.add_blockdev('quorum,children.0=drive0-verify,vote-threshold=1,node-name=drive0-quorum') |
55 | +. ./common.filter | 70 | + root = "drive0-quorum" |
71 | + else: | ||
72 | + root = "drive0-verify" | ||
56 | + | 73 | + |
57 | +_supported_fmt generic | 74 | + vm.add_device('virtio-blk,drive=%s,iothread=iothread0' % root) |
58 | +_supported_proto file | ||
59 | +_supported_os Linux | ||
60 | + | 75 | + |
61 | +function do_run_qemu() | 76 | + iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, img_path, '64M') |
62 | +{ | ||
63 | + echo Testing: "$@" | ||
64 | + ( | ||
65 | + if ! test -t 0; then | ||
66 | + while read cmd; do | ||
67 | + echo $cmd | ||
68 | + done | ||
69 | + fi | ||
70 | + echo quit | ||
71 | + ) | $QEMU -nographic -monitor stdio -nodefaults "$@" | ||
72 | + echo | ||
73 | +} | ||
74 | + | 77 | + |
75 | +function run_qemu() | 78 | + os.mkfifo(fifo) |
76 | +{ | ||
77 | + do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp | | ||
78 | + _filter_generated_node_ids | _filter_imgfmt | ||
79 | +} | ||
80 | + | 79 | + |
81 | +function run_qemu_info_block() | 80 | + iotests.log('Launching source VM...') |
82 | +{ | 81 | + add_opts(vm_a) |
83 | + echo "info block -n" | run_qemu "$@" | grep -e "(file" -e "QEMU_PROG" | 82 | + vm_a.launch() |
84 | +} | ||
85 | + | 83 | + |
86 | +size=128M | 84 | + vm_a.enable_migration_events('A') |
87 | + | 85 | + |
88 | +_make_test_img $size | 86 | + iotests.log('Launching destination VM...') |
87 | + add_opts(vm_b) | ||
88 | + vm_b.add_incoming("exec: cat '%s'" % (fifo)) | ||
89 | + vm_b.launch() | ||
89 | + | 90 | + |
90 | +echo | 91 | + vm_b.enable_migration_events('B') |
91 | +echo "=== -drive with read-write image: read-only/auto-read-only combinations ===" | ||
92 | +echo | ||
93 | + | 92 | + |
94 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=off | 93 | + iotests.log('Starting migration to B...') |
95 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=on | 94 | + iotests.log(vm_a.qmp('migrate', uri='exec:cat >%s' % (fifo))) |
96 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on | 95 | + with iotests.Timeout(3, 'Migration does not complete'): |
97 | +echo | 96 | + # Wait for the source first (which includes setup=setup) |
98 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=off | 97 | + vm_a.wait_migration() |
99 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=on | 98 | + # Wait for the destination second (which does not) |
100 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off | 99 | + vm_b.wait_migration() |
101 | +echo | ||
102 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=off | ||
103 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=on | ||
104 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none | ||
105 | + | 100 | + |
106 | +echo | 101 | + iotests.log(vm_a.qmp('query-migrate')['return']['status']) |
107 | +echo "=== -drive with read-only image: read-only/auto-read-only combinations ===" | 102 | + iotests.log(vm_b.qmp('query-migrate')['return']['status']) |
108 | +echo | ||
109 | + | 103 | + |
110 | +chmod a-w $TEST_IMG | 104 | + iotests.log(vm_a.qmp('query-status')) |
111 | + | 105 | + iotests.log(vm_b.qmp('query-status')) |
112 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=off | 106 | diff --git a/tests/qemu-iotests/262.out b/tests/qemu-iotests/262.out |
113 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=on | ||
114 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on | ||
115 | +echo | ||
116 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=off | ||
117 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=on | ||
118 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off | ||
119 | +echo | ||
120 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=off | ||
121 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=on | ||
122 | +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none | ||
123 | + | ||
124 | +echo | ||
125 | +echo "=== -blockdev with read-write image: read-only/auto-read-only combinations ===" | ||
126 | +echo | ||
127 | + | ||
128 | +chmod a+w $TEST_IMG | ||
129 | + | ||
130 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=off | ||
131 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=on | ||
132 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on | ||
133 | +echo | ||
134 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=off | ||
135 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=on | ||
136 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off | ||
137 | +echo | ||
138 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=off | ||
139 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=on | ||
140 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0 | ||
141 | + | ||
142 | +echo | ||
143 | +echo "=== -blockdev with read-only image: read-only/auto-read-only combinations ===" | ||
144 | +echo | ||
145 | + | ||
146 | +chmod a-w $TEST_IMG | ||
147 | + | ||
148 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=off | ||
149 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=on | ||
150 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on | ||
151 | +echo | ||
152 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=off | ||
153 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=on | ||
154 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off | ||
155 | +echo | ||
156 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=off | ||
157 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=on | ||
158 | +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0 | ||
159 | + | ||
160 | +# success, all done | ||
161 | +echo "*** done" | ||
162 | +rm -f $seq.full | ||
163 | +status=0 | ||
164 | diff --git a/tests/qemu-iotests/232.out b/tests/qemu-iotests/232.out | ||
165 | new file mode 100644 | 107 | new file mode 100644 |
166 | index XXXXXXX..XXXXXXX | 108 | index XXXXXXX..XXXXXXX |
167 | --- /dev/null | 109 | --- /dev/null |
168 | +++ b/tests/qemu-iotests/232.out | 110 | +++ b/tests/qemu-iotests/262.out |
169 | @@ -XXX,XX +XXX,XX @@ | 111 | @@ -XXX,XX +XXX,XX @@ |
170 | +QA output created by 232 | 112 | +Launching source VM... |
171 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | 113 | +Enabling migration QMP events on A... |
172 | + | 114 | +{"return": {}} |
173 | +=== -drive with read-write image: read-only/auto-read-only combinations === | 115 | +Launching destination VM... |
174 | + | 116 | +Enabling migration QMP events on B... |
175 | +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) | 117 | +{"return": {}} |
176 | +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) | 118 | +Starting migration to B... |
177 | +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) | 119 | +{"return": {}} |
178 | + | 120 | +{"data": {"status": "setup"}, "event": "MIGRATION", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} |
179 | +NODE_NAME: TEST_DIR/t.IMGFMT (file) | 121 | +{"data": {"status": "active"}, "event": "MIGRATION", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} |
180 | +NODE_NAME: TEST_DIR/t.IMGFMT (file) | 122 | +{"data": {"status": "completed"}, "event": "MIGRATION", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} |
181 | +NODE_NAME: TEST_DIR/t.IMGFMT (file) | 123 | +{"data": {"status": "active"}, "event": "MIGRATION", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} |
182 | + | 124 | +{"data": {"status": "completed"}, "event": "MIGRATION", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} |
183 | +NODE_NAME: TEST_DIR/t.IMGFMT (file) | 125 | +completed |
184 | +NODE_NAME: TEST_DIR/t.IMGFMT (file) | 126 | +completed |
185 | +NODE_NAME: TEST_DIR/t.IMGFMT (file) | 127 | +{"return": {"running": false, "singlestep": false, "status": "postmigrate"}} |
186 | + | 128 | +{"return": {"running": true, "singlestep": false, "status": "running"}} |
187 | +=== -drive with read-only image: read-only/auto-read-only combinations === | ||
188 | + | ||
189 | +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) | ||
190 | +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) | ||
191 | +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) | ||
192 | + | ||
193 | +QEMU_PROG: -drive driver=file,file=TEST_DIR/t.IMGFMT,if=none,read-only=off,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied | ||
194 | +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) | ||
195 | +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) | ||
196 | + | ||
197 | +QEMU_PROG: -drive driver=file,file=TEST_DIR/t.IMGFMT,if=none,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied | ||
198 | +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) | ||
199 | +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) | ||
200 | + | ||
201 | +=== -blockdev with read-write image: read-only/auto-read-only combinations === | ||
202 | + | ||
203 | +node0: TEST_DIR/t.IMGFMT (file, read-only) | ||
204 | +node0: TEST_DIR/t.IMGFMT (file, read-only) | ||
205 | +node0: TEST_DIR/t.IMGFMT (file, read-only) | ||
206 | + | ||
207 | +node0: TEST_DIR/t.IMGFMT (file) | ||
208 | +node0: TEST_DIR/t.IMGFMT (file) | ||
209 | +node0: TEST_DIR/t.IMGFMT (file) | ||
210 | + | ||
211 | +node0: TEST_DIR/t.IMGFMT (file) | ||
212 | +node0: TEST_DIR/t.IMGFMT (file) | ||
213 | +node0: TEST_DIR/t.IMGFMT (file) | ||
214 | + | ||
215 | +=== -blockdev with read-only image: read-only/auto-read-only combinations === | ||
216 | + | ||
217 | +node0: TEST_DIR/t.IMGFMT (file, read-only) | ||
218 | +node0: TEST_DIR/t.IMGFMT (file, read-only) | ||
219 | +node0: TEST_DIR/t.IMGFMT (file, read-only) | ||
220 | + | ||
221 | +QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,read-only=off,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied | ||
222 | +node0: TEST_DIR/t.IMGFMT (file, read-only) | ||
223 | +QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied | ||
224 | + | ||
225 | +QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied | ||
226 | +node0: TEST_DIR/t.IMGFMT (file, read-only) | ||
227 | +QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0: Could not open 'TEST_DIR/t.IMGFMT': Permission denied | ||
228 | +*** done | ||
229 | diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group | 129 | diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group |
230 | index XXXXXXX..XXXXXXX 100644 | 130 | index XXXXXXX..XXXXXXX 100644 |
231 | --- a/tests/qemu-iotests/group | 131 | --- a/tests/qemu-iotests/group |
232 | +++ b/tests/qemu-iotests/group | 132 | +++ b/tests/qemu-iotests/group |
233 | @@ -XXX,XX +XXX,XX @@ | 133 | @@ -XXX,XX +XXX,XX @@ |
234 | 227 auto quick | 134 | 254 rw backing quick |
235 | 229 auto quick | 135 | 255 rw quick |
236 | 231 auto quick | 136 | 256 rw quick |
237 | +232 auto quick | 137 | +262 rw quick migration |
238 | -- | 138 | -- |
239 | 2.19.1 | 139 | 2.20.1 |
240 | 140 | ||
241 | 141 | diff view generated by jsdifflib |
1 | To fully change the read-only state of a node, we must not only change | 1 | The same change as commit 2b23f28639 ('block/copy-on-read: Fix |
---|---|---|---|
2 | bs->read_only, but also update bs->open_flags. | 2 | permissions for inactive node') made for the copy-on-read driver can be |
3 | made for bdrv_filter_default_perms(): Retaining the old permissions from | ||
4 | the BdrvChild if it is given complicates things unnecessarily when in | ||
5 | the end this only means that the options set in the c == NULL case (i.e. | ||
6 | during child creation) are retained. | ||
3 | 7 | ||
4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
5 | Reviewed-by: Eric Blake <eblake@redhat.com> | 9 | Reviewed-by: Eric Blake <eblake@redhat.com> |
6 | Reviewed-by: Alberto Garcia <berto@igalia.com> | 10 | Reviewed-by: Max Reitz <mreitz@redhat.com> |
7 | --- | 11 | --- |
8 | block.c | 7 +++++++ | 12 | block.c | 12 ++---------- |
9 | 1 file changed, 7 insertions(+) | 13 | 1 file changed, 2 insertions(+), 10 deletions(-) |
10 | 14 | ||
11 | diff --git a/block.c b/block.c | 15 | diff --git a/block.c b/block.c |
12 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/block.c | 17 | --- a/block.c |
14 | +++ b/block.c | 18 | +++ b/block.c |
15 | @@ -XXX,XX +XXX,XX @@ int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp) | 19 | @@ -XXX,XX +XXX,XX @@ void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c, |
16 | } | 20 | uint64_t perm, uint64_t shared, |
17 | 21 | uint64_t *nperm, uint64_t *nshared) | |
18 | bs->read_only = read_only; | 22 | { |
19 | + | 23 | - if (c == NULL) { |
20 | + if (read_only) { | 24 | - *nperm = perm & DEFAULT_PERM_PASSTHROUGH; |
21 | + bs->open_flags &= ~BDRV_O_RDWR; | 25 | - *nshared = (shared & DEFAULT_PERM_PASSTHROUGH) | DEFAULT_PERM_UNCHANGED; |
22 | + } else { | 26 | - return; |
23 | + bs->open_flags |= BDRV_O_RDWR; | 27 | - } |
24 | + } | 28 | - |
25 | + | 29 | - *nperm = (perm & DEFAULT_PERM_PASSTHROUGH) | |
26 | return 0; | 30 | - (c->perm & DEFAULT_PERM_UNCHANGED); |
31 | - *nshared = (shared & DEFAULT_PERM_PASSTHROUGH) | | ||
32 | - (c->shared_perm & DEFAULT_PERM_UNCHANGED); | ||
33 | + *nperm = perm & DEFAULT_PERM_PASSTHROUGH; | ||
34 | + *nshared = (shared & DEFAULT_PERM_PASSTHROUGH) | DEFAULT_PERM_UNCHANGED; | ||
27 | } | 35 | } |
28 | 36 | ||
37 | void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c, | ||
29 | -- | 38 | -- |
30 | 2.19.1 | 39 | 2.20.1 |
31 | 40 | ||
32 | 41 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | 1 | From: Max Reitz <mreitz@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | There is no good reason why there should be a newline in this | 3 | bdrv_drop_intermediate() calls BdrvChildRole.update_filename(). That |
4 | description, so remove it. | 4 | may poll, thus changing the graph, which potentially breaks the |
5 | QLIST_FOREACH_SAFE() loop. | ||
6 | |||
7 | Just keep the whole subtree drained. This is probably the right thing | ||
8 | to do anyway (dropping nodes while the subtree is not drained seems | ||
9 | wrong). | ||
5 | 10 | ||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 11 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 12 | Reviewed-by: Kevin Wolf <kwolf@redhat.com> |
8 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | ||
9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 13 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
10 | --- | 14 | --- |
11 | vl.c | 2 +- | 15 | block.c | 2 ++ |
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | 16 | 1 file changed, 2 insertions(+) |
13 | 17 | ||
14 | diff --git a/vl.c b/vl.c | 18 | diff --git a/block.c b/block.c |
15 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/vl.c | 20 | --- a/block.c |
17 | +++ b/vl.c | 21 | +++ b/block.c |
18 | @@ -XXX,XX +XXX,XX @@ static QemuOptsList qemu_fw_cfg_opts = { | 22 | @@ -XXX,XX +XXX,XX @@ int bdrv_drop_intermediate(BlockDriverState *top, BlockDriverState *base, |
19 | }, { | 23 | int ret = -EIO; |
20 | .name = "file", | 24 | |
21 | .type = QEMU_OPT_STRING, | 25 | bdrv_ref(top); |
22 | - .help = "Sets the name of the file from which\n" | 26 | + bdrv_subtree_drained_begin(top); |
23 | + .help = "Sets the name of the file from which " | 27 | |
24 | "the fw_cfg blob will be loaded", | 28 | if (!top->drv || !base->drv) { |
25 | }, { | 29 | goto exit; |
26 | .name = "string", | 30 | @@ -XXX,XX +XXX,XX @@ int bdrv_drop_intermediate(BlockDriverState *top, BlockDriverState *base, |
31 | |||
32 | ret = 0; | ||
33 | exit: | ||
34 | + bdrv_subtree_drained_end(top); | ||
35 | bdrv_unref(top); | ||
36 | return ret; | ||
37 | } | ||
27 | -- | 38 | -- |
28 | 2.19.1 | 39 | 2.20.1 |
29 | 40 | ||
30 | 41 | diff view generated by jsdifflib |
1 | From: Alberto Garcia <berto@igalia.com> | 1 | From: Max Reitz <mreitz@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Alberto Garcia <berto@igalia.com> | 3 | Currently, bdrv_replace_child_noperm() undrains the parent until it is |
4 | completely undrained, then re-drains it after attaching the new child | ||
5 | node. | ||
6 | |||
7 | This is a problem with bdrv_drop_intermediate(): We want to keep the | ||
8 | whole subtree drained, including parents, while the operation is | ||
9 | under way. bdrv_replace_child_noperm() breaks this by allowing every | ||
10 | parent to become unquiesced briefly, and then redraining it. | ||
11 | |||
12 | In fact, there is no reason why the parent should become unquiesced and | ||
13 | be allowed to submit requests to the new child node if that new node is | ||
14 | supposed to be kept drained. So if anything, we have to drain the | ||
15 | parent before detaching the old child node. Conversely, we have to | ||
16 | undrain it only after attaching the new child node. | ||
17 | |||
18 | Thus, change the whole drain algorithm here: Calculate the number of | ||
19 | times we have to drain/undrain the parent before replacing the child | ||
20 | node then drain it (if necessary), replace the child node, and then | ||
21 | undrain it. | ||
22 | |||
23 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 24 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
5 | --- | 25 | --- |
6 | block.c | 6 +++--- | 26 | block.c | 49 +++++++++++++++++++++++++++++++++---------------- |
7 | 1 file changed, 3 insertions(+), 3 deletions(-) | 27 | 1 file changed, 33 insertions(+), 16 deletions(-) |
8 | 28 | ||
9 | diff --git a/block.c b/block.c | 29 | diff --git a/block.c b/block.c |
10 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
11 | --- a/block.c | 31 | --- a/block.c |
12 | +++ b/block.c | 32 | +++ b/block.c |
13 | @@ -XXX,XX +XXX,XX @@ QemuOptsList bdrv_runtime_opts = { | 33 | @@ -XXX,XX +XXX,XX @@ static void bdrv_replace_child_noperm(BdrvChild *child, |
14 | .help = "try to optimize zero writes (off, on, unmap)", | 34 | BlockDriverState *new_bs) |
15 | }, | 35 | { |
16 | { | 36 | BlockDriverState *old_bs = child->bs; |
17 | - .name = "discard", | 37 | - int i; |
18 | + .name = BDRV_OPT_DISCARD, | 38 | + int new_bs_quiesce_counter; |
19 | .type = QEMU_OPT_STRING, | 39 | + int drain_saldo; |
20 | .help = "discard operation (ignore/off, unmap/on)", | 40 | |
21 | }, | 41 | assert(!child->frozen); |
22 | @@ -XXX,XX +XXX,XX @@ static int bdrv_open_common(BlockDriverState *bs, BlockBackend *file, | 42 | |
43 | if (old_bs && new_bs) { | ||
44 | assert(bdrv_get_aio_context(old_bs) == bdrv_get_aio_context(new_bs)); | ||
45 | } | ||
46 | + | ||
47 | + new_bs_quiesce_counter = (new_bs ? new_bs->quiesce_counter : 0); | ||
48 | + drain_saldo = new_bs_quiesce_counter - child->parent_quiesce_counter; | ||
49 | + | ||
50 | + /* | ||
51 | + * If the new child node is drained but the old one was not, flush | ||
52 | + * all outstanding requests to the old child node. | ||
53 | + */ | ||
54 | + while (drain_saldo > 0 && child->role->drained_begin) { | ||
55 | + bdrv_parent_drained_begin_single(child, true); | ||
56 | + drain_saldo--; | ||
57 | + } | ||
58 | + | ||
59 | if (old_bs) { | ||
60 | /* Detach first so that the recursive drain sections coming from @child | ||
61 | * are already gone and we only end the drain sections that came from | ||
62 | @@ -XXX,XX +XXX,XX @@ static void bdrv_replace_child_noperm(BdrvChild *child, | ||
63 | if (child->role->detach) { | ||
64 | child->role->detach(child); | ||
65 | } | ||
66 | - while (child->parent_quiesce_counter) { | ||
67 | - bdrv_parent_drained_end_single(child); | ||
68 | - } | ||
69 | QLIST_REMOVE(child, next_parent); | ||
70 | - } else { | ||
71 | - assert(child->parent_quiesce_counter == 0); | ||
72 | } | ||
73 | |||
74 | child->bs = new_bs; | ||
75 | |||
76 | if (new_bs) { | ||
77 | QLIST_INSERT_HEAD(&new_bs->parents, child, next_parent); | ||
78 | - if (new_bs->quiesce_counter) { | ||
79 | - int num = new_bs->quiesce_counter; | ||
80 | - if (child->role->parent_is_bds) { | ||
81 | - num -= bdrv_drain_all_count; | ||
82 | - } | ||
83 | - assert(num >= 0); | ||
84 | - for (i = 0; i < num; i++) { | ||
85 | - bdrv_parent_drained_begin_single(child, true); | ||
86 | - } | ||
87 | - } | ||
88 | + | ||
89 | + /* | ||
90 | + * Detaching the old node may have led to the new node's | ||
91 | + * quiesce_counter having been decreased. Not a problem, we | ||
92 | + * just need to recognize this here and then invoke | ||
93 | + * drained_end appropriately more often. | ||
94 | + */ | ||
95 | + assert(new_bs->quiesce_counter <= new_bs_quiesce_counter); | ||
96 | + drain_saldo += new_bs->quiesce_counter - new_bs_quiesce_counter; | ||
97 | |||
98 | /* Attach only after starting new drained sections, so that recursive | ||
99 | * drain sections coming from @child don't get an extra .drained_begin | ||
100 | @@ -XXX,XX +XXX,XX @@ static void bdrv_replace_child_noperm(BdrvChild *child, | ||
101 | child->role->attach(child); | ||
23 | } | 102 | } |
24 | } | 103 | } |
25 | 104 | + | |
26 | - discard = qemu_opt_get(opts, "discard"); | 105 | + /* |
27 | + discard = qemu_opt_get(opts, BDRV_OPT_DISCARD); | 106 | + * If the old child node was drained but the new one is not, allow |
28 | if (discard != NULL) { | 107 | + * requests to come in only after the new node has been attached. |
29 | if (bdrv_parse_discard_flags(discard, &bs->open_flags) != 0) { | 108 | + */ |
30 | error_setg(errp, "Invalid discard option"); | 109 | + while (drain_saldo < 0 && child->role->drained_end) { |
31 | @@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, | 110 | + bdrv_parent_drained_end_single(child); |
32 | 111 | + drain_saldo++; | |
33 | update_flags_from_options(&reopen_state->flags, opts); | 112 | + } |
34 | 113 | } | |
35 | - discard = qemu_opt_get_del(opts, "discard"); | 114 | |
36 | + discard = qemu_opt_get_del(opts, BDRV_OPT_DISCARD); | 115 | /* |
37 | if (discard != NULL) { | ||
38 | if (bdrv_parse_discard_flags(discard, &reopen_state->flags) != 0) { | ||
39 | error_setg(errp, "Invalid discard option"); | ||
40 | -- | 116 | -- |
41 | 2.19.1 | 117 | 2.20.1 |
42 | 118 | ||
43 | 119 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Stefan Weil <sw@weilnetz.de> | ||
2 | 1 | ||
3 | Use %zu instead of %zd for unsigned numbers. | ||
4 | |||
5 | This fixes two error messages from the LSTM static code analyzer: | ||
6 | |||
7 | This argument should be of type 'ssize_t' but is of type 'unsigned long' | ||
8 | |||
9 | Signed-off-by: Stefan Weil <sw@weilnetz.de> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
12 | --- | ||
13 | qemu-io-cmds.c | 4 ++-- | ||
14 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
15 | |||
16 | diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/qemu-io-cmds.c | ||
19 | +++ b/qemu-io-cmds.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static int readv_f(BlockBackend *blk, int argc, char **argv) | ||
21 | memset(cmp_buf, pattern, qiov.size); | ||
22 | if (memcmp(buf, cmp_buf, qiov.size)) { | ||
23 | printf("Pattern verification failed at offset %" | ||
24 | - PRId64 ", %zd bytes\n", offset, qiov.size); | ||
25 | + PRId64 ", %zu bytes\n", offset, qiov.size); | ||
26 | ret = -EINVAL; | ||
27 | } | ||
28 | g_free(cmp_buf); | ||
29 | @@ -XXX,XX +XXX,XX @@ static void aio_read_done(void *opaque, int ret) | ||
30 | memset(cmp_buf, ctx->pattern, ctx->qiov.size); | ||
31 | if (memcmp(ctx->buf, cmp_buf, ctx->qiov.size)) { | ||
32 | printf("Pattern verification failed at offset %" | ||
33 | - PRId64 ", %zd bytes\n", ctx->offset, ctx->qiov.size); | ||
34 | + PRId64 ", %zu bytes\n", ctx->offset, ctx->qiov.size); | ||
35 | } | ||
36 | g_free(cmp_buf); | ||
37 | } | ||
38 | -- | ||
39 | 2.19.1 | ||
40 | |||
41 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Peter Maydell <peter.maydell@linaro.org> | ||
2 | 1 | ||
3 | Taking the address of a field in a packed struct is a bad idea, because | ||
4 | it might not be actually aligned enough for that pointer type (and | ||
5 | thus cause a crash on dereference on some host architectures). Newer | ||
6 | versions of clang warn about this. Avoid the bug by not using the | ||
7 | "modify in place" byte swapping functions. | ||
8 | |||
9 | There are a few places where the in-place swap function is | ||
10 | used on something other than a packed struct field; we convert | ||
11 | those anyway, for consistency. | ||
12 | |||
13 | This patch was produced with the following spatch script | ||
14 | (and hand-editing to fold a few resulting overlength lines): | ||
15 | |||
16 | @@ | ||
17 | expression E; | ||
18 | @@ | ||
19 | -be16_to_cpus(&E); | ||
20 | +E = be16_to_cpu(E); | ||
21 | @@ | ||
22 | expression E; | ||
23 | @@ | ||
24 | -be32_to_cpus(&E); | ||
25 | +E = be32_to_cpu(E); | ||
26 | @@ | ||
27 | expression E; | ||
28 | @@ | ||
29 | -be64_to_cpus(&E); | ||
30 | +E = be64_to_cpu(E); | ||
31 | @@ | ||
32 | expression E; | ||
33 | @@ | ||
34 | -cpu_to_be16s(&E); | ||
35 | +E = cpu_to_be16(E); | ||
36 | @@ | ||
37 | expression E; | ||
38 | @@ | ||
39 | -cpu_to_be32s(&E); | ||
40 | +E = cpu_to_be32(E); | ||
41 | @@ | ||
42 | expression E; | ||
43 | @@ | ||
44 | -cpu_to_be64s(&E); | ||
45 | +E = cpu_to_be64(E); | ||
46 | |||
47 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
48 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
49 | Tested-by: John Snow <jsnow@redhat.com> | ||
50 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
51 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
52 | --- | ||
53 | block/qcow2.c | 64 +++++++++++++++++++++++++++------------------------ | ||
54 | 1 file changed, 34 insertions(+), 30 deletions(-) | ||
55 | |||
56 | diff --git a/block/qcow2.c b/block/qcow2.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/block/qcow2.c | ||
59 | +++ b/block/qcow2.c | ||
60 | @@ -XXX,XX +XXX,XX @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, | ||
61 | "pread fail from offset %" PRIu64, offset); | ||
62 | return 1; | ||
63 | } | ||
64 | - be32_to_cpus(&ext.magic); | ||
65 | - be32_to_cpus(&ext.len); | ||
66 | + ext.magic = be32_to_cpu(ext.magic); | ||
67 | + ext.len = be32_to_cpu(ext.len); | ||
68 | offset += sizeof(ext); | ||
69 | #ifdef DEBUG_EXT | ||
70 | printf("ext.magic = 0x%x\n", ext.magic); | ||
71 | @@ -XXX,XX +XXX,XX @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, | ||
72 | "Unable to read CRYPTO header extension"); | ||
73 | return ret; | ||
74 | } | ||
75 | - be64_to_cpus(&s->crypto_header.offset); | ||
76 | - be64_to_cpus(&s->crypto_header.length); | ||
77 | + s->crypto_header.offset = be64_to_cpu(s->crypto_header.offset); | ||
78 | + s->crypto_header.length = be64_to_cpu(s->crypto_header.length); | ||
79 | |||
80 | if ((s->crypto_header.offset % s->cluster_size) != 0) { | ||
81 | error_setg(errp, "Encryption header offset '%" PRIu64 "' is " | ||
82 | @@ -XXX,XX +XXX,XX @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, | ||
83 | return -EINVAL; | ||
84 | } | ||
85 | |||
86 | - be32_to_cpus(&bitmaps_ext.nb_bitmaps); | ||
87 | - be64_to_cpus(&bitmaps_ext.bitmap_directory_size); | ||
88 | - be64_to_cpus(&bitmaps_ext.bitmap_directory_offset); | ||
89 | + bitmaps_ext.nb_bitmaps = be32_to_cpu(bitmaps_ext.nb_bitmaps); | ||
90 | + bitmaps_ext.bitmap_directory_size = | ||
91 | + be64_to_cpu(bitmaps_ext.bitmap_directory_size); | ||
92 | + bitmaps_ext.bitmap_directory_offset = | ||
93 | + be64_to_cpu(bitmaps_ext.bitmap_directory_offset); | ||
94 | |||
95 | if (bitmaps_ext.nb_bitmaps > QCOW2_MAX_BITMAPS) { | ||
96 | error_setg(errp, | ||
97 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, | ||
98 | error_setg_errno(errp, -ret, "Could not read qcow2 header"); | ||
99 | goto fail; | ||
100 | } | ||
101 | - be32_to_cpus(&header.magic); | ||
102 | - be32_to_cpus(&header.version); | ||
103 | - be64_to_cpus(&header.backing_file_offset); | ||
104 | - be32_to_cpus(&header.backing_file_size); | ||
105 | - be64_to_cpus(&header.size); | ||
106 | - be32_to_cpus(&header.cluster_bits); | ||
107 | - be32_to_cpus(&header.crypt_method); | ||
108 | - be64_to_cpus(&header.l1_table_offset); | ||
109 | - be32_to_cpus(&header.l1_size); | ||
110 | - be64_to_cpus(&header.refcount_table_offset); | ||
111 | - be32_to_cpus(&header.refcount_table_clusters); | ||
112 | - be64_to_cpus(&header.snapshots_offset); | ||
113 | - be32_to_cpus(&header.nb_snapshots); | ||
114 | + header.magic = be32_to_cpu(header.magic); | ||
115 | + header.version = be32_to_cpu(header.version); | ||
116 | + header.backing_file_offset = be64_to_cpu(header.backing_file_offset); | ||
117 | + header.backing_file_size = be32_to_cpu(header.backing_file_size); | ||
118 | + header.size = be64_to_cpu(header.size); | ||
119 | + header.cluster_bits = be32_to_cpu(header.cluster_bits); | ||
120 | + header.crypt_method = be32_to_cpu(header.crypt_method); | ||
121 | + header.l1_table_offset = be64_to_cpu(header.l1_table_offset); | ||
122 | + header.l1_size = be32_to_cpu(header.l1_size); | ||
123 | + header.refcount_table_offset = be64_to_cpu(header.refcount_table_offset); | ||
124 | + header.refcount_table_clusters = | ||
125 | + be32_to_cpu(header.refcount_table_clusters); | ||
126 | + header.snapshots_offset = be64_to_cpu(header.snapshots_offset); | ||
127 | + header.nb_snapshots = be32_to_cpu(header.nb_snapshots); | ||
128 | |||
129 | if (header.magic != QCOW_MAGIC) { | ||
130 | error_setg(errp, "Image is not in qcow2 format"); | ||
131 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, | ||
132 | header.refcount_order = 4; | ||
133 | header.header_length = 72; | ||
134 | } else { | ||
135 | - be64_to_cpus(&header.incompatible_features); | ||
136 | - be64_to_cpus(&header.compatible_features); | ||
137 | - be64_to_cpus(&header.autoclear_features); | ||
138 | - be32_to_cpus(&header.refcount_order); | ||
139 | - be32_to_cpus(&header.header_length); | ||
140 | + header.incompatible_features = | ||
141 | + be64_to_cpu(header.incompatible_features); | ||
142 | + header.compatible_features = be64_to_cpu(header.compatible_features); | ||
143 | + header.autoclear_features = be64_to_cpu(header.autoclear_features); | ||
144 | + header.refcount_order = be32_to_cpu(header.refcount_order); | ||
145 | + header.header_length = be32_to_cpu(header.header_length); | ||
146 | |||
147 | if (header.header_length < 104) { | ||
148 | error_setg(errp, "qcow2 header too short"); | ||
149 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, | ||
150 | goto fail; | ||
151 | } | ||
152 | for(i = 0;i < s->l1_size; i++) { | ||
153 | - be64_to_cpus(&s->l1_table[i]); | ||
154 | + s->l1_table[i] = be64_to_cpu(s->l1_table[i]); | ||
155 | } | ||
156 | } | ||
157 | |||
158 | @@ -XXX,XX +XXX,XX @@ int qcow2_update_header(BlockDriverState *bs) | ||
159 | |||
160 | /* Full disk encryption header pointer extension */ | ||
161 | if (s->crypto_header.offset != 0) { | ||
162 | - cpu_to_be64s(&s->crypto_header.offset); | ||
163 | - cpu_to_be64s(&s->crypto_header.length); | ||
164 | + s->crypto_header.offset = cpu_to_be64(s->crypto_header.offset); | ||
165 | + s->crypto_header.length = cpu_to_be64(s->crypto_header.length); | ||
166 | ret = header_ext_add(buf, QCOW2_EXT_MAGIC_CRYPTO_HEADER, | ||
167 | &s->crypto_header, sizeof(s->crypto_header), | ||
168 | buflen); | ||
169 | - be64_to_cpus(&s->crypto_header.offset); | ||
170 | - be64_to_cpus(&s->crypto_header.length); | ||
171 | + s->crypto_header.offset = be64_to_cpu(s->crypto_header.offset); | ||
172 | + s->crypto_header.length = be64_to_cpu(s->crypto_header.length); | ||
173 | if (ret < 0) { | ||
174 | goto fail; | ||
175 | } | ||
176 | -- | ||
177 | 2.19.1 | ||
178 | |||
179 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Peter Maydell <peter.maydell@linaro.org> | ||
2 | 1 | ||
3 | Taking the address of a field in a packed struct is a bad idea, because | ||
4 | it might not be actually aligned enough for that pointer type (and | ||
5 | thus cause a crash on dereference on some host architectures). Newer | ||
6 | versions of clang warn about this. Avoid the bug by not using the | ||
7 | "modify in place" byte swapping functions. | ||
8 | |||
9 | There are a few places where the in-place swap function is | ||
10 | used on something other than a packed struct field; we convert | ||
11 | those anyway, for consistency. | ||
12 | |||
13 | This patch was produced with the following spatch script: | ||
14 | |||
15 | @@ | ||
16 | expression E; | ||
17 | @@ | ||
18 | -be16_to_cpus(&E); | ||
19 | +E = be16_to_cpu(E); | ||
20 | @@ | ||
21 | expression E; | ||
22 | @@ | ||
23 | -be32_to_cpus(&E); | ||
24 | +E = be32_to_cpu(E); | ||
25 | @@ | ||
26 | expression E; | ||
27 | @@ | ||
28 | -be64_to_cpus(&E); | ||
29 | +E = be64_to_cpu(E); | ||
30 | @@ | ||
31 | expression E; | ||
32 | @@ | ||
33 | -cpu_to_be16s(&E); | ||
34 | +E = cpu_to_be16(E); | ||
35 | @@ | ||
36 | expression E; | ||
37 | @@ | ||
38 | -cpu_to_be32s(&E); | ||
39 | +E = cpu_to_be32(E); | ||
40 | @@ | ||
41 | expression E; | ||
42 | @@ | ||
43 | -cpu_to_be64s(&E); | ||
44 | +E = cpu_to_be64(E); | ||
45 | |||
46 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
47 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
48 | Tested-by: John Snow <jsnow@redhat.com> | ||
49 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
50 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
51 | --- | ||
52 | block/qcow.c | 18 +++++++++--------- | ||
53 | 1 file changed, 9 insertions(+), 9 deletions(-) | ||
54 | |||
55 | diff --git a/block/qcow.c b/block/qcow.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/block/qcow.c | ||
58 | +++ b/block/qcow.c | ||
59 | @@ -XXX,XX +XXX,XX @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags, | ||
60 | if (ret < 0) { | ||
61 | goto fail; | ||
62 | } | ||
63 | - be32_to_cpus(&header.magic); | ||
64 | - be32_to_cpus(&header.version); | ||
65 | - be64_to_cpus(&header.backing_file_offset); | ||
66 | - be32_to_cpus(&header.backing_file_size); | ||
67 | - be32_to_cpus(&header.mtime); | ||
68 | - be64_to_cpus(&header.size); | ||
69 | - be32_to_cpus(&header.crypt_method); | ||
70 | - be64_to_cpus(&header.l1_table_offset); | ||
71 | + header.magic = be32_to_cpu(header.magic); | ||
72 | + header.version = be32_to_cpu(header.version); | ||
73 | + header.backing_file_offset = be64_to_cpu(header.backing_file_offset); | ||
74 | + header.backing_file_size = be32_to_cpu(header.backing_file_size); | ||
75 | + header.mtime = be32_to_cpu(header.mtime); | ||
76 | + header.size = be64_to_cpu(header.size); | ||
77 | + header.crypt_method = be32_to_cpu(header.crypt_method); | ||
78 | + header.l1_table_offset = be64_to_cpu(header.l1_table_offset); | ||
79 | |||
80 | if (header.magic != QCOW_MAGIC) { | ||
81 | error_setg(errp, "Image not in qcow format"); | ||
82 | @@ -XXX,XX +XXX,XX @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags, | ||
83 | } | ||
84 | |||
85 | for(i = 0;i < s->l1_size; i++) { | ||
86 | - be64_to_cpus(&s->l1_table[i]); | ||
87 | + s->l1_table[i] = be64_to_cpu(s->l1_table[i]); | ||
88 | } | ||
89 | |||
90 | /* alloc L2 cache (max. 64k * 16 * 8 = 8 MB) */ | ||
91 | -- | ||
92 | 2.19.1 | ||
93 | |||
94 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Peter Maydell <peter.maydell@linaro.org> | ||
2 | 1 | ||
3 | Taking the address of a field in a packed struct is a bad idea, because | ||
4 | it might not be actually aligned enough for that pointer type (and | ||
5 | thus cause a crash on dereference on some host architectures). Newer | ||
6 | versions of clang warn about this. Avoid the bug by not using the | ||
7 | "modify in place" byte swapping functions. | ||
8 | |||
9 | There are a few places where the in-place swap function is | ||
10 | used on something other than a packed struct field; we convert | ||
11 | those anyway, for consistency. | ||
12 | |||
13 | This patch was produced with the following spatch script: | ||
14 | |||
15 | @@ | ||
16 | expression E; | ||
17 | @@ | ||
18 | -be16_to_cpus(&E); | ||
19 | +E = be16_to_cpu(E); | ||
20 | @@ | ||
21 | expression E; | ||
22 | @@ | ||
23 | -be32_to_cpus(&E); | ||
24 | +E = be32_to_cpu(E); | ||
25 | @@ | ||
26 | expression E; | ||
27 | @@ | ||
28 | -be64_to_cpus(&E); | ||
29 | +E = be64_to_cpu(E); | ||
30 | @@ | ||
31 | expression E; | ||
32 | @@ | ||
33 | -cpu_to_be16s(&E); | ||
34 | +E = cpu_to_be16(E); | ||
35 | @@ | ||
36 | expression E; | ||
37 | @@ | ||
38 | -cpu_to_be32s(&E); | ||
39 | +E = cpu_to_be32(E); | ||
40 | @@ | ||
41 | expression E; | ||
42 | @@ | ||
43 | -cpu_to_be64s(&E); | ||
44 | +E = cpu_to_be64(E); | ||
45 | |||
46 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
47 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
48 | Tested-by: John Snow <jsnow@redhat.com> | ||
49 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
50 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
51 | --- | ||
52 | block/qcow2-bitmap.c | 24 ++++++++++++------------ | ||
53 | 1 file changed, 12 insertions(+), 12 deletions(-) | ||
54 | |||
55 | diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/block/qcow2-bitmap.c | ||
58 | +++ b/block/qcow2-bitmap.c | ||
59 | @@ -XXX,XX +XXX,XX @@ static inline void bitmap_table_to_be(uint64_t *bitmap_table, size_t size) | ||
60 | size_t i; | ||
61 | |||
62 | for (i = 0; i < size; ++i) { | ||
63 | - cpu_to_be64s(&bitmap_table[i]); | ||
64 | + bitmap_table[i] = cpu_to_be64(bitmap_table[i]); | ||
65 | } | ||
66 | } | ||
67 | |||
68 | @@ -XXX,XX +XXX,XX @@ static int bitmap_table_load(BlockDriverState *bs, Qcow2BitmapTable *tb, | ||
69 | } | ||
70 | |||
71 | for (i = 0; i < tb->size; ++i) { | ||
72 | - be64_to_cpus(&table[i]); | ||
73 | + table[i] = be64_to_cpu(table[i]); | ||
74 | ret = check_table_entry(table[i], s->cluster_size); | ||
75 | if (ret < 0) { | ||
76 | goto fail; | ||
77 | @@ -XXX,XX +XXX,XX @@ fail: | ||
78 | |||
79 | static inline void bitmap_dir_entry_to_cpu(Qcow2BitmapDirEntry *entry) | ||
80 | { | ||
81 | - be64_to_cpus(&entry->bitmap_table_offset); | ||
82 | - be32_to_cpus(&entry->bitmap_table_size); | ||
83 | - be32_to_cpus(&entry->flags); | ||
84 | - be16_to_cpus(&entry->name_size); | ||
85 | - be32_to_cpus(&entry->extra_data_size); | ||
86 | + entry->bitmap_table_offset = be64_to_cpu(entry->bitmap_table_offset); | ||
87 | + entry->bitmap_table_size = be32_to_cpu(entry->bitmap_table_size); | ||
88 | + entry->flags = be32_to_cpu(entry->flags); | ||
89 | + entry->name_size = be16_to_cpu(entry->name_size); | ||
90 | + entry->extra_data_size = be32_to_cpu(entry->extra_data_size); | ||
91 | } | ||
92 | |||
93 | static inline void bitmap_dir_entry_to_be(Qcow2BitmapDirEntry *entry) | ||
94 | { | ||
95 | - cpu_to_be64s(&entry->bitmap_table_offset); | ||
96 | - cpu_to_be32s(&entry->bitmap_table_size); | ||
97 | - cpu_to_be32s(&entry->flags); | ||
98 | - cpu_to_be16s(&entry->name_size); | ||
99 | - cpu_to_be32s(&entry->extra_data_size); | ||
100 | + entry->bitmap_table_offset = cpu_to_be64(entry->bitmap_table_offset); | ||
101 | + entry->bitmap_table_size = cpu_to_be32(entry->bitmap_table_size); | ||
102 | + entry->flags = cpu_to_be32(entry->flags); | ||
103 | + entry->name_size = cpu_to_be16(entry->name_size); | ||
104 | + entry->extra_data_size = cpu_to_be32(entry->extra_data_size); | ||
105 | } | ||
106 | |||
107 | static inline int calc_dir_entry_size(size_t name_size, size_t extra_data_size) | ||
108 | -- | ||
109 | 2.19.1 | ||
110 | |||
111 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Daniel P. Berrangé <berrange@redhat.com> | ||
2 | 1 | ||
3 | The qcow2 block driver expects to see a valid sector size even when it | ||
4 | has opened the crypto layer with QCRYPTO_BLOCK_OPEN_NO_IO. | ||
5 | |||
6 | Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> | ||
7 | Reviewed-by: Alberto Garcia <berto@igalia.com> | ||
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
9 | --- | ||
10 | crypto/block-qcow.c | 2 ++ | ||
11 | 1 file changed, 2 insertions(+) | ||
12 | |||
13 | diff --git a/crypto/block-qcow.c b/crypto/block-qcow.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/crypto/block-qcow.c | ||
16 | +++ b/crypto/block-qcow.c | ||
17 | @@ -XXX,XX +XXX,XX @@ qcrypto_block_qcow_open(QCryptoBlock *block, | ||
18 | Error **errp) | ||
19 | { | ||
20 | if (flags & QCRYPTO_BLOCK_OPEN_NO_IO) { | ||
21 | + block->sector_size = QCRYPTO_BLOCK_QCOW_SECTOR_SIZE; | ||
22 | + block->payload_offset = 0; | ||
23 | return 0; | ||
24 | } else { | ||
25 | if (!options->u.qcow.key_secret) { | ||
26 | -- | ||
27 | 2.19.1 | ||
28 | |||
29 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alberto Garcia <berto@igalia.com> | ||
2 | 1 | ||
3 | This doesn't have any practical effect at the moment because the | ||
4 | values of BDRV_SECTOR_SIZE, QCRYPTO_BLOCK_LUKS_SECTOR_SIZE and | ||
5 | QCRYPTO_BLOCK_QCOW_SECTOR_SIZE are all the same (512 bytes), but | ||
6 | future encryption methods could have different requirements. | ||
7 | |||
8 | Signed-off-by: Alberto Garcia <berto@igalia.com> | ||
9 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
11 | --- | ||
12 | block/qcow2.c | 2 +- | ||
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
14 | |||
15 | diff --git a/block/qcow2.c b/block/qcow2.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/block/qcow2.c | ||
18 | +++ b/block/qcow2.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void qcow2_refresh_limits(BlockDriverState *bs, Error **errp) | ||
20 | |||
21 | if (bs->encrypted) { | ||
22 | /* Encryption works on a sector granularity */ | ||
23 | - bs->bl.request_alignment = BDRV_SECTOR_SIZE; | ||
24 | + bs->bl.request_alignment = qcrypto_block_get_sector_size(s->crypto); | ||
25 | } | ||
26 | bs->bl.pwrite_zeroes_alignment = s->cluster_size; | ||
27 | bs->bl.pdiscard_alignment = s->cluster_size; | ||
28 | -- | ||
29 | 2.19.1 | ||
30 | |||
31 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | 1 | From: Max Reitz <mreitz@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Just like in qemu_opts_print_help(), print the object name as a caption | ||
4 | instead of on every single line, indent all options, add angle brackets | ||
5 | around types, and align the descriptions after 24 characters. | ||
6 | |||
7 | Also, indent every object name in the list of available objects. | ||
8 | |||
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 3 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
10 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | ||
11 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
12 | --- | 5 | --- |
13 | vl.c | 13 ++++++++++--- | 6 | tests/test-bdrv-drain.c | 167 ++++++++++++++++++++++++++++++++++++++++ |
14 | 1 file changed, 10 insertions(+), 3 deletions(-) | 7 | 1 file changed, 167 insertions(+) |
15 | 8 | ||
16 | diff --git a/vl.c b/vl.c | 9 | diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c |
17 | index XXXXXXX..XXXXXXX 100644 | 10 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/vl.c | 11 | --- a/tests/test-bdrv-drain.c |
19 | +++ b/vl.c | 12 | +++ b/tests/test-bdrv-drain.c |
20 | @@ -XXX,XX +XXX,XX @@ static bool object_create_initial(const char *type, QemuOpts *opts) | 13 | @@ -XXX,XX +XXX,XX @@ static void bdrv_test_child_perm(BlockDriverState *bs, BdrvChild *c, |
21 | list = object_class_get_list_sorted(TYPE_USER_CREATABLE, false); | 14 | nperm, nshared); |
22 | for (l = list; l != NULL; l = l->next) { | 15 | } |
23 | ObjectClass *oc = OBJECT_CLASS(l->data); | 16 | |
24 | - printf("%s\n", object_class_get_name(oc)); | 17 | +static int bdrv_test_change_backing_file(BlockDriverState *bs, |
25 | + printf(" %s\n", object_class_get_name(oc)); | 18 | + const char *backing_file, |
26 | } | 19 | + const char *backing_fmt) |
27 | g_slist_free(list); | 20 | +{ |
28 | exit(0); | 21 | + return 0; |
29 | @@ -XXX,XX +XXX,XX @@ static bool object_create_initial(const char *type, QemuOpts *opts) | 22 | +} |
30 | } | 23 | + |
31 | 24 | static BlockDriver bdrv_test = { | |
32 | str = g_string_new(NULL); | 25 | .format_name = "test", |
33 | - g_string_append_printf(str, "%s.%s=%s", type, | 26 | .instance_size = sizeof(BDRVTestState), |
34 | - prop->name, prop->type); | 27 | @@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_test = { |
35 | + g_string_append_printf(str, " %s=<%s>", prop->name, prop->type); | 28 | .bdrv_co_drain_end = bdrv_test_co_drain_end, |
36 | if (prop->description) { | 29 | |
37 | + if (str->len < 24) { | 30 | .bdrv_child_perm = bdrv_test_child_perm, |
38 | + g_string_append_printf(str, "%*s", 24 - (int)str->len, ""); | 31 | + |
39 | + } | 32 | + .bdrv_change_backing_file = bdrv_test_change_backing_file, |
40 | g_string_append_printf(str, " - %s", prop->description); | 33 | }; |
41 | } | 34 | |
42 | g_ptr_array_add(array, g_string_free(str, false)); | 35 | static void aio_ret_cb(void *opaque, int ret) |
43 | } | 36 | @@ -XXX,XX +XXX,XX @@ static void test_blockjob_commit_by_drained_end(void) |
44 | g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0); | 37 | bdrv_unref(bs_child); |
45 | + if (array->len > 0) { | 38 | } |
46 | + printf("%s options:\n", type); | 39 | |
47 | + } else { | 40 | + |
48 | + printf("There are no options for %s.\n", type); | 41 | +typedef struct TestSimpleBlockJob { |
42 | + BlockJob common; | ||
43 | + bool should_complete; | ||
44 | + bool *did_complete; | ||
45 | +} TestSimpleBlockJob; | ||
46 | + | ||
47 | +static int coroutine_fn test_simple_job_run(Job *job, Error **errp) | ||
48 | +{ | ||
49 | + TestSimpleBlockJob *s = container_of(job, TestSimpleBlockJob, common.job); | ||
50 | + | ||
51 | + while (!s->should_complete) { | ||
52 | + job_sleep_ns(job, 0); | ||
53 | + } | ||
54 | + | ||
55 | + return 0; | ||
56 | +} | ||
57 | + | ||
58 | +static void test_simple_job_clean(Job *job) | ||
59 | +{ | ||
60 | + TestSimpleBlockJob *s = container_of(job, TestSimpleBlockJob, common.job); | ||
61 | + *s->did_complete = true; | ||
62 | +} | ||
63 | + | ||
64 | +static const BlockJobDriver test_simple_job_driver = { | ||
65 | + .job_driver = { | ||
66 | + .instance_size = sizeof(TestSimpleBlockJob), | ||
67 | + .free = block_job_free, | ||
68 | + .user_resume = block_job_user_resume, | ||
69 | + .drain = block_job_drain, | ||
70 | + .run = test_simple_job_run, | ||
71 | + .clean = test_simple_job_clean, | ||
72 | + }, | ||
73 | +}; | ||
74 | + | ||
75 | +static int drop_intermediate_poll_update_filename(BdrvChild *child, | ||
76 | + BlockDriverState *new_base, | ||
77 | + const char *filename, | ||
78 | + Error **errp) | ||
79 | +{ | ||
80 | + /* | ||
81 | + * We are free to poll here, which may change the block graph, if | ||
82 | + * it is not drained. | ||
83 | + */ | ||
84 | + | ||
85 | + /* If the job is not drained: Complete it, schedule job_exit() */ | ||
86 | + aio_poll(qemu_get_current_aio_context(), false); | ||
87 | + /* If the job is not drained: Run job_exit(), finish the job */ | ||
88 | + aio_poll(qemu_get_current_aio_context(), false); | ||
89 | + | ||
90 | + return 0; | ||
91 | +} | ||
92 | + | ||
93 | +/** | ||
94 | + * Test a poll in the midst of bdrv_drop_intermediate(). | ||
95 | + * | ||
96 | + * bdrv_drop_intermediate() calls BdrvChildRole.update_filename(), | ||
97 | + * which can yield or poll. This may lead to graph changes, unless | ||
98 | + * the whole subtree in question is drained. | ||
99 | + * | ||
100 | + * We test this on the following graph: | ||
101 | + * | ||
102 | + * Job | ||
103 | + * | ||
104 | + * | | ||
105 | + * job-node | ||
106 | + * | | ||
107 | + * v | ||
108 | + * | ||
109 | + * job-node | ||
110 | + * | ||
111 | + * | | ||
112 | + * backing | ||
113 | + * | | ||
114 | + * v | ||
115 | + * | ||
116 | + * node-2 --chain--> node-1 --chain--> node-0 | ||
117 | + * | ||
118 | + * We drop node-1 with bdrv_drop_intermediate(top=node-1, base=node-0). | ||
119 | + * | ||
120 | + * This first updates node-2's backing filename by invoking | ||
121 | + * drop_intermediate_poll_update_filename(), which polls twice. This | ||
122 | + * causes the job to finish, which in turns causes the job-node to be | ||
123 | + * deleted. | ||
124 | + * | ||
125 | + * bdrv_drop_intermediate() uses a QLIST_FOREACH_SAFE() loop, so it | ||
126 | + * already has a pointer to the BdrvChild edge between job-node and | ||
127 | + * node-1. When it tries to handle that edge, we probably get a | ||
128 | + * segmentation fault because the object no longer exists. | ||
129 | + * | ||
130 | + * | ||
131 | + * The solution is for bdrv_drop_intermediate() to drain top's | ||
132 | + * subtree. This prevents graph changes from happening just because | ||
133 | + * BdrvChildRole.update_filename() yields or polls. Thus, the block | ||
134 | + * job is paused during that drained section and must finish before or | ||
135 | + * after. | ||
136 | + * | ||
137 | + * (In addition, bdrv_replace_child() must keep the job paused.) | ||
138 | + */ | ||
139 | +static void test_drop_intermediate_poll(void) | ||
140 | +{ | ||
141 | + static BdrvChildRole chain_child_role; | ||
142 | + BlockDriverState *chain[3]; | ||
143 | + TestSimpleBlockJob *job; | ||
144 | + BlockDriverState *job_node; | ||
145 | + bool job_has_completed = false; | ||
146 | + int i; | ||
147 | + int ret; | ||
148 | + | ||
149 | + chain_child_role = child_backing; | ||
150 | + chain_child_role.update_filename = drop_intermediate_poll_update_filename; | ||
151 | + | ||
152 | + for (i = 0; i < 3; i++) { | ||
153 | + char name[32]; | ||
154 | + snprintf(name, 32, "node-%i", i); | ||
155 | + | ||
156 | + chain[i] = bdrv_new_open_driver(&bdrv_test, name, 0, &error_abort); | ||
157 | + } | ||
158 | + | ||
159 | + job_node = bdrv_new_open_driver(&bdrv_test, "job-node", BDRV_O_RDWR, | ||
160 | + &error_abort); | ||
161 | + bdrv_set_backing_hd(job_node, chain[1], &error_abort); | ||
162 | + | ||
163 | + /* | ||
164 | + * Establish the chain last, so the chain links are the first | ||
165 | + * elements in the BDS.parents lists | ||
166 | + */ | ||
167 | + for (i = 0; i < 3; i++) { | ||
168 | + if (i) { | ||
169 | + /* Takes the reference to chain[i - 1] */ | ||
170 | + chain[i]->backing = bdrv_attach_child(chain[i], chain[i - 1], | ||
171 | + "chain", &chain_child_role, | ||
172 | + &error_abort); | ||
49 | + } | 173 | + } |
50 | for (i = 0; i < array->len; i++) { | 174 | + } |
51 | printf("%s\n", (char *)array->pdata[i]); | 175 | + |
52 | } | 176 | + job = block_job_create("job", &test_simple_job_driver, NULL, job_node, |
177 | + 0, BLK_PERM_ALL, 0, 0, NULL, NULL, &error_abort); | ||
178 | + | ||
179 | + /* The job has a reference now */ | ||
180 | + bdrv_unref(job_node); | ||
181 | + | ||
182 | + job->did_complete = &job_has_completed; | ||
183 | + | ||
184 | + job_start(&job->common.job); | ||
185 | + job->should_complete = true; | ||
186 | + | ||
187 | + g_assert(!job_has_completed); | ||
188 | + ret = bdrv_drop_intermediate(chain[1], chain[0], NULL); | ||
189 | + g_assert(ret == 0); | ||
190 | + g_assert(job_has_completed); | ||
191 | + | ||
192 | + bdrv_unref(chain[2]); | ||
193 | +} | ||
194 | + | ||
195 | int main(int argc, char **argv) | ||
196 | { | ||
197 | int ret; | ||
198 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | ||
199 | g_test_add_func("/bdrv-drain/blockjob/commit_by_drained_end", | ||
200 | test_blockjob_commit_by_drained_end); | ||
201 | |||
202 | + g_test_add_func("/bdrv-drain/bdrv_drop_intermediate/poll", | ||
203 | + test_drop_intermediate_poll); | ||
204 | + | ||
205 | ret = g_test_run(); | ||
206 | qemu_event_destroy(&done_event); | ||
207 | return ret; | ||
53 | -- | 208 | -- |
54 | 2.19.1 | 209 | 2.20.1 |
55 | 210 | ||
56 | 211 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | 1 | From: Max Reitz <mreitz@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Following the example of qemu_opts_print_help(), indent all entries in | 3 | Add a test for what happens when you call bdrv_replace_child_noperm() |
4 | the list of character devices. | 4 | for various drain situations ({old,new} child {drained,not drained}). |
5 | |||
6 | Most importantly, if both the old and the new child are drained, the | ||
7 | parent must not be undrained at any point. | ||
5 | 8 | ||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 9 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
7 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | ||
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
9 | --- | 11 | --- |
10 | chardev/char.c | 2 +- | 12 | tests/test-bdrv-drain.c | 308 ++++++++++++++++++++++++++++++++++++++++ |
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | 13 | 1 file changed, 308 insertions(+) |
12 | 14 | ||
13 | diff --git a/chardev/char.c b/chardev/char.c | 15 | diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/chardev/char.c | 17 | --- a/tests/test-bdrv-drain.c |
16 | +++ b/chardev/char.c | 18 | +++ b/tests/test-bdrv-drain.c |
17 | @@ -XXX,XX +XXX,XX @@ help_string_append(const char *name, void *opaque) | 19 | @@ -XXX,XX +XXX,XX @@ static void test_drop_intermediate_poll(void) |
20 | bdrv_unref(chain[2]); | ||
21 | } | ||
22 | |||
23 | + | ||
24 | +typedef struct BDRVReplaceTestState { | ||
25 | + bool was_drained; | ||
26 | + bool was_undrained; | ||
27 | + bool has_read; | ||
28 | + | ||
29 | + int drain_count; | ||
30 | + | ||
31 | + bool yield_before_read; | ||
32 | + Coroutine *io_co; | ||
33 | + Coroutine *drain_co; | ||
34 | +} BDRVReplaceTestState; | ||
35 | + | ||
36 | +static void bdrv_replace_test_close(BlockDriverState *bs) | ||
37 | +{ | ||
38 | +} | ||
39 | + | ||
40 | +/** | ||
41 | + * If @bs has a backing file: | ||
42 | + * Yield if .yield_before_read is true (and wait for drain_begin to | ||
43 | + * wake us up). | ||
44 | + * Forward the read to bs->backing. Set .has_read to true. | ||
45 | + * If drain_begin has woken us, wake it in turn. | ||
46 | + * | ||
47 | + * Otherwise: | ||
48 | + * Set .has_read to true and return success. | ||
49 | + */ | ||
50 | +static int coroutine_fn bdrv_replace_test_co_preadv(BlockDriverState *bs, | ||
51 | + uint64_t offset, | ||
52 | + uint64_t bytes, | ||
53 | + QEMUIOVector *qiov, | ||
54 | + int flags) | ||
55 | +{ | ||
56 | + BDRVReplaceTestState *s = bs->opaque; | ||
57 | + | ||
58 | + if (bs->backing) { | ||
59 | + int ret; | ||
60 | + | ||
61 | + g_assert(!s->drain_count); | ||
62 | + | ||
63 | + s->io_co = qemu_coroutine_self(); | ||
64 | + if (s->yield_before_read) { | ||
65 | + s->yield_before_read = false; | ||
66 | + qemu_coroutine_yield(); | ||
67 | + } | ||
68 | + s->io_co = NULL; | ||
69 | + | ||
70 | + ret = bdrv_preadv(bs->backing, offset, qiov); | ||
71 | + s->has_read = true; | ||
72 | + | ||
73 | + /* Wake up drain_co if it runs */ | ||
74 | + if (s->drain_co) { | ||
75 | + aio_co_wake(s->drain_co); | ||
76 | + } | ||
77 | + | ||
78 | + return ret; | ||
79 | + } | ||
80 | + | ||
81 | + s->has_read = true; | ||
82 | + return 0; | ||
83 | +} | ||
84 | + | ||
85 | +/** | ||
86 | + * If .drain_count is 0, wake up .io_co if there is one; and set | ||
87 | + * .was_drained. | ||
88 | + * Increment .drain_count. | ||
89 | + */ | ||
90 | +static void coroutine_fn bdrv_replace_test_co_drain_begin(BlockDriverState *bs) | ||
91 | +{ | ||
92 | + BDRVReplaceTestState *s = bs->opaque; | ||
93 | + | ||
94 | + if (!s->drain_count) { | ||
95 | + /* Keep waking io_co up until it is done */ | ||
96 | + s->drain_co = qemu_coroutine_self(); | ||
97 | + while (s->io_co) { | ||
98 | + aio_co_wake(s->io_co); | ||
99 | + s->io_co = NULL; | ||
100 | + qemu_coroutine_yield(); | ||
101 | + } | ||
102 | + s->drain_co = NULL; | ||
103 | + | ||
104 | + s->was_drained = true; | ||
105 | + } | ||
106 | + s->drain_count++; | ||
107 | +} | ||
108 | + | ||
109 | +/** | ||
110 | + * Reduce .drain_count, set .was_undrained once it reaches 0. | ||
111 | + * If .drain_count reaches 0 and the node has a backing file, issue a | ||
112 | + * read request. | ||
113 | + */ | ||
114 | +static void coroutine_fn bdrv_replace_test_co_drain_end(BlockDriverState *bs) | ||
115 | +{ | ||
116 | + BDRVReplaceTestState *s = bs->opaque; | ||
117 | + | ||
118 | + g_assert(s->drain_count > 0); | ||
119 | + if (!--s->drain_count) { | ||
120 | + int ret; | ||
121 | + | ||
122 | + s->was_undrained = true; | ||
123 | + | ||
124 | + if (bs->backing) { | ||
125 | + char data; | ||
126 | + QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, &data, 1); | ||
127 | + | ||
128 | + /* Queue a read request post-drain */ | ||
129 | + ret = bdrv_replace_test_co_preadv(bs, 0, 1, &qiov, 0); | ||
130 | + g_assert(ret >= 0); | ||
131 | + } | ||
132 | + } | ||
133 | +} | ||
134 | + | ||
135 | +static BlockDriver bdrv_replace_test = { | ||
136 | + .format_name = "replace_test", | ||
137 | + .instance_size = sizeof(BDRVReplaceTestState), | ||
138 | + | ||
139 | + .bdrv_close = bdrv_replace_test_close, | ||
140 | + .bdrv_co_preadv = bdrv_replace_test_co_preadv, | ||
141 | + | ||
142 | + .bdrv_co_drain_begin = bdrv_replace_test_co_drain_begin, | ||
143 | + .bdrv_co_drain_end = bdrv_replace_test_co_drain_end, | ||
144 | + | ||
145 | + .bdrv_child_perm = bdrv_format_default_perms, | ||
146 | +}; | ||
147 | + | ||
148 | +static void coroutine_fn test_replace_child_mid_drain_read_co(void *opaque) | ||
149 | +{ | ||
150 | + int ret; | ||
151 | + char data; | ||
152 | + | ||
153 | + ret = blk_co_pread(opaque, 0, 1, &data, 0); | ||
154 | + g_assert(ret >= 0); | ||
155 | +} | ||
156 | + | ||
157 | +/** | ||
158 | + * We test two things: | ||
159 | + * (1) bdrv_replace_child_noperm() must not undrain the parent if both | ||
160 | + * children are drained. | ||
161 | + * (2) bdrv_replace_child_noperm() must never flush I/O requests to a | ||
162 | + * drained child. If the old child is drained, it must flush I/O | ||
163 | + * requests after the new one has been attached. If the new child | ||
164 | + * is drained, it must flush I/O requests before the old one is | ||
165 | + * detached. | ||
166 | + * | ||
167 | + * To do so, we create one parent node and two child nodes; then | ||
168 | + * attach one of the children (old_child_bs) to the parent, then | ||
169 | + * drain both old_child_bs and new_child_bs according to | ||
170 | + * old_drain_count and new_drain_count, respectively, and finally | ||
171 | + * we invoke bdrv_replace_node() to replace old_child_bs by | ||
172 | + * new_child_bs. | ||
173 | + * | ||
174 | + * The test block driver we use here (bdrv_replace_test) has a read | ||
175 | + * function that: | ||
176 | + * - For the parent node, can optionally yield, and then forwards the | ||
177 | + * read to bdrv_preadv(), | ||
178 | + * - For the child node, just returns immediately. | ||
179 | + * | ||
180 | + * If the read yields, the drain_begin function will wake it up. | ||
181 | + * | ||
182 | + * The drain_end function issues a read on the parent once it is fully | ||
183 | + * undrained (which simulates requests starting to come in again). | ||
184 | + */ | ||
185 | +static void do_test_replace_child_mid_drain(int old_drain_count, | ||
186 | + int new_drain_count) | ||
187 | +{ | ||
188 | + BlockBackend *parent_blk; | ||
189 | + BlockDriverState *parent_bs; | ||
190 | + BlockDriverState *old_child_bs, *new_child_bs; | ||
191 | + BDRVReplaceTestState *parent_s; | ||
192 | + BDRVReplaceTestState *old_child_s, *new_child_s; | ||
193 | + Coroutine *io_co; | ||
194 | + int i; | ||
195 | + | ||
196 | + parent_bs = bdrv_new_open_driver(&bdrv_replace_test, "parent", 0, | ||
197 | + &error_abort); | ||
198 | + parent_s = parent_bs->opaque; | ||
199 | + | ||
200 | + parent_blk = blk_new(qemu_get_aio_context(), | ||
201 | + BLK_PERM_CONSISTENT_READ, BLK_PERM_ALL); | ||
202 | + blk_insert_bs(parent_blk, parent_bs, &error_abort); | ||
203 | + | ||
204 | + old_child_bs = bdrv_new_open_driver(&bdrv_replace_test, "old-child", 0, | ||
205 | + &error_abort); | ||
206 | + new_child_bs = bdrv_new_open_driver(&bdrv_replace_test, "new-child", 0, | ||
207 | + &error_abort); | ||
208 | + old_child_s = old_child_bs->opaque; | ||
209 | + new_child_s = new_child_bs->opaque; | ||
210 | + | ||
211 | + /* So that we can read something */ | ||
212 | + parent_bs->total_sectors = 1; | ||
213 | + old_child_bs->total_sectors = 1; | ||
214 | + new_child_bs->total_sectors = 1; | ||
215 | + | ||
216 | + bdrv_ref(old_child_bs); | ||
217 | + parent_bs->backing = bdrv_attach_child(parent_bs, old_child_bs, "child", | ||
218 | + &child_backing, &error_abort); | ||
219 | + | ||
220 | + for (i = 0; i < old_drain_count; i++) { | ||
221 | + bdrv_drained_begin(old_child_bs); | ||
222 | + } | ||
223 | + for (i = 0; i < new_drain_count; i++) { | ||
224 | + bdrv_drained_begin(new_child_bs); | ||
225 | + } | ||
226 | + | ||
227 | + if (!old_drain_count) { | ||
228 | + /* | ||
229 | + * Start a read operation that will yield, so it will not | ||
230 | + * complete before the node is drained. | ||
231 | + */ | ||
232 | + parent_s->yield_before_read = true; | ||
233 | + io_co = qemu_coroutine_create(test_replace_child_mid_drain_read_co, | ||
234 | + parent_blk); | ||
235 | + qemu_coroutine_enter(io_co); | ||
236 | + } | ||
237 | + | ||
238 | + /* If we have started a read operation, it should have yielded */ | ||
239 | + g_assert(!parent_s->has_read); | ||
240 | + | ||
241 | + /* Reset drained status so we can see what bdrv_replace_node() does */ | ||
242 | + parent_s->was_drained = false; | ||
243 | + parent_s->was_undrained = false; | ||
244 | + | ||
245 | + g_assert(parent_bs->quiesce_counter == old_drain_count); | ||
246 | + bdrv_replace_node(old_child_bs, new_child_bs, &error_abort); | ||
247 | + g_assert(parent_bs->quiesce_counter == new_drain_count); | ||
248 | + | ||
249 | + if (!old_drain_count && !new_drain_count) { | ||
250 | + /* | ||
251 | + * From undrained to undrained drains and undrains the parent, | ||
252 | + * because bdrv_replace_node() contains a drained section for | ||
253 | + * @old_child_bs. | ||
254 | + */ | ||
255 | + g_assert(parent_s->was_drained && parent_s->was_undrained); | ||
256 | + } else if (!old_drain_count && new_drain_count) { | ||
257 | + /* | ||
258 | + * From undrained to drained should drain the parent and keep | ||
259 | + * it that way. | ||
260 | + */ | ||
261 | + g_assert(parent_s->was_drained && !parent_s->was_undrained); | ||
262 | + } else if (old_drain_count && !new_drain_count) { | ||
263 | + /* | ||
264 | + * From drained to undrained should undrain the parent and | ||
265 | + * keep it that way. | ||
266 | + */ | ||
267 | + g_assert(!parent_s->was_drained && parent_s->was_undrained); | ||
268 | + } else /* if (old_drain_count && new_drain_count) */ { | ||
269 | + /* | ||
270 | + * From drained to drained must not undrain the parent at any | ||
271 | + * point | ||
272 | + */ | ||
273 | + g_assert(!parent_s->was_drained && !parent_s->was_undrained); | ||
274 | + } | ||
275 | + | ||
276 | + if (!old_drain_count || !new_drain_count) { | ||
277 | + /* | ||
278 | + * If !old_drain_count, we have started a read request before | ||
279 | + * bdrv_replace_node(). If !new_drain_count, the parent must | ||
280 | + * have been undrained at some point, and | ||
281 | + * bdrv_replace_test_co_drain_end() starts a read request | ||
282 | + * then. | ||
283 | + */ | ||
284 | + g_assert(parent_s->has_read); | ||
285 | + } else { | ||
286 | + /* | ||
287 | + * If the parent was never undrained, there is no way to start | ||
288 | + * a read request. | ||
289 | + */ | ||
290 | + g_assert(!parent_s->has_read); | ||
291 | + } | ||
292 | + | ||
293 | + /* A drained child must have not received any request */ | ||
294 | + g_assert(!(old_drain_count && old_child_s->has_read)); | ||
295 | + g_assert(!(new_drain_count && new_child_s->has_read)); | ||
296 | + | ||
297 | + for (i = 0; i < new_drain_count; i++) { | ||
298 | + bdrv_drained_end(new_child_bs); | ||
299 | + } | ||
300 | + for (i = 0; i < old_drain_count; i++) { | ||
301 | + bdrv_drained_end(old_child_bs); | ||
302 | + } | ||
303 | + | ||
304 | + /* | ||
305 | + * By now, bdrv_replace_test_co_drain_end() must have been called | ||
306 | + * at some point while the new child was attached to the parent. | ||
307 | + */ | ||
308 | + g_assert(parent_s->has_read); | ||
309 | + g_assert(new_child_s->has_read); | ||
310 | + | ||
311 | + blk_unref(parent_blk); | ||
312 | + bdrv_unref(parent_bs); | ||
313 | + bdrv_unref(old_child_bs); | ||
314 | + bdrv_unref(new_child_bs); | ||
315 | +} | ||
316 | + | ||
317 | +static void test_replace_child_mid_drain(void) | ||
318 | +{ | ||
319 | + int old_drain_count, new_drain_count; | ||
320 | + | ||
321 | + for (old_drain_count = 0; old_drain_count < 2; old_drain_count++) { | ||
322 | + for (new_drain_count = 0; new_drain_count < 2; new_drain_count++) { | ||
323 | + do_test_replace_child_mid_drain(old_drain_count, new_drain_count); | ||
324 | + } | ||
325 | + } | ||
326 | +} | ||
327 | + | ||
328 | int main(int argc, char **argv) | ||
18 | { | 329 | { |
19 | GString *str = opaque; | 330 | int ret; |
20 | 331 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | |
21 | - g_string_append_printf(str, "\n%s", name); | 332 | g_test_add_func("/bdrv-drain/bdrv_drop_intermediate/poll", |
22 | + g_string_append_printf(str, "\n %s", name); | 333 | test_drop_intermediate_poll); |
23 | } | 334 | |
24 | 335 | + g_test_add_func("/bdrv-drain/replace_child/mid-drain", | |
25 | static const char *chardev_alias_translate(const char *name) | 336 | + test_replace_child_mid_drain); |
337 | + | ||
338 | ret = g_test_run(); | ||
339 | qemu_event_destroy(&done_event); | ||
340 | return ret; | ||
26 | -- | 341 | -- |
27 | 2.19.1 | 342 | 2.20.1 |
28 | 343 | ||
29 | 344 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | 1 | From: Max Reitz <mreitz@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Just like in qemu_opts_print_help(), print the device name as a caption | 3 | We already have 030 for that in general, but this tests very specific |
4 | instead of on every single line, indent all options, add angle brackets | 4 | cases of both jobs finishing concurrently. |
5 | around types, and align the descriptions after 24 characters. Also, | ||
6 | separate the descriptions with " - " instead of putting them in | ||
7 | parentheses, because that is what we do everywhere else. This does look | ||
8 | a bit funny here because basically all bits have the description | ||
9 | "on/off", but funny does not mean it is less readable. | ||
10 | 5 | ||
11 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 6 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
12 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | ||
13 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 7 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
14 | --- | 8 | --- |
15 | qdev-monitor.c | 13 +++++++++++-- | 9 | tests/qemu-iotests/258 | 163 +++++++++++++++++++++++++++++++++++++ |
16 | 1 file changed, 11 insertions(+), 2 deletions(-) | 10 | tests/qemu-iotests/258.out | 33 ++++++++ |
17 | 11 | tests/qemu-iotests/group | 1 + | |
18 | diff --git a/qdev-monitor.c b/qdev-monitor.c | 12 | 3 files changed, 197 insertions(+) |
13 | create mode 100755 tests/qemu-iotests/258 | ||
14 | create mode 100644 tests/qemu-iotests/258.out | ||
15 | |||
16 | diff --git a/tests/qemu-iotests/258 b/tests/qemu-iotests/258 | ||
17 | new file mode 100755 | ||
18 | index XXXXXXX..XXXXXXX | ||
19 | --- /dev/null | ||
20 | +++ b/tests/qemu-iotests/258 | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | +#!/usr/bin/env python | ||
23 | +# | ||
24 | +# Very specific tests for adjacent commit/stream block jobs | ||
25 | +# | ||
26 | +# Copyright (C) 2019 Red Hat, Inc. | ||
27 | +# | ||
28 | +# This program is free software; you can redistribute it and/or modify | ||
29 | +# it under the terms of the GNU General Public License as published by | ||
30 | +# the Free Software Foundation; either version 2 of the License, or | ||
31 | +# (at your option) any later version. | ||
32 | +# | ||
33 | +# This program is distributed in the hope that it will be useful, | ||
34 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
35 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
36 | +# GNU General Public License for more details. | ||
37 | +# | ||
38 | +# You should have received a copy of the GNU General Public License | ||
39 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
40 | +# | ||
41 | +# Creator/Owner: Max Reitz <mreitz@redhat.com> | ||
42 | + | ||
43 | +import iotests | ||
44 | +from iotests import log, qemu_img, qemu_io_silent, \ | ||
45 | + filter_qmp_testfiles, filter_qmp_imgfmt | ||
46 | + | ||
47 | +# Need backing file and change-backing-file support | ||
48 | +iotests.verify_image_format(supported_fmts=['qcow2', 'qed']) | ||
49 | +iotests.verify_platform(['linux']) | ||
50 | + | ||
51 | + | ||
52 | +# Returns a node for blockdev-add | ||
53 | +def node(node_name, path, backing=None, fmt=None, throttle=None): | ||
54 | + if fmt is None: | ||
55 | + fmt = iotests.imgfmt | ||
56 | + | ||
57 | + res = { | ||
58 | + 'node-name': node_name, | ||
59 | + 'driver': fmt, | ||
60 | + 'file': { | ||
61 | + 'driver': 'file', | ||
62 | + 'filename': path | ||
63 | + } | ||
64 | + } | ||
65 | + | ||
66 | + if backing is not None: | ||
67 | + res['backing'] = backing | ||
68 | + | ||
69 | + if throttle: | ||
70 | + res['file'] = { | ||
71 | + 'driver': 'throttle', | ||
72 | + 'throttle-group': throttle, | ||
73 | + 'file': res['file'] | ||
74 | + } | ||
75 | + | ||
76 | + return res | ||
77 | + | ||
78 | +# Finds a node in the debug block graph | ||
79 | +def find_graph_node(graph, node_id): | ||
80 | + return next(node for node in graph['nodes'] if node['id'] == node_id) | ||
81 | + | ||
82 | + | ||
83 | +def test_concurrent_finish(write_to_stream_node): | ||
84 | + log('') | ||
85 | + log('=== Commit and stream finish concurrently (letting %s write) ===' % \ | ||
86 | + ('stream' if write_to_stream_node else 'commit')) | ||
87 | + log('') | ||
88 | + | ||
89 | + # All chosen in such a way that when the commit job wants to | ||
90 | + # finish, it polls and thus makes stream finish concurrently -- | ||
91 | + # and the other way around, depending on whether the commit job | ||
92 | + # is finalized before stream completes or not. | ||
93 | + | ||
94 | + with iotests.FilePath('node4.img') as node4_path, \ | ||
95 | + iotests.FilePath('node3.img') as node3_path, \ | ||
96 | + iotests.FilePath('node2.img') as node2_path, \ | ||
97 | + iotests.FilePath('node1.img') as node1_path, \ | ||
98 | + iotests.FilePath('node0.img') as node0_path, \ | ||
99 | + iotests.VM() as vm: | ||
100 | + | ||
101 | + # It is important to use raw for the base layer (so that | ||
102 | + # permissions are just handed through to the protocol layer) | ||
103 | + assert qemu_img('create', '-f', 'raw', node0_path, '64M') == 0 | ||
104 | + | ||
105 | + stream_throttle=None | ||
106 | + commit_throttle=None | ||
107 | + | ||
108 | + for path in [node1_path, node2_path, node3_path, node4_path]: | ||
109 | + assert qemu_img('create', '-f', iotests.imgfmt, path, '64M') == 0 | ||
110 | + | ||
111 | + if write_to_stream_node: | ||
112 | + # This is what (most of the time) makes commit finish | ||
113 | + # earlier and then pull in stream | ||
114 | + assert qemu_io_silent(node2_path, | ||
115 | + '-c', 'write %iK 64K' % (65536 - 192), | ||
116 | + '-c', 'write %iK 64K' % (65536 - 64)) == 0 | ||
117 | + | ||
118 | + stream_throttle='tg' | ||
119 | + else: | ||
120 | + # And this makes stream finish earlier | ||
121 | + assert qemu_io_silent(node1_path, | ||
122 | + '-c', 'write %iK 64K' % (65536 - 64)) == 0 | ||
123 | + | ||
124 | + commit_throttle='tg' | ||
125 | + | ||
126 | + vm.launch() | ||
127 | + | ||
128 | + vm.qmp_log('object-add', | ||
129 | + qom_type='throttle-group', | ||
130 | + id='tg', | ||
131 | + props={ | ||
132 | + 'x-iops-write': 1, | ||
133 | + 'x-iops-write-max': 1 | ||
134 | + }) | ||
135 | + | ||
136 | + vm.qmp_log('blockdev-add', | ||
137 | + filters=[filter_qmp_testfiles, filter_qmp_imgfmt], | ||
138 | + **node('node4', node4_path, throttle=stream_throttle, | ||
139 | + backing=node('node3', node3_path, | ||
140 | + backing=node('node2', node2_path, | ||
141 | + backing=node('node1', node1_path, | ||
142 | + backing=node('node0', node0_path, throttle=commit_throttle, | ||
143 | + fmt='raw')))))) | ||
144 | + | ||
145 | + vm.qmp_log('block-commit', | ||
146 | + job_id='commit', | ||
147 | + device='node4', | ||
148 | + filter_node_name='commit-filter', | ||
149 | + top_node='node1', | ||
150 | + base_node='node0', | ||
151 | + auto_finalize=False) | ||
152 | + | ||
153 | + vm.qmp_log('block-stream', | ||
154 | + job_id='stream', | ||
155 | + device='node3', | ||
156 | + base_node='commit-filter') | ||
157 | + | ||
158 | + if write_to_stream_node: | ||
159 | + vm.run_job('commit', auto_finalize=False, auto_dismiss=True) | ||
160 | + vm.run_job('stream', auto_finalize=True, auto_dismiss=True) | ||
161 | + else: | ||
162 | + # No, the jobs do not really finish concurrently here, | ||
163 | + # the stream job does complete strictly before commit. | ||
164 | + # But still, this is close enough for what we want to | ||
165 | + # test. | ||
166 | + vm.run_job('stream', auto_finalize=True, auto_dismiss=True) | ||
167 | + vm.run_job('commit', auto_finalize=False, auto_dismiss=True) | ||
168 | + | ||
169 | + # Assert that the backing node of node3 is node 0 now | ||
170 | + graph = vm.qmp('x-debug-query-block-graph')['return'] | ||
171 | + for edge in graph['edges']: | ||
172 | + if edge['name'] == 'backing' and \ | ||
173 | + find_graph_node(graph, edge['parent'])['name'] == 'node3': | ||
174 | + assert find_graph_node(graph, edge['child'])['name'] == 'node0' | ||
175 | + break | ||
176 | + | ||
177 | + | ||
178 | +def main(): | ||
179 | + log('Running tests:') | ||
180 | + test_concurrent_finish(True) | ||
181 | + test_concurrent_finish(False) | ||
182 | + | ||
183 | +if __name__ == '__main__': | ||
184 | + main() | ||
185 | diff --git a/tests/qemu-iotests/258.out b/tests/qemu-iotests/258.out | ||
186 | new file mode 100644 | ||
187 | index XXXXXXX..XXXXXXX | ||
188 | --- /dev/null | ||
189 | +++ b/tests/qemu-iotests/258.out | ||
190 | @@ -XXX,XX +XXX,XX @@ | ||
191 | +Running tests: | ||
192 | + | ||
193 | +=== Commit and stream finish concurrently (letting stream write) === | ||
194 | + | ||
195 | +{"execute": "object-add", "arguments": {"id": "tg", "props": {"x-iops-write": 1, "x-iops-write-max": 1}, "qom-type": "throttle-group"}} | ||
196 | +{"return": {}} | ||
197 | +{"execute": "blockdev-add", "arguments": {"backing": {"backing": {"backing": {"backing": {"driver": "raw", "file": {"driver": "file", "filename": "TEST_DIR/PID-node0.img"}, "node-name": "node0"}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/PID-node1.img"}, "node-name": "node1"}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/PID-node2.img"}, "node-name": "node2"}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/PID-node3.img"}, "node-name": "node3"}, "driver": "IMGFMT", "file": {"driver": "throttle", "file": {"driver": "file", "filename": "TEST_DIR/PID-node4.img"}, "throttle-group": "tg"}, "node-name": "node4"}} | ||
198 | +{"return": {}} | ||
199 | +{"execute": "block-commit", "arguments": {"auto-finalize": false, "base-node": "node0", "device": "node4", "filter-node-name": "commit-filter", "job-id": "commit", "top-node": "node1"}} | ||
200 | +{"return": {}} | ||
201 | +{"execute": "block-stream", "arguments": {"base-node": "commit-filter", "device": "node3", "job-id": "stream"}} | ||
202 | +{"return": {}} | ||
203 | +{"execute": "job-finalize", "arguments": {"id": "commit"}} | ||
204 | +{"return": {}} | ||
205 | +{"data": {"id": "commit", "type": "commit"}, "event": "BLOCK_JOB_PENDING", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} | ||
206 | +{"data": {"device": "commit", "len": 67108864, "offset": 67108864, "speed": 0, "type": "commit"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} | ||
207 | +{"data": {"device": "stream", "len": 67108864, "offset": 67108864, "speed": 0, "type": "stream"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} | ||
208 | + | ||
209 | +=== Commit and stream finish concurrently (letting commit write) === | ||
210 | + | ||
211 | +{"execute": "object-add", "arguments": {"id": "tg", "props": {"x-iops-write": 1, "x-iops-write-max": 1}, "qom-type": "throttle-group"}} | ||
212 | +{"return": {}} | ||
213 | +{"execute": "blockdev-add", "arguments": {"backing": {"backing": {"backing": {"backing": {"driver": "raw", "file": {"driver": "throttle", "file": {"driver": "file", "filename": "TEST_DIR/PID-node0.img"}, "throttle-group": "tg"}, "node-name": "node0"}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/PID-node1.img"}, "node-name": "node1"}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/PID-node2.img"}, "node-name": "node2"}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/PID-node3.img"}, "node-name": "node3"}, "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/PID-node4.img"}, "node-name": "node4"}} | ||
214 | +{"return": {}} | ||
215 | +{"execute": "block-commit", "arguments": {"auto-finalize": false, "base-node": "node0", "device": "node4", "filter-node-name": "commit-filter", "job-id": "commit", "top-node": "node1"}} | ||
216 | +{"return": {}} | ||
217 | +{"execute": "block-stream", "arguments": {"base-node": "commit-filter", "device": "node3", "job-id": "stream"}} | ||
218 | +{"return": {}} | ||
219 | +{"data": {"device": "stream", "len": 67108864, "offset": 67108864, "speed": 0, "type": "stream"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} | ||
220 | +{"execute": "job-finalize", "arguments": {"id": "commit"}} | ||
221 | +{"return": {}} | ||
222 | +{"data": {"id": "commit", "type": "commit"}, "event": "BLOCK_JOB_PENDING", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} | ||
223 | +{"data": {"device": "commit", "len": 67108864, "offset": 67108864, "speed": 0, "type": "commit"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} | ||
224 | diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group | ||
19 | index XXXXXXX..XXXXXXX 100644 | 225 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/qdev-monitor.c | 226 | --- a/tests/qemu-iotests/group |
21 | +++ b/qdev-monitor.c | 227 | +++ b/tests/qemu-iotests/group |
22 | @@ -XXX,XX +XXX,XX @@ int qdev_device_help(QemuOpts *opts) | 228 | @@ -XXX,XX +XXX,XX @@ |
23 | goto error; | 229 | 254 rw backing quick |
24 | } | 230 | 255 rw quick |
25 | 231 | 256 rw quick | |
26 | + if (prop_list) { | 232 | +258 rw quick |
27 | + out_printf("%s options:\n", driver); | 233 | 262 rw quick migration |
28 | + } else { | ||
29 | + out_printf("There are no options for %s.\n", driver); | ||
30 | + } | ||
31 | for (prop = prop_list; prop; prop = prop->next) { | ||
32 | - out_printf("%s.%s=%s", driver, prop->value->name, prop->value->type); | ||
33 | + int len; | ||
34 | + out_printf(" %s=<%s>%n", prop->value->name, prop->value->type, &len); | ||
35 | if (prop->value->has_description) { | ||
36 | - out_printf(" (%s)\n", prop->value->description); | ||
37 | + if (len < 24) { | ||
38 | + out_printf("%*s", 24 - len, ""); | ||
39 | + } | ||
40 | + out_printf(" - %s\n", prop->value->description); | ||
41 | } else { | ||
42 | out_printf("\n"); | ||
43 | } | ||
44 | -- | 234 | -- |
45 | 2.19.1 | 235 | 2.20.1 |
46 | 236 | ||
47 | 237 | diff view generated by jsdifflib |
1 | Some block drivers have traditionally changed their node to read-only | 1 | The functionality offered by blk_pread_unthrottled() goes back to commit |
---|---|---|---|
2 | mode without asking the user. This behaviour has been marked deprecated | 2 | 498e386c584. Then, we couldn't perform I/O throttling with synchronous |
3 | since 2.11, expecting users to provide an explicit read-only=on option. | 3 | requests because timers wouldn't be executed in polling loops. So the |
4 | commit automatically disabled I/O throttling as soon as a synchronous | ||
5 | request was issued. | ||
4 | 6 | ||
5 | Now that we have auto-read-only=on, enable these drivers to make use of | 7 | However, for geometry detection during disk initialisation, we always |
6 | the option. | 8 | used (and still use) synchronous requests even if guest requests use AIO |
9 | later. Geometry detection was not wanted to disable I/O throttling, so | ||
10 | bdrv_pread_unthrottled() was introduced which disabled throttling only | ||
11 | temporarily. | ||
7 | 12 | ||
8 | This is the only use of bdrv_set_read_only(), so we can make it a bit | 13 | All of this isn't necessary any more because we do run timers in polling |
9 | more specific and turn it into a bdrv_apply_auto_read_only() that is | 14 | loop and even synchronous requests are now using coroutine |
10 | more convenient for drivers to use. | 15 | infrastructure internally. For this reason, commit 90c78624f already |
16 | removed the automatic disabling of I/O throttling. | ||
17 | |||
18 | It's time to get rid of the workaround for the removed code, and its | ||
19 | abuse of blk_root_drained_begin()/end(), as well. | ||
11 | 20 | ||
12 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 21 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
13 | Reviewed-by: Eric Blake <eblake@redhat.com> | 22 | Reviewed-by: Max Reitz <mreitz@redhat.com> |
14 | --- | 23 | --- |
15 | include/block/block.h | 3 ++- | 24 | include/sysemu/block-backend.h | 2 -- |
16 | block.c | 42 +++++++++++++++++++++++++++--------------- | 25 | block/block-backend.c | 16 ---------------- |
17 | block/bochs.c | 17 ++++++----------- | 26 | hw/block/hd-geometry.c | 7 +------ |
18 | block/cloop.c | 16 +++++----------- | 27 | 3 files changed, 1 insertion(+), 24 deletions(-) |
19 | block/dmg.c | 16 +++++----------- | ||
20 | block/rbd.c | 15 ++++----------- | ||
21 | block/vvfat.c | 10 ++-------- | ||
22 | 7 files changed, 51 insertions(+), 68 deletions(-) | ||
23 | 28 | ||
24 | diff --git a/include/block/block.h b/include/block/block.h | 29 | diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h |
25 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/block/block.h | 31 | --- a/include/sysemu/block-backend.h |
27 | +++ b/include/block/block.h | 32 | +++ b/include/sysemu/block-backend.h |
28 | @@ -XXX,XX +XXX,XX @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base, | 33 | @@ -XXX,XX +XXX,XX @@ char *blk_get_attached_dev_id(BlockBackend *blk); |
29 | bool bdrv_is_read_only(BlockDriverState *bs); | 34 | BlockBackend *blk_by_dev(void *dev); |
30 | int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, | 35 | BlockBackend *blk_by_qdev_id(const char *id, Error **errp); |
31 | bool ignore_allow_rdw, Error **errp); | 36 | void blk_set_dev_ops(BlockBackend *blk, const BlockDevOps *ops, void *opaque); |
32 | -int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp); | 37 | -int blk_pread_unthrottled(BlockBackend *blk, int64_t offset, uint8_t *buf, |
33 | +int bdrv_apply_auto_read_only(BlockDriverState *bs, const char *errmsg, | 38 | - int bytes); |
34 | + Error **errp); | 39 | int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, |
35 | bool bdrv_is_writable(BlockDriverState *bs); | 40 | unsigned int bytes, QEMUIOVector *qiov, |
36 | bool bdrv_is_sg(BlockDriverState *bs); | 41 | BdrvRequestFlags flags); |
37 | bool bdrv_is_inserted(BlockDriverState *bs); | 42 | diff --git a/block/block-backend.c b/block/block-backend.c |
38 | diff --git a/block.c b/block.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | 43 | index XXXXXXX..XXXXXXX 100644 |
40 | --- a/block.c | 44 | --- a/block/block-backend.c |
41 | +++ b/block.c | 45 | +++ b/block/block-backend.c |
42 | @@ -XXX,XX +XXX,XX @@ int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, | 46 | @@ -XXX,XX +XXX,XX @@ static int blk_prw(BlockBackend *blk, int64_t offset, uint8_t *buf, |
43 | return 0; | 47 | return rwco.ret; |
44 | } | 48 | } |
45 | 49 | ||
46 | -/* TODO Remove (deprecated since 2.11) | 50 | -int blk_pread_unthrottled(BlockBackend *blk, int64_t offset, uint8_t *buf, |
47 | - * Block drivers are not supposed to automatically change bs->read_only. | 51 | - int count) |
48 | - * Instead, they should just check whether they can provide what the user | 52 | -{ |
49 | - * explicitly requested and error out if read-write is requested, but they can | 53 | - int ret; |
50 | - * only provide read-only access. */ | 54 | - |
51 | -int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp) | 55 | - ret = blk_check_byte_request(blk, offset, count); |
52 | +/* | ||
53 | + * Called by a driver that can only provide a read-only image. | ||
54 | + * | ||
55 | + * Returns 0 if the node is already read-only or it could switch the node to | ||
56 | + * read-only because BDRV_O_AUTO_RDONLY is set. | ||
57 | + * | ||
58 | + * Returns -EACCES if the node is read-write and BDRV_O_AUTO_RDONLY is not set | ||
59 | + * or bdrv_can_set_read_only() forbids making the node read-only. If @errmsg | ||
60 | + * is not NULL, it is used as the error message for the Error object. | ||
61 | + */ | ||
62 | +int bdrv_apply_auto_read_only(BlockDriverState *bs, const char *errmsg, | ||
63 | + Error **errp) | ||
64 | { | ||
65 | int ret = 0; | ||
66 | |||
67 | - ret = bdrv_can_set_read_only(bs, read_only, false, errp); | ||
68 | - if (ret < 0) { | 56 | - if (ret < 0) { |
69 | - return ret; | 57 | - return ret; |
70 | + if (!(bs->open_flags & BDRV_O_RDWR)) { | ||
71 | + return 0; | ||
72 | + } | ||
73 | + if (!(bs->open_flags & BDRV_O_AUTO_RDONLY)) { | ||
74 | + goto fail; | ||
75 | } | ||
76 | |||
77 | - bs->read_only = read_only; | ||
78 | - | ||
79 | - if (read_only) { | ||
80 | - bs->open_flags &= ~BDRV_O_RDWR; | ||
81 | - } else { | ||
82 | - bs->open_flags |= BDRV_O_RDWR; | ||
83 | + ret = bdrv_can_set_read_only(bs, true, false, NULL); | ||
84 | + if (ret < 0) { | ||
85 | + goto fail; | ||
86 | } | ||
87 | |||
88 | + bs->read_only = true; | ||
89 | + bs->open_flags &= ~BDRV_O_RDWR; | ||
90 | + | ||
91 | return 0; | ||
92 | + | ||
93 | +fail: | ||
94 | + error_setg(errp, "%s", errmsg ?: "Image is read-only"); | ||
95 | + return -EACCES; | ||
96 | } | ||
97 | |||
98 | void bdrv_get_full_backing_filename_from_filename(const char *backed, | ||
99 | diff --git a/block/bochs.c b/block/bochs.c | ||
100 | index XXXXXXX..XXXXXXX 100644 | ||
101 | --- a/block/bochs.c | ||
102 | +++ b/block/bochs.c | ||
103 | @@ -XXX,XX +XXX,XX @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags, | ||
104 | struct bochs_header bochs; | ||
105 | int ret; | ||
106 | |||
107 | + /* No write support yet */ | ||
108 | + ret = bdrv_apply_auto_read_only(bs, NULL, errp); | ||
109 | + if (ret < 0) { | ||
110 | + return ret; | ||
111 | + } | ||
112 | + | ||
113 | bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, | ||
114 | false, errp); | ||
115 | if (!bs->file) { | ||
116 | return -EINVAL; | ||
117 | } | ||
118 | |||
119 | - if (!bdrv_is_read_only(bs)) { | ||
120 | - error_report("Opening bochs images without an explicit read-only=on " | ||
121 | - "option is deprecated. Future versions will refuse to " | ||
122 | - "open the image instead of automatically marking the " | ||
123 | - "image read-only."); | ||
124 | - ret = bdrv_set_read_only(bs, true, errp); /* no write support yet */ | ||
125 | - if (ret < 0) { | ||
126 | - return ret; | ||
127 | - } | ||
128 | - } | 58 | - } |
129 | - | 59 | - |
130 | ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs)); | 60 | - blk_root_drained_begin(blk->root); |
131 | if (ret < 0) { | 61 | - ret = blk_pread(blk, offset, buf, count); |
132 | return ret; | 62 | - blk_root_drained_end(blk->root, NULL); |
133 | diff --git a/block/cloop.c b/block/cloop.c | 63 | - return ret; |
64 | -} | ||
65 | - | ||
66 | int blk_pwrite_zeroes(BlockBackend *blk, int64_t offset, | ||
67 | int bytes, BdrvRequestFlags flags) | ||
68 | { | ||
69 | diff --git a/hw/block/hd-geometry.c b/hw/block/hd-geometry.c | ||
134 | index XXXXXXX..XXXXXXX 100644 | 70 | index XXXXXXX..XXXXXXX 100644 |
135 | --- a/block/cloop.c | 71 | --- a/hw/block/hd-geometry.c |
136 | +++ b/block/cloop.c | 72 | +++ b/hw/block/hd-geometry.c |
137 | @@ -XXX,XX +XXX,XX @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags, | 73 | @@ -XXX,XX +XXX,XX @@ static int guess_disk_lchs(BlockBackend *blk, |
138 | uint32_t offsets_size, max_compressed_block_size = 1, i; | 74 | |
139 | int ret; | 75 | blk_get_geometry(blk, &nb_sectors); |
140 | 76 | ||
141 | + ret = bdrv_apply_auto_read_only(bs, NULL, errp); | 77 | - /** |
142 | + if (ret < 0) { | 78 | - * The function will be invoked during startup not only in sync I/O mode, |
143 | + return ret; | 79 | - * but also in async I/O mode. So the I/O throttling function has to |
144 | + } | 80 | - * be disabled temporarily here, not permanently. |
145 | + | 81 | - */ |
146 | bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, | 82 | - if (blk_pread_unthrottled(blk, 0, buf, BDRV_SECTOR_SIZE) < 0) { |
147 | false, errp); | 83 | + if (blk_pread(blk, 0, buf, BDRV_SECTOR_SIZE) < 0) { |
148 | if (!bs->file) { | 84 | return -1; |
149 | return -EINVAL; | ||
150 | } | 85 | } |
151 | 86 | /* test msdos magic */ | |
152 | - if (!bdrv_is_read_only(bs)) { | ||
153 | - error_report("Opening cloop images without an explicit read-only=on " | ||
154 | - "option is deprecated. Future versions will refuse to " | ||
155 | - "open the image instead of automatically marking the " | ||
156 | - "image read-only."); | ||
157 | - ret = bdrv_set_read_only(bs, true, errp); | ||
158 | - if (ret < 0) { | ||
159 | - return ret; | ||
160 | - } | ||
161 | - } | ||
162 | - | ||
163 | /* read header */ | ||
164 | ret = bdrv_pread(bs->file, 128, &s->block_size, 4); | ||
165 | if (ret < 0) { | ||
166 | diff --git a/block/dmg.c b/block/dmg.c | ||
167 | index XXXXXXX..XXXXXXX 100644 | ||
168 | --- a/block/dmg.c | ||
169 | +++ b/block/dmg.c | ||
170 | @@ -XXX,XX +XXX,XX @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags, | ||
171 | int64_t offset; | ||
172 | int ret; | ||
173 | |||
174 | + ret = bdrv_apply_auto_read_only(bs, NULL, errp); | ||
175 | + if (ret < 0) { | ||
176 | + return ret; | ||
177 | + } | ||
178 | + | ||
179 | bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, | ||
180 | false, errp); | ||
181 | if (!bs->file) { | ||
182 | return -EINVAL; | ||
183 | } | ||
184 | |||
185 | - if (!bdrv_is_read_only(bs)) { | ||
186 | - error_report("Opening dmg images without an explicit read-only=on " | ||
187 | - "option is deprecated. Future versions will refuse to " | ||
188 | - "open the image instead of automatically marking the " | ||
189 | - "image read-only."); | ||
190 | - ret = bdrv_set_read_only(bs, true, errp); | ||
191 | - if (ret < 0) { | ||
192 | - return ret; | ||
193 | - } | ||
194 | - } | ||
195 | - | ||
196 | block_module_load_one("dmg-bz2"); | ||
197 | |||
198 | s->n_chunks = 0; | ||
199 | diff --git a/block/rbd.c b/block/rbd.c | ||
200 | index XXXXXXX..XXXXXXX 100644 | ||
201 | --- a/block/rbd.c | ||
202 | +++ b/block/rbd.c | ||
203 | @@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, | ||
204 | /* If we are using an rbd snapshot, we must be r/o, otherwise | ||
205 | * leave as-is */ | ||
206 | if (s->snap != NULL) { | ||
207 | - if (!bdrv_is_read_only(bs)) { | ||
208 | - error_report("Opening rbd snapshots without an explicit " | ||
209 | - "read-only=on option is deprecated. Future versions " | ||
210 | - "will refuse to open the image instead of " | ||
211 | - "automatically marking the image read-only."); | ||
212 | - r = bdrv_set_read_only(bs, true, &local_err); | ||
213 | - if (r < 0) { | ||
214 | - rbd_close(s->image); | ||
215 | - error_propagate(errp, local_err); | ||
216 | - goto failed_open; | ||
217 | - } | ||
218 | + r = bdrv_apply_auto_read_only(bs, "rbd snapshots are read-only", errp); | ||
219 | + if (r < 0) { | ||
220 | + rbd_close(s->image); | ||
221 | + goto failed_open; | ||
222 | } | ||
223 | } | ||
224 | |||
225 | diff --git a/block/vvfat.c b/block/vvfat.c | ||
226 | index XXXXXXX..XXXXXXX 100644 | ||
227 | --- a/block/vvfat.c | ||
228 | +++ b/block/vvfat.c | ||
229 | @@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, | ||
230 | "Unable to set VVFAT to 'rw' when drive is read-only"); | ||
231 | goto fail; | ||
232 | } | ||
233 | - } else if (!bdrv_is_read_only(bs)) { | ||
234 | - error_report("Opening non-rw vvfat images without an explicit " | ||
235 | - "read-only=on option is deprecated. Future versions " | ||
236 | - "will refuse to open the image instead of " | ||
237 | - "automatically marking the image read-only."); | ||
238 | - /* read only is the default for safety */ | ||
239 | - ret = bdrv_set_read_only(bs, true, &local_err); | ||
240 | + } else { | ||
241 | + ret = bdrv_apply_auto_read_only(bs, NULL, errp); | ||
242 | if (ret < 0) { | ||
243 | - error_propagate(errp, local_err); | ||
244 | goto fail; | ||
245 | } | ||
246 | } | ||
247 | -- | 87 | -- |
248 | 2.19.1 | 88 | 2.20.1 |
249 | 89 | ||
250 | 90 | diff view generated by jsdifflib |
1 | From: Leonid Bloch <lbloch@janustech.com> | 1 | mirror_top_bs is currently implicitly drained through its connection to |
---|---|---|---|
2 | the source or the target node. However, the drain section for target_bs | ||
3 | ends early after moving mirror_top_bs from src to target_bs, so that | ||
4 | requests can already be restarted while mirror_top_bs is still present | ||
5 | in the chain, but has dropped all permissions and therefore runs into an | ||
6 | assertion failure like this: | ||
2 | 7 | ||
3 | The lookup table for power-of-two sizes was added in commit 540b8492618eb | 8 | qemu-system-x86_64: block/io.c:1634: bdrv_co_write_req_prepare: |
4 | for the purpose of having convenient shortcuts for these sizes in cases | 9 | Assertion `child->perm & BLK_PERM_WRITE' failed. |
5 | when the literal number has to be present at compile time, and | ||
6 | expressions as '(1 * KiB)' can not be used. One such case is the | ||
7 | stringification of sizes. Beyond that, it is convenient to use these | ||
8 | shortcuts for all power-of-two sizes, even if they don't have to be | ||
9 | literal numbers. | ||
10 | 10 | ||
11 | Despite its convenience, this table introduced 55 lines of "dumb" code, | 11 | Keep mirror_top_bs drained until all graph changes have completed. |
12 | the purpose and origin of which are obscure without reading the message | ||
13 | of the commit which introduced it. This patch fixes that by adding a | ||
14 | comment to the code itself with a brief explanation for the reasoning | ||
15 | behind this table. This comment includes the short AWK script that | ||
16 | generated the table, so that anyone who's interested could make sure | ||
17 | that the values in it are correct (otherwise these values look as if | ||
18 | they were typed manually). | ||
19 | 12 | ||
20 | Signed-off-by: Leonid Bloch <lbloch@janustech.com> | 13 | Cc: qemu-stable@nongnu.org |
21 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 14 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
15 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
22 | --- | 16 | --- |
23 | include/qemu/units.h | 18 ++++++++++++++++++ | 17 | block/mirror.c | 6 +++++- |
24 | 1 file changed, 18 insertions(+) | 18 | 1 file changed, 5 insertions(+), 1 deletion(-) |
25 | 19 | ||
26 | diff --git a/include/qemu/units.h b/include/qemu/units.h | 20 | diff --git a/block/mirror.c b/block/mirror.c |
27 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/include/qemu/units.h | 22 | --- a/block/mirror.c |
29 | +++ b/include/qemu/units.h | 23 | +++ b/block/mirror.c |
30 | @@ -XXX,XX +XXX,XX @@ | 24 | @@ -XXX,XX +XXX,XX @@ static int mirror_exit_common(Job *job) |
31 | #define PiB (INT64_C(1) << 50) | 25 | s->target = NULL; |
32 | #define EiB (INT64_C(1) << 60) | 26 | |
33 | 27 | /* We don't access the source any more. Dropping any WRITE/RESIZE is | |
34 | +/* | 28 | - * required before it could become a backing file of target_bs. */ |
35 | + * The following lookup table is intended to be used when a literal string of | 29 | + * required before it could become a backing file of target_bs. Not having |
36 | + * the number of bytes is required (for example if it needs to be stringified). | 30 | + * these permissions any more means that we can't allow any new requests on |
37 | + * It can also be used for generic shortcuts of power-of-two sizes. | 31 | + * mirror_top_bs from now on, so keep it drained. */ |
38 | + * This table is generated using the AWK script below: | 32 | + bdrv_drained_begin(mirror_top_bs); |
39 | + * | 33 | bs_opaque->stop = true; |
40 | + * BEGIN { | 34 | bdrv_child_refresh_perms(mirror_top_bs, mirror_top_bs->backing, |
41 | + * suffix="KMGTPE"; | 35 | &error_abort); |
42 | + * for(i=10; i<64; i++) { | 36 | @@ -XXX,XX +XXX,XX @@ static int mirror_exit_common(Job *job) |
43 | + * val=2**i; | 37 | bs_opaque->job = NULL; |
44 | + * s=substr(suffix, int(i/10), 1); | 38 | |
45 | + * n=2**(i%10); | 39 | bdrv_drained_end(src); |
46 | + * pad=21-int(log(n)/log(10)); | 40 | + bdrv_drained_end(mirror_top_bs); |
47 | + * printf("#define S_%d%siB %*d\n", n, s, pad, val); | 41 | s->in_drain = false; |
48 | + * } | 42 | bdrv_unref(mirror_top_bs); |
49 | + * } | 43 | bdrv_unref(src); |
50 | + */ | ||
51 | + | ||
52 | #define S_1KiB 1024 | ||
53 | #define S_2KiB 2048 | ||
54 | #define S_4KiB 4096 | ||
55 | -- | 44 | -- |
56 | 2.19.1 | 45 | 2.20.1 |
57 | 46 | ||
58 | 47 | diff view generated by jsdifflib |
1 | From: Li Qiang <liq3ea@163.com> | 1 | This fixes devices like IDE that can still start new requests from I/O |
---|---|---|---|
2 | 2 | handlers in the CPU thread while the block backend is drained. | |
3 | Signed-off-by: Li Qiang <liq3ea@163.com> | 3 | |
4 | Reviewed-by: Alberto Garcia <berto@igalia.com> | 4 | The basic assumption is that in a drain section, no new requests should |
5 | be allowed through a BlockBackend (blk_drained_begin/end don't exist, | ||
6 | we get drain sections only on the node level). However, there are two | ||
7 | special cases where requests should not be queued: | ||
8 | |||
9 | 1. Block jobs: We already make sure that block jobs are paused in a | ||
10 | drain section, so they won't start new requests. However, if the | ||
11 | drain_begin is called on the job's BlockBackend first, it can happen | ||
12 | that we deadlock because the job stays busy until it reaches a pause | ||
13 | point - which it can't if its requests aren't processed any more. | ||
14 | |||
15 | The proper solution here would be to make all requests through the | ||
16 | job's filter node instead of using a BlockBackend. For now, just | ||
17 | disabling request queuing on the job BlockBackend is simpler. | ||
18 | |||
19 | 2. In test cases where making requests through bdrv_* would be | ||
20 | cumbersome because we'd need a BdrvChild. As we already got the | ||
21 | functionality to disable request queuing from 1., use it in tests, | ||
22 | too, for convenience. | ||
23 | |||
5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 24 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
25 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
6 | --- | 26 | --- |
7 | include/sysemu/block-backend.h | 6 +++--- | 27 | include/sysemu/block-backend.h | 1 + |
8 | block/block-backend.c | 8 ++++---- | 28 | block/backup.c | 1 + |
9 | 2 files changed, 7 insertions(+), 7 deletions(-) | 29 | block/block-backend.c | 53 ++++++++++++++++++++++++++++++++-- |
30 | block/commit.c | 2 ++ | ||
31 | block/mirror.c | 1 + | ||
32 | blockjob.c | 3 ++ | ||
33 | tests/test-bdrv-drain.c | 1 + | ||
34 | 7 files changed, 59 insertions(+), 3 deletions(-) | ||
10 | 35 | ||
11 | diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h | 36 | diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h |
12 | index XXXXXXX..XXXXXXX 100644 | 37 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/include/sysemu/block-backend.h | 38 | --- a/include/sysemu/block-backend.h |
14 | +++ b/include/sysemu/block-backend.h | 39 | +++ b/include/sysemu/block-backend.h |
15 | @@ -XXX,XX +XXX,XX @@ BlockErrorAction blk_get_error_action(BlockBackend *blk, bool is_read, | 40 | @@ -XXX,XX +XXX,XX @@ void blk_get_perm(BlockBackend *blk, uint64_t *perm, uint64_t *shared_perm); |
16 | int error); | 41 | |
17 | void blk_error_action(BlockBackend *blk, BlockErrorAction action, | 42 | void blk_set_allow_write_beyond_eof(BlockBackend *blk, bool allow); |
18 | bool is_read, int error); | 43 | void blk_set_allow_aio_context_change(BlockBackend *blk, bool allow); |
19 | -int blk_is_read_only(BlockBackend *blk); | 44 | +void blk_set_disable_request_queuing(BlockBackend *blk, bool disable); |
20 | -int blk_is_sg(BlockBackend *blk); | 45 | void blk_iostatus_enable(BlockBackend *blk); |
21 | -int blk_enable_write_cache(BlockBackend *blk); | 46 | bool blk_iostatus_is_enabled(const BlockBackend *blk); |
22 | +bool blk_is_read_only(BlockBackend *blk); | 47 | BlockDeviceIoStatus blk_iostatus(const BlockBackend *blk); |
23 | +bool blk_is_sg(BlockBackend *blk); | 48 | diff --git a/block/backup.c b/block/backup.c |
24 | +bool blk_enable_write_cache(BlockBackend *blk); | 49 | index XXXXXXX..XXXXXXX 100644 |
25 | void blk_set_enable_write_cache(BlockBackend *blk, bool wce); | 50 | --- a/block/backup.c |
26 | void blk_invalidate_cache(BlockBackend *blk, Error **errp); | 51 | +++ b/block/backup.c |
27 | bool blk_is_inserted(BlockBackend *blk); | 52 | @@ -XXX,XX +XXX,XX @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, |
53 | if (ret < 0) { | ||
54 | goto error; | ||
55 | } | ||
56 | + blk_set_disable_request_queuing(job->target, true); | ||
57 | |||
58 | job->on_source_error = on_source_error; | ||
59 | job->on_target_error = on_target_error; | ||
28 | diff --git a/block/block-backend.c b/block/block-backend.c | 60 | diff --git a/block/block-backend.c b/block/block-backend.c |
29 | index XXXXXXX..XXXXXXX 100644 | 61 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/block/block-backend.c | 62 | --- a/block/block-backend.c |
31 | +++ b/block/block-backend.c | 63 | +++ b/block/block-backend.c |
32 | @@ -XXX,XX +XXX,XX @@ void blk_error_action(BlockBackend *blk, BlockErrorAction action, | 64 | @@ -XXX,XX +XXX,XX @@ struct BlockBackend { |
33 | } | 65 | QLIST_HEAD(, BlockBackendAioNotifier) aio_notifiers; |
66 | |||
67 | int quiesce_counter; | ||
68 | + CoQueue queued_requests; | ||
69 | + bool disable_request_queuing; | ||
70 | + | ||
71 | VMChangeStateEntry *vmsh; | ||
72 | bool force_allow_inactivate; | ||
73 | |||
74 | @@ -XXX,XX +XXX,XX @@ BlockBackend *blk_new(AioContext *ctx, uint64_t perm, uint64_t shared_perm) | ||
75 | |||
76 | block_acct_init(&blk->stats); | ||
77 | |||
78 | + qemu_co_queue_init(&blk->queued_requests); | ||
79 | notifier_list_init(&blk->remove_bs_notifiers); | ||
80 | notifier_list_init(&blk->insert_bs_notifiers); | ||
81 | QLIST_INIT(&blk->aio_notifiers); | ||
82 | @@ -XXX,XX +XXX,XX @@ void blk_set_allow_aio_context_change(BlockBackend *blk, bool allow) | ||
83 | blk->allow_aio_context_change = allow; | ||
34 | } | 84 | } |
35 | 85 | ||
36 | -int blk_is_read_only(BlockBackend *blk) | 86 | +void blk_set_disable_request_queuing(BlockBackend *blk, bool disable) |
37 | +bool blk_is_read_only(BlockBackend *blk) | 87 | +{ |
38 | { | 88 | + blk->disable_request_queuing = disable; |
39 | BlockDriverState *bs = blk_bs(blk); | 89 | +} |
40 | 90 | + | |
41 | @@ -XXX,XX +XXX,XX @@ int blk_is_read_only(BlockBackend *blk) | 91 | static int blk_check_byte_request(BlockBackend *blk, int64_t offset, |
42 | } | 92 | size_t size) |
93 | { | ||
94 | @@ -XXX,XX +XXX,XX @@ static int blk_check_byte_request(BlockBackend *blk, int64_t offset, | ||
95 | return 0; | ||
43 | } | 96 | } |
44 | 97 | ||
45 | -int blk_is_sg(BlockBackend *blk) | 98 | +static void coroutine_fn blk_wait_while_drained(BlockBackend *blk) |
46 | +bool blk_is_sg(BlockBackend *blk) | 99 | +{ |
47 | { | 100 | + if (blk->quiesce_counter && !blk->disable_request_queuing) { |
48 | BlockDriverState *bs = blk_bs(blk); | 101 | + qemu_co_queue_wait(&blk->queued_requests, NULL); |
49 | 102 | + } | |
50 | if (!bs) { | 103 | +} |
51 | - return 0; | 104 | + |
52 | + return false; | 105 | int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, |
53 | } | 106 | unsigned int bytes, QEMUIOVector *qiov, |
54 | 107 | BdrvRequestFlags flags) | |
55 | return bdrv_is_sg(bs); | 108 | { |
109 | int ret; | ||
110 | - BlockDriverState *bs = blk_bs(blk); | ||
111 | + BlockDriverState *bs; | ||
112 | |||
113 | + blk_wait_while_drained(blk); | ||
114 | + | ||
115 | + /* Call blk_bs() only after waiting, the graph may have changed */ | ||
116 | + bs = blk_bs(blk); | ||
117 | trace_blk_co_preadv(blk, bs, offset, bytes, flags); | ||
118 | |||
119 | ret = blk_check_byte_request(blk, offset, bytes); | ||
120 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset, | ||
121 | BdrvRequestFlags flags) | ||
122 | { | ||
123 | int ret; | ||
124 | - BlockDriverState *bs = blk_bs(blk); | ||
125 | + BlockDriverState *bs; | ||
126 | |||
127 | + blk_wait_while_drained(blk); | ||
128 | + | ||
129 | + /* Call blk_bs() only after waiting, the graph may have changed */ | ||
130 | + bs = blk_bs(blk); | ||
131 | trace_blk_co_pwritev(blk, bs, offset, bytes, flags); | ||
132 | |||
133 | ret = blk_check_byte_request(blk, offset, bytes); | ||
134 | @@ -XXX,XX +XXX,XX @@ static void blk_aio_read_entry(void *opaque) | ||
135 | BlkRwCo *rwco = &acb->rwco; | ||
136 | QEMUIOVector *qiov = rwco->iobuf; | ||
137 | |||
138 | + if (rwco->blk->quiesce_counter) { | ||
139 | + blk_dec_in_flight(rwco->blk); | ||
140 | + blk_wait_while_drained(rwco->blk); | ||
141 | + blk_inc_in_flight(rwco->blk); | ||
142 | + } | ||
143 | + | ||
144 | assert(qiov->size == acb->bytes); | ||
145 | rwco->ret = blk_co_preadv(rwco->blk, rwco->offset, acb->bytes, | ||
146 | qiov, rwco->flags); | ||
147 | @@ -XXX,XX +XXX,XX @@ static void blk_aio_write_entry(void *opaque) | ||
148 | BlkRwCo *rwco = &acb->rwco; | ||
149 | QEMUIOVector *qiov = rwco->iobuf; | ||
150 | |||
151 | + if (rwco->blk->quiesce_counter) { | ||
152 | + blk_dec_in_flight(rwco->blk); | ||
153 | + blk_wait_while_drained(rwco->blk); | ||
154 | + blk_inc_in_flight(rwco->blk); | ||
155 | + } | ||
156 | + | ||
157 | assert(!qiov || qiov->size == acb->bytes); | ||
158 | rwco->ret = blk_co_pwritev(rwco->blk, rwco->offset, acb->bytes, | ||
159 | qiov, rwco->flags); | ||
160 | @@ -XXX,XX +XXX,XX @@ void blk_aio_cancel_async(BlockAIOCB *acb) | ||
161 | |||
162 | int blk_co_ioctl(BlockBackend *blk, unsigned long int req, void *buf) | ||
163 | { | ||
164 | + blk_wait_while_drained(blk); | ||
165 | + | ||
166 | if (!blk_is_available(blk)) { | ||
167 | return -ENOMEDIUM; | ||
168 | } | ||
169 | @@ -XXX,XX +XXX,XX @@ BlockAIOCB *blk_aio_ioctl(BlockBackend *blk, unsigned long int req, void *buf, | ||
170 | |||
171 | int blk_co_pdiscard(BlockBackend *blk, int64_t offset, int bytes) | ||
172 | { | ||
173 | - int ret = blk_check_byte_request(blk, offset, bytes); | ||
174 | + int ret; | ||
175 | + | ||
176 | + blk_wait_while_drained(blk); | ||
177 | + | ||
178 | + ret = blk_check_byte_request(blk, offset, bytes); | ||
179 | if (ret < 0) { | ||
180 | return ret; | ||
181 | } | ||
182 | @@ -XXX,XX +XXX,XX @@ int blk_co_pdiscard(BlockBackend *blk, int64_t offset, int bytes) | ||
183 | |||
184 | int blk_co_flush(BlockBackend *blk) | ||
185 | { | ||
186 | + blk_wait_while_drained(blk); | ||
187 | + | ||
188 | if (!blk_is_available(blk)) { | ||
189 | return -ENOMEDIUM; | ||
190 | } | ||
191 | @@ -XXX,XX +XXX,XX @@ static void blk_root_drained_end(BdrvChild *child, int *drained_end_counter) | ||
192 | if (blk->dev_ops && blk->dev_ops->drained_end) { | ||
193 | blk->dev_ops->drained_end(blk->dev_opaque); | ||
194 | } | ||
195 | + while (qemu_co_enter_next(&blk->queued_requests, NULL)) { | ||
196 | + /* Resume all queued requests */ | ||
197 | + } | ||
198 | } | ||
56 | } | 199 | } |
57 | 200 | ||
58 | -int blk_enable_write_cache(BlockBackend *blk) | 201 | diff --git a/block/commit.c b/block/commit.c |
59 | +bool blk_enable_write_cache(BlockBackend *blk) | 202 | index XXXXXXX..XXXXXXX 100644 |
60 | { | 203 | --- a/block/commit.c |
61 | return blk->enable_write_cache; | 204 | +++ b/block/commit.c |
62 | } | 205 | @@ -XXX,XX +XXX,XX @@ void commit_start(const char *job_id, BlockDriverState *bs, |
206 | if (ret < 0) { | ||
207 | goto fail; | ||
208 | } | ||
209 | + blk_set_disable_request_queuing(s->base, true); | ||
210 | s->base_bs = base; | ||
211 | |||
212 | /* Required permissions are already taken with block_job_add_bdrv() */ | ||
213 | @@ -XXX,XX +XXX,XX @@ void commit_start(const char *job_id, BlockDriverState *bs, | ||
214 | if (ret < 0) { | ||
215 | goto fail; | ||
216 | } | ||
217 | + blk_set_disable_request_queuing(s->top, true); | ||
218 | |||
219 | s->backing_file_str = g_strdup(backing_file_str); | ||
220 | s->on_error = on_error; | ||
221 | diff --git a/block/mirror.c b/block/mirror.c | ||
222 | index XXXXXXX..XXXXXXX 100644 | ||
223 | --- a/block/mirror.c | ||
224 | +++ b/block/mirror.c | ||
225 | @@ -XXX,XX +XXX,XX @@ static BlockJob *mirror_start_job( | ||
226 | blk_set_force_allow_inactivate(s->target); | ||
227 | } | ||
228 | blk_set_allow_aio_context_change(s->target, true); | ||
229 | + blk_set_disable_request_queuing(s->target, true); | ||
230 | |||
231 | s->replaces = g_strdup(replaces); | ||
232 | s->on_source_error = on_source_error; | ||
233 | diff --git a/blockjob.c b/blockjob.c | ||
234 | index XXXXXXX..XXXXXXX 100644 | ||
235 | --- a/blockjob.c | ||
236 | +++ b/blockjob.c | ||
237 | @@ -XXX,XX +XXX,XX @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver, | ||
238 | |||
239 | bdrv_op_unblock(bs, BLOCK_OP_TYPE_DATAPLANE, job->blocker); | ||
240 | |||
241 | + /* Disable request queuing in the BlockBackend to avoid deadlocks on drain: | ||
242 | + * The job reports that it's busy until it reaches a pause point. */ | ||
243 | + blk_set_disable_request_queuing(blk, true); | ||
244 | blk_set_allow_aio_context_change(blk, true); | ||
245 | |||
246 | /* Only set speed when necessary to avoid NotSupported error */ | ||
247 | diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c | ||
248 | index XXXXXXX..XXXXXXX 100644 | ||
249 | --- a/tests/test-bdrv-drain.c | ||
250 | +++ b/tests/test-bdrv-drain.c | ||
251 | @@ -XXX,XX +XXX,XX @@ static void test_iothread_common(enum drain_type drain_type, int drain_thread) | ||
252 | &error_abort); | ||
253 | s = bs->opaque; | ||
254 | blk_insert_bs(blk, bs, &error_abort); | ||
255 | + blk_set_disable_request_queuing(blk, true); | ||
256 | |||
257 | blk_set_aio_context(blk, ctx_a, &error_abort); | ||
258 | aio_context_acquire(ctx_a); | ||
63 | -- | 259 | -- |
64 | 2.19.1 | 260 | 2.20.1 |
65 | 261 | ||
66 | 262 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cleber Rosa <crosa@redhat.com> | ||
2 | 1 | ||
3 | While testing the Python 3 changes which touch the 083 test, I noticed | ||
4 | that it would fail with qcow2. Expanding the testing, I noticed it | ||
5 | had nothing to do with the Python 3 changes, and in fact, it would not | ||
6 | pass on anything but raw: | ||
7 | |||
8 | raw: pass | ||
9 | bochs: not generic | ||
10 | cloop: not generic | ||
11 | parallels: fail | ||
12 | qcow: fail | ||
13 | qcow2: fail | ||
14 | qed: fail | ||
15 | vdi: fail | ||
16 | vhdx: fail | ||
17 | vmdk: fail | ||
18 | vpc: fail | ||
19 | luks: fail | ||
20 | |||
21 | The errors are a mixture I/O and "image not in xxx format", such as: | ||
22 | |||
23 | === Check disconnect before data === | ||
24 | |||
25 | Unexpected end-of-file before all bytes were read | ||
26 | -read failed: Input/output error | ||
27 | +can't open device nbd+tcp://127.0.0.1:PORT/foo: Could not open 'nbd://127.0.0.1:PORT/foo': Input/output error | ||
28 | |||
29 | === Check disconnect after data === | ||
30 | |||
31 | -read 512/512 bytes at offset 0 | ||
32 | -512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
33 | +can't open device nbd+tcp://127.0.0.1:PORT/foo: Image not in qcow format | ||
34 | |||
35 | I'm not aware if there's a quick fix, so, for the time being, it looks | ||
36 | like the honest approach is to make the test known to work on raw | ||
37 | only. | ||
38 | |||
39 | Signed-off-by: Cleber Rosa <crosa@redhat.com> | ||
40 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
41 | --- | ||
42 | tests/qemu-iotests/083 | 2 +- | ||
43 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
44 | |||
45 | diff --git a/tests/qemu-iotests/083 b/tests/qemu-iotests/083 | ||
46 | index XXXXXXX..XXXXXXX 100755 | ||
47 | --- a/tests/qemu-iotests/083 | ||
48 | +++ b/tests/qemu-iotests/083 | ||
49 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
50 | . ./common.rc | ||
51 | . ./common.filter | ||
52 | |||
53 | -_supported_fmt generic | ||
54 | +_supported_fmt raw | ||
55 | _supported_proto nbd | ||
56 | _supported_os Linux | ||
57 | |||
58 | -- | ||
59 | 2.19.1 | ||
60 | |||
61 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
2 | Reviewed-by: Alberto Garcia <berto@igalia.com> | ||
3 | --- | ||
4 | block/vpc.c | 2 ++ | ||
5 | 1 file changed, 2 insertions(+) | ||
6 | 1 | ||
7 | diff --git a/block/vpc.c b/block/vpc.c | ||
8 | index XXXXXXX..XXXXXXX 100644 | ||
9 | --- a/block/vpc.c | ||
10 | +++ b/block/vpc.c | ||
11 | @@ -XXX,XX +XXX,XX @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, | ||
12 | } | ||
13 | |||
14 | qemu_co_mutex_init(&s->lock); | ||
15 | + qemu_opts_del(opts); | ||
16 | |||
17 | return 0; | ||
18 | |||
19 | fail: | ||
20 | + qemu_opts_del(opts); | ||
21 | qemu_vfree(s->pagetable); | ||
22 | #ifdef CACHE | ||
23 | g_free(s->pageentry_u8); | ||
24 | -- | ||
25 | 2.19.1 | ||
26 | |||
27 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Peter Maydell <peter.maydell@linaro.org> | ||
2 | 1 | ||
3 | Taking the address of a field in a packed struct is a bad idea, because | ||
4 | it might not be actually aligned enough for that pointer type (and | ||
5 | thus cause a crash on dereference on some host architectures). Newer | ||
6 | versions of clang warn about this. Avoid the bug by not using the | ||
7 | "modify in place" byte swapping functions. | ||
8 | |||
9 | There are a few places where the in-place swap function is | ||
10 | used on something other than a packed struct field; we convert | ||
11 | those anyway, for consistency. | ||
12 | |||
13 | Patch produced with scripts/coccinelle/inplace-byteswaps.cocci. | ||
14 | |||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
17 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
18 | --- | ||
19 | block/vhdx.h | 12 ++--- | ||
20 | block/vhdx-endian.c | 118 ++++++++++++++++++++++---------------------- | ||
21 | block/vhdx-log.c | 4 +- | ||
22 | block/vhdx.c | 18 +++---- | ||
23 | 4 files changed, 76 insertions(+), 76 deletions(-) | ||
24 | |||
25 | diff --git a/block/vhdx.h b/block/vhdx.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/block/vhdx.h | ||
28 | +++ b/block/vhdx.h | ||
29 | @@ -XXX,XX +XXX,XX @@ int vhdx_log_write_and_flush(BlockDriverState *bs, BDRVVHDXState *s, | ||
30 | |||
31 | static inline void leguid_to_cpus(MSGUID *guid) | ||
32 | { | ||
33 | - le32_to_cpus(&guid->data1); | ||
34 | - le16_to_cpus(&guid->data2); | ||
35 | - le16_to_cpus(&guid->data3); | ||
36 | + guid->data1 = le32_to_cpu(guid->data1); | ||
37 | + guid->data2 = le16_to_cpu(guid->data2); | ||
38 | + guid->data3 = le16_to_cpu(guid->data3); | ||
39 | } | ||
40 | |||
41 | static inline void cpu_to_leguids(MSGUID *guid) | ||
42 | { | ||
43 | - cpu_to_le32s(&guid->data1); | ||
44 | - cpu_to_le16s(&guid->data2); | ||
45 | - cpu_to_le16s(&guid->data3); | ||
46 | + guid->data1 = cpu_to_le32(guid->data1); | ||
47 | + guid->data2 = cpu_to_le16(guid->data2); | ||
48 | + guid->data3 = cpu_to_le16(guid->data3); | ||
49 | } | ||
50 | |||
51 | void vhdx_header_le_import(VHDXHeader *h); | ||
52 | diff --git a/block/vhdx-endian.c b/block/vhdx-endian.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/block/vhdx-endian.c | ||
55 | +++ b/block/vhdx-endian.c | ||
56 | @@ -XXX,XX +XXX,XX @@ void vhdx_header_le_import(VHDXHeader *h) | ||
57 | { | ||
58 | assert(h != NULL); | ||
59 | |||
60 | - le32_to_cpus(&h->signature); | ||
61 | - le32_to_cpus(&h->checksum); | ||
62 | - le64_to_cpus(&h->sequence_number); | ||
63 | + h->signature = le32_to_cpu(h->signature); | ||
64 | + h->checksum = le32_to_cpu(h->checksum); | ||
65 | + h->sequence_number = le64_to_cpu(h->sequence_number); | ||
66 | |||
67 | leguid_to_cpus(&h->file_write_guid); | ||
68 | leguid_to_cpus(&h->data_write_guid); | ||
69 | leguid_to_cpus(&h->log_guid); | ||
70 | |||
71 | - le16_to_cpus(&h->log_version); | ||
72 | - le16_to_cpus(&h->version); | ||
73 | - le32_to_cpus(&h->log_length); | ||
74 | - le64_to_cpus(&h->log_offset); | ||
75 | + h->log_version = le16_to_cpu(h->log_version); | ||
76 | + h->version = le16_to_cpu(h->version); | ||
77 | + h->log_length = le32_to_cpu(h->log_length); | ||
78 | + h->log_offset = le64_to_cpu(h->log_offset); | ||
79 | } | ||
80 | |||
81 | void vhdx_header_le_export(VHDXHeader *orig_h, VHDXHeader *new_h) | ||
82 | @@ -XXX,XX +XXX,XX @@ void vhdx_log_desc_le_import(VHDXLogDescriptor *d) | ||
83 | { | ||
84 | assert(d != NULL); | ||
85 | |||
86 | - le32_to_cpus(&d->signature); | ||
87 | - le64_to_cpus(&d->file_offset); | ||
88 | - le64_to_cpus(&d->sequence_number); | ||
89 | + d->signature = le32_to_cpu(d->signature); | ||
90 | + d->file_offset = le64_to_cpu(d->file_offset); | ||
91 | + d->sequence_number = le64_to_cpu(d->sequence_number); | ||
92 | } | ||
93 | |||
94 | void vhdx_log_desc_le_export(VHDXLogDescriptor *d) | ||
95 | { | ||
96 | assert(d != NULL); | ||
97 | |||
98 | - cpu_to_le32s(&d->signature); | ||
99 | - cpu_to_le32s(&d->trailing_bytes); | ||
100 | - cpu_to_le64s(&d->leading_bytes); | ||
101 | - cpu_to_le64s(&d->file_offset); | ||
102 | - cpu_to_le64s(&d->sequence_number); | ||
103 | + d->signature = cpu_to_le32(d->signature); | ||
104 | + d->trailing_bytes = cpu_to_le32(d->trailing_bytes); | ||
105 | + d->leading_bytes = cpu_to_le64(d->leading_bytes); | ||
106 | + d->file_offset = cpu_to_le64(d->file_offset); | ||
107 | + d->sequence_number = cpu_to_le64(d->sequence_number); | ||
108 | } | ||
109 | |||
110 | void vhdx_log_data_le_import(VHDXLogDataSector *d) | ||
111 | { | ||
112 | assert(d != NULL); | ||
113 | |||
114 | - le32_to_cpus(&d->data_signature); | ||
115 | - le32_to_cpus(&d->sequence_high); | ||
116 | - le32_to_cpus(&d->sequence_low); | ||
117 | + d->data_signature = le32_to_cpu(d->data_signature); | ||
118 | + d->sequence_high = le32_to_cpu(d->sequence_high); | ||
119 | + d->sequence_low = le32_to_cpu(d->sequence_low); | ||
120 | } | ||
121 | |||
122 | void vhdx_log_data_le_export(VHDXLogDataSector *d) | ||
123 | { | ||
124 | assert(d != NULL); | ||
125 | |||
126 | - cpu_to_le32s(&d->data_signature); | ||
127 | - cpu_to_le32s(&d->sequence_high); | ||
128 | - cpu_to_le32s(&d->sequence_low); | ||
129 | + d->data_signature = cpu_to_le32(d->data_signature); | ||
130 | + d->sequence_high = cpu_to_le32(d->sequence_high); | ||
131 | + d->sequence_low = cpu_to_le32(d->sequence_low); | ||
132 | } | ||
133 | |||
134 | void vhdx_log_entry_hdr_le_import(VHDXLogEntryHeader *hdr) | ||
135 | { | ||
136 | assert(hdr != NULL); | ||
137 | |||
138 | - le32_to_cpus(&hdr->signature); | ||
139 | - le32_to_cpus(&hdr->checksum); | ||
140 | - le32_to_cpus(&hdr->entry_length); | ||
141 | - le32_to_cpus(&hdr->tail); | ||
142 | - le64_to_cpus(&hdr->sequence_number); | ||
143 | - le32_to_cpus(&hdr->descriptor_count); | ||
144 | + hdr->signature = le32_to_cpu(hdr->signature); | ||
145 | + hdr->checksum = le32_to_cpu(hdr->checksum); | ||
146 | + hdr->entry_length = le32_to_cpu(hdr->entry_length); | ||
147 | + hdr->tail = le32_to_cpu(hdr->tail); | ||
148 | + hdr->sequence_number = le64_to_cpu(hdr->sequence_number); | ||
149 | + hdr->descriptor_count = le32_to_cpu(hdr->descriptor_count); | ||
150 | leguid_to_cpus(&hdr->log_guid); | ||
151 | - le64_to_cpus(&hdr->flushed_file_offset); | ||
152 | - le64_to_cpus(&hdr->last_file_offset); | ||
153 | + hdr->flushed_file_offset = le64_to_cpu(hdr->flushed_file_offset); | ||
154 | + hdr->last_file_offset = le64_to_cpu(hdr->last_file_offset); | ||
155 | } | ||
156 | |||
157 | void vhdx_log_entry_hdr_le_export(VHDXLogEntryHeader *hdr) | ||
158 | { | ||
159 | assert(hdr != NULL); | ||
160 | |||
161 | - cpu_to_le32s(&hdr->signature); | ||
162 | - cpu_to_le32s(&hdr->checksum); | ||
163 | - cpu_to_le32s(&hdr->entry_length); | ||
164 | - cpu_to_le32s(&hdr->tail); | ||
165 | - cpu_to_le64s(&hdr->sequence_number); | ||
166 | - cpu_to_le32s(&hdr->descriptor_count); | ||
167 | + hdr->signature = cpu_to_le32(hdr->signature); | ||
168 | + hdr->checksum = cpu_to_le32(hdr->checksum); | ||
169 | + hdr->entry_length = cpu_to_le32(hdr->entry_length); | ||
170 | + hdr->tail = cpu_to_le32(hdr->tail); | ||
171 | + hdr->sequence_number = cpu_to_le64(hdr->sequence_number); | ||
172 | + hdr->descriptor_count = cpu_to_le32(hdr->descriptor_count); | ||
173 | cpu_to_leguids(&hdr->log_guid); | ||
174 | - cpu_to_le64s(&hdr->flushed_file_offset); | ||
175 | - cpu_to_le64s(&hdr->last_file_offset); | ||
176 | + hdr->flushed_file_offset = cpu_to_le64(hdr->flushed_file_offset); | ||
177 | + hdr->last_file_offset = cpu_to_le64(hdr->last_file_offset); | ||
178 | } | ||
179 | |||
180 | |||
181 | @@ -XXX,XX +XXX,XX @@ void vhdx_region_header_le_import(VHDXRegionTableHeader *hdr) | ||
182 | { | ||
183 | assert(hdr != NULL); | ||
184 | |||
185 | - le32_to_cpus(&hdr->signature); | ||
186 | - le32_to_cpus(&hdr->checksum); | ||
187 | - le32_to_cpus(&hdr->entry_count); | ||
188 | + hdr->signature = le32_to_cpu(hdr->signature); | ||
189 | + hdr->checksum = le32_to_cpu(hdr->checksum); | ||
190 | + hdr->entry_count = le32_to_cpu(hdr->entry_count); | ||
191 | } | ||
192 | |||
193 | void vhdx_region_header_le_export(VHDXRegionTableHeader *hdr) | ||
194 | { | ||
195 | assert(hdr != NULL); | ||
196 | |||
197 | - cpu_to_le32s(&hdr->signature); | ||
198 | - cpu_to_le32s(&hdr->checksum); | ||
199 | - cpu_to_le32s(&hdr->entry_count); | ||
200 | + hdr->signature = cpu_to_le32(hdr->signature); | ||
201 | + hdr->checksum = cpu_to_le32(hdr->checksum); | ||
202 | + hdr->entry_count = cpu_to_le32(hdr->entry_count); | ||
203 | } | ||
204 | |||
205 | void vhdx_region_entry_le_import(VHDXRegionTableEntry *e) | ||
206 | @@ -XXX,XX +XXX,XX @@ void vhdx_region_entry_le_import(VHDXRegionTableEntry *e) | ||
207 | assert(e != NULL); | ||
208 | |||
209 | leguid_to_cpus(&e->guid); | ||
210 | - le64_to_cpus(&e->file_offset); | ||
211 | - le32_to_cpus(&e->length); | ||
212 | - le32_to_cpus(&e->data_bits); | ||
213 | + e->file_offset = le64_to_cpu(e->file_offset); | ||
214 | + e->length = le32_to_cpu(e->length); | ||
215 | + e->data_bits = le32_to_cpu(e->data_bits); | ||
216 | } | ||
217 | |||
218 | void vhdx_region_entry_le_export(VHDXRegionTableEntry *e) | ||
219 | @@ -XXX,XX +XXX,XX @@ void vhdx_region_entry_le_export(VHDXRegionTableEntry *e) | ||
220 | assert(e != NULL); | ||
221 | |||
222 | cpu_to_leguids(&e->guid); | ||
223 | - cpu_to_le64s(&e->file_offset); | ||
224 | - cpu_to_le32s(&e->length); | ||
225 | - cpu_to_le32s(&e->data_bits); | ||
226 | + e->file_offset = cpu_to_le64(e->file_offset); | ||
227 | + e->length = cpu_to_le32(e->length); | ||
228 | + e->data_bits = cpu_to_le32(e->data_bits); | ||
229 | } | ||
230 | |||
231 | |||
232 | @@ -XXX,XX +XXX,XX @@ void vhdx_metadata_header_le_import(VHDXMetadataTableHeader *hdr) | ||
233 | { | ||
234 | assert(hdr != NULL); | ||
235 | |||
236 | - le64_to_cpus(&hdr->signature); | ||
237 | - le16_to_cpus(&hdr->entry_count); | ||
238 | + hdr->signature = le64_to_cpu(hdr->signature); | ||
239 | + hdr->entry_count = le16_to_cpu(hdr->entry_count); | ||
240 | } | ||
241 | |||
242 | void vhdx_metadata_header_le_export(VHDXMetadataTableHeader *hdr) | ||
243 | { | ||
244 | assert(hdr != NULL); | ||
245 | |||
246 | - cpu_to_le64s(&hdr->signature); | ||
247 | - cpu_to_le16s(&hdr->entry_count); | ||
248 | + hdr->signature = cpu_to_le64(hdr->signature); | ||
249 | + hdr->entry_count = cpu_to_le16(hdr->entry_count); | ||
250 | } | ||
251 | |||
252 | void vhdx_metadata_entry_le_import(VHDXMetadataTableEntry *e) | ||
253 | @@ -XXX,XX +XXX,XX @@ void vhdx_metadata_entry_le_import(VHDXMetadataTableEntry *e) | ||
254 | assert(e != NULL); | ||
255 | |||
256 | leguid_to_cpus(&e->item_id); | ||
257 | - le32_to_cpus(&e->offset); | ||
258 | - le32_to_cpus(&e->length); | ||
259 | - le32_to_cpus(&e->data_bits); | ||
260 | + e->offset = le32_to_cpu(e->offset); | ||
261 | + e->length = le32_to_cpu(e->length); | ||
262 | + e->data_bits = le32_to_cpu(e->data_bits); | ||
263 | } | ||
264 | void vhdx_metadata_entry_le_export(VHDXMetadataTableEntry *e) | ||
265 | { | ||
266 | assert(e != NULL); | ||
267 | |||
268 | cpu_to_leguids(&e->item_id); | ||
269 | - cpu_to_le32s(&e->offset); | ||
270 | - cpu_to_le32s(&e->length); | ||
271 | - cpu_to_le32s(&e->data_bits); | ||
272 | + e->offset = cpu_to_le32(e->offset); | ||
273 | + e->length = cpu_to_le32(e->length); | ||
274 | + e->data_bits = cpu_to_le32(e->data_bits); | ||
275 | } | ||
276 | diff --git a/block/vhdx-log.c b/block/vhdx-log.c | ||
277 | index XXXXXXX..XXXXXXX 100644 | ||
278 | --- a/block/vhdx-log.c | ||
279 | +++ b/block/vhdx-log.c | ||
280 | @@ -XXX,XX +XXX,XX @@ static void vhdx_log_raw_to_le_sector(VHDXLogDescriptor *desc, | ||
281 | /* 8 + 4084 + 4 = 4096, 1 log sector */ | ||
282 | memcpy(&desc->leading_bytes, data, 8); | ||
283 | data += 8; | ||
284 | - cpu_to_le64s(&desc->leading_bytes); | ||
285 | + desc->leading_bytes = cpu_to_le64(desc->leading_bytes); | ||
286 | memcpy(sector->data, data, 4084); | ||
287 | data += 4084; | ||
288 | memcpy(&desc->trailing_bytes, data, 4); | ||
289 | - cpu_to_le32s(&desc->trailing_bytes); | ||
290 | + desc->trailing_bytes = cpu_to_le32(desc->trailing_bytes); | ||
291 | data += 4; | ||
292 | |||
293 | sector->sequence_high = (uint32_t) (seq >> 32); | ||
294 | diff --git a/block/vhdx.c b/block/vhdx.c | ||
295 | index XXXXXXX..XXXXXXX 100644 | ||
296 | --- a/block/vhdx.c | ||
297 | +++ b/block/vhdx.c | ||
298 | @@ -XXX,XX +XXX,XX @@ uint32_t vhdx_update_checksum(uint8_t *buf, size_t size, int crc_offset) | ||
299 | |||
300 | memset(buf + crc_offset, 0, sizeof(crc)); | ||
301 | crc = crc32c(0xffffffff, buf, size); | ||
302 | - cpu_to_le32s(&crc); | ||
303 | + crc = cpu_to_le32(crc); | ||
304 | memcpy(buf + crc_offset, &crc, sizeof(crc)); | ||
305 | |||
306 | return crc; | ||
307 | @@ -XXX,XX +XXX,XX @@ static int vhdx_parse_metadata(BlockDriverState *bs, BDRVVHDXState *s) | ||
308 | goto exit; | ||
309 | } | ||
310 | |||
311 | - le32_to_cpus(&s->params.block_size); | ||
312 | - le32_to_cpus(&s->params.data_bits); | ||
313 | + s->params.block_size = le32_to_cpu(s->params.block_size); | ||
314 | + s->params.data_bits = le32_to_cpu(s->params.data_bits); | ||
315 | |||
316 | |||
317 | /* We now have the file parameters, so we can tell if this is a | ||
318 | @@ -XXX,XX +XXX,XX @@ static int vhdx_parse_metadata(BlockDriverState *bs, BDRVVHDXState *s) | ||
319 | goto exit; | ||
320 | } | ||
321 | |||
322 | - le64_to_cpus(&s->virtual_disk_size); | ||
323 | - le32_to_cpus(&s->logical_sector_size); | ||
324 | - le32_to_cpus(&s->physical_sector_size); | ||
325 | + s->virtual_disk_size = le64_to_cpu(s->virtual_disk_size); | ||
326 | + s->logical_sector_size = le32_to_cpu(s->logical_sector_size); | ||
327 | + s->physical_sector_size = le32_to_cpu(s->physical_sector_size); | ||
328 | |||
329 | if (s->params.block_size < VHDX_BLOCK_SIZE_MIN || | ||
330 | s->params.block_size > VHDX_BLOCK_SIZE_MAX) { | ||
331 | @@ -XXX,XX +XXX,XX @@ static int vhdx_open(BlockDriverState *bs, QDict *options, int flags, | ||
332 | /* endian convert, and verify populated BAT field file offsets against | ||
333 | * region table and log entries */ | ||
334 | for (i = 0; i < s->bat_entries; i++) { | ||
335 | - le64_to_cpus(&s->bat[i]); | ||
336 | + s->bat[i] = le64_to_cpu(s->bat[i]); | ||
337 | if (payblocks--) { | ||
338 | /* payload bat entries */ | ||
339 | if ((s->bat[i] & VHDX_BAT_STATE_BIT_MASK) == | ||
340 | @@ -XXX,XX +XXX,XX @@ static int vhdx_create_new_metadata(BlockBackend *blk, | ||
341 | mt_file_params->block_size = cpu_to_le32(block_size); | ||
342 | if (type == VHDX_TYPE_FIXED) { | ||
343 | mt_file_params->data_bits |= VHDX_PARAMS_LEAVE_BLOCKS_ALLOCED; | ||
344 | - cpu_to_le32s(&mt_file_params->data_bits); | ||
345 | + mt_file_params->data_bits = cpu_to_le32(mt_file_params->data_bits); | ||
346 | } | ||
347 | |||
348 | vhdx_guid_generate(&mt_page83->page_83_data); | ||
349 | @@ -XXX,XX +XXX,XX @@ static int vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s, | ||
350 | sinfo.file_offset = ROUND_UP(sinfo.file_offset, MiB); | ||
351 | vhdx_update_bat_table_entry(blk_bs(blk), s, &sinfo, &unused, &unused, | ||
352 | block_state); | ||
353 | - cpu_to_le64s(&s->bat[sinfo.bat_idx]); | ||
354 | + s->bat[sinfo.bat_idx] = cpu_to_le64(s->bat[sinfo.bat_idx]); | ||
355 | sector_num += s->sectors_per_block; | ||
356 | } | ||
357 | ret = blk_pwrite(blk, file_offset, s->bat, length, 0); | ||
358 | -- | ||
359 | 2.19.1 | ||
360 | |||
361 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Peter Maydell <peter.maydell@linaro.org> | ||
2 | 1 | ||
3 | Taking the address of a field in a packed struct is a bad idea, because | ||
4 | it might not be actually aligned enough for that pointer type (and | ||
5 | thus cause a crash on dereference on some host architectures). Newer | ||
6 | versions of clang warn about this. Avoid the bug by not using the | ||
7 | "modify in place" byte swapping functions. | ||
8 | |||
9 | There are a few places where the in-place swap function is | ||
10 | used on something other than a packed struct field; we convert | ||
11 | those anyway, for consistency. | ||
12 | |||
13 | Patch produced with scripts/coccinelle/inplace-byteswaps.cocci. | ||
14 | |||
15 | There are other places where we take the address of a packed member | ||
16 | in this file for other purposes than passing it to a byteswap | ||
17 | function (all the calls to qemu_uuid_*()); we leave those for now. | ||
18 | |||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
21 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
22 | --- | ||
23 | block/vdi.c | 64 ++++++++++++++++++++++++++--------------------------- | ||
24 | 1 file changed, 32 insertions(+), 32 deletions(-) | ||
25 | |||
26 | diff --git a/block/vdi.c b/block/vdi.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/block/vdi.c | ||
29 | +++ b/block/vdi.c | ||
30 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
31 | |||
32 | static void vdi_header_to_cpu(VdiHeader *header) | ||
33 | { | ||
34 | - le32_to_cpus(&header->signature); | ||
35 | - le32_to_cpus(&header->version); | ||
36 | - le32_to_cpus(&header->header_size); | ||
37 | - le32_to_cpus(&header->image_type); | ||
38 | - le32_to_cpus(&header->image_flags); | ||
39 | - le32_to_cpus(&header->offset_bmap); | ||
40 | - le32_to_cpus(&header->offset_data); | ||
41 | - le32_to_cpus(&header->cylinders); | ||
42 | - le32_to_cpus(&header->heads); | ||
43 | - le32_to_cpus(&header->sectors); | ||
44 | - le32_to_cpus(&header->sector_size); | ||
45 | - le64_to_cpus(&header->disk_size); | ||
46 | - le32_to_cpus(&header->block_size); | ||
47 | - le32_to_cpus(&header->block_extra); | ||
48 | - le32_to_cpus(&header->blocks_in_image); | ||
49 | - le32_to_cpus(&header->blocks_allocated); | ||
50 | + header->signature = le32_to_cpu(header->signature); | ||
51 | + header->version = le32_to_cpu(header->version); | ||
52 | + header->header_size = le32_to_cpu(header->header_size); | ||
53 | + header->image_type = le32_to_cpu(header->image_type); | ||
54 | + header->image_flags = le32_to_cpu(header->image_flags); | ||
55 | + header->offset_bmap = le32_to_cpu(header->offset_bmap); | ||
56 | + header->offset_data = le32_to_cpu(header->offset_data); | ||
57 | + header->cylinders = le32_to_cpu(header->cylinders); | ||
58 | + header->heads = le32_to_cpu(header->heads); | ||
59 | + header->sectors = le32_to_cpu(header->sectors); | ||
60 | + header->sector_size = le32_to_cpu(header->sector_size); | ||
61 | + header->disk_size = le64_to_cpu(header->disk_size); | ||
62 | + header->block_size = le32_to_cpu(header->block_size); | ||
63 | + header->block_extra = le32_to_cpu(header->block_extra); | ||
64 | + header->blocks_in_image = le32_to_cpu(header->blocks_in_image); | ||
65 | + header->blocks_allocated = le32_to_cpu(header->blocks_allocated); | ||
66 | qemu_uuid_bswap(&header->uuid_image); | ||
67 | qemu_uuid_bswap(&header->uuid_last_snap); | ||
68 | qemu_uuid_bswap(&header->uuid_link); | ||
69 | @@ -XXX,XX +XXX,XX @@ static void vdi_header_to_cpu(VdiHeader *header) | ||
70 | |||
71 | static void vdi_header_to_le(VdiHeader *header) | ||
72 | { | ||
73 | - cpu_to_le32s(&header->signature); | ||
74 | - cpu_to_le32s(&header->version); | ||
75 | - cpu_to_le32s(&header->header_size); | ||
76 | - cpu_to_le32s(&header->image_type); | ||
77 | - cpu_to_le32s(&header->image_flags); | ||
78 | - cpu_to_le32s(&header->offset_bmap); | ||
79 | - cpu_to_le32s(&header->offset_data); | ||
80 | - cpu_to_le32s(&header->cylinders); | ||
81 | - cpu_to_le32s(&header->heads); | ||
82 | - cpu_to_le32s(&header->sectors); | ||
83 | - cpu_to_le32s(&header->sector_size); | ||
84 | - cpu_to_le64s(&header->disk_size); | ||
85 | - cpu_to_le32s(&header->block_size); | ||
86 | - cpu_to_le32s(&header->block_extra); | ||
87 | - cpu_to_le32s(&header->blocks_in_image); | ||
88 | - cpu_to_le32s(&header->blocks_allocated); | ||
89 | + header->signature = cpu_to_le32(header->signature); | ||
90 | + header->version = cpu_to_le32(header->version); | ||
91 | + header->header_size = cpu_to_le32(header->header_size); | ||
92 | + header->image_type = cpu_to_le32(header->image_type); | ||
93 | + header->image_flags = cpu_to_le32(header->image_flags); | ||
94 | + header->offset_bmap = cpu_to_le32(header->offset_bmap); | ||
95 | + header->offset_data = cpu_to_le32(header->offset_data); | ||
96 | + header->cylinders = cpu_to_le32(header->cylinders); | ||
97 | + header->heads = cpu_to_le32(header->heads); | ||
98 | + header->sectors = cpu_to_le32(header->sectors); | ||
99 | + header->sector_size = cpu_to_le32(header->sector_size); | ||
100 | + header->disk_size = cpu_to_le64(header->disk_size); | ||
101 | + header->block_size = cpu_to_le32(header->block_size); | ||
102 | + header->block_extra = cpu_to_le32(header->block_extra); | ||
103 | + header->blocks_in_image = cpu_to_le32(header->blocks_in_image); | ||
104 | + header->blocks_allocated = cpu_to_le32(header->blocks_allocated); | ||
105 | qemu_uuid_bswap(&header->uuid_image); | ||
106 | qemu_uuid_bswap(&header->uuid_last_snap); | ||
107 | qemu_uuid_bswap(&header->uuid_link); | ||
108 | -- | ||
109 | 2.19.1 | ||
110 | |||
111 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alberto Garcia <berto@igalia.com> | ||
2 | 1 | ||
3 | This is a static function with only one caller, so there's no need to | ||
4 | keep it. Inlining the code in quorum_compare() makes it much simpler. | ||
5 | |||
6 | Signed-off-by: Alberto Garcia <berto@igalia.com> | ||
7 | Reported-by: Markus Armbruster <armbru@redhat.com> | ||
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
9 | --- | ||
10 | block/quorum.c | 24 +++++------------------- | ||
11 | 1 file changed, 5 insertions(+), 19 deletions(-) | ||
12 | |||
13 | diff --git a/block/quorum.c b/block/quorum.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/block/quorum.c | ||
16 | +++ b/block/quorum.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static bool quorum_iovec_compare(QEMUIOVector *a, QEMUIOVector *b) | ||
18 | return true; | ||
19 | } | ||
20 | |||
21 | -static void GCC_FMT_ATTR(2, 3) quorum_err(QuorumAIOCB *acb, | ||
22 | - const char *fmt, ...) | ||
23 | -{ | ||
24 | - va_list ap; | ||
25 | - | ||
26 | - va_start(ap, fmt); | ||
27 | - fprintf(stderr, "quorum: offset=%" PRIu64 " bytes=%" PRIu64 " ", | ||
28 | - acb->offset, acb->bytes); | ||
29 | - vfprintf(stderr, fmt, ap); | ||
30 | - fprintf(stderr, "\n"); | ||
31 | - va_end(ap); | ||
32 | - exit(1); | ||
33 | -} | ||
34 | - | ||
35 | -static bool quorum_compare(QuorumAIOCB *acb, | ||
36 | - QEMUIOVector *a, | ||
37 | - QEMUIOVector *b) | ||
38 | +static bool quorum_compare(QuorumAIOCB *acb, QEMUIOVector *a, QEMUIOVector *b) | ||
39 | { | ||
40 | BDRVQuorumState *s = acb->bs->opaque; | ||
41 | ssize_t offset; | ||
42 | @@ -XXX,XX +XXX,XX @@ static bool quorum_compare(QuorumAIOCB *acb, | ||
43 | if (s->is_blkverify) { | ||
44 | offset = qemu_iovec_compare(a, b); | ||
45 | if (offset != -1) { | ||
46 | - quorum_err(acb, "contents mismatch at offset %" PRIu64, | ||
47 | - acb->offset + offset); | ||
48 | + fprintf(stderr, "quorum: offset=%" PRIu64 " bytes=%" PRIu64 | ||
49 | + " contents mismatch at offset %" PRIu64 "\n", | ||
50 | + acb->offset, acb->bytes, acb->offset + offset); | ||
51 | + exit(1); | ||
52 | } | ||
53 | return true; | ||
54 | } | ||
55 | -- | ||
56 | 2.19.1 | ||
57 | |||
58 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alberto Garcia <berto@igalia.com> | ||
2 | 1 | ||
3 | The blkverify mode of Quorum can only be enabled if the number of | ||
4 | children is exactly two and the value of vote-threshold is also two. | ||
5 | |||
6 | If the user tries to enable it but the other settings are incorrect | ||
7 | then QEMU simply prints an error message to stderr and carries on | ||
8 | disabling the blkverify setting. | ||
9 | |||
10 | This patch makes quorum_open() fail and return an error in this case. | ||
11 | |||
12 | Signed-off-by: Alberto Garcia <berto@igalia.com> | ||
13 | Reported-by: Markus Armbruster <armbru@redhat.com> | ||
14 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
15 | --- | ||
16 | block/quorum.c | 13 ++++++------- | ||
17 | 1 file changed, 6 insertions(+), 7 deletions(-) | ||
18 | |||
19 | diff --git a/block/quorum.c b/block/quorum.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/block/quorum.c | ||
22 | +++ b/block/quorum.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, | ||
24 | s->read_pattern = ret; | ||
25 | |||
26 | if (s->read_pattern == QUORUM_READ_PATTERN_QUORUM) { | ||
27 | - /* is the driver in blkverify mode */ | ||
28 | - if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false) && | ||
29 | - s->num_children == 2 && s->threshold == 2) { | ||
30 | - s->is_blkverify = true; | ||
31 | - } else if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false)) { | ||
32 | - fprintf(stderr, "blkverify mode is set by setting blkverify=on " | ||
33 | - "and using two files with vote_threshold=2\n"); | ||
34 | + s->is_blkverify = qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false); | ||
35 | + if (s->is_blkverify && (s->num_children != 2 || s->threshold != 2)) { | ||
36 | + error_setg(&local_err, "blkverify=on can only be set if there are " | ||
37 | + "exactly two files and vote-threshold is 2"); | ||
38 | + ret = -EINVAL; | ||
39 | + goto exit; | ||
40 | } | ||
41 | |||
42 | s->rewrite_corrupted = qemu_opt_get_bool(opts, QUORUM_OPT_REWRITE, | ||
43 | -- | ||
44 | 2.19.1 | ||
45 | |||
46 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alberto Garcia <berto@igalia.com> | ||
2 | 1 | ||
3 | Signed-off-by: Alberto Garcia <berto@igalia.com> | ||
4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
5 | --- | ||
6 | tests/qemu-iotests/081 | 30 ++++++++++++++++++++++++++++++ | ||
7 | tests/qemu-iotests/081.out | 16 ++++++++++++++++ | ||
8 | 2 files changed, 46 insertions(+) | ||
9 | |||
10 | diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081 | ||
11 | index XXXXXXX..XXXXXXX 100755 | ||
12 | --- a/tests/qemu-iotests/081 | ||
13 | +++ b/tests/qemu-iotests/081 | ||
14 | @@ -XXX,XX +XXX,XX @@ echo "== checking that quorum is broken ==" | ||
15 | |||
16 | $QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io | ||
17 | |||
18 | +echo | ||
19 | +echo "== checking the blkverify mode with broken content ==" | ||
20 | + | ||
21 | +quorum="driver=raw,file.driver=quorum,file.vote-threshold=2,file.blkverify=on" | ||
22 | +quorum="$quorum,file.children.0.file.filename=$TEST_DIR/1.raw" | ||
23 | +quorum="$quorum,file.children.1.file.filename=$TEST_DIR/2.raw" | ||
24 | +quorum="$quorum,file.children.0.driver=raw" | ||
25 | +quorum="$quorum,file.children.1.driver=raw" | ||
26 | + | ||
27 | +$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io | ||
28 | + | ||
29 | +echo | ||
30 | +echo "== writing the same data to both files ==" | ||
31 | + | ||
32 | +$QEMU_IO -c "write -P 0x32 0 $size" "$TEST_DIR/1.raw" | _filter_qemu_io | ||
33 | +$QEMU_IO -c "write -P 0x32 0 $size" "$TEST_DIR/2.raw" | _filter_qemu_io | ||
34 | + | ||
35 | +echo | ||
36 | +echo "== checking the blkverify mode with valid content ==" | ||
37 | + | ||
38 | +$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io | ||
39 | + | ||
40 | +echo | ||
41 | +echo "== checking the blkverify mode with invalid settings ==" | ||
42 | + | ||
43 | +quorum="$quorum,file.children.2.file.filename=$TEST_DIR/3.raw" | ||
44 | +quorum="$quorum,file.children.2.driver=raw" | ||
45 | + | ||
46 | +$QEMU_IO -c "open -o $quorum" | _filter_qemu_io | ||
47 | + | ||
48 | # success, all done | ||
49 | echo "*** done" | ||
50 | rm -f $seq.full | ||
51 | diff --git a/tests/qemu-iotests/081.out b/tests/qemu-iotests/081.out | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/tests/qemu-iotests/081.out | ||
54 | +++ b/tests/qemu-iotests/081.out | ||
55 | @@ -XXX,XX +XXX,XX @@ wrote 10485760/10485760 bytes at offset 0 | ||
56 | |||
57 | == checking that quorum is broken == | ||
58 | read failed: Input/output error | ||
59 | + | ||
60 | +== checking the blkverify mode with broken content == | ||
61 | +quorum: offset=0 bytes=10485760 contents mismatch at offset 0 | ||
62 | + | ||
63 | +== writing the same data to both files == | ||
64 | +wrote 10485760/10485760 bytes at offset 0 | ||
65 | +10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
66 | +wrote 10485760/10485760 bytes at offset 0 | ||
67 | +10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
68 | + | ||
69 | +== checking the blkverify mode with valid content == | ||
70 | +read 10485760/10485760 bytes at offset 0 | ||
71 | +10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
72 | + | ||
73 | +== checking the blkverify mode with invalid settings == | ||
74 | +can't open: blkverify=on can only be set if there are exactly two files and vote-threshold is 2 | ||
75 | *** done | ||
76 | -- | ||
77 | 2.19.1 | ||
78 | |||
79 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alberto Garcia <berto@igalia.com> | ||
2 | 1 | ||
3 | The blkverify mode of Quorum only works when the number of children is | ||
4 | exactly two, so any attempt to add a new one must return an error. | ||
5 | |||
6 | quorum_del_child() on the other hand doesn't need any additional check | ||
7 | because decreasing the number of children would make it go under the | ||
8 | vote threshold. | ||
9 | |||
10 | Signed-off-by: Alberto Garcia <berto@igalia.com> | ||
11 | Reported-by: Kevin Wolf <kwolf@redhat.com> | ||
12 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
13 | --- | ||
14 | block/quorum.c | 8 ++++++++ | ||
15 | 1 file changed, 8 insertions(+) | ||
16 | |||
17 | diff --git a/block/quorum.c b/block/quorum.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/block/quorum.c | ||
20 | +++ b/block/quorum.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static void quorum_add_child(BlockDriverState *bs, BlockDriverState *child_bs, | ||
22 | char indexstr[32]; | ||
23 | int ret; | ||
24 | |||
25 | + if (s->is_blkverify) { | ||
26 | + error_setg(errp, "Cannot add a child to a quorum in blkverify mode"); | ||
27 | + return; | ||
28 | + } | ||
29 | + | ||
30 | assert(s->num_children <= INT_MAX / sizeof(BdrvChild *)); | ||
31 | if (s->num_children == INT_MAX / sizeof(BdrvChild *) || | ||
32 | s->next_child_index == UINT_MAX) { | ||
33 | @@ -XXX,XX +XXX,XX @@ static void quorum_del_child(BlockDriverState *bs, BdrvChild *child, | ||
34 | return; | ||
35 | } | ||
36 | |||
37 | + /* We know now that num_children > threshold, so blkverify must be false */ | ||
38 | + assert(!s->is_blkverify); | ||
39 | + | ||
40 | bdrv_drained_begin(bs); | ||
41 | |||
42 | /* We can safely remove this child now */ | ||
43 | -- | ||
44 | 2.19.1 | ||
45 | |||
46 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alberto Garcia <berto@igalia.com> | ||
2 | 1 | ||
3 | This patch tests that you can add and remove drives from a Quorum | ||
4 | using the x-blockdev-change command. | ||
5 | |||
6 | Signed-off-by: Alberto Garcia <berto@igalia.com> | ||
7 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
8 | --- | ||
9 | tests/qemu-iotests/081 | 86 ++++++++++++++++++++++++++++++++++++++ | ||
10 | tests/qemu-iotests/081.out | 54 ++++++++++++++++++++++++ | ||
11 | 2 files changed, 140 insertions(+) | ||
12 | |||
13 | diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081 | ||
14 | index XXXXXXX..XXXXXXX 100755 | ||
15 | --- a/tests/qemu-iotests/081 | ||
16 | +++ b/tests/qemu-iotests/081 | ||
17 | @@ -XXX,XX +XXX,XX @@ quorum="$quorum,file.children.2.driver=raw" | ||
18 | |||
19 | $QEMU_IO -c "open -o $quorum" | _filter_qemu_io | ||
20 | |||
21 | +echo | ||
22 | +echo "== dynamically adding a child to a quorum ==" | ||
23 | + | ||
24 | +for verify in false true; do | ||
25 | + run_qemu <<EOF | ||
26 | + { "execute": "qmp_capabilities" } | ||
27 | + { "execute": "blockdev-add", | ||
28 | + "arguments": { | ||
29 | + "driver": "quorum", | ||
30 | + "node-name": "drive0-quorum", | ||
31 | + "vote-threshold": 2, | ||
32 | + "blkverify": ${verify}, | ||
33 | + "children": [ | ||
34 | + { | ||
35 | + "driver": "$IMGFMT", | ||
36 | + "file": { | ||
37 | + "driver": "file", | ||
38 | + "filename": "$TEST_DIR/1.raw" | ||
39 | + } | ||
40 | + }, | ||
41 | + { | ||
42 | + "driver": "$IMGFMT", | ||
43 | + "file": { | ||
44 | + "driver": "file", | ||
45 | + "filename": "$TEST_DIR/2.raw" | ||
46 | + } | ||
47 | + } | ||
48 | + ] | ||
49 | + } | ||
50 | + } | ||
51 | + { "execute": "blockdev-add", | ||
52 | + "arguments": { | ||
53 | + "node-name": "drive3", | ||
54 | + "driver": "$IMGFMT", | ||
55 | + "file": { | ||
56 | + "driver": "file", | ||
57 | + "filename": "$TEST_DIR/2.raw" | ||
58 | + } | ||
59 | + } | ||
60 | + } | ||
61 | + { "execute": "x-blockdev-change", | ||
62 | + "arguments": { "parent": "drive0-quorum", | ||
63 | + "node": "drive3" } } | ||
64 | + { "execute": "quit" } | ||
65 | +EOF | ||
66 | +done | ||
67 | + | ||
68 | +echo | ||
69 | +echo "== dynamically removing a child from a quorum ==" | ||
70 | + | ||
71 | +for verify in false true; do | ||
72 | + for vote_threshold in 1 2; do | ||
73 | + run_qemu <<EOF | ||
74 | + { "execute": "qmp_capabilities" } | ||
75 | + { "execute": "blockdev-add", | ||
76 | + "arguments": { | ||
77 | + "driver": "quorum", | ||
78 | + "node-name": "drive0-quorum", | ||
79 | + "vote-threshold": ${vote_threshold}, | ||
80 | + "blkverify": ${verify}, | ||
81 | + "children": [ | ||
82 | + { | ||
83 | + "driver": "$IMGFMT", | ||
84 | + "file": { | ||
85 | + "driver": "file", | ||
86 | + "filename": "$TEST_DIR/1.raw" | ||
87 | + } | ||
88 | + }, | ||
89 | + { | ||
90 | + "driver": "$IMGFMT", | ||
91 | + "file": { | ||
92 | + "driver": "file", | ||
93 | + "filename": "$TEST_DIR/2.raw" | ||
94 | + } | ||
95 | + } | ||
96 | + ] | ||
97 | + } | ||
98 | + } | ||
99 | + { "execute": "x-blockdev-change", | ||
100 | + "arguments": { "parent": "drive0-quorum", | ||
101 | + "child": "children.1" } } | ||
102 | + { "execute": "quit" } | ||
103 | +EOF | ||
104 | + done | ||
105 | +done | ||
106 | + | ||
107 | # success, all done | ||
108 | echo "*** done" | ||
109 | rm -f $seq.full | ||
110 | diff --git a/tests/qemu-iotests/081.out b/tests/qemu-iotests/081.out | ||
111 | index XXXXXXX..XXXXXXX 100644 | ||
112 | --- a/tests/qemu-iotests/081.out | ||
113 | +++ b/tests/qemu-iotests/081.out | ||
114 | @@ -XXX,XX +XXX,XX @@ read 10485760/10485760 bytes at offset 0 | ||
115 | |||
116 | == checking the blkverify mode with invalid settings == | ||
117 | can't open: blkverify=on can only be set if there are exactly two files and vote-threshold is 2 | ||
118 | + | ||
119 | +== dynamically adding a child to a quorum == | ||
120 | +Testing: | ||
121 | +QMP_VERSION | ||
122 | +{"return": {}} | ||
123 | +{"return": {}} | ||
124 | +{"return": {}} | ||
125 | +{"return": {}} | ||
126 | +{"return": {}} | ||
127 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} | ||
128 | + | ||
129 | +Testing: | ||
130 | +QMP_VERSION | ||
131 | +{"return": {}} | ||
132 | +{"return": {}} | ||
133 | +{"return": {}} | ||
134 | +{"error": {"class": "GenericError", "desc": "Cannot add a child to a quorum in blkverify mode"}} | ||
135 | +{"return": {}} | ||
136 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} | ||
137 | + | ||
138 | + | ||
139 | +== dynamically removing a child from a quorum == | ||
140 | +Testing: | ||
141 | +QMP_VERSION | ||
142 | +{"return": {}} | ||
143 | +{"return": {}} | ||
144 | +{"return": {}} | ||
145 | +{"return": {}} | ||
146 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} | ||
147 | + | ||
148 | +Testing: | ||
149 | +QMP_VERSION | ||
150 | +{"return": {}} | ||
151 | +{"return": {}} | ||
152 | +{"error": {"class": "GenericError", "desc": "The number of children cannot be lower than the vote threshold 2"}} | ||
153 | +{"return": {}} | ||
154 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} | ||
155 | + | ||
156 | +Testing: | ||
157 | +QMP_VERSION | ||
158 | +{"return": {}} | ||
159 | +{"error": {"class": "GenericError", "desc": "blkverify=on can only be set if there are exactly two files and vote-threshold is 2"}} | ||
160 | +{"error": {"class": "GenericError", "desc": "Cannot find device=drive0-quorum nor node_name=drive0-quorum"}} | ||
161 | +{"return": {}} | ||
162 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} | ||
163 | + | ||
164 | +Testing: | ||
165 | +QMP_VERSION | ||
166 | +{"return": {}} | ||
167 | +{"return": {}} | ||
168 | +{"error": {"class": "GenericError", "desc": "The number of children cannot be lower than the vote threshold 2"}} | ||
169 | +{"return": {}} | ||
170 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} | ||
171 | + | ||
172 | *** done | ||
173 | -- | ||
174 | 2.19.1 | ||
175 | |||
176 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | If a management application builds the block graph node by node, the | ||
2 | protocol layer doesn't inherit its read-only option from the format | ||
3 | layer any more, so it must be set explicitly. | ||
4 | 1 | ||
5 | Backing files should work on read-only storage, but at the same time, a | ||
6 | block job like commit should be able to reopen them read-write if they | ||
7 | are on read-write storage. However, without option inheritance, reopen | ||
8 | only changes the read-only option for the root node (typically the | ||
9 | format layer), but not the protocol layer, so reopening fails (the | ||
10 | format layer wants to get write permissions, but the protocol layer is | ||
11 | still read-only). | ||
12 | |||
13 | A simple workaround for the problem in the management tool would be to | ||
14 | open the protocol layer always read-write and to make only the format | ||
15 | layer read-only for backing files. However, sometimes the file is | ||
16 | actually stored on read-only storage and we don't know whether the image | ||
17 | can be opened read-write (for example, for NBD it depends on the server | ||
18 | we're trying to connect to). This adds an option that makes QEMU try to | ||
19 | open the image read-write, but allows it to degrade to a read-only mode | ||
20 | without returning an error. | ||
21 | |||
22 | The documentation for this option is consciously phrased in a way that | ||
23 | allows QEMU to switch to a better model eventually: Instead of trying | ||
24 | when the image is first opened, making the read-only flag dynamic and | ||
25 | changing it automatically whenever the first BLK_PERM_WRITE user is | ||
26 | attached or the last one is detached would be much more useful | ||
27 | behaviour. | ||
28 | |||
29 | Unfortunately, this more useful behaviour is also a lot harder to | ||
30 | implement, and libvirt needs a solution now before it can switch to | ||
31 | -blockdev, so let's start with this easier approach for now. | ||
32 | |||
33 | Instead of adding a new auto-read-only option, turning the existing | ||
34 | read-only into an enum (with a bool alternate for compatibility) was | ||
35 | considered, but it complicated the implementation to the point that it | ||
36 | didn't seem to be worth it. | ||
37 | |||
38 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
39 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
40 | --- | ||
41 | qapi/block-core.json | 7 +++++++ | ||
42 | include/block/block.h | 2 ++ | ||
43 | block.c | 17 +++++++++++++++++ | ||
44 | block/vvfat.c | 1 + | ||
45 | blockdev.c | 2 +- | ||
46 | 5 files changed, 28 insertions(+), 1 deletion(-) | ||
47 | |||
48 | diff --git a/qapi/block-core.json b/qapi/block-core.json | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/qapi/block-core.json | ||
51 | +++ b/qapi/block-core.json | ||
52 | @@ -XXX,XX +XXX,XX @@ | ||
53 | # either generally or in certain configurations. In this case, | ||
54 | # the default value does not work and the option must be | ||
55 | # specified explicitly. | ||
56 | +# @auto-read-only: if true and @read-only is false, QEMU may automatically | ||
57 | +# decide not to open the image read-write as requested, but | ||
58 | +# fall back to read-only instead (and switch between the modes | ||
59 | +# later), e.g. depending on whether the image file is writable | ||
60 | +# or whether a writing user is attached to the node | ||
61 | +# (default: false, since 3.1) | ||
62 | # @detect-zeroes: detect and optimize zero writes (Since 2.1) | ||
63 | # (default: off) | ||
64 | # @force-share: force share all permission on added nodes. | ||
65 | @@ -XXX,XX +XXX,XX @@ | ||
66 | '*discard': 'BlockdevDiscardOptions', | ||
67 | '*cache': 'BlockdevCacheOptions', | ||
68 | '*read-only': 'bool', | ||
69 | + '*auto-read-only': 'bool', | ||
70 | '*force-share': 'bool', | ||
71 | '*detect-zeroes': 'BlockdevDetectZeroesOptions' }, | ||
72 | 'discriminator': 'driver', | ||
73 | diff --git a/include/block/block.h b/include/block/block.h | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/include/block/block.h | ||
76 | +++ b/include/block/block.h | ||
77 | @@ -XXX,XX +XXX,XX @@ typedef struct HDGeometry { | ||
78 | select an appropriate protocol driver, | ||
79 | ignoring the format layer */ | ||
80 | #define BDRV_O_NO_IO 0x10000 /* don't initialize for I/O */ | ||
81 | +#define BDRV_O_AUTO_RDONLY 0x20000 /* degrade to read-only if opening read-write fails */ | ||
82 | |||
83 | #define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_NO_FLUSH) | ||
84 | |||
85 | @@ -XXX,XX +XXX,XX @@ typedef struct HDGeometry { | ||
86 | #define BDRV_OPT_CACHE_DIRECT "cache.direct" | ||
87 | #define BDRV_OPT_CACHE_NO_FLUSH "cache.no-flush" | ||
88 | #define BDRV_OPT_READ_ONLY "read-only" | ||
89 | +#define BDRV_OPT_AUTO_READ_ONLY "auto-read-only" | ||
90 | #define BDRV_OPT_DISCARD "discard" | ||
91 | #define BDRV_OPT_FORCE_SHARE "force-share" | ||
92 | |||
93 | diff --git a/block.c b/block.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/block.c | ||
96 | +++ b/block.c | ||
97 | @@ -XXX,XX +XXX,XX @@ static void bdrv_inherited_options(int *child_flags, QDict *child_options, | ||
98 | |||
99 | /* Inherit the read-only option from the parent if it's not set */ | ||
100 | qdict_copy_default(child_options, parent_options, BDRV_OPT_READ_ONLY); | ||
101 | + qdict_copy_default(child_options, parent_options, BDRV_OPT_AUTO_READ_ONLY); | ||
102 | |||
103 | /* Our block drivers take care to send flushes and respect unmap policy, | ||
104 | * so we can default to enable both on lower layers regardless of the | ||
105 | @@ -XXX,XX +XXX,XX @@ static void bdrv_backing_options(int *child_flags, QDict *child_options, | ||
106 | |||
107 | /* backing files always opened read-only */ | ||
108 | qdict_set_default_str(child_options, BDRV_OPT_READ_ONLY, "on"); | ||
109 | + qdict_set_default_str(child_options, BDRV_OPT_AUTO_READ_ONLY, "off"); | ||
110 | flags &= ~BDRV_O_COPY_ON_READ; | ||
111 | |||
112 | /* snapshot=on is handled on the top layer */ | ||
113 | @@ -XXX,XX +XXX,XX @@ static void update_flags_from_options(int *flags, QemuOpts *opts) | ||
114 | *flags |= BDRV_O_RDWR; | ||
115 | } | ||
116 | |||
117 | + assert(qemu_opt_find(opts, BDRV_OPT_AUTO_READ_ONLY)); | ||
118 | + if (qemu_opt_get_bool_del(opts, BDRV_OPT_AUTO_READ_ONLY, false)) { | ||
119 | + *flags |= BDRV_O_AUTO_RDONLY; | ||
120 | + } | ||
121 | } | ||
122 | |||
123 | static void update_options_from_flags(QDict *options, int flags) | ||
124 | @@ -XXX,XX +XXX,XX @@ static void update_options_from_flags(QDict *options, int flags) | ||
125 | if (!qdict_haskey(options, BDRV_OPT_READ_ONLY)) { | ||
126 | qdict_put_bool(options, BDRV_OPT_READ_ONLY, !(flags & BDRV_O_RDWR)); | ||
127 | } | ||
128 | + if (!qdict_haskey(options, BDRV_OPT_AUTO_READ_ONLY)) { | ||
129 | + qdict_put_bool(options, BDRV_OPT_AUTO_READ_ONLY, | ||
130 | + flags & BDRV_O_AUTO_RDONLY); | ||
131 | + } | ||
132 | } | ||
133 | |||
134 | static void bdrv_assign_node_name(BlockDriverState *bs, | ||
135 | @@ -XXX,XX +XXX,XX @@ QemuOptsList bdrv_runtime_opts = { | ||
136 | .type = QEMU_OPT_BOOL, | ||
137 | .help = "Node is opened in read-only mode", | ||
138 | }, | ||
139 | + { | ||
140 | + .name = BDRV_OPT_AUTO_READ_ONLY, | ||
141 | + .type = QEMU_OPT_BOOL, | ||
142 | + .help = "Node can become read-only if opening read-write fails", | ||
143 | + }, | ||
144 | { | ||
145 | .name = "detect-zeroes", | ||
146 | .type = QEMU_OPT_STRING, | ||
147 | @@ -XXX,XX +XXX,XX @@ BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp) | ||
148 | qdict_set_default_str(qdict, BDRV_OPT_CACHE_DIRECT, "off"); | ||
149 | qdict_set_default_str(qdict, BDRV_OPT_CACHE_NO_FLUSH, "off"); | ||
150 | qdict_set_default_str(qdict, BDRV_OPT_READ_ONLY, "off"); | ||
151 | + qdict_set_default_str(qdict, BDRV_OPT_AUTO_READ_ONLY, "off"); | ||
152 | + | ||
153 | } | ||
154 | |||
155 | bs = bdrv_open_inherit(NULL, reference, qdict, 0, NULL, NULL, errp); | ||
156 | diff --git a/block/vvfat.c b/block/vvfat.c | ||
157 | index XXXXXXX..XXXXXXX 100644 | ||
158 | --- a/block/vvfat.c | ||
159 | +++ b/block/vvfat.c | ||
160 | @@ -XXX,XX +XXX,XX @@ static void vvfat_qcow_options(int *child_flags, QDict *child_options, | ||
161 | int parent_flags, QDict *parent_options) | ||
162 | { | ||
163 | qdict_set_default_str(child_options, BDRV_OPT_READ_ONLY, "off"); | ||
164 | + qdict_set_default_str(child_options, BDRV_OPT_AUTO_READ_ONLY, "off"); | ||
165 | qdict_set_default_str(child_options, BDRV_OPT_CACHE_NO_FLUSH, "on"); | ||
166 | } | ||
167 | |||
168 | diff --git a/blockdev.c b/blockdev.c | ||
169 | index XXXXXXX..XXXXXXX 100644 | ||
170 | --- a/blockdev.c | ||
171 | +++ b/blockdev.c | ||
172 | @@ -XXX,XX +XXX,XX @@ void qmp_blockdev_change_medium(bool has_device, const char *device, | ||
173 | |||
174 | bdrv_flags = blk_get_open_flags_from_root_state(blk); | ||
175 | bdrv_flags &= ~(BDRV_O_TEMPORARY | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING | | ||
176 | - BDRV_O_PROTOCOL); | ||
177 | + BDRV_O_PROTOCOL | BDRV_O_AUTO_RDONLY); | ||
178 | |||
179 | if (!has_read_only) { | ||
180 | read_only = BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN; | ||
181 | -- | ||
182 | 2.19.1 | ||
183 | |||
184 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Commit e2b8247a322 introduced an error path in qemu_rbd_open() after | ||
2 | calling rbd_open(), but neglected to close the image again in this error | ||
3 | path. The error path should contain everything that the regular close | ||
4 | function qemu_rbd_close() contains. | ||
5 | 1 | ||
6 | This adds the missing rbd_close() call. | ||
7 | |||
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
9 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
10 | --- | ||
11 | block/rbd.c | 1 + | ||
12 | 1 file changed, 1 insertion(+) | ||
13 | |||
14 | diff --git a/block/rbd.c b/block/rbd.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/block/rbd.c | ||
17 | +++ b/block/rbd.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, | ||
19 | "automatically marking the image read-only."); | ||
20 | r = bdrv_set_read_only(bs, true, &local_err); | ||
21 | if (r < 0) { | ||
22 | + rbd_close(s->image); | ||
23 | error_propagate(errp, local_err); | ||
24 | goto failed_open; | ||
25 | } | ||
26 | -- | ||
27 | 2.19.1 | ||
28 | |||
29 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | If read-only=off, but auto-read-only=on is given, open a read-write NBD | ||
2 | connection if the server provides a read-write export, but instead of | ||
3 | erroring out for read-only exports, just degrade to read-only. | ||
4 | 1 | ||
5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
6 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
7 | --- | ||
8 | block/nbd-client.c | 10 +++++----- | ||
9 | 1 file changed, 5 insertions(+), 5 deletions(-) | ||
10 | |||
11 | diff --git a/block/nbd-client.c b/block/nbd-client.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/block/nbd-client.c | ||
14 | +++ b/block/nbd-client.c | ||
15 | @@ -XXX,XX +XXX,XX @@ int nbd_client_init(BlockDriverState *bs, | ||
16 | logout("Failed to negotiate with the NBD server\n"); | ||
17 | return ret; | ||
18 | } | ||
19 | - if (client->info.flags & NBD_FLAG_READ_ONLY && | ||
20 | - !bdrv_is_read_only(bs)) { | ||
21 | - error_setg(errp, | ||
22 | - "request for write access conflicts with read-only export"); | ||
23 | - return -EACCES; | ||
24 | + if (client->info.flags & NBD_FLAG_READ_ONLY) { | ||
25 | + ret = bdrv_apply_auto_read_only(bs, "NBD export is read-only", errp); | ||
26 | + if (ret < 0) { | ||
27 | + return ret; | ||
28 | + } | ||
29 | } | ||
30 | if (client->info.flags & NBD_FLAG_SEND_FUA) { | ||
31 | bs->supported_write_flags = BDRV_REQ_FUA; | ||
32 | -- | ||
33 | 2.19.1 | ||
34 | |||
35 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | 1 | bdrv_create options specified with -o have no effect when skipping image |
---|---|---|---|
2 | creation with -n, so this doesn't make sense. Warn against the misuse | ||
3 | and deprecate the combination so we can make it a hard error later. | ||
2 | 4 | ||
3 | This adds some whitespace into the option help (including indentation) | 5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
4 | and puts angle brackets around the type names. Furthermore, the list | 6 | Reviewed-by: Max Reitz <mreitz@redhat.com> |
5 | name is no longer printed as part of every line, but only once in | 7 | Reviewed-by: John Snow <jsnow@redhat.com> |
6 | advance, and only if the caller did not print a caption already. | 8 | Reviewed-by: Eric Blake <eblake@redhat.com> |
9 | --- | ||
10 | qemu-img.c | 5 +++++ | ||
11 | qemu-deprecated.texi | 7 +++++++ | ||
12 | 2 files changed, 12 insertions(+) | ||
7 | 13 | ||
8 | This patch also restores the description alignment we had before commit | ||
9 | 9cbef9d68ee1d8d0, just at 24 instead of 16 characters like we used to. | ||
10 | This increase is because now we have the type and two spaces of | ||
11 | indentation before the description, and with a usual type name length of | ||
12 | three chracters, this sums up to eight additional characters -- which | ||
13 | means that we now need 24 characters to get the same amount of padding | ||
14 | for most options. Also, 24 is a third of 80, which makes it kind of a | ||
15 | round number in terminal terms. | ||
16 | |||
17 | Finally, this patch amends the reference output of iotest 082 to match | ||
18 | the changes (and thus makes it pass again). | ||
19 | |||
20 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
21 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | ||
22 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
23 | --- | ||
24 | include/qemu/option.h | 2 +- | ||
25 | qemu-img.c | 4 +- | ||
26 | util/qemu-option.c | 32 +- | ||
27 | tests/qemu-iotests/082.out | 956 ++++++++++++++++++------------------- | ||
28 | 4 files changed, 507 insertions(+), 487 deletions(-) | ||
29 | |||
30 | diff --git a/include/qemu/option.h b/include/qemu/option.h | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/include/qemu/option.h | ||
33 | +++ b/include/qemu/option.h | ||
34 | @@ -XXX,XX +XXX,XX @@ typedef int (*qemu_opts_loopfunc)(void *opaque, QemuOpts *opts, Error **errp); | ||
35 | int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, | ||
36 | void *opaque, Error **errp); | ||
37 | void qemu_opts_print(QemuOpts *opts, const char *sep); | ||
38 | -void qemu_opts_print_help(QemuOptsList *list); | ||
39 | +void qemu_opts_print_help(QemuOptsList *list, bool print_caption); | ||
40 | void qemu_opts_free(QemuOptsList *list); | ||
41 | QemuOptsList *qemu_opts_append(QemuOptsList *dst, QemuOptsList *list); | ||
42 | |||
43 | diff --git a/qemu-img.c b/qemu-img.c | 14 | diff --git a/qemu-img.c b/qemu-img.c |
44 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
45 | --- a/qemu-img.c | 16 | --- a/qemu-img.c |
46 | +++ b/qemu-img.c | 17 | +++ b/qemu-img.c |
47 | @@ -XXX,XX +XXX,XX @@ static int print_block_option_help(const char *filename, const char *fmt) | 18 | @@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv) |
19 | goto fail_getopt; | ||
48 | } | 20 | } |
49 | 21 | ||
50 | printf("Supported options:\n"); | 22 | + if (skip_create && options) { |
51 | - qemu_opts_print_help(create_opts); | 23 | + warn_report("-o has no effect when skipping image creation"); |
52 | + qemu_opts_print_help(create_opts, false); | 24 | + warn_report("This will become an error in future QEMU versions."); |
53 | qemu_opts_free(create_opts); | 25 | + } |
54 | return 0; | 26 | + |
55 | } | 27 | s.src_num = argc - optind - 1; |
56 | @@ -XXX,XX +XXX,XX @@ static int print_amend_option_help(const char *format) | 28 | out_filename = s.src_num >= 1 ? argv[argc - 1] : NULL; |
57 | assert(drv->create_opts); | 29 | |
58 | 30 | diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi | |
59 | printf("Creation options for '%s':\n", format); | ||
60 | - qemu_opts_print_help(drv->create_opts); | ||
61 | + qemu_opts_print_help(drv->create_opts, false); | ||
62 | printf("\nNote that not all of these options may be amendable.\n"); | ||
63 | return 0; | ||
64 | } | ||
65 | diff --git a/util/qemu-option.c b/util/qemu-option.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
67 | --- a/util/qemu-option.c | 32 | --- a/qemu-deprecated.texi |
68 | +++ b/util/qemu-option.c | 33 | +++ b/qemu-deprecated.texi |
69 | @@ -XXX,XX +XXX,XX @@ static const char *opt_type_to_string(enum QemuOptType type) | 34 | @@ -XXX,XX +XXX,XX @@ to just export the entire image and then mount only /dev/nbd0p1 than |
70 | g_assert_not_reached(); | 35 | it is to reinvoke @command{qemu-nbd -c /dev/nbd0} limited to just a |
71 | } | 36 | subset of the image. |
72 | 37 | ||
73 | -void qemu_opts_print_help(QemuOptsList *list) | 38 | +@subsection qemu-img convert -n -o (since 4.2.0) |
74 | +/** | 39 | + |
75 | + * Print the list of options available in the given list. If | 40 | +All options specified in @option{-o} are image creation options, so |
76 | + * @print_caption is true, a caption (including the list name, if it | 41 | +they have no effect when used with @option{-n} to skip image creation. |
77 | + * exists) is printed. The options itself will be indented, so | 42 | +Silently ignored options can be confusing, so this combination of |
78 | + * @print_caption should only be set to false if the caller prints its | 43 | +options will be made an error in future versions. |
79 | + * own custom caption (so that the indentation makes sense). | 44 | + |
80 | + */ | 45 | @section Build system |
81 | +void qemu_opts_print_help(QemuOptsList *list, bool print_caption) | 46 | |
82 | { | 47 | @subsection Python 2 support (since 4.1.0) |
83 | QemuOptDesc *desc; | ||
84 | int i; | ||
85 | @@ -XXX,XX +XXX,XX @@ void qemu_opts_print_help(QemuOptsList *list) | ||
86 | desc = list->desc; | ||
87 | while (desc && desc->name) { | ||
88 | GString *str = g_string_new(NULL); | ||
89 | - if (list->name) { | ||
90 | - g_string_append_printf(str, "%s.", list->name); | ||
91 | - } | ||
92 | - g_string_append_printf(str, "%s=%s", desc->name, | ||
93 | + g_string_append_printf(str, " %s=<%s>", desc->name, | ||
94 | opt_type_to_string(desc->type)); | ||
95 | if (desc->help) { | ||
96 | + if (str->len < 24) { | ||
97 | + g_string_append_printf(str, "%*s", 24 - (int)str->len, ""); | ||
98 | + } | ||
99 | g_string_append_printf(str, " - %s", desc->help); | ||
100 | } | ||
101 | g_ptr_array_add(array, g_string_free(str, false)); | ||
102 | @@ -XXX,XX +XXX,XX @@ void qemu_opts_print_help(QemuOptsList *list) | ||
103 | } | ||
104 | |||
105 | g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0); | ||
106 | + if (print_caption && array->len > 0) { | ||
107 | + if (list->name) { | ||
108 | + printf("%s options:\n", list->name); | ||
109 | + } else { | ||
110 | + printf("Options:\n"); | ||
111 | + } | ||
112 | + } else if (array->len == 0) { | ||
113 | + if (list->name) { | ||
114 | + printf("There are no options for %s.\n", list->name); | ||
115 | + } else { | ||
116 | + printf("No options available.\n"); | ||
117 | + } | ||
118 | + } | ||
119 | for (i = 0; i < array->len; i++) { | ||
120 | printf("%s\n", (char *)array->pdata[i]); | ||
121 | } | ||
122 | @@ -XXX,XX +XXX,XX @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params, | ||
123 | opts = opts_parse(list, params, permit_abbrev, false, &invalidp, &err); | ||
124 | if (err) { | ||
125 | if (invalidp && has_help_option(params)) { | ||
126 | - qemu_opts_print_help(list); | ||
127 | + qemu_opts_print_help(list, true); | ||
128 | error_free(err); | ||
129 | } else { | ||
130 | error_report_err(err); | ||
131 | diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out | ||
132 | index XXXXXXX..XXXXXXX 100644 | ||
133 | --- a/tests/qemu-iotests/082.out | ||
134 | +++ b/tests/qemu-iotests/082.out | ||
135 | @@ -XXX,XX +XXX,XX @@ cluster_size: 8192 | ||
136 | |||
137 | Testing: create -f qcow2 -o help TEST_DIR/t.qcow2 128M | ||
138 | Supported options: | ||
139 | -size Virtual disk size | ||
140 | -compat Compatibility level (0.10 or 1.1) | ||
141 | -backing_file File name of a base image | ||
142 | -backing_fmt Image format of the base image | ||
143 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
144 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
145 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
146 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
147 | -encrypt.cipher-mode Name of encryption cipher mode | ||
148 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
149 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
150 | -encrypt.hash-alg Name of encryption hash algorithm | ||
151 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
152 | -cluster_size qcow2 cluster size | ||
153 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
154 | -lazy_refcounts Postpone refcount updates | ||
155 | -refcount_bits Width of a reference count entry in bits | ||
156 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
157 | + backing_file=<str> - File name of a base image | ||
158 | + backing_fmt=<str> - Image format of the base image | ||
159 | + cluster_size=<size> - qcow2 cluster size | ||
160 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
161 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
162 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
163 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
164 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
165 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
166 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
167 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
168 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
169 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
170 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
171 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
172 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
173 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
174 | + size=<size> - Virtual disk size | ||
175 | |||
176 | Testing: create -f qcow2 -o ? TEST_DIR/t.qcow2 128M | ||
177 | Supported options: | ||
178 | -size Virtual disk size | ||
179 | -compat Compatibility level (0.10 or 1.1) | ||
180 | -backing_file File name of a base image | ||
181 | -backing_fmt Image format of the base image | ||
182 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
183 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
184 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
185 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
186 | -encrypt.cipher-mode Name of encryption cipher mode | ||
187 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
188 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
189 | -encrypt.hash-alg Name of encryption hash algorithm | ||
190 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
191 | -cluster_size qcow2 cluster size | ||
192 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
193 | -lazy_refcounts Postpone refcount updates | ||
194 | -refcount_bits Width of a reference count entry in bits | ||
195 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
196 | + backing_file=<str> - File name of a base image | ||
197 | + backing_fmt=<str> - Image format of the base image | ||
198 | + cluster_size=<size> - qcow2 cluster size | ||
199 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
200 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
201 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
202 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
203 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
204 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
205 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
206 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
207 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
208 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
209 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
210 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
211 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
212 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
213 | + size=<size> - Virtual disk size | ||
214 | |||
215 | Testing: create -f qcow2 -o cluster_size=4k,help TEST_DIR/t.qcow2 128M | ||
216 | Supported options: | ||
217 | -size Virtual disk size | ||
218 | -compat Compatibility level (0.10 or 1.1) | ||
219 | -backing_file File name of a base image | ||
220 | -backing_fmt Image format of the base image | ||
221 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
222 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
223 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
224 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
225 | -encrypt.cipher-mode Name of encryption cipher mode | ||
226 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
227 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
228 | -encrypt.hash-alg Name of encryption hash algorithm | ||
229 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
230 | -cluster_size qcow2 cluster size | ||
231 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
232 | -lazy_refcounts Postpone refcount updates | ||
233 | -refcount_bits Width of a reference count entry in bits | ||
234 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
235 | + backing_file=<str> - File name of a base image | ||
236 | + backing_fmt=<str> - Image format of the base image | ||
237 | + cluster_size=<size> - qcow2 cluster size | ||
238 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
239 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
240 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
241 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
242 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
243 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
244 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
245 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
246 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
247 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
248 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
249 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
250 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
251 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
252 | + size=<size> - Virtual disk size | ||
253 | |||
254 | Testing: create -f qcow2 -o cluster_size=4k,? TEST_DIR/t.qcow2 128M | ||
255 | Supported options: | ||
256 | -size Virtual disk size | ||
257 | -compat Compatibility level (0.10 or 1.1) | ||
258 | -backing_file File name of a base image | ||
259 | -backing_fmt Image format of the base image | ||
260 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
261 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
262 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
263 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
264 | -encrypt.cipher-mode Name of encryption cipher mode | ||
265 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
266 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
267 | -encrypt.hash-alg Name of encryption hash algorithm | ||
268 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
269 | -cluster_size qcow2 cluster size | ||
270 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
271 | -lazy_refcounts Postpone refcount updates | ||
272 | -refcount_bits Width of a reference count entry in bits | ||
273 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
274 | + backing_file=<str> - File name of a base image | ||
275 | + backing_fmt=<str> - Image format of the base image | ||
276 | + cluster_size=<size> - qcow2 cluster size | ||
277 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
278 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
279 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
280 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
281 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
282 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
283 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
284 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
285 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
286 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
287 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
288 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
289 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
290 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
291 | + size=<size> - Virtual disk size | ||
292 | |||
293 | Testing: create -f qcow2 -o help,cluster_size=4k TEST_DIR/t.qcow2 128M | ||
294 | Supported options: | ||
295 | -size Virtual disk size | ||
296 | -compat Compatibility level (0.10 or 1.1) | ||
297 | -backing_file File name of a base image | ||
298 | -backing_fmt Image format of the base image | ||
299 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
300 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
301 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
302 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
303 | -encrypt.cipher-mode Name of encryption cipher mode | ||
304 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
305 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
306 | -encrypt.hash-alg Name of encryption hash algorithm | ||
307 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
308 | -cluster_size qcow2 cluster size | ||
309 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
310 | -lazy_refcounts Postpone refcount updates | ||
311 | -refcount_bits Width of a reference count entry in bits | ||
312 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
313 | + backing_file=<str> - File name of a base image | ||
314 | + backing_fmt=<str> - Image format of the base image | ||
315 | + cluster_size=<size> - qcow2 cluster size | ||
316 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
317 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
318 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
319 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
320 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
321 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
322 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
323 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
324 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
325 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
326 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
327 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
328 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
329 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
330 | + size=<size> - Virtual disk size | ||
331 | |||
332 | Testing: create -f qcow2 -o ?,cluster_size=4k TEST_DIR/t.qcow2 128M | ||
333 | Supported options: | ||
334 | -size Virtual disk size | ||
335 | -compat Compatibility level (0.10 or 1.1) | ||
336 | -backing_file File name of a base image | ||
337 | -backing_fmt Image format of the base image | ||
338 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
339 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
340 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
341 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
342 | -encrypt.cipher-mode Name of encryption cipher mode | ||
343 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
344 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
345 | -encrypt.hash-alg Name of encryption hash algorithm | ||
346 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
347 | -cluster_size qcow2 cluster size | ||
348 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
349 | -lazy_refcounts Postpone refcount updates | ||
350 | -refcount_bits Width of a reference count entry in bits | ||
351 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
352 | + backing_file=<str> - File name of a base image | ||
353 | + backing_fmt=<str> - Image format of the base image | ||
354 | + cluster_size=<size> - qcow2 cluster size | ||
355 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
356 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
357 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
358 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
359 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
360 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
361 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
362 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
363 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
364 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
365 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
366 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
367 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
368 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
369 | + size=<size> - Virtual disk size | ||
370 | |||
371 | Testing: create -f qcow2 -o cluster_size=4k -o help TEST_DIR/t.qcow2 128M | ||
372 | Supported options: | ||
373 | -size Virtual disk size | ||
374 | -compat Compatibility level (0.10 or 1.1) | ||
375 | -backing_file File name of a base image | ||
376 | -backing_fmt Image format of the base image | ||
377 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
378 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
379 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
380 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
381 | -encrypt.cipher-mode Name of encryption cipher mode | ||
382 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
383 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
384 | -encrypt.hash-alg Name of encryption hash algorithm | ||
385 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
386 | -cluster_size qcow2 cluster size | ||
387 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
388 | -lazy_refcounts Postpone refcount updates | ||
389 | -refcount_bits Width of a reference count entry in bits | ||
390 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
391 | + backing_file=<str> - File name of a base image | ||
392 | + backing_fmt=<str> - Image format of the base image | ||
393 | + cluster_size=<size> - qcow2 cluster size | ||
394 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
395 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
396 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
397 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
398 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
399 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
400 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
401 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
402 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
403 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
404 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
405 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
406 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
407 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
408 | + size=<size> - Virtual disk size | ||
409 | |||
410 | Testing: create -f qcow2 -o cluster_size=4k -o ? TEST_DIR/t.qcow2 128M | ||
411 | Supported options: | ||
412 | -size Virtual disk size | ||
413 | -compat Compatibility level (0.10 or 1.1) | ||
414 | -backing_file File name of a base image | ||
415 | -backing_fmt Image format of the base image | ||
416 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
417 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
418 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
419 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
420 | -encrypt.cipher-mode Name of encryption cipher mode | ||
421 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
422 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
423 | -encrypt.hash-alg Name of encryption hash algorithm | ||
424 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
425 | -cluster_size qcow2 cluster size | ||
426 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
427 | -lazy_refcounts Postpone refcount updates | ||
428 | -refcount_bits Width of a reference count entry in bits | ||
429 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
430 | + backing_file=<str> - File name of a base image | ||
431 | + backing_fmt=<str> - Image format of the base image | ||
432 | + cluster_size=<size> - qcow2 cluster size | ||
433 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
434 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
435 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
436 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
437 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
438 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
439 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
440 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
441 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
442 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
443 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
444 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
445 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
446 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
447 | + size=<size> - Virtual disk size | ||
448 | |||
449 | Testing: create -f qcow2 -u -o backing_file=TEST_DIR/t.qcow2,,help TEST_DIR/t.qcow2 128M | ||
450 | Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/t.qcow2,,help cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
451 | @@ -XXX,XX +XXX,XX @@ qemu-img: Invalid option list: ,, | ||
452 | |||
453 | Testing: create -f qcow2 -o help | ||
454 | Supported options: | ||
455 | -size Virtual disk size | ||
456 | -compat Compatibility level (0.10 or 1.1) | ||
457 | -backing_file File name of a base image | ||
458 | -backing_fmt Image format of the base image | ||
459 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
460 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
461 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
462 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
463 | -encrypt.cipher-mode Name of encryption cipher mode | ||
464 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
465 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
466 | -encrypt.hash-alg Name of encryption hash algorithm | ||
467 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
468 | -cluster_size qcow2 cluster size | ||
469 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
470 | -lazy_refcounts Postpone refcount updates | ||
471 | -refcount_bits Width of a reference count entry in bits | ||
472 | + backing_file=<str> - File name of a base image | ||
473 | + backing_fmt=<str> - Image format of the base image | ||
474 | + cluster_size=<size> - qcow2 cluster size | ||
475 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
476 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
477 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
478 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
479 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
480 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
481 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
482 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
483 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
484 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
485 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
486 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
487 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
488 | + size=<size> - Virtual disk size | ||
489 | |||
490 | Testing: create -o help | ||
491 | Supported options: | ||
492 | -size Virtual disk size | ||
493 | + size=<size> - Virtual disk size | ||
494 | |||
495 | Testing: create -f bochs -o help | ||
496 | qemu-img: Format driver 'bochs' does not support image creation | ||
497 | @@ -XXX,XX +XXX,XX @@ cluster_size: 8192 | ||
498 | |||
499 | Testing: convert -O qcow2 -o help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base | ||
500 | Supported options: | ||
501 | -size Virtual disk size | ||
502 | -compat Compatibility level (0.10 or 1.1) | ||
503 | -backing_file File name of a base image | ||
504 | -backing_fmt Image format of the base image | ||
505 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
506 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
507 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
508 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
509 | -encrypt.cipher-mode Name of encryption cipher mode | ||
510 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
511 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
512 | -encrypt.hash-alg Name of encryption hash algorithm | ||
513 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
514 | -cluster_size qcow2 cluster size | ||
515 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
516 | -lazy_refcounts Postpone refcount updates | ||
517 | -refcount_bits Width of a reference count entry in bits | ||
518 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
519 | + backing_file=<str> - File name of a base image | ||
520 | + backing_fmt=<str> - Image format of the base image | ||
521 | + cluster_size=<size> - qcow2 cluster size | ||
522 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
523 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
524 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
525 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
526 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
527 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
528 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
529 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
530 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
531 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
532 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
533 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
534 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
535 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
536 | + size=<size> - Virtual disk size | ||
537 | |||
538 | Testing: convert -O qcow2 -o ? TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base | ||
539 | Supported options: | ||
540 | -size Virtual disk size | ||
541 | -compat Compatibility level (0.10 or 1.1) | ||
542 | -backing_file File name of a base image | ||
543 | -backing_fmt Image format of the base image | ||
544 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
545 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
546 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
547 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
548 | -encrypt.cipher-mode Name of encryption cipher mode | ||
549 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
550 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
551 | -encrypt.hash-alg Name of encryption hash algorithm | ||
552 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
553 | -cluster_size qcow2 cluster size | ||
554 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
555 | -lazy_refcounts Postpone refcount updates | ||
556 | -refcount_bits Width of a reference count entry in bits | ||
557 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
558 | + backing_file=<str> - File name of a base image | ||
559 | + backing_fmt=<str> - Image format of the base image | ||
560 | + cluster_size=<size> - qcow2 cluster size | ||
561 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
562 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
563 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
564 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
565 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
566 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
567 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
568 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
569 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
570 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
571 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
572 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
573 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
574 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
575 | + size=<size> - Virtual disk size | ||
576 | |||
577 | Testing: convert -O qcow2 -o cluster_size=4k,help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base | ||
578 | Supported options: | ||
579 | -size Virtual disk size | ||
580 | -compat Compatibility level (0.10 or 1.1) | ||
581 | -backing_file File name of a base image | ||
582 | -backing_fmt Image format of the base image | ||
583 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
584 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
585 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
586 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
587 | -encrypt.cipher-mode Name of encryption cipher mode | ||
588 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
589 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
590 | -encrypt.hash-alg Name of encryption hash algorithm | ||
591 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
592 | -cluster_size qcow2 cluster size | ||
593 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
594 | -lazy_refcounts Postpone refcount updates | ||
595 | -refcount_bits Width of a reference count entry in bits | ||
596 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
597 | + backing_file=<str> - File name of a base image | ||
598 | + backing_fmt=<str> - Image format of the base image | ||
599 | + cluster_size=<size> - qcow2 cluster size | ||
600 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
601 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
602 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
603 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
604 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
605 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
606 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
607 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
608 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
609 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
610 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
611 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
612 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
613 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
614 | + size=<size> - Virtual disk size | ||
615 | |||
616 | Testing: convert -O qcow2 -o cluster_size=4k,? TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base | ||
617 | Supported options: | ||
618 | -size Virtual disk size | ||
619 | -compat Compatibility level (0.10 or 1.1) | ||
620 | -backing_file File name of a base image | ||
621 | -backing_fmt Image format of the base image | ||
622 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
623 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
624 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
625 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
626 | -encrypt.cipher-mode Name of encryption cipher mode | ||
627 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
628 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
629 | -encrypt.hash-alg Name of encryption hash algorithm | ||
630 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
631 | -cluster_size qcow2 cluster size | ||
632 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
633 | -lazy_refcounts Postpone refcount updates | ||
634 | -refcount_bits Width of a reference count entry in bits | ||
635 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
636 | + backing_file=<str> - File name of a base image | ||
637 | + backing_fmt=<str> - Image format of the base image | ||
638 | + cluster_size=<size> - qcow2 cluster size | ||
639 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
640 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
641 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
642 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
643 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
644 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
645 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
646 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
647 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
648 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
649 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
650 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
651 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
652 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
653 | + size=<size> - Virtual disk size | ||
654 | |||
655 | Testing: convert -O qcow2 -o help,cluster_size=4k TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base | ||
656 | Supported options: | ||
657 | -size Virtual disk size | ||
658 | -compat Compatibility level (0.10 or 1.1) | ||
659 | -backing_file File name of a base image | ||
660 | -backing_fmt Image format of the base image | ||
661 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
662 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
663 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
664 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
665 | -encrypt.cipher-mode Name of encryption cipher mode | ||
666 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
667 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
668 | -encrypt.hash-alg Name of encryption hash algorithm | ||
669 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
670 | -cluster_size qcow2 cluster size | ||
671 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
672 | -lazy_refcounts Postpone refcount updates | ||
673 | -refcount_bits Width of a reference count entry in bits | ||
674 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
675 | + backing_file=<str> - File name of a base image | ||
676 | + backing_fmt=<str> - Image format of the base image | ||
677 | + cluster_size=<size> - qcow2 cluster size | ||
678 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
679 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
680 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
681 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
682 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
683 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
684 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
685 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
686 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
687 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
688 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
689 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
690 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
691 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
692 | + size=<size> - Virtual disk size | ||
693 | |||
694 | Testing: convert -O qcow2 -o ?,cluster_size=4k TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base | ||
695 | Supported options: | ||
696 | -size Virtual disk size | ||
697 | -compat Compatibility level (0.10 or 1.1) | ||
698 | -backing_file File name of a base image | ||
699 | -backing_fmt Image format of the base image | ||
700 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
701 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
702 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
703 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
704 | -encrypt.cipher-mode Name of encryption cipher mode | ||
705 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
706 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
707 | -encrypt.hash-alg Name of encryption hash algorithm | ||
708 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
709 | -cluster_size qcow2 cluster size | ||
710 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
711 | -lazy_refcounts Postpone refcount updates | ||
712 | -refcount_bits Width of a reference count entry in bits | ||
713 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
714 | + backing_file=<str> - File name of a base image | ||
715 | + backing_fmt=<str> - Image format of the base image | ||
716 | + cluster_size=<size> - qcow2 cluster size | ||
717 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
718 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
719 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
720 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
721 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
722 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
723 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
724 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
725 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
726 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
727 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
728 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
729 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
730 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
731 | + size=<size> - Virtual disk size | ||
732 | |||
733 | Testing: convert -O qcow2 -o cluster_size=4k -o help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base | ||
734 | Supported options: | ||
735 | -size Virtual disk size | ||
736 | -compat Compatibility level (0.10 or 1.1) | ||
737 | -backing_file File name of a base image | ||
738 | -backing_fmt Image format of the base image | ||
739 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
740 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
741 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
742 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
743 | -encrypt.cipher-mode Name of encryption cipher mode | ||
744 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
745 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
746 | -encrypt.hash-alg Name of encryption hash algorithm | ||
747 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
748 | -cluster_size qcow2 cluster size | ||
749 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
750 | -lazy_refcounts Postpone refcount updates | ||
751 | -refcount_bits Width of a reference count entry in bits | ||
752 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
753 | + backing_file=<str> - File name of a base image | ||
754 | + backing_fmt=<str> - Image format of the base image | ||
755 | + cluster_size=<size> - qcow2 cluster size | ||
756 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
757 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
758 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
759 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
760 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
761 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
762 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
763 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
764 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
765 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
766 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
767 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
768 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
769 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
770 | + size=<size> - Virtual disk size | ||
771 | |||
772 | Testing: convert -O qcow2 -o cluster_size=4k -o ? TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base | ||
773 | Supported options: | ||
774 | -size Virtual disk size | ||
775 | -compat Compatibility level (0.10 or 1.1) | ||
776 | -backing_file File name of a base image | ||
777 | -backing_fmt Image format of the base image | ||
778 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
779 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
780 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
781 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
782 | -encrypt.cipher-mode Name of encryption cipher mode | ||
783 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
784 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
785 | -encrypt.hash-alg Name of encryption hash algorithm | ||
786 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
787 | -cluster_size qcow2 cluster size | ||
788 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
789 | -lazy_refcounts Postpone refcount updates | ||
790 | -refcount_bits Width of a reference count entry in bits | ||
791 | -nocow Turn off copy-on-write (valid only on btrfs) | ||
792 | + backing_file=<str> - File name of a base image | ||
793 | + backing_fmt=<str> - Image format of the base image | ||
794 | + cluster_size=<size> - qcow2 cluster size | ||
795 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
796 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
797 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
798 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
799 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
800 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
801 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
802 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
803 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
804 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
805 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
806 | + nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs) | ||
807 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
808 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
809 | + size=<size> - Virtual disk size | ||
810 | |||
811 | Testing: convert -O qcow2 -o backing_file=TEST_DIR/t.qcow2,,help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base | ||
812 | qemu-img: Could not open 'TEST_DIR/t.qcow2.base': Could not open backing file: Could not open 'TEST_DIR/t.qcow2,help': No such file or directory | ||
813 | @@ -XXX,XX +XXX,XX @@ qemu-img: Invalid option list: ,, | ||
814 | |||
815 | Testing: convert -O qcow2 -o help | ||
816 | Supported options: | ||
817 | -size Virtual disk size | ||
818 | -compat Compatibility level (0.10 or 1.1) | ||
819 | -backing_file File name of a base image | ||
820 | -backing_fmt Image format of the base image | ||
821 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
822 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
823 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
824 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
825 | -encrypt.cipher-mode Name of encryption cipher mode | ||
826 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
827 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
828 | -encrypt.hash-alg Name of encryption hash algorithm | ||
829 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
830 | -cluster_size qcow2 cluster size | ||
831 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
832 | -lazy_refcounts Postpone refcount updates | ||
833 | -refcount_bits Width of a reference count entry in bits | ||
834 | + backing_file=<str> - File name of a base image | ||
835 | + backing_fmt=<str> - Image format of the base image | ||
836 | + cluster_size=<size> - qcow2 cluster size | ||
837 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
838 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
839 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
840 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
841 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
842 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
843 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
844 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
845 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
846 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
847 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
848 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
849 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
850 | + size=<size> - Virtual disk size | ||
851 | |||
852 | Testing: convert -o help | ||
853 | Supported options: | ||
854 | -size Virtual disk size | ||
855 | + size=<size> - Virtual disk size | ||
856 | |||
857 | Testing: convert -O bochs -o help | ||
858 | qemu-img: Format driver 'bochs' does not support image creation | ||
859 | @@ -XXX,XX +XXX,XX @@ cluster_size: 65536 | ||
860 | |||
861 | Testing: amend -f qcow2 -o help TEST_DIR/t.qcow2 | ||
862 | Creation options for 'qcow2': | ||
863 | -size Virtual disk size | ||
864 | -compat Compatibility level (0.10 or 1.1) | ||
865 | -backing_file File name of a base image | ||
866 | -backing_fmt Image format of the base image | ||
867 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
868 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
869 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
870 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
871 | -encrypt.cipher-mode Name of encryption cipher mode | ||
872 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
873 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
874 | -encrypt.hash-alg Name of encryption hash algorithm | ||
875 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
876 | -cluster_size qcow2 cluster size | ||
877 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
878 | -lazy_refcounts Postpone refcount updates | ||
879 | -refcount_bits Width of a reference count entry in bits | ||
880 | + backing_file=<str> - File name of a base image | ||
881 | + backing_fmt=<str> - Image format of the base image | ||
882 | + cluster_size=<size> - qcow2 cluster size | ||
883 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
884 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
885 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
886 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
887 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
888 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
889 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
890 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
891 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
892 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
893 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
894 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
895 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
896 | + size=<size> - Virtual disk size | ||
897 | |||
898 | Note that not all of these options may be amendable. | ||
899 | |||
900 | Testing: amend -f qcow2 -o ? TEST_DIR/t.qcow2 | ||
901 | Creation options for 'qcow2': | ||
902 | -size Virtual disk size | ||
903 | -compat Compatibility level (0.10 or 1.1) | ||
904 | -backing_file File name of a base image | ||
905 | -backing_fmt Image format of the base image | ||
906 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
907 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
908 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
909 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
910 | -encrypt.cipher-mode Name of encryption cipher mode | ||
911 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
912 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
913 | -encrypt.hash-alg Name of encryption hash algorithm | ||
914 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
915 | -cluster_size qcow2 cluster size | ||
916 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
917 | -lazy_refcounts Postpone refcount updates | ||
918 | -refcount_bits Width of a reference count entry in bits | ||
919 | + backing_file=<str> - File name of a base image | ||
920 | + backing_fmt=<str> - Image format of the base image | ||
921 | + cluster_size=<size> - qcow2 cluster size | ||
922 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
923 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
924 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
925 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
926 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
927 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
928 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
929 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
930 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
931 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
932 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
933 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
934 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
935 | + size=<size> - Virtual disk size | ||
936 | |||
937 | Note that not all of these options may be amendable. | ||
938 | |||
939 | Testing: amend -f qcow2 -o cluster_size=4k,help TEST_DIR/t.qcow2 | ||
940 | Creation options for 'qcow2': | ||
941 | -size Virtual disk size | ||
942 | -compat Compatibility level (0.10 or 1.1) | ||
943 | -backing_file File name of a base image | ||
944 | -backing_fmt Image format of the base image | ||
945 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
946 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
947 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
948 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
949 | -encrypt.cipher-mode Name of encryption cipher mode | ||
950 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
951 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
952 | -encrypt.hash-alg Name of encryption hash algorithm | ||
953 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
954 | -cluster_size qcow2 cluster size | ||
955 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
956 | -lazy_refcounts Postpone refcount updates | ||
957 | -refcount_bits Width of a reference count entry in bits | ||
958 | + backing_file=<str> - File name of a base image | ||
959 | + backing_fmt=<str> - Image format of the base image | ||
960 | + cluster_size=<size> - qcow2 cluster size | ||
961 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
962 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
963 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
964 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
965 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
966 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
967 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
968 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
969 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
970 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
971 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
972 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
973 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
974 | + size=<size> - Virtual disk size | ||
975 | |||
976 | Note that not all of these options may be amendable. | ||
977 | |||
978 | Testing: amend -f qcow2 -o cluster_size=4k,? TEST_DIR/t.qcow2 | ||
979 | Creation options for 'qcow2': | ||
980 | -size Virtual disk size | ||
981 | -compat Compatibility level (0.10 or 1.1) | ||
982 | -backing_file File name of a base image | ||
983 | -backing_fmt Image format of the base image | ||
984 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
985 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
986 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
987 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
988 | -encrypt.cipher-mode Name of encryption cipher mode | ||
989 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
990 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
991 | -encrypt.hash-alg Name of encryption hash algorithm | ||
992 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
993 | -cluster_size qcow2 cluster size | ||
994 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
995 | -lazy_refcounts Postpone refcount updates | ||
996 | -refcount_bits Width of a reference count entry in bits | ||
997 | + backing_file=<str> - File name of a base image | ||
998 | + backing_fmt=<str> - Image format of the base image | ||
999 | + cluster_size=<size> - qcow2 cluster size | ||
1000 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
1001 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
1002 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
1003 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
1004 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
1005 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
1006 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
1007 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
1008 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
1009 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
1010 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
1011 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
1012 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
1013 | + size=<size> - Virtual disk size | ||
1014 | |||
1015 | Note that not all of these options may be amendable. | ||
1016 | |||
1017 | Testing: amend -f qcow2 -o help,cluster_size=4k TEST_DIR/t.qcow2 | ||
1018 | Creation options for 'qcow2': | ||
1019 | -size Virtual disk size | ||
1020 | -compat Compatibility level (0.10 or 1.1) | ||
1021 | -backing_file File name of a base image | ||
1022 | -backing_fmt Image format of the base image | ||
1023 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
1024 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
1025 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
1026 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
1027 | -encrypt.cipher-mode Name of encryption cipher mode | ||
1028 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
1029 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
1030 | -encrypt.hash-alg Name of encryption hash algorithm | ||
1031 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
1032 | -cluster_size qcow2 cluster size | ||
1033 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
1034 | -lazy_refcounts Postpone refcount updates | ||
1035 | -refcount_bits Width of a reference count entry in bits | ||
1036 | + backing_file=<str> - File name of a base image | ||
1037 | + backing_fmt=<str> - Image format of the base image | ||
1038 | + cluster_size=<size> - qcow2 cluster size | ||
1039 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
1040 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
1041 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
1042 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
1043 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
1044 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
1045 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
1046 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
1047 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
1048 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
1049 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
1050 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
1051 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
1052 | + size=<size> - Virtual disk size | ||
1053 | |||
1054 | Note that not all of these options may be amendable. | ||
1055 | |||
1056 | Testing: amend -f qcow2 -o ?,cluster_size=4k TEST_DIR/t.qcow2 | ||
1057 | Creation options for 'qcow2': | ||
1058 | -size Virtual disk size | ||
1059 | -compat Compatibility level (0.10 or 1.1) | ||
1060 | -backing_file File name of a base image | ||
1061 | -backing_fmt Image format of the base image | ||
1062 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
1063 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
1064 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
1065 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
1066 | -encrypt.cipher-mode Name of encryption cipher mode | ||
1067 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
1068 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
1069 | -encrypt.hash-alg Name of encryption hash algorithm | ||
1070 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
1071 | -cluster_size qcow2 cluster size | ||
1072 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
1073 | -lazy_refcounts Postpone refcount updates | ||
1074 | -refcount_bits Width of a reference count entry in bits | ||
1075 | + backing_file=<str> - File name of a base image | ||
1076 | + backing_fmt=<str> - Image format of the base image | ||
1077 | + cluster_size=<size> - qcow2 cluster size | ||
1078 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
1079 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
1080 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
1081 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
1082 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
1083 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
1084 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
1085 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
1086 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
1087 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
1088 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
1089 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
1090 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
1091 | + size=<size> - Virtual disk size | ||
1092 | |||
1093 | Note that not all of these options may be amendable. | ||
1094 | |||
1095 | Testing: amend -f qcow2 -o cluster_size=4k -o help TEST_DIR/t.qcow2 | ||
1096 | Creation options for 'qcow2': | ||
1097 | -size Virtual disk size | ||
1098 | -compat Compatibility level (0.10 or 1.1) | ||
1099 | -backing_file File name of a base image | ||
1100 | -backing_fmt Image format of the base image | ||
1101 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
1102 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
1103 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
1104 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
1105 | -encrypt.cipher-mode Name of encryption cipher mode | ||
1106 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
1107 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
1108 | -encrypt.hash-alg Name of encryption hash algorithm | ||
1109 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
1110 | -cluster_size qcow2 cluster size | ||
1111 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
1112 | -lazy_refcounts Postpone refcount updates | ||
1113 | -refcount_bits Width of a reference count entry in bits | ||
1114 | + backing_file=<str> - File name of a base image | ||
1115 | + backing_fmt=<str> - Image format of the base image | ||
1116 | + cluster_size=<size> - qcow2 cluster size | ||
1117 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
1118 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
1119 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
1120 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
1121 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
1122 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
1123 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
1124 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
1125 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
1126 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
1127 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
1128 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
1129 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
1130 | + size=<size> - Virtual disk size | ||
1131 | |||
1132 | Note that not all of these options may be amendable. | ||
1133 | |||
1134 | Testing: amend -f qcow2 -o cluster_size=4k -o ? TEST_DIR/t.qcow2 | ||
1135 | Creation options for 'qcow2': | ||
1136 | -size Virtual disk size | ||
1137 | -compat Compatibility level (0.10 or 1.1) | ||
1138 | -backing_file File name of a base image | ||
1139 | -backing_fmt Image format of the base image | ||
1140 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
1141 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
1142 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
1143 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
1144 | -encrypt.cipher-mode Name of encryption cipher mode | ||
1145 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
1146 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
1147 | -encrypt.hash-alg Name of encryption hash algorithm | ||
1148 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
1149 | -cluster_size qcow2 cluster size | ||
1150 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
1151 | -lazy_refcounts Postpone refcount updates | ||
1152 | -refcount_bits Width of a reference count entry in bits | ||
1153 | + backing_file=<str> - File name of a base image | ||
1154 | + backing_fmt=<str> - Image format of the base image | ||
1155 | + cluster_size=<size> - qcow2 cluster size | ||
1156 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
1157 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
1158 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
1159 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
1160 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
1161 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
1162 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
1163 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
1164 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
1165 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
1166 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
1167 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
1168 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
1169 | + size=<size> - Virtual disk size | ||
1170 | |||
1171 | Note that not all of these options may be amendable. | ||
1172 | |||
1173 | @@ -XXX,XX +XXX,XX @@ qemu-img: Invalid option list: ,, | ||
1174 | |||
1175 | Testing: amend -f qcow2 -o help | ||
1176 | Creation options for 'qcow2': | ||
1177 | -size Virtual disk size | ||
1178 | -compat Compatibility level (0.10 or 1.1) | ||
1179 | -backing_file File name of a base image | ||
1180 | -backing_fmt Image format of the base image | ||
1181 | -encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
1182 | -encrypt.format Encrypt the image, format choices: 'aes', 'luks' | ||
1183 | -encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase | ||
1184 | -encrypt.cipher-alg Name of encryption cipher algorithm | ||
1185 | -encrypt.cipher-mode Name of encryption cipher mode | ||
1186 | -encrypt.ivgen-alg Name of IV generator algorithm | ||
1187 | -encrypt.ivgen-hash-alg Name of IV generator hash algorithm | ||
1188 | -encrypt.hash-alg Name of encryption hash algorithm | ||
1189 | -encrypt.iter-time Time to spend in PBKDF in milliseconds | ||
1190 | -cluster_size qcow2 cluster size | ||
1191 | -preallocation Preallocation mode (allowed values: off, metadata, falloc, full) | ||
1192 | -lazy_refcounts Postpone refcount updates | ||
1193 | -refcount_bits Width of a reference count entry in bits | ||
1194 | + backing_file=<str> - File name of a base image | ||
1195 | + backing_fmt=<str> - Image format of the base image | ||
1196 | + cluster_size=<size> - qcow2 cluster size | ||
1197 | + compat=<str> - Compatibility level (0.10 or 1.1) | ||
1198 | + encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
1199 | + encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
1200 | + encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
1201 | + encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
1202 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
1203 | + encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
1204 | + encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
1205 | + encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
1206 | + encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
1207 | + lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
1208 | + preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
1209 | + refcount_bits=<num> - Width of a reference count entry in bits | ||
1210 | + size=<size> - Virtual disk size | ||
1211 | |||
1212 | Note that not all of these options may be amendable. | ||
1213 | |||
1214 | Testing: convert -o help | ||
1215 | Supported options: | ||
1216 | -size Virtual disk size | ||
1217 | + size=<size> - Virtual disk size | ||
1218 | |||
1219 | Testing: amend -f bochs -o help | ||
1220 | qemu-img: Format driver 'bochs' does not support option amendment | ||
1221 | -- | 48 | -- |
1222 | 2.19.1 | 49 | 2.20.1 |
1223 | 50 | ||
1224 | 51 | diff view generated by jsdifflib |
1 | If read-only=off, but auto-read-only=on is given, open the file | 1 | From: Nir Soffer <nirsof@gmail.com> |
---|---|---|---|
2 | read-write if we have the permissions, but instead of erroring out for | ||
3 | read-only files, just degrade to read-only. | ||
4 | 2 | ||
3 | In some cases buf_align or request_alignment cannot be detected: | ||
4 | |||
5 | 1. With Gluster, buf_align cannot be detected since the actual I/O is | ||
6 | done on Gluster server, and qemu buffer alignment does not matter. | ||
7 | Since we don't have alignment requirement, buf_align=1 is the best | ||
8 | value. | ||
9 | |||
10 | 2. With local XFS filesystem, buf_align cannot be detected if reading | ||
11 | from unallocated area. In this we must align the buffer, but we don't | ||
12 | know what is the correct size. Using the wrong alignment results in | ||
13 | I/O error. | ||
14 | |||
15 | 3. With Gluster backed by XFS, request_alignment cannot be detected if | ||
16 | reading from unallocated area. In this case we need to use the | ||
17 | correct alignment, and failing to do so results in I/O errors. | ||
18 | |||
19 | 4. With NFS, the server does not use direct I/O, so both buf_align cannot | ||
20 | be detected. In this case we don't need any alignment so we can use | ||
21 | buf_align=1 and request_alignment=1. | ||
22 | |||
23 | These cases seems to work when storage sector size is 512 bytes, because | ||
24 | the current code starts checking align=512. If the check succeeds | ||
25 | because alignment cannot be detected we use 512. But this does not work | ||
26 | for storage with 4k sector size. | ||
27 | |||
28 | To determine if we can detect the alignment, we probe first with | ||
29 | align=1. If probing succeeds, maybe there are no alignment requirement | ||
30 | (cases 1, 4) or we are probing unallocated area (cases 2, 3). Since we | ||
31 | don't have any way to tell, we treat this as undetectable alignment. If | ||
32 | probing with align=1 fails with EINVAL, but probing with one of the | ||
33 | expected alignments succeeds, we know that we found a working alignment. | ||
34 | |||
35 | Practically the alignment requirements are the same for buffer | ||
36 | alignment, buffer length, and offset in file. So in case we cannot | ||
37 | detect buf_align, we can use request alignment. If we cannot detect | ||
38 | request alignment, we can fallback to a safe value. To use this logic, | ||
39 | we probe first request alignment instead of buf_align. | ||
40 | |||
41 | Here is a table showing the behaviour with current code (the value in | ||
42 | parenthesis is the optimal value). | ||
43 | |||
44 | Case Sector buf_align (opt) request_alignment (opt) result | ||
45 | ====================================================================== | ||
46 | 1 512 512 (1) 512 (512) OK | ||
47 | 1 4096 512 (1) 4096 (4096) FAIL | ||
48 | ---------------------------------------------------------------------- | ||
49 | 2 512 512 (512) 512 (512) OK | ||
50 | 2 4096 512 (4096) 4096 (4096) FAIL | ||
51 | ---------------------------------------------------------------------- | ||
52 | 3 512 512 (1) 512 (512) OK | ||
53 | 3 4096 512 (1) 512 (4096) FAIL | ||
54 | ---------------------------------------------------------------------- | ||
55 | 4 512 512 (1) 512 (1) OK | ||
56 | 4 4096 512 (1) 512 (1) OK | ||
57 | |||
58 | Same cases with this change: | ||
59 | |||
60 | Case Sector buf_align (opt) request_alignment (opt) result | ||
61 | ====================================================================== | ||
62 | 1 512 512 (1) 512 (512) OK | ||
63 | 1 4096 4096 (1) 4096 (4096) OK | ||
64 | ---------------------------------------------------------------------- | ||
65 | 2 512 512 (512) 512 (512) OK | ||
66 | 2 4096 4096 (4096) 4096 (4096) OK | ||
67 | ---------------------------------------------------------------------- | ||
68 | 3 512 4096 (1) 4096 (512) OK | ||
69 | 3 4096 4096 (1) 4096 (4096) OK | ||
70 | ---------------------------------------------------------------------- | ||
71 | 4 512 4096 (1) 4096 (1) OK | ||
72 | 4 4096 4096 (1) 4096 (1) OK | ||
73 | |||
74 | I tested that provisioning VMs and copying disks on local XFS and | ||
75 | Gluster with 4k bytes sector size work now, resolving bugs [1],[2]. | ||
76 | I tested also on XFS, NFS, Gluster with 512 bytes sector size. | ||
77 | |||
78 | [1] https://bugzilla.redhat.com/1737256 | ||
79 | [2] https://bugzilla.redhat.com/1738657 | ||
80 | |||
81 | Signed-off-by: Nir Soffer <nsoffer@redhat.com> | ||
5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 82 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
6 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
7 | --- | 83 | --- |
8 | block/file-posix.c | 19 ++++++++++++++++--- | 84 | block/file-posix.c | 36 +++++++++++++++++++++++++----------- |
9 | 1 file changed, 16 insertions(+), 3 deletions(-) | 85 | 1 file changed, 25 insertions(+), 11 deletions(-) |
10 | 86 | ||
11 | diff --git a/block/file-posix.c b/block/file-posix.c | 87 | diff --git a/block/file-posix.c b/block/file-posix.c |
12 | index XXXXXXX..XXXXXXX 100644 | 88 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/block/file-posix.c | 89 | --- a/block/file-posix.c |
14 | +++ b/block/file-posix.c | 90 | +++ b/block/file-posix.c |
15 | @@ -XXX,XX +XXX,XX @@ static int raw_open_common(BlockDriverState *bs, QDict *options, | 91 | @@ -XXX,XX +XXX,XX @@ static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp) |
16 | 92 | BDRVRawState *s = bs->opaque; | |
17 | s->fd = -1; | 93 | char *buf; |
18 | fd = qemu_open(filename, s->open_flags, 0644); | 94 | size_t max_align = MAX(MAX_BLOCKSIZE, getpagesize()); |
19 | - if (fd < 0) { | 95 | + size_t alignments[] = {1, 512, 1024, 2048, 4096}; |
20 | - ret = -errno; | 96 | |
21 | - error_setg_errno(errp, errno, "Could not open '%s'", filename); | 97 | /* For SCSI generic devices the alignment is not really used. |
22 | + ret = fd < 0 ? -errno : 0; | 98 | With buffered I/O, we don't have any restrictions. */ |
99 | @@ -XXX,XX +XXX,XX @@ static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp) | ||
100 | } | ||
101 | #endif | ||
102 | |||
103 | - /* If we could not get the sizes so far, we can only guess them */ | ||
104 | - if (!s->buf_align) { | ||
105 | + /* | ||
106 | + * If we could not get the sizes so far, we can only guess them. First try | ||
107 | + * to detect request alignment, since it is more likely to succeed. Then | ||
108 | + * try to detect buf_align, which cannot be detected in some cases (e.g. | ||
109 | + * Gluster). If buf_align cannot be detected, we fallback to the value of | ||
110 | + * request_alignment. | ||
111 | + */ | ||
23 | + | 112 | + |
24 | + if (ret == -EACCES || ret == -EROFS) { | 113 | + if (!bs->bl.request_alignment) { |
25 | + /* Try to degrade to read-only, but if it doesn't work, still use the | 114 | + int i; |
26 | + * normal error message. */ | 115 | size_t align; |
27 | + if (bdrv_apply_auto_read_only(bs, NULL, NULL) == 0) { | 116 | - buf = qemu_memalign(max_align, 2 * max_align); |
28 | + bdrv_flags &= ~BDRV_O_RDWR; | 117 | - for (align = 512; align <= max_align; align <<= 1) { |
29 | + raw_parse_flags(bdrv_flags, &s->open_flags); | 118 | - if (raw_is_io_aligned(fd, buf + align, max_align)) { |
30 | + assert(!(s->open_flags & O_CREAT)); | 119 | - s->buf_align = align; |
31 | + fd = qemu_open(filename, s->open_flags); | 120 | + buf = qemu_memalign(max_align, max_align); |
32 | + ret = fd < 0 ? -errno : 0; | 121 | + for (i = 0; i < ARRAY_SIZE(alignments); i++) { |
33 | + } | 122 | + align = alignments[i]; |
34 | + } | 123 | + if (raw_is_io_aligned(fd, buf, align)) { |
35 | + | 124 | + /* Fallback to safe value. */ |
36 | + if (ret < 0) { | 125 | + bs->bl.request_alignment = (align != 1) ? align : max_align; |
37 | + error_setg_errno(errp, -ret, "Could not open '%s'", filename); | 126 | break; |
38 | if (ret == -EROFS) { | 127 | } |
39 | ret = -EACCES; | 128 | } |
129 | qemu_vfree(buf); | ||
130 | } | ||
131 | |||
132 | - if (!bs->bl.request_alignment) { | ||
133 | + if (!s->buf_align) { | ||
134 | + int i; | ||
135 | size_t align; | ||
136 | - buf = qemu_memalign(s->buf_align, max_align); | ||
137 | - for (align = 512; align <= max_align; align <<= 1) { | ||
138 | - if (raw_is_io_aligned(fd, buf, align)) { | ||
139 | - bs->bl.request_alignment = align; | ||
140 | + buf = qemu_memalign(max_align, 2 * max_align); | ||
141 | + for (i = 0; i < ARRAY_SIZE(alignments); i++) { | ||
142 | + align = alignments[i]; | ||
143 | + if (raw_is_io_aligned(fd, buf + align, max_align)) { | ||
144 | + /* Fallback to request_aligment. */ | ||
145 | + s->buf_align = (align != 1) ? align : bs->bl.request_alignment; | ||
146 | break; | ||
147 | } | ||
40 | } | 148 | } |
41 | -- | 149 | -- |
42 | 2.19.1 | 150 | 2.20.1 |
43 | 151 | ||
44 | 152 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Leonid Bloch <lbloch@janustech.com> | ||
2 | 1 | ||
3 | If an expression is used to define DEFAULT_CLUSTER_SIZE, when compiled, | ||
4 | it will be embedded as a literal expression in the binary (as the | ||
5 | default value) because it is stringified to mark the size of the default | ||
6 | value. Now this is fixed by using a defined number to define this value. | ||
7 | |||
8 | Signed-off-by: Leonid Bloch <lbloch@janustech.com> | ||
9 | Reviewed-by: Stefan Weil <sw@weilnetz.de> | ||
10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
11 | --- | ||
12 | block/vdi.c | 4 ++-- | ||
13 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
14 | |||
15 | diff --git a/block/vdi.c b/block/vdi.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/block/vdi.c | ||
18 | +++ b/block/vdi.c | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #define BLOCK_OPT_STATIC "static" | ||
21 | |||
22 | #define SECTOR_SIZE 512 | ||
23 | -#define DEFAULT_CLUSTER_SIZE (1 * MiB) | ||
24 | +#define DEFAULT_CLUSTER_SIZE S_1MiB | ||
25 | |||
26 | #if defined(CONFIG_VDI_DEBUG) | ||
27 | #define VDI_DEBUG 1 | ||
28 | @@ -XXX,XX +XXX,XX @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags, | ||
29 | goto fail; | ||
30 | } else if (header.block_size != DEFAULT_CLUSTER_SIZE) { | ||
31 | error_setg(errp, "unsupported VDI image (block size %" PRIu32 | ||
32 | - " is not %" PRIu64 ")", | ||
33 | + " is not %" PRIu32 ")", | ||
34 | header.block_size, DEFAULT_CLUSTER_SIZE); | ||
35 | ret = -ENOTSUP; | ||
36 | goto fail; | ||
37 | -- | ||
38 | 2.19.1 | ||
39 | |||
40 | diff view generated by jsdifflib |