...
...
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
git://github.com/stefanha/qemu.git tags/block-pull-request
7
git://github.com/stefanha/qemu.git tags/block-pull-request
8
8
9
for you to fetch changes up to 91661dbdff76d526d22bc7ddf9df3d41e80cdbbf:
9
for you to fetch changes up to bcbb3866da19cce4360c828b6ec1c2a137757927:
10
10
11
block: add block_set_io_throttle virtio-blk-pci QMP example (2018-01-22 12:19:14 +0000)
11
block/parallels: add backing support to readv/writev (2018-01-22 14:02:33 +0000)
12
13
----------------------------------------------------------------
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
12
20
13
----------------------------------------------------------------
21
----------------------------------------------------------------
14
22
15
----------------------------------------------------------------
23
Edgar Kaziakhmedov (1):
24
block/parallels: add backing support to readv/writev
16
25
17
Mao Zhongyi (1):
26
Klim Kireev (4):
18
hw/block: Use errp directly rather than local_err
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
19
31
20
Stefan Hajnoczi (1):
32
Stefan Hajnoczi (1):
21
block: add block_set_io_throttle virtio-blk-pci QMP example
33
block: add block_set_io_throttle virtio-blk-pci QMP example
22
34
23
qapi/block-core.json | 18 ++++++++++++++++++
35
docs/interop/prl-xml.txt | 158 +++++++++++++++++++++++++++++++++++++++++++++++
24
hw/block/virtio-blk.c | 5 +----
36
qapi/block-core.json | 18 ++++++
25
2 files changed, 19 insertions(+), 4 deletions(-)
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
26
45
27
--
46
--
28
2.14.3
47
2.14.3
29
48
30
49
diff view generated by jsdifflib
1
The block_set_io_throttle command can look up BlockBackends by the
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
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
3
actual VirtIOBlock device is the "/virtio-backend" child of the PCI
4
adapter device.
4
adapter device.
5
5
6
Add a QMP schema example so clients will know how to use
6
Add a QMP schema example so clients will know how to use
7
block_set_io_throttle on the virtio-blk-pci device.
7
block_set_io_throttle on the virtio-blk-pci device.
8
8
9
The alternative is to implement some sort of aliasing for qmp_get_blk()
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.
10
but that is likely to cause confusion and could break future use cases.
11
Let's not go there.
11
Let's not go there.
12
12
13
Cc: Kevin Wolf <kwolf@redhat.com>
13
Cc: Kevin Wolf <kwolf@redhat.com>
14
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
15
Reviewed-by: Alberto Garcia <berto@igalia.com>
15
Reviewed-by: Alberto Garcia <berto@igalia.com>
16
Message-id: 20180117090700.25811-1-stefanha@redhat.com
16
Message-id: 20180117090700.25811-1-stefanha@redhat.com
17
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
17
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
18
---
18
---
19
qapi/block-core.json | 18 ++++++++++++++++++
19
qapi/block-core.json | 18 ++++++++++++++++++
20
1 file changed, 18 insertions(+)
20
1 file changed, 18 insertions(+)
21
21
22
diff --git a/qapi/block-core.json b/qapi/block-core.json
22
diff --git a/qapi/block-core.json b/qapi/block-core.json
23
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
24
--- a/qapi/block-core.json
24
--- a/qapi/block-core.json
25
+++ b/qapi/block-core.json
25
+++ b/qapi/block-core.json
26
@@ -XXX,XX +XXX,XX @@
26
@@ -XXX,XX +XXX,XX @@
27
# Example:
27
# Example:
28
#
28
#
29
# -> { "execute": "block_set_io_throttle",
29
# -> { "execute": "block_set_io_throttle",
30
+# "arguments": { "id": "virtio-blk-pci0/virtio-backend",
30
+# "arguments": { "id": "virtio-blk-pci0/virtio-backend",
31
+# "bps": 0,
31
+# "bps": 0,
32
+# "bps_rd": 0,
32
+# "bps_rd": 0,
33
+# "bps_wr": 0,
33
+# "bps_wr": 0,
34
+# "iops": 512,
34
+# "iops": 512,
35
+# "iops_rd": 0,
35
+# "iops_rd": 0,
36
+# "iops_wr": 0,
36
+# "iops_wr": 0,
37
+# "bps_max": 0,
37
+# "bps_max": 0,
38
+# "bps_rd_max": 0,
38
+# "bps_rd_max": 0,
39
+# "bps_wr_max": 0,
39
+# "bps_wr_max": 0,
40
+# "iops_max": 0,
40
+# "iops_max": 0,
41
+# "iops_rd_max": 0,
41
+# "iops_rd_max": 0,
42
+# "iops_wr_max": 0,
42
+# "iops_wr_max": 0,
43
+# "bps_max_length": 0,
43
+# "bps_max_length": 0,
44
+# "iops_size": 0 } }
44
+# "iops_size": 0 } }
45
+# <- { "return": {} }
45
+# <- { "return": {} }
46
+#
46
+#
47
+# -> { "execute": "block_set_io_throttle",
47
+# -> { "execute": "block_set_io_throttle",
48
# "arguments": { "id": "ide0-1-0",
48
# "arguments": { "id": "ide0-1-0",
49
# "bps": 1000000,
49
# "bps": 1000000,
50
# "bps_rd": 0,
50
# "bps_rd": 0,
51
--
51
--
52
2.14.3
52
2.14.3
53
53
54
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: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
1
From: Edgar Kaziakhmedov <edgar.kaziakhmedov@virtuozzo.com>
2
2
3
Cc: John Snow <jsnow@redhat.com>
3
Since parallels format supports backing files, refine
4
Cc: Kevin Wolf <kwolf@redhat.com>
4
readv/writev (allocate_clusters) to redirect read/write requests
5
Cc: Max Reitz <mreitz@redhat.com>
5
to a backing file (if cluster is not available in the current bs).
6
Cc: Keith Busch <keith.busch@intel.com>
7
Cc: Stefan Hajnoczi <stefanha@redhat.com>
8
Cc: "Michael S. Tsirkin" <mst@redhat.com>
9
Cc: Paolo Bonzini <pbonzini@redhat.com>
10
Cc: Gerd Hoffmann <kraxel@redhat.com>
11
Cc: Markus Armbruster <armbru@redhat.com>
12
6
13
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
7
Signed-off-by: Edgar Kaziakhmedov <edgar.kaziakhmedov@virtuozzo.com>
14
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
8
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
15
Message-id: e77848d3735ba590f23ffbf8094379c646c33d79.1511317952.git.maozy.fnst@cn.fujitsu.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>
16
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
17
---
14
---
18
hw/block/virtio-blk.c | 5 +----
15
block/parallels.c | 50 ++++++++++++++++++++++++++++++++++++++++++++------
19
1 file changed, 1 insertion(+), 4 deletions(-)
16
1 file changed, 44 insertions(+), 6 deletions(-)
20
17
21
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
18
diff --git a/block/parallels.c b/block/parallels.c
22
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/block/virtio-blk.c
20
--- a/block/parallels.c
24
+++ b/hw/block/virtio-blk.c
21
+++ b/block/parallels.c
25
@@ -XXX,XX +XXX,XX @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
22
@@ -XXX,XX +XXX,XX @@ static int64_t block_status(BDRVParallelsState *s, int64_t sector_num,
26
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
23
static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num,
27
VirtIOBlock *s = VIRTIO_BLK(dev);
24
int nb_sectors, int *pnum)
28
VirtIOBlkConf *conf = &s->conf;
25
{
29
- Error *err = NULL;
26
+ int ret;
30
unsigned i;
27
BDRVParallelsState *s = bs->opaque;
31
28
int64_t pos, space, idx, to_allocate, i, len;
32
if (!conf->conf.blk) {
29
33
@@ -XXX,XX +XXX,XX @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
30
@@ -XXX,XX +XXX,XX @@ static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num,
34
for (i = 0; i < conf->num_queues; i++) {
31
return len;
35
virtio_add_queue(vdev, conf->queue_size, virtio_blk_handle_output);
36
}
32
}
37
- virtio_blk_data_plane_create(vdev, conf, &s->dataplane, &err);
33
if (s->data_end + space > (len >> BDRV_SECTOR_BITS)) {
38
- if (err != NULL) {
34
- int ret;
39
- error_propagate(errp, err);
35
space += s->prealloc_size;
40
+ if (!virtio_blk_data_plane_create(vdev, conf, &s->dataplane, errp)) {
36
if (s->prealloc_mode == PRL_PREALLOC_MODE_FALLOCATE) {
41
virtio_cleanup(vdev);
37
ret = bdrv_pwrite_zeroes(bs->file,
42
return;
38
@@ -XXX,XX +XXX,XX @@ static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num,
39
}
43
}
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);
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 = &parallels_create_opts,
44
--
109
--
45
2.14.3
110
2.14.3
46
111
47
112
diff view generated by jsdifflib