1 | The following changes since commit 19b599f7664b2ebfd0f405fb79c14dd241557452: | 1 | The following changes since commit b384cd95eb9c6f73ad84ed1bb0717a26e29cc78f: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2018-08-27-v2' into staging (2018-08-27 16:44:20 +0100) | 3 | Merge remote-tracking branch 'remotes/ehabkost/tags/machine-next-pull-request' into staging (2018-01-19 16:35:25 +0000) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | git://github.com/codyprime/qemu-kvm-jtc.git tags/block-pull-request | 7 | git://github.com/stefanha/qemu.git tags/block-pull-request |
8 | 8 | ||
9 | for you to fetch changes up to 8af2eb7b43a1b694fd6d1d090025027d6b72caac: | 9 | for you to fetch changes up to bcbb3866da19cce4360c828b6ec1c2a137757927: |
10 | 10 | ||
11 | block/rbd: add deprecation documentation for filename keyvalue pairs (2018-09-12 08:51:45 -0400) | 11 | block/parallels: add backing support to readv/writev (2018-01-22 14:02:33 +0000) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Block patches for RBD | 14 | Pull request |
15 | |||
16 | v2: | ||
17 | * Drop merge failure from a previous pull request that broke virtio-blk on ARM | ||
18 | guests | ||
19 | * Add Parallels XML patch series | ||
20 | |||
15 | ---------------------------------------------------------------- | 21 | ---------------------------------------------------------------- |
16 | 22 | ||
17 | Jeff Cody (4): | 23 | Edgar Kaziakhmedov (1): |
18 | block/rbd: pull out qemu_rbd_convert_options | 24 | block/parallels: add backing support to readv/writev |
19 | block/rbd: Attempt to parse legacy filenames | ||
20 | block/rbd: add iotest for rbd legacy keyvalue filename parsing | ||
21 | block/rbd: add deprecation documentation for filename keyvalue pairs | ||
22 | 25 | ||
23 | block/rbd.c | 89 ++++++++++++++++++++++++++++++++------ | 26 | Klim Kireev (4): |
24 | qemu-deprecated.texi | 15 +++++++ | 27 | docs/interop/prl-xml: description of Parallels Disk format |
25 | tests/qemu-iotests/231 | 62 ++++++++++++++++++++++++++ | 28 | configure: add dependency |
26 | tests/qemu-iotests/231.out | 9 ++++ | 29 | block/parallels: move some structures into header |
27 | tests/qemu-iotests/group | 1 + | 30 | block/parallels: replace some magic numbers |
28 | 5 files changed, 162 insertions(+), 14 deletions(-) | 31 | |
29 | create mode 100755 tests/qemu-iotests/231 | 32 | Stefan Hajnoczi (1): |
30 | create mode 100644 tests/qemu-iotests/231.out | 33 | block: add block_set_io_throttle virtio-blk-pci QMP example |
34 | |||
35 | docs/interop/prl-xml.txt | 158 +++++++++++++++++++++++++++++++++++++++++++++++ | ||
36 | qapi/block-core.json | 18 ++++++ | ||
37 | configure | 27 ++++++++ | ||
38 | block/Makefile.objs | 2 + | ||
39 | block/parallels.h | 88 ++++++++++++++++++++++++++ | ||
40 | block/parallels.c | 108 ++++++++++++++------------------ | ||
41 | scripts/checkpatch.pl | 1 + | ||
42 | 7 files changed, 342 insertions(+), 60 deletions(-) | ||
43 | create mode 100644 docs/interop/prl-xml.txt | ||
44 | create mode 100644 block/parallels.h | ||
31 | 45 | ||
32 | -- | 46 | -- |
33 | 2.17.1 | 47 | 2.14.3 |
34 | 48 | ||
35 | 49 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The block_set_io_throttle command can look up BlockBackends by the | ||
2 | attached qdev device ID. virtio-blk-pci is a special case because the | ||
3 | actual VirtIOBlock device is the "/virtio-backend" child of the PCI | ||
4 | adapter device. | ||
1 | 5 | ||
6 | Add a QMP schema example so clients will know how to use | ||
7 | block_set_io_throttle on the virtio-blk-pci device. | ||
8 | |||
9 | The alternative is to implement some sort of aliasing for qmp_get_blk() | ||
10 | but that is likely to cause confusion and could break future use cases. | ||
11 | Let's not go there. | ||
12 | |||
13 | Cc: Kevin Wolf <kwolf@redhat.com> | ||
14 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
15 | Reviewed-by: Alberto Garcia <berto@igalia.com> | ||
16 | Message-id: 20180117090700.25811-1-stefanha@redhat.com | ||
17 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
18 | --- | ||
19 | qapi/block-core.json | 18 ++++++++++++++++++ | ||
20 | 1 file changed, 18 insertions(+) | ||
21 | |||
22 | diff --git a/qapi/block-core.json b/qapi/block-core.json | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/qapi/block-core.json | ||
25 | +++ b/qapi/block-core.json | ||
26 | @@ -XXX,XX +XXX,XX @@ | ||
27 | # Example: | ||
28 | # | ||
29 | # -> { "execute": "block_set_io_throttle", | ||
30 | +# "arguments": { "id": "virtio-blk-pci0/virtio-backend", | ||
31 | +# "bps": 0, | ||
32 | +# "bps_rd": 0, | ||
33 | +# "bps_wr": 0, | ||
34 | +# "iops": 512, | ||
35 | +# "iops_rd": 0, | ||
36 | +# "iops_wr": 0, | ||
37 | +# "bps_max": 0, | ||
38 | +# "bps_rd_max": 0, | ||
39 | +# "bps_wr_max": 0, | ||
40 | +# "iops_max": 0, | ||
41 | +# "iops_rd_max": 0, | ||
42 | +# "iops_wr_max": 0, | ||
43 | +# "bps_max_length": 0, | ||
44 | +# "iops_size": 0 } } | ||
45 | +# <- { "return": {} } | ||
46 | +# | ||
47 | +# -> { "execute": "block_set_io_throttle", | ||
48 | # "arguments": { "id": "ide0-1-0", | ||
49 | # "bps": 1000000, | ||
50 | # "bps_rd": 0, | ||
51 | -- | ||
52 | 2.14.3 | ||
53 | |||
54 | diff view generated by jsdifflib |
1 | This is a small test that will check for the ability to parse | 1 | From: Klim Kireev <klim.kireev@virtuozzo.com> |
---|---|---|---|
2 | both legacy and modern options for rbd. | ||
3 | 2 | ||
4 | The way the test is set up is for failure to occur, but without | 3 | This patch adds main information about Parallels Disk |
5 | having to wait to timeout on a non-existent rbd server. The error | 4 | format, which consists of DiskDescriptor.xml and other files. |
6 | messages in the success path show that the arguments were parsed. | ||
7 | 5 | ||
8 | The failure behavior prior to the patch series that has this test, is | 6 | Signed-off-by: Edgar Kaziakhmedov <edgar.kaziakhmedov@virtuozzo.com> |
9 | qemu-img complaining about mandatory options (e.g. 'pool') not being | 7 | Signed-off-by: Klim Kireev <klim.kireev@virtuozzo.com> |
10 | provided. | 8 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
9 | Signed-off-by: Denis V. Lunev <den@openvz.org> | ||
10 | Message-id: 20180112090122.1702-2-klim.kireev@virtuozzo.com | ||
11 | CC: Stefan Hajnoczi <stefanha@redhat.com> | ||
12 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
13 | --- | ||
14 | docs/interop/prl-xml.txt | 158 +++++++++++++++++++++++++++++++++++++++++++++++ | ||
15 | 1 file changed, 158 insertions(+) | ||
16 | create mode 100644 docs/interop/prl-xml.txt | ||
11 | 17 | ||
12 | Reviewed-by: Eric Blake <eblake@redhat.com> | 18 | diff --git a/docs/interop/prl-xml.txt b/docs/interop/prl-xml.txt |
13 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
14 | Message-id: f830580e339b974a83ed4870d11adcdc17f49a47.1536704901.git.jcody@redhat.com | ||
15 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
16 | --- | ||
17 | tests/qemu-iotests/231 | 62 ++++++++++++++++++++++++++++++++++++++ | ||
18 | tests/qemu-iotests/231.out | 9 ++++++ | ||
19 | tests/qemu-iotests/group | 1 + | ||
20 | 3 files changed, 72 insertions(+) | ||
21 | create mode 100755 tests/qemu-iotests/231 | ||
22 | create mode 100644 tests/qemu-iotests/231.out | ||
23 | |||
24 | diff --git a/tests/qemu-iotests/231 b/tests/qemu-iotests/231 | ||
25 | new file mode 100755 | ||
26 | index XXXXXXX..XXXXXXX | ||
27 | --- /dev/null | ||
28 | +++ b/tests/qemu-iotests/231 | ||
29 | @@ -XXX,XX +XXX,XX @@ | ||
30 | +#!/bin/bash | ||
31 | +# | ||
32 | +# Test legacy and modern option parsing for rbd/ceph. This will not | ||
33 | +# actually connect to a ceph server, but rather looks for the appropriate | ||
34 | +# error message that indicates we parsed the options correctly. | ||
35 | +# | ||
36 | +# Copyright (C) 2018 Red Hat, Inc. | ||
37 | +# | ||
38 | +# This program is free software; you can redistribute it and/or modify | ||
39 | +# it under the terms of the GNU General Public License as published by | ||
40 | +# the Free Software Foundation; either version 2 of the License, or | ||
41 | +# (at your option) any later version. | ||
42 | +# | ||
43 | +# This program is distributed in the hope that it will be useful, | ||
44 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
45 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
46 | +# GNU General Public License for more details. | ||
47 | +# | ||
48 | +# You should have received a copy of the GNU General Public License | ||
49 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
50 | +# | ||
51 | + | ||
52 | +# creator | ||
53 | +owner=jcody@redhat.com | ||
54 | + | ||
55 | +seq=`basename $0` | ||
56 | +echo "QA output created by $seq" | ||
57 | + | ||
58 | +here=`pwd` | ||
59 | +status=1 # failure is the default! | ||
60 | + | ||
61 | +_cleanup() | ||
62 | +{ | ||
63 | + rm "${BOGUS_CONF}" | ||
64 | +} | ||
65 | +trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
66 | + | ||
67 | +# get standard environment, filters and checks | ||
68 | +. ./common.rc | ||
69 | +. ./common.filter | ||
70 | + | ||
71 | +_supported_fmt generic | ||
72 | +_supported_proto rbd | ||
73 | +_supported_os Linux | ||
74 | + | ||
75 | +BOGUS_CONF=${TEST_DIR}/ceph-$$.conf | ||
76 | +touch "${BOGUS_CONF}" | ||
77 | + | ||
78 | +_filter_conf() | ||
79 | +{ | ||
80 | + sed -e "s#$BOGUS_CONF#BOGUS_CONF#g" | ||
81 | +} | ||
82 | + | ||
83 | +# We expect this to fail, with no monitor ip provided and a null conf file. Just want it | ||
84 | +# to fail in the right way. | ||
85 | +$QEMU_IMG info "json:{'file.driver':'rbd','file.filename':'rbd:rbd/bogus:conf=${BOGUS_CONF}'}" 2>&1 | _filter_conf | ||
86 | +$QEMU_IMG info "json:{'file.driver':'rbd','file.pool':'rbd','file.image':'bogus','file.conf':'${BOGUS_CONF}'}" 2>&1 | _filter_conf | ||
87 | + | ||
88 | +# success, all done | ||
89 | +echo "*** done" | ||
90 | +rm -f $seq.full | ||
91 | +status=0 | ||
92 | diff --git a/tests/qemu-iotests/231.out b/tests/qemu-iotests/231.out | ||
93 | new file mode 100644 | 19 | new file mode 100644 |
94 | index XXXXXXX..XXXXXXX | 20 | index XXXXXXX..XXXXXXX |
95 | --- /dev/null | 21 | --- /dev/null |
96 | +++ b/tests/qemu-iotests/231.out | 22 | +++ b/docs/interop/prl-xml.txt |
97 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ |
98 | +QA output created by 231 | 24 | += License = |
99 | +qemu-img: RBD options encoded in the filename as keyvalue pairs is deprecated. Future versions may cease to parse these options in the future. | 25 | + |
100 | +unable to get monitor info from DNS SRV with service name: ceph-mon | 26 | +Copyright (c) 2015-2017, Virtuozzo, Inc. |
101 | +no monitors specified to connect to. | 27 | +Authors: |
102 | +qemu-img: Could not open 'json:{'file.driver':'rbd','file.filename':'rbd:rbd/bogus:conf=BOGUS_CONF'}': error connecting: No such file or directory | 28 | + 2015 Denis Lunev <den@openvz.org> |
103 | +unable to get monitor info from DNS SRV with service name: ceph-mon | 29 | + 2015 Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
104 | +no monitors specified to connect to. | 30 | + 2016-2017 Klim Kireev <klim.kireev@virtuozzo.com> |
105 | +qemu-img: Could not open 'json:{'file.driver':'rbd','file.pool':'rbd','file.image':'bogus','file.conf':'BOGUS_CONF'}': error connecting: No such file or directory | 31 | + 2016-2017 Edgar Kaziakhmedov <edgar.kaziakhmedov@virtuozzo.com> |
106 | +*** done | 32 | + |
107 | diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group | 33 | +This work is licensed under the terms of the GNU GPL, version 2 or later. |
108 | index XXXXXXX..XXXXXXX 100644 | 34 | +See the COPYING file in the top-level directory. |
109 | --- a/tests/qemu-iotests/group | 35 | + |
110 | +++ b/tests/qemu-iotests/group | 36 | +This specification contains minimal information about Parallels Disk Format, |
111 | @@ -XXX,XX +XXX,XX @@ | 37 | +which is enough to proper work with QEMU. Nevertheless, Parallels Cloud Server |
112 | 226 auto quick | 38 | +and Parallels Desktop are able to add some unspecified nodes to xml and use |
113 | 227 auto quick | 39 | +them, but they are for internal work and don't affect functionality. Also it |
114 | 229 auto quick | 40 | +uses auxiliary xml "Snapshot.xml", which allows to store optional snapshot |
115 | +231 auto quick | 41 | +information, but it doesn't influence open/read/write functionality. QEMU and |
42 | +other software should not use fields not covered in this document and | ||
43 | +Snapshot.xml file and must leave them as is. | ||
44 | + | ||
45 | += Parallels Disk Format = | ||
46 | + | ||
47 | +Parallels disk consists of two parts: the set of snapshots and the disk | ||
48 | +descriptor file, which stores information about all files and snapshots. | ||
49 | + | ||
50 | +== Definitions == | ||
51 | + Snapshot a record of the contents captured at a particular time, | ||
52 | + capable of storing current state. A snapshot has UUID and | ||
53 | + parent UUID. | ||
54 | + | ||
55 | + Snapshot image an overlay representing the difference between this | ||
56 | + snapshot and some earlier snapshot. | ||
57 | + | ||
58 | + Overlay an image storing the different sectors between two captured | ||
59 | + states. | ||
60 | + | ||
61 | + Root image snapshot image with no parent, the root of snapshot tree. | ||
62 | + | ||
63 | + Storage the backing storage for a subset of the virtual disk. When | ||
64 | + there is more than one storage in a Parallels disk then that | ||
65 | + is referred to as a split image. In this case every storage | ||
66 | + covers specific address space area of the disk and has its | ||
67 | + particular root image. Split images are not considered here | ||
68 | + and are not supported. Each storage consists of disk | ||
69 | + parameters and a list of images. The list of images always | ||
70 | + contains a root image and may also contain overlays. The | ||
71 | + root image can be an expandable Parallels image file or | ||
72 | + plain. Overlays must be expandable. | ||
73 | + | ||
74 | + Description DiskDescriptor.xml stores information about disk parameters, | ||
75 | + file snapshots, storages. | ||
76 | + | ||
77 | + Top The overlay between actual state and some previous snapshot. | ||
78 | + Snapshot It is not a snapshot in the classical sense because it | ||
79 | + serves as the active image that the guest writes to. | ||
80 | + | ||
81 | + Sector a 512-byte data chunk. | ||
82 | + | ||
83 | +== Description file == | ||
84 | +All information is placed in a single XML element Parallels_disk_image. | ||
85 | +The element has only one attribute "Version", that must be 1.0. | ||
86 | +Schema of DiskDescriptor.xml: | ||
87 | + | ||
88 | +<Parallels_disk_image Version="1.0"> | ||
89 | + <Disk_Parameters> | ||
90 | + ... | ||
91 | + </Disk_Parameters> | ||
92 | + <StorageData> | ||
93 | + ... | ||
94 | + </StorageData> | ||
95 | + <Snapshots> | ||
96 | + ... | ||
97 | + </Snapshots> | ||
98 | +</Parallels_disk_image> | ||
99 | + | ||
100 | +== Disk_Parameters element == | ||
101 | +The Disk_Parameters element describes the physical layout of the virtual disk | ||
102 | +and some general settings. | ||
103 | + | ||
104 | +The Disk_Parameters element MUST contain the following child elements: | ||
105 | + * Disk_size - number of sectors in the disk, | ||
106 | + desired size of the disk. | ||
107 | + * Cylinders - number of the disk cylinders. | ||
108 | + * Heads - number of the disk heads. | ||
109 | + * Sectors - number of the disk sectors per cylinder | ||
110 | + (sector size is 512 bytes) | ||
111 | + Limitation: Product of the Heads, Sectors and Cylinders | ||
112 | + values MUST be equal to the value of the Disk_size parameter. | ||
113 | + * Padding - must be 0. Parallels Cloud Server and Parallels Desktop may | ||
114 | + use padding set to 1, however this case is not covered | ||
115 | + by this spec, QEMU and other software should not open | ||
116 | + such disks and should not create them. | ||
117 | + | ||
118 | +== StorageData element == | ||
119 | +This element of the file describes the root image and all snapshot images. | ||
120 | + | ||
121 | +The StorageData element consists of the Storage child element, as shown below: | ||
122 | +<StorageData> | ||
123 | + <Storage> | ||
124 | + ... | ||
125 | + </Storage> | ||
126 | +</StorageData> | ||
127 | + | ||
128 | +A Storage element has following child elements: | ||
129 | + * Start - start sector of the storage, in case of non split storage | ||
130 | + equals to 0. | ||
131 | + * End - number of sector following the last sector, in case of non | ||
132 | + split storage equals to Disk_size. | ||
133 | + * Blocksize - storage cluster size, number of sectors per one cluster. | ||
134 | + Cluster size for each "Compressed" (see below) image in | ||
135 | + parallels disk must be equal to this field. Note: cluster | ||
136 | + size for Parallels Expandable Image is in 'tracks' field of | ||
137 | + its header (see docs/interop/parallels.txt). | ||
138 | + * Several Image child elements. | ||
139 | + | ||
140 | +Each Image element has following child elements: | ||
141 | + * GUID - image identifier, UUID in curly brackets. | ||
142 | + For instance, {12345678-9abc-def1-2345-6789abcdef12}. | ||
143 | + The GUID is used by the Snapshots element to reference images | ||
144 | + (see below) | ||
145 | + * Type - image type of the element. It can be: | ||
146 | + "Plain" for raw files. | ||
147 | + "Compressed" for expanding disks. | ||
148 | + * File - path to image file. Path can be relative to DiskDecriptor.xml or | ||
149 | + absolute. | ||
150 | + | ||
151 | +== Snapshots element == | ||
152 | +The Snapshots element describes the snapshot relations with the snapshot tree. | ||
153 | + | ||
154 | +The element contains the set of Shot child elements, as shown below: | ||
155 | +<Snapshots> | ||
156 | + <TopGUID> ... </TopGUID> /* Optional child element */ | ||
157 | + <Shot> | ||
158 | + ... | ||
159 | + </Shot> | ||
160 | + <Shot> | ||
161 | + ... | ||
162 | + </Shot> | ||
163 | + ... | ||
164 | +</Snapshots> | ||
165 | + | ||
166 | +Each Shot element contains the following child elements: | ||
167 | + * GUID - an image GUID. | ||
168 | + * ParentGUID - GUID of the image of the parent snapshot. | ||
169 | + | ||
170 | +The software may traverse snapshots from child to parent using <ParentGUID> | ||
171 | +field as reference. ParentGUID of root snapshot is | ||
172 | +{00000000-0000-0000-0000-000000000000}. There should be only one root | ||
173 | +snapshot. Top snapshot could be described via two ways: via TopGUID child | ||
174 | +element of the Snapshots element or via predefined GUID | ||
175 | +{5fbaabe3-6958-40ff-92a7-860e329aab41}. If TopGUID is defined, predefined GUID is | ||
176 | +interpreted as usual GUID. All snapshot images (except Top Snapshot) should be | ||
177 | +opened read-only. There is another predefined GUID, | ||
178 | +BackupID = {704718e1-2314-44c8-9087-d78ed36b0f4e}, which is used by original and | ||
179 | +some third-party software for backup, QEMU and other software may operate with | ||
180 | +images with GUID = BackupID as usual, however, it is not recommended to use this | ||
181 | +GUID for new disks. Top snapshot cannot have this GUID. | ||
116 | -- | 182 | -- |
117 | 2.17.1 | 183 | 2.14.3 |
118 | 184 | ||
119 | 185 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Klim Kireev <klim.kireev@virtuozzo.com> | ||
1 | 2 | ||
3 | This dependency is required for adequate Parallels images support. | ||
4 | Typically the disk consists of several images which are glued by | ||
5 | XML disk descriptor. Also XML hides inside several important parameters | ||
6 | which are not available in the image header. | ||
7 | |||
8 | The patch also adds clause to checkpatch.pl to understand libxml2 types. | ||
9 | |||
10 | Signed-off-by: Denis V. Lunev <den@openvz.org> | ||
11 | Signed-off-by: Klim Kireev <klim.kireev@virtuozzo.com> | ||
12 | Signed-off-by: Edgar Kaziakhmedov <edgar.kaziakhmedov@virtuozzo.com> | ||
13 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
14 | Message-id: 20180112090122.1702-3-klim.kireev@virtuozzo.com | ||
15 | CC: Stefan Hajnoczi <stefanha@redhat.com> | ||
16 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
17 | --- | ||
18 | configure | 27 +++++++++++++++++++++++++++ | ||
19 | block/Makefile.objs | 2 ++ | ||
20 | scripts/checkpatch.pl | 1 + | ||
21 | 3 files changed, 30 insertions(+) | ||
22 | |||
23 | diff --git a/configure b/configure | ||
24 | index XXXXXXX..XXXXXXX 100755 | ||
25 | --- a/configure | ||
26 | +++ b/configure | ||
27 | @@ -XXX,XX +XXX,XX @@ tcmalloc="no" | ||
28 | jemalloc="no" | ||
29 | replication="yes" | ||
30 | vxhs="" | ||
31 | +libxml2="" | ||
32 | |||
33 | supported_cpu="no" | ||
34 | supported_os="no" | ||
35 | @@ -XXX,XX +XXX,XX @@ for opt do | ||
36 | ;; | ||
37 | --enable-numa) numa="yes" | ||
38 | ;; | ||
39 | + --disable-libxml2) libxml2="no" | ||
40 | + ;; | ||
41 | + --enable-libxml2) libxml2="yes" | ||
42 | + ;; | ||
43 | --disable-tcmalloc) tcmalloc="no" | ||
44 | ;; | ||
45 | --enable-tcmalloc) tcmalloc="yes" | ||
46 | @@ -XXX,XX +XXX,XX @@ disabled with --disable-FEATURE, default is enabled if available: | ||
47 | tpm TPM support | ||
48 | libssh2 ssh block device support | ||
49 | numa libnuma support | ||
50 | + libxml2 for Parallels image format | ||
51 | tcmalloc tcmalloc support | ||
52 | jemalloc jemalloc support | ||
53 | replication replication support | ||
54 | @@ -XXX,XX +XXX,XX @@ EOF | ||
55 | fi | ||
56 | fi | ||
57 | |||
58 | +########################################## | ||
59 | +# libxml2 probe | ||
60 | +if test "$libxml2" != "no" ; then | ||
61 | + if $pkg_config --exists libxml-2.0; then | ||
62 | + libxml2="yes" | ||
63 | + libxml2_cflags=$($pkg_config --cflags libxml-2.0) | ||
64 | + libxml2_libs=$($pkg_config --libs libxml-2.0) | ||
65 | + else | ||
66 | + if test "$libxml2" = "yes"; then | ||
67 | + feature_not_found "libxml2" "Install libxml2 devel" | ||
68 | + fi | ||
69 | + libxml2="no" | ||
70 | + fi | ||
71 | +fi | ||
72 | |||
73 | ########################################## | ||
74 | # glusterfs probe | ||
75 | @@ -XXX,XX +XXX,XX @@ echo "lzo support $lzo" | ||
76 | echo "snappy support $snappy" | ||
77 | echo "bzip2 support $bzip2" | ||
78 | echo "NUMA host support $numa" | ||
79 | +echo "libxml2 $libxml2" | ||
80 | echo "tcmalloc support $tcmalloc" | ||
81 | echo "jemalloc support $jemalloc" | ||
82 | echo "avx2 optimization $avx2_opt" | ||
83 | @@ -XXX,XX +XXX,XX @@ if test "$have_rtnetlink" = "yes" ; then | ||
84 | echo "CONFIG_RTNETLINK=y" >> $config_host_mak | ||
85 | fi | ||
86 | |||
87 | +if test "$libxml2" = "yes" ; then | ||
88 | + echo "CONFIG_LIBXML2=y" >> $config_host_mak | ||
89 | + echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak | ||
90 | + echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak | ||
91 | +fi | ||
92 | + | ||
93 | if test "$replication" = "yes" ; then | ||
94 | echo "CONFIG_REPLICATION=y" >> $config_host_mak | ||
95 | fi | ||
96 | diff --git a/block/Makefile.objs b/block/Makefile.objs | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/block/Makefile.objs | ||
99 | +++ b/block/Makefile.objs | ||
100 | @@ -XXX,XX +XXX,XX @@ block-obj-$(if $(CONFIG_BZIP2),m,n) += dmg-bz2.o | ||
101 | dmg-bz2.o-libs := $(BZIP2_LIBS) | ||
102 | qcow.o-libs := -lz | ||
103 | linux-aio.o-libs := -laio | ||
104 | +parallels.o-cflags := $(LIBXML2_CFLAGS) | ||
105 | +parallels.o-libs := $(LIBXML2_LIBS) | ||
106 | diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl | ||
107 | index XXXXXXX..XXXXXXX 100755 | ||
108 | --- a/scripts/checkpatch.pl | ||
109 | +++ b/scripts/checkpatch.pl | ||
110 | @@ -XXX,XX +XXX,XX @@ our @typeList = ( | ||
111 | qr{${Ident}_handler_fn}, | ||
112 | qr{target_(?:u)?long}, | ||
113 | qr{hwaddr}, | ||
114 | + qr{xml${Ident}}, | ||
115 | ); | ||
116 | |||
117 | # This can be modified by sub possible. Since it can be empty, be careful | ||
118 | -- | ||
119 | 2.14.3 | ||
120 | |||
121 | diff view generated by jsdifflib |
1 | Code movement to pull the conversion from Qdict to BlockdevOptionsRbd | 1 | From: Klim Kireev <klim.kireev@virtuozzo.com> |
---|---|---|---|
2 | into a helper function. | ||
3 | 2 | ||
4 | Reviewed-by: Eric Blake <eblake@redhat.com> | 3 | To implement xml format, some defines and structures |
5 | Reviewed-by: John Snow <jsnow@redhat.com> | 4 | from parallels.c are required. |
6 | Signed-off-by: Jeff Cody <jcody@redhat.com> | 5 | |
7 | Message-id: 5b49a980f2cde6610ab1df41bb0277d00b5db893.1536704901.git.jcody@redhat.com | 6 | Signed-off-by: Klim Kireev <klim.kireev@virtuozzo.com> |
8 | Signed-off-by: Jeff Cody <jcody@redhat.com> | 7 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
8 | Signed-off-by: Denis V. Lunev <den@openvz.org> | ||
9 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
10 | Signed-off-by: Edgar Kaziakhmedov <edgar.kaziakhmedov@virtuozzo.com> | ||
11 | Message-id: 20180112090122.1702-4-klim.kireev@virtuozzo.com | ||
12 | CC: Stefan Hajnoczi <stefanha@redhat.com> | ||
13 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
9 | --- | 14 | --- |
10 | block/rbd.c | 36 ++++++++++++++++++++++++------------ | 15 | block/parallels.h | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
11 | 1 file changed, 24 insertions(+), 12 deletions(-) | 16 | block/parallels.c | 53 +--------------------------------- |
17 | 2 files changed, 87 insertions(+), 52 deletions(-) | ||
18 | create mode 100644 block/parallels.h | ||
12 | 19 | ||
13 | diff --git a/block/rbd.c b/block/rbd.c | 20 | diff --git a/block/parallels.h b/block/parallels.h |
21 | new file mode 100644 | ||
22 | index XXXXXXX..XXXXXXX | ||
23 | --- /dev/null | ||
24 | +++ b/block/parallels.h | ||
25 | @@ -XXX,XX +XXX,XX @@ | ||
26 | +/* | ||
27 | +* Block driver for Parallels disk image format | ||
28 | +* | ||
29 | +* Copyright (c) 2015-2017 Virtuozzo, Inc. | ||
30 | +* Authors: | ||
31 | +* 2016-2017 Klim S. Kireev <klim.kireev@virtuozzo.com> | ||
32 | +* 2015 Denis V. Lunev <den@openvz.org> | ||
33 | +* | ||
34 | +* This code was originally based on comparing different disk images created | ||
35 | +* by Parallels. Currently it is based on opened OpenVZ sources | ||
36 | +* available at | ||
37 | +* https://github.com/OpenVZ/ploop | ||
38 | +* | ||
39 | +* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
40 | +* of this software and associated documentation files (the "Software"), to deal | ||
41 | +* in the Software without restriction, including without limitation the rights | ||
42 | +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
43 | +* copies of the Software, and to permit persons to whom the Software is | ||
44 | +* furnished to do so, subject to the following conditions: | ||
45 | +* | ||
46 | +* The above copyright notice and this permission notice shall be included in | ||
47 | +* all copies or substantial portions of the Software. | ||
48 | +* | ||
49 | +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
50 | +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
51 | +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
52 | +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
53 | +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
54 | +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
55 | +* THE SOFTWARE. | ||
56 | +*/ | ||
57 | +#ifndef BLOCK_PARALLELS_H | ||
58 | +#define BLOCK_PARALLELS_H | ||
59 | +#include "qemu/coroutine.h" | ||
60 | +#include "qemu/typedefs.h" | ||
61 | + | ||
62 | +#define DEFAULT_CLUSTER_SIZE 1048576 /* 1 MiB */ | ||
63 | + | ||
64 | +/* always little-endian */ | ||
65 | +typedef struct ParallelsHeader { | ||
66 | + char magic[16]; /* "WithoutFreeSpace" */ | ||
67 | + uint32_t version; | ||
68 | + uint32_t heads; | ||
69 | + uint32_t cylinders; | ||
70 | + uint32_t tracks; | ||
71 | + uint32_t bat_entries; | ||
72 | + uint64_t nb_sectors; | ||
73 | + uint32_t inuse; | ||
74 | + uint32_t data_off; | ||
75 | + char padding[12]; | ||
76 | +} QEMU_PACKED ParallelsHeader; | ||
77 | + | ||
78 | +typedef enum ParallelsPreallocMode { | ||
79 | + PRL_PREALLOC_MODE_FALLOCATE = 0, | ||
80 | + PRL_PREALLOC_MODE_TRUNCATE = 1, | ||
81 | + PRL_PREALLOC_MODE__MAX = 2, | ||
82 | +} ParallelsPreallocMode; | ||
83 | + | ||
84 | +typedef struct BDRVParallelsState { | ||
85 | + /** Locking is conservative, the lock protects | ||
86 | + * - image file extending (truncate, fallocate) | ||
87 | + * - any access to block allocation table | ||
88 | + */ | ||
89 | + CoMutex lock; | ||
90 | + | ||
91 | + ParallelsHeader *header; | ||
92 | + uint32_t header_size; | ||
93 | + bool header_unclean; | ||
94 | + | ||
95 | + unsigned long *bat_dirty_bmap; | ||
96 | + unsigned int bat_dirty_block; | ||
97 | + | ||
98 | + uint32_t *bat_bitmap; | ||
99 | + unsigned int bat_size; | ||
100 | + | ||
101 | + int64_t data_end; | ||
102 | + uint64_t prealloc_size; | ||
103 | + ParallelsPreallocMode prealloc_mode; | ||
104 | + | ||
105 | + unsigned int tracks; | ||
106 | + | ||
107 | + unsigned int off_multiplier; | ||
108 | + Error *migration_blocker; | ||
109 | +} BDRVParallelsState; | ||
110 | + | ||
111 | +#endif | ||
112 | diff --git a/block/parallels.c b/block/parallels.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | 113 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/block/rbd.c | 114 | --- a/block/parallels.c |
16 | +++ b/block/rbd.c | 115 | +++ b/block/parallels.c |
17 | @@ -XXX,XX +XXX,XX @@ failed_opts: | 116 | @@ -XXX,XX +XXX,XX @@ |
18 | return r; | 117 | #include "qemu/bswap.h" |
19 | } | 118 | #include "qemu/bitmap.h" |
20 | 119 | #include "migration/blocker.h" | |
21 | +static int qemu_rbd_convert_options(QDict *options, BlockdevOptionsRbd **opts, | 120 | +#include "parallels.h" |
22 | + Error **errp) | 121 | |
23 | +{ | 122 | /**************************************************************/ |
24 | + Visitor *v; | 123 | |
25 | + Error *local_err = NULL; | 124 | @@ -XXX,XX +XXX,XX @@ |
26 | + | 125 | #define HEADER_INUSE_MAGIC (0x746F6E59) |
27 | + /* Convert the remaining options into a QAPI object */ | 126 | #define MAX_PARALLELS_IMAGE_FACTOR (1ull << 32) |
28 | + v = qobject_input_visitor_new_flat_confused(options, errp); | 127 | |
29 | + if (!v) { | 128 | -#define DEFAULT_CLUSTER_SIZE 1048576 /* 1 MiB */ |
30 | + return -EINVAL; | ||
31 | + } | ||
32 | + | ||
33 | + visit_type_BlockdevOptionsRbd(v, NULL, opts, &local_err); | ||
34 | + visit_free(v); | ||
35 | + | ||
36 | + if (local_err) { | ||
37 | + error_propagate(errp, local_err); | ||
38 | + return -EINVAL; | ||
39 | + } | ||
40 | + | ||
41 | + return 0; | ||
42 | +} | ||
43 | + | ||
44 | static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, | ||
45 | Error **errp) | ||
46 | { | ||
47 | BDRVRBDState *s = bs->opaque; | ||
48 | BlockdevOptionsRbd *opts = NULL; | ||
49 | - Visitor *v; | ||
50 | const QDictEntry *e; | ||
51 | Error *local_err = NULL; | ||
52 | char *keypairs, *secretid; | ||
53 | @@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, | ||
54 | qdict_del(options, "password-secret"); | ||
55 | } | ||
56 | |||
57 | - /* Convert the remaining options into a QAPI object */ | ||
58 | - v = qobject_input_visitor_new_flat_confused(options, errp); | ||
59 | - if (!v) { | ||
60 | - r = -EINVAL; | ||
61 | - goto out; | ||
62 | - } | ||
63 | - | 129 | - |
64 | - visit_type_BlockdevOptionsRbd(v, NULL, &opts, &local_err); | ||
65 | - visit_free(v); | ||
66 | - | 130 | - |
67 | + r = qemu_rbd_convert_options(options, &opts, &local_err); | 131 | -// always little-endian |
68 | if (local_err) { | 132 | -typedef struct ParallelsHeader { |
69 | error_propagate(errp, local_err); | 133 | - char magic[16]; // "WithoutFreeSpace" |
70 | - r = -EINVAL; | 134 | - uint32_t version; |
71 | goto out; | 135 | - uint32_t heads; |
72 | } | 136 | - uint32_t cylinders; |
137 | - uint32_t tracks; | ||
138 | - uint32_t bat_entries; | ||
139 | - uint64_t nb_sectors; | ||
140 | - uint32_t inuse; | ||
141 | - uint32_t data_off; | ||
142 | - char padding[12]; | ||
143 | -} QEMU_PACKED ParallelsHeader; | ||
144 | - | ||
145 | - | ||
146 | -typedef enum ParallelsPreallocMode { | ||
147 | - PRL_PREALLOC_MODE_FALLOCATE = 0, | ||
148 | - PRL_PREALLOC_MODE_TRUNCATE = 1, | ||
149 | - PRL_PREALLOC_MODE__MAX = 2, | ||
150 | -} ParallelsPreallocMode; | ||
151 | - | ||
152 | static QEnumLookup prealloc_mode_lookup = { | ||
153 | .array = (const char *const[]) { | ||
154 | "falloc", | ||
155 | @@ -XXX,XX +XXX,XX @@ static QEnumLookup prealloc_mode_lookup = { | ||
156 | .size = PRL_PREALLOC_MODE__MAX | ||
157 | }; | ||
158 | |||
159 | -typedef struct BDRVParallelsState { | ||
160 | - /** Locking is conservative, the lock protects | ||
161 | - * - image file extending (truncate, fallocate) | ||
162 | - * - any access to block allocation table | ||
163 | - */ | ||
164 | - CoMutex lock; | ||
165 | - | ||
166 | - ParallelsHeader *header; | ||
167 | - uint32_t header_size; | ||
168 | - bool header_unclean; | ||
169 | - | ||
170 | - unsigned long *bat_dirty_bmap; | ||
171 | - unsigned int bat_dirty_block; | ||
172 | - | ||
173 | - uint32_t *bat_bitmap; | ||
174 | - unsigned int bat_size; | ||
175 | - | ||
176 | - int64_t data_end; | ||
177 | - uint64_t prealloc_size; | ||
178 | - ParallelsPreallocMode prealloc_mode; | ||
179 | - | ||
180 | - unsigned int tracks; | ||
181 | - | ||
182 | - unsigned int off_multiplier; | ||
183 | - Error *migration_blocker; | ||
184 | -} BDRVParallelsState; | ||
185 | - | ||
186 | - | ||
187 | #define PARALLELS_OPT_PREALLOC_MODE "prealloc-mode" | ||
188 | #define PARALLELS_OPT_PREALLOC_SIZE "prealloc-size" | ||
73 | 189 | ||
74 | -- | 190 | -- |
75 | 2.17.1 | 191 | 2.14.3 |
76 | 192 | ||
77 | 193 | diff view generated by jsdifflib |
1 | Signed-off-by: Jeff Cody <jcody@redhat.com> | 1 | From: Klim Kireev <klim.kireev@virtuozzo.com> |
---|---|---|---|
2 | Message-id: 647f5b5ab7efd8bf567a504c832b1d2d6f719b23.1536704901.git.jcody@redhat.com | 2 | |
3 | Signed-off-by: Jeff Cody <jcody@redhat.com> | 3 | Signed-off-by: Klim Kireev <klim.kireev@virtuozzo.com> |
4 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
5 | Signed-off-by: Denis V. Lunev <den@openvz.org> | ||
6 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
7 | Signed-off-by: Edgar Kaziakhmedov <edgar.kaziakhmedov@virtuozzo.com> | ||
8 | Message-id: 20180112090122.1702-5-klim.kireev@virtuozzo.com | ||
9 | CC: Stefan Hajnoczi <stefanha@redhat.com> | ||
10 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
4 | --- | 11 | --- |
5 | qemu-deprecated.texi | 15 +++++++++++++++ | 12 | block/parallels.h | 2 ++ |
6 | 1 file changed, 15 insertions(+) | 13 | block/parallels.c | 5 +++-- |
14 | 2 files changed, 5 insertions(+), 2 deletions(-) | ||
7 | 15 | ||
8 | diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi | 16 | diff --git a/block/parallels.h b/block/parallels.h |
9 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
10 | --- a/qemu-deprecated.texi | 18 | --- a/block/parallels.h |
11 | +++ b/qemu-deprecated.texi | 19 | +++ b/block/parallels.h |
12 | @@ -XXX,XX +XXX,XX @@ used instead. | 20 | @@ -XXX,XX +XXX,XX @@ |
13 | In order to prevent QEMU from automatically opening an image's backing | 21 | #include "qemu/coroutine.h" |
14 | chain, use ``"backing": null'' instead. | 22 | #include "qemu/typedefs.h" |
15 | 23 | ||
16 | +@subsubsection rbd keyvalue pair encoded filenames: "" (since 3.1.0) | 24 | +#define HEADS_NUMBER 16 |
17 | + | 25 | +#define SEC_IN_CYL 32 |
18 | +Options for ``rbd'' should be specified according to its runtime options, | 26 | #define DEFAULT_CLUSTER_SIZE 1048576 /* 1 MiB */ |
19 | +like other block drivers. Legacy parsing of keyvalue pair encoded | 27 | |
20 | +filenames is useful to open images with the old format for backing files; | 28 | /* always little-endian */ |
21 | +These image files should be updated to use the current format. | 29 | diff --git a/block/parallels.c b/block/parallels.c |
22 | + | 30 | index XXXXXXX..XXXXXXX 100644 |
23 | +Example of legacy encoding: | 31 | --- a/block/parallels.c |
24 | + | 32 | +++ b/block/parallels.c |
25 | +@code{json:@{"file.driver":"rbd", "file.filename":"rbd:rbd/name"@}} | 33 | @@ -XXX,XX +XXX,XX @@ static int parallels_create(const char *filename, QemuOpts *opts, Error **errp) |
26 | + | 34 | memcpy(header.magic, HEADER_MAGIC2, sizeof(header.magic)); |
27 | +The above, converted to the current supported format: | 35 | header.version = cpu_to_le32(HEADER_VERSION); |
28 | + | 36 | /* don't care much about geometry, it is not used on image level */ |
29 | +@code{json:@{"file.driver":"rbd", "file.pool":"rbd", "file.image":"name"@}} | 37 | - header.heads = cpu_to_le32(16); |
30 | + | 38 | - header.cylinders = cpu_to_le32(total_size / BDRV_SECTOR_SIZE / 16 / 32); |
31 | @subsection vio-spapr-device device options | 39 | + header.heads = cpu_to_le32(HEADS_NUMBER); |
32 | 40 | + header.cylinders = cpu_to_le32(total_size / BDRV_SECTOR_SIZE | |
33 | @subsubsection "irq": "" (since 3.0.0) | 41 | + / HEADS_NUMBER / SEC_IN_CYL); |
42 | header.tracks = cpu_to_le32(cl_size >> BDRV_SECTOR_BITS); | ||
43 | header.bat_entries = cpu_to_le32(bat_entries); | ||
44 | header.nb_sectors = cpu_to_le64(DIV_ROUND_UP(total_size, BDRV_SECTOR_SIZE)); | ||
34 | -- | 45 | -- |
35 | 2.17.1 | 46 | 2.14.3 |
36 | 47 | ||
37 | 48 | diff view generated by jsdifflib |
1 | When we converted rbd to get rid of the older key/value-centric | 1 | From: Edgar Kaziakhmedov <edgar.kaziakhmedov@virtuozzo.com> |
---|---|---|---|
2 | encoding format, we broke compatibility with image files with backing | ||
3 | file strings encoded in the old format. | ||
4 | 2 | ||
5 | This leaves a bit of an ugly conundrum, and a hacky solution. | 3 | Since parallels format supports backing files, refine |
4 | readv/writev (allocate_clusters) to redirect read/write requests | ||
5 | to a backing file (if cluster is not available in the current bs). | ||
6 | 6 | ||
7 | If the initial attempt to parse the "proper" options fails, it assumes | 7 | Signed-off-by: Edgar Kaziakhmedov <edgar.kaziakhmedov@virtuozzo.com> |
8 | that we may have an older key/value encoded filename. Fall back to | 8 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
9 | attempting to parse the filename, and extract the required options from | 9 | Signed-off-by: Denis V. Lunev <den@openvz.org> |
10 | it. If that fails, pass along the original error message. | 10 | Signed-off-by: Klim Kireev <klim.kireev@virtuozzo.com> |
11 | Message-id: 20180112090122.1702-6-klim.kireev@virtuozzo.com | ||
12 | CC: Stefan Hajnoczi <stefanha@redhat.com> | ||
13 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
14 | --- | ||
15 | block/parallels.c | 50 ++++++++++++++++++++++++++++++++++++++++++++------ | ||
16 | 1 file changed, 44 insertions(+), 6 deletions(-) | ||
11 | 17 | ||
12 | We do not support mixed modern usage alongside legacy keyvalue pair | 18 | diff --git a/block/parallels.c b/block/parallels.c |
13 | usage. | ||
14 | |||
15 | A deprecation warning has been added, although care should be taken | ||
16 | when actually deprecating since the impact is not limited to | ||
17 | commandline or qapi usage, but also opening existing images. | ||
18 | |||
19 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
20 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
21 | Message-id: 15b332e5432ad069441f7275a46080f465d789a0.1536704901.git.jcody@redhat.com | ||
22 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
23 | --- | ||
24 | block/rbd.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++-- | ||
25 | 1 file changed, 51 insertions(+), 2 deletions(-) | ||
26 | |||
27 | diff --git a/block/rbd.c b/block/rbd.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/block/rbd.c | 20 | --- a/block/parallels.c |
30 | +++ b/block/rbd.c | 21 | +++ b/block/parallels.c |
31 | @@ -XXX,XX +XXX,XX @@ static int qemu_rbd_convert_options(QDict *options, BlockdevOptionsRbd **opts, | 22 | @@ -XXX,XX +XXX,XX @@ static int64_t block_status(BDRVParallelsState *s, int64_t sector_num, |
32 | return 0; | 23 | static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num, |
33 | } | 24 | int nb_sectors, int *pnum) |
34 | 25 | { | |
35 | +static int qemu_rbd_attempt_legacy_options(QDict *options, | 26 | + int ret; |
36 | + BlockdevOptionsRbd **opts, | 27 | BDRVParallelsState *s = bs->opaque; |
37 | + char **keypairs) | 28 | int64_t pos, space, idx, to_allocate, i, len; |
38 | +{ | 29 | |
39 | + char *filename; | 30 | @@ -XXX,XX +XXX,XX @@ static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num, |
40 | + int r; | 31 | return len; |
32 | } | ||
33 | if (s->data_end + space > (len >> BDRV_SECTOR_BITS)) { | ||
34 | - int ret; | ||
35 | space += s->prealloc_size; | ||
36 | if (s->prealloc_mode == PRL_PREALLOC_MODE_FALLOCATE) { | ||
37 | ret = bdrv_pwrite_zeroes(bs->file, | ||
38 | @@ -XXX,XX +XXX,XX @@ static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num, | ||
39 | } | ||
40 | } | ||
41 | |||
42 | + /* Try to read from backing to fill empty clusters | ||
43 | + * FIXME: 1. previous write_zeroes may be redundant | ||
44 | + * 2. most of data we read from backing will be rewritten by | ||
45 | + * parallels_co_writev. On aligned-to-cluster write we do not need | ||
46 | + * this read at all. | ||
47 | + * 3. it would be good to combine write of data from backing and new | ||
48 | + * data into one write call */ | ||
49 | + if (bs->backing) { | ||
50 | + int64_t nb_cow_sectors = to_allocate * s->tracks; | ||
51 | + int64_t nb_cow_bytes = nb_cow_sectors << BDRV_SECTOR_BITS; | ||
52 | + QEMUIOVector qiov; | ||
53 | + struct iovec iov = { | ||
54 | + .iov_len = nb_cow_bytes, | ||
55 | + .iov_base = qemu_blockalign(bs, nb_cow_bytes) | ||
56 | + }; | ||
57 | + qemu_iovec_init_external(&qiov, &iov, 1); | ||
41 | + | 58 | + |
42 | + filename = g_strdup(qdict_get_try_str(options, "filename")); | 59 | + ret = bdrv_co_readv(bs->backing, idx * s->tracks, nb_cow_sectors, |
43 | + if (!filename) { | 60 | + &qiov); |
44 | + return -EINVAL; | 61 | + if (ret < 0) { |
45 | + } | 62 | + qemu_vfree(iov.iov_base); |
46 | + qdict_del(options, "filename"); | 63 | + return ret; |
64 | + } | ||
47 | + | 65 | + |
48 | + qemu_rbd_parse_filename(filename, options, NULL); | 66 | + ret = bdrv_co_writev(bs->file, s->data_end, nb_cow_sectors, &qiov); |
49 | + | 67 | + qemu_vfree(iov.iov_base); |
50 | + /* keypairs freed by caller */ | 68 | + if (ret < 0) { |
51 | + *keypairs = g_strdup(qdict_get_try_str(options, "=keyvalue-pairs")); | 69 | + return ret; |
52 | + if (*keypairs) { | 70 | + } |
53 | + qdict_del(options, "=keyvalue-pairs"); | ||
54 | + } | 71 | + } |
55 | + | 72 | + |
56 | + r = qemu_rbd_convert_options(options, opts, NULL); | 73 | for (i = 0; i < to_allocate; i++) { |
74 | s->bat_bitmap[idx + i] = cpu_to_le32(s->data_end / s->off_multiplier); | ||
75 | s->data_end += s->tracks; | ||
76 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int parallels_co_readv(BlockDriverState *bs, | ||
77 | |||
78 | nbytes = n << BDRV_SECTOR_BITS; | ||
79 | |||
80 | + qemu_iovec_reset(&hd_qiov); | ||
81 | + qemu_iovec_concat(&hd_qiov, qiov, bytes_done, nbytes); | ||
57 | + | 82 | + |
58 | + g_free(filename); | 83 | if (position < 0) { |
59 | + return r; | 84 | - qemu_iovec_memset(qiov, bytes_done, 0, nbytes); |
60 | +} | 85 | + if (bs->backing) { |
61 | + | 86 | + ret = bdrv_co_readv(bs->backing, sector_num, n, &hd_qiov); |
62 | static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, | 87 | + if (ret < 0) { |
63 | Error **errp) | 88 | + break; |
64 | { | 89 | + } |
65 | @@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, | 90 | + } else { |
66 | 91 | + qemu_iovec_memset(&hd_qiov, 0, 0, nbytes); | |
67 | r = qemu_rbd_convert_options(options, &opts, &local_err); | 92 | + } |
68 | if (local_err) { | 93 | } else { |
69 | - error_propagate(errp, local_err); | 94 | - qemu_iovec_reset(&hd_qiov); |
70 | - goto out; | 95 | - qemu_iovec_concat(&hd_qiov, qiov, bytes_done, nbytes); |
71 | + /* If keypairs are present, that means some options are present in | 96 | - |
72 | + * the modern option format. Don't attempt to parse legacy option | 97 | ret = bdrv_co_readv(bs->file, position, n, &hd_qiov); |
73 | + * formats, as we won't support mixed usage. */ | 98 | if (ret < 0) { |
74 | + if (keypairs) { | 99 | break; |
75 | + error_propagate(errp, local_err); | 100 | @@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_parallels = { |
76 | + goto out; | 101 | .bdrv_co_flush_to_os = parallels_co_flush_to_os, |
77 | + } | 102 | .bdrv_co_readv = parallels_co_readv, |
78 | + | 103 | .bdrv_co_writev = parallels_co_writev, |
79 | + /* If the initial attempt to convert and process the options failed, | 104 | - |
80 | + * we may be attempting to open an image file that has the rbd options | 105 | + .supports_backing = true, |
81 | + * specified in the older format consisting of all key/value pairs | 106 | .bdrv_create = parallels_create, |
82 | + * encoded in the filename. Go ahead and attempt to parse the | 107 | .bdrv_check = parallels_check, |
83 | + * filename, and see if we can pull out the required options. */ | 108 | .create_opts = ¶llels_create_opts, |
84 | + r = qemu_rbd_attempt_legacy_options(options, &opts, &keypairs); | ||
85 | + if (r < 0) { | ||
86 | + error_propagate(errp, local_err); | ||
87 | + goto out; | ||
88 | + } | ||
89 | + /* Take care whenever deciding to actually deprecate; once this ability | ||
90 | + * is removed, we will not be able to open any images with legacy-styled | ||
91 | + * backing image strings. */ | ||
92 | + error_report("RBD options encoded in the filename as keyvalue pairs " | ||
93 | + "is deprecated. Future versions may cease to parse " | ||
94 | + "these options in the future."); | ||
95 | } | ||
96 | |||
97 | /* Remove the processed options from the QDict (the visitor processes | ||
98 | -- | 109 | -- |
99 | 2.17.1 | 110 | 2.14.3 |
100 | 111 | ||
101 | 112 | diff view generated by jsdifflib |