1 | The following changes since commit 2480f3bbd03814b0651a1f74959f5c6631ee5819: | 1 | The following changes since commit b384cd95eb9c6f73ad84ed1bb0717a26e29cc78f: |
---|---|---|---|
2 | 2 | ||
3 | Merge tag 'linux-user-for-7.1-pull-request' of https://gitlab.com/laurent_vivier/qemu into staging (2022-08-03 08:32:44 -0700) | 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 | https://gitlab.com/stefanha/qemu.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 7b0ca313647532a2c7007379ff800c9a2415c95d: | 9 | for you to fetch changes up to bcbb3866da19cce4360c828b6ec1c2a137757927: |
10 | 10 | ||
11 | virtiofsd: Fix format strings (2022-08-04 14:44:25 -0400) | 11 | block/parallels: add backing support to readv/writev (2018-01-22 14:02:33 +0000) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Pull request | 14 | Pull request |
15 | 15 | ||
16 | - Format string portability fix in virtiofsd | 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 | ||
17 | 20 | ||
18 | ---------------------------------------------------------------- | 21 | ---------------------------------------------------------------- |
19 | 22 | ||
20 | Stefan Weil (1): | 23 | Edgar Kaziakhmedov (1): |
21 | virtiofsd: Fix format strings | 24 | block/parallels: add backing support to readv/writev |
22 | 25 | ||
23 | tools/virtiofsd/fuse_lowlevel.c | 4 ++-- | 26 | Klim Kireev (4): |
24 | 1 file changed, 2 insertions(+), 2 deletions(-) | 27 | docs/interop/prl-xml: description of Parallels Disk format |
28 | configure: add dependency | ||
29 | block/parallels: move some structures into header | ||
30 | block/parallels: replace some magic numbers | ||
31 | |||
32 | Stefan Hajnoczi (1): | ||
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 | ||
25 | 45 | ||
26 | -- | 46 | -- |
27 | 2.37.1 | 47 | 2.14.3 |
48 | |||
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 |
New patch | |||
---|---|---|---|
1 | From: Klim Kireev <klim.kireev@virtuozzo.com> | ||
1 | 2 | ||
3 | This patch adds main information about Parallels Disk | ||
4 | format, which consists of DiskDescriptor.xml and other files. | ||
5 | |||
6 | Signed-off-by: Edgar Kaziakhmedov <edgar.kaziakhmedov@virtuozzo.com> | ||
7 | Signed-off-by: Klim Kireev <klim.kireev@virtuozzo.com> | ||
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 | ||
17 | |||
18 | diff --git a/docs/interop/prl-xml.txt b/docs/interop/prl-xml.txt | ||
19 | new file mode 100644 | ||
20 | index XXXXXXX..XXXXXXX | ||
21 | --- /dev/null | ||
22 | +++ b/docs/interop/prl-xml.txt | ||
23 | @@ -XXX,XX +XXX,XX @@ | ||
24 | += License = | ||
25 | + | ||
26 | +Copyright (c) 2015-2017, Virtuozzo, Inc. | ||
27 | +Authors: | ||
28 | + 2015 Denis Lunev <den@openvz.org> | ||
29 | + 2015 Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
30 | + 2016-2017 Klim Kireev <klim.kireev@virtuozzo.com> | ||
31 | + 2016-2017 Edgar Kaziakhmedov <edgar.kaziakhmedov@virtuozzo.com> | ||
32 | + | ||
33 | +This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
34 | +See the COPYING file in the top-level directory. | ||
35 | + | ||
36 | +This specification contains minimal information about Parallels Disk Format, | ||
37 | +which is enough to proper work with QEMU. Nevertheless, Parallels Cloud Server | ||
38 | +and Parallels Desktop are able to add some unspecified nodes to xml and use | ||
39 | +them, but they are for internal work and don't affect functionality. Also it | ||
40 | +uses auxiliary xml "Snapshot.xml", which allows to store optional snapshot | ||
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. | ||
182 | -- | ||
183 | 2.14.3 | ||
184 | |||
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 |
New patch | |||
---|---|---|---|
1 | From: Klim Kireev <klim.kireev@virtuozzo.com> | ||
1 | 2 | ||
3 | To implement xml format, some defines and structures | ||
4 | from parallels.c are required. | ||
5 | |||
6 | Signed-off-by: Klim Kireev <klim.kireev@virtuozzo.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> | ||
14 | --- | ||
15 | block/parallels.h | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
16 | block/parallels.c | 53 +--------------------------------- | ||
17 | 2 files changed, 87 insertions(+), 52 deletions(-) | ||
18 | create mode 100644 block/parallels.h | ||
19 | |||
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 | ||
113 | index XXXXXXX..XXXXXXX 100644 | ||
114 | --- a/block/parallels.c | ||
115 | +++ b/block/parallels.c | ||
116 | @@ -XXX,XX +XXX,XX @@ | ||
117 | #include "qemu/bswap.h" | ||
118 | #include "qemu/bitmap.h" | ||
119 | #include "migration/blocker.h" | ||
120 | +#include "parallels.h" | ||
121 | |||
122 | /**************************************************************/ | ||
123 | |||
124 | @@ -XXX,XX +XXX,XX @@ | ||
125 | #define HEADER_INUSE_MAGIC (0x746F6E59) | ||
126 | #define MAX_PARALLELS_IMAGE_FACTOR (1ull << 32) | ||
127 | |||
128 | -#define DEFAULT_CLUSTER_SIZE 1048576 /* 1 MiB */ | ||
129 | - | ||
130 | - | ||
131 | -// always little-endian | ||
132 | -typedef struct ParallelsHeader { | ||
133 | - char magic[16]; // "WithoutFreeSpace" | ||
134 | - uint32_t version; | ||
135 | - uint32_t heads; | ||
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" | ||
189 | |||
190 | -- | ||
191 | 2.14.3 | ||
192 | |||
193 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Klim Kireev <klim.kireev@virtuozzo.com> | ||
1 | 2 | ||
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> | ||
11 | --- | ||
12 | block/parallels.h | 2 ++ | ||
13 | block/parallels.c | 5 +++-- | ||
14 | 2 files changed, 5 insertions(+), 2 deletions(-) | ||
15 | |||
16 | diff --git a/block/parallels.h b/block/parallels.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/block/parallels.h | ||
19 | +++ b/block/parallels.h | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | #include "qemu/coroutine.h" | ||
22 | #include "qemu/typedefs.h" | ||
23 | |||
24 | +#define HEADS_NUMBER 16 | ||
25 | +#define SEC_IN_CYL 32 | ||
26 | #define DEFAULT_CLUSTER_SIZE 1048576 /* 1 MiB */ | ||
27 | |||
28 | /* always little-endian */ | ||
29 | diff --git a/block/parallels.c b/block/parallels.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/block/parallels.c | ||
32 | +++ b/block/parallels.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static int parallels_create(const char *filename, QemuOpts *opts, Error **errp) | ||
34 | memcpy(header.magic, HEADER_MAGIC2, sizeof(header.magic)); | ||
35 | header.version = cpu_to_le32(HEADER_VERSION); | ||
36 | /* don't care much about geometry, it is not used on image level */ | ||
37 | - header.heads = cpu_to_le32(16); | ||
38 | - header.cylinders = cpu_to_le32(total_size / BDRV_SECTOR_SIZE / 16 / 32); | ||
39 | + header.heads = cpu_to_le32(HEADS_NUMBER); | ||
40 | + header.cylinders = cpu_to_le32(total_size / BDRV_SECTOR_SIZE | ||
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)); | ||
45 | -- | ||
46 | 2.14.3 | ||
47 | |||
48 | diff view generated by jsdifflib |
1 | From: Stefan Weil <sw@weilnetz.de> | 1 | From: Edgar Kaziakhmedov <edgar.kaziakhmedov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Stefan Weil <sw@weilnetz.de> | 3 | Since parallels format supports backing files, refine |
4 | Message-Id: <20220804074833.892604-1-sw@weilnetz.de> | 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 | |||
7 | Signed-off-by: Edgar Kaziakhmedov <edgar.kaziakhmedov@virtuozzo.com> | ||
8 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
9 | Signed-off-by: Denis V. Lunev <den@openvz.org> | ||
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> | ||
5 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 13 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
6 | --- | 14 | --- |
7 | tools/virtiofsd/fuse_lowlevel.c | 4 ++-- | 15 | block/parallels.c | 50 ++++++++++++++++++++++++++++++++++++++++++++------ |
8 | 1 file changed, 2 insertions(+), 2 deletions(-) | 16 | 1 file changed, 44 insertions(+), 6 deletions(-) |
9 | 17 | ||
10 | diff --git a/tools/virtiofsd/fuse_lowlevel.c b/tools/virtiofsd/fuse_lowlevel.c | 18 | diff --git a/block/parallels.c b/block/parallels.c |
11 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/tools/virtiofsd/fuse_lowlevel.c | 20 | --- a/block/parallels.c |
13 | +++ b/tools/virtiofsd/fuse_lowlevel.c | 21 | +++ b/block/parallels.c |
14 | @@ -XXX,XX +XXX,XX @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, | 22 | @@ -XXX,XX +XXX,XX @@ static int64_t block_status(BDRVParallelsState *s, int64_t sector_num, |
15 | 23 | static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num, | |
16 | fuse_log(FUSE_LOG_DEBUG, "INIT: %u.%u\n", arg->major, arg->minor); | 24 | int nb_sectors, int *pnum) |
17 | if (arg->major == 7 && arg->minor >= 6) { | 25 | { |
18 | - fuse_log(FUSE_LOG_DEBUG, "flags=0x%016llx\n", flags); | 26 | + int ret; |
19 | + fuse_log(FUSE_LOG_DEBUG, "flags=0x%016" PRIx64 "\n", flags); | 27 | BDRVParallelsState *s = bs->opaque; |
20 | fuse_log(FUSE_LOG_DEBUG, "max_readahead=0x%08x\n", arg->max_readahead); | 28 | int64_t pos, space, idx, to_allocate, i, len; |
29 | |||
30 | @@ -XXX,XX +XXX,XX @@ static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num, | ||
31 | return len; | ||
21 | } | 32 | } |
22 | se->conn.proto_major = arg->major; | 33 | if (s->data_end + space > (len >> BDRV_SECTOR_BITS)) { |
23 | @@ -XXX,XX +XXX,XX @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, | 34 | - int ret; |
24 | if (se->conn.want & (~se->conn.capable)) { | 35 | space += s->prealloc_size; |
25 | fuse_log(FUSE_LOG_ERR, | 36 | if (s->prealloc_mode == PRL_PREALLOC_MODE_FALLOCATE) { |
26 | "fuse: error: filesystem requested capabilities " | 37 | ret = bdrv_pwrite_zeroes(bs->file, |
27 | - "0x%llx that are not supported by kernel, aborting.\n", | 38 | @@ -XXX,XX +XXX,XX @@ static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num, |
28 | + "0x%" PRIx64 " that are not supported by kernel, aborting.\n", | 39 | } |
29 | se->conn.want & (~se->conn.capable)); | 40 | } |
30 | fuse_reply_err(req, EPROTO); | 41 | |
31 | se->error = -EPROTO; | 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); | ||
58 | + | ||
59 | + ret = bdrv_co_readv(bs->backing, idx * s->tracks, nb_cow_sectors, | ||
60 | + &qiov); | ||
61 | + if (ret < 0) { | ||
62 | + qemu_vfree(iov.iov_base); | ||
63 | + return ret; | ||
64 | + } | ||
65 | + | ||
66 | + ret = bdrv_co_writev(bs->file, s->data_end, nb_cow_sectors, &qiov); | ||
67 | + qemu_vfree(iov.iov_base); | ||
68 | + if (ret < 0) { | ||
69 | + return ret; | ||
70 | + } | ||
71 | + } | ||
72 | + | ||
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); | ||
82 | + | ||
83 | if (position < 0) { | ||
84 | - qemu_iovec_memset(qiov, bytes_done, 0, nbytes); | ||
85 | + if (bs->backing) { | ||
86 | + ret = bdrv_co_readv(bs->backing, sector_num, n, &hd_qiov); | ||
87 | + if (ret < 0) { | ||
88 | + break; | ||
89 | + } | ||
90 | + } else { | ||
91 | + qemu_iovec_memset(&hd_qiov, 0, 0, nbytes); | ||
92 | + } | ||
93 | } else { | ||
94 | - qemu_iovec_reset(&hd_qiov); | ||
95 | - qemu_iovec_concat(&hd_qiov, qiov, bytes_done, nbytes); | ||
96 | - | ||
97 | ret = bdrv_co_readv(bs->file, position, n, &hd_qiov); | ||
98 | if (ret < 0) { | ||
99 | break; | ||
100 | @@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_parallels = { | ||
101 | .bdrv_co_flush_to_os = parallels_co_flush_to_os, | ||
102 | .bdrv_co_readv = parallels_co_readv, | ||
103 | .bdrv_co_writev = parallels_co_writev, | ||
104 | - | ||
105 | + .supports_backing = true, | ||
106 | .bdrv_create = parallels_create, | ||
107 | .bdrv_check = parallels_check, | ||
108 | .create_opts = ¶llels_create_opts, | ||
32 | -- | 109 | -- |
33 | 2.37.1 | 110 | 2.14.3 |
111 | |||
112 | diff view generated by jsdifflib |