1
The following changes since commit fb68096da3d35e64c88cd610c1fa42766c58e92a:
1
The following changes since commit b2f7a038bb4c4fc5ce6b8486e8513dfd97665e2a:
2
2
3
Revert "tests: use memfd in vhost-user-test" (2018-02-13 09:51:52 +0000)
3
Merge remote-tracking branch 'remotes/rth/tags/pull-softfloat-20181104' into staging (2018-11-05 10:32:49 +0000)
4
4
5
are available in the git repository at:
5
are available in the Git repository at:
6
6
7
git://repo.or.cz/qemu/kevin.git tags/for-upstream
7
git://repo.or.cz/qemu/kevin.git tags/for-upstream
8
8
9
for you to fetch changes up to 0a4dc980e6c935e9be745ce3ee1a4c71629ecd00:
9
for you to fetch changes up to 1240ac558d348f6c7a5752b1a57c1da58e4efe3e:
10
10
11
Merge remote-tracking branch 'mreitz/tags/pull-block-2018-02-13' into queue-block (2018-02-13 17:01:13 +0100)
11
include: Add a comment to explain the origin of sizes' lookup table (2018-11-05 15:29:59 +0100)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Block layer patches
14
Block layer patches:
15
16
- auto-read-only option to fix commit job when used with -blockdev
17
- Fix help text related qemu-iotests failure (by improving the help text
18
and updating the reference output)
19
- quorum: Add missing checks when adding/removing child nodes
20
- Don't take address of fields in packed structs
21
- vvfat: Fix crash when reporting error about too many files in directory
15
22
16
----------------------------------------------------------------
23
----------------------------------------------------------------
17
Alberto Garcia (40):
24
Alberto Garcia (7):
18
qcow2: Use g_try_realloc() in qcow2_expand_zero_clusters()
25
block: replace "discard" literal with BDRV_OPT_DISCARD macro
19
qcow2: Fix documentation of get_cluster_table()
26
qcow2: Get the request alignment for encrypted images from QCryptoBlock
20
qcow2: Add table size field to Qcow2Cache
27
quorum: Remove quorum_err()
21
qcow2: Remove BDS parameter from qcow2_cache_get_table_addr()
28
quorum: Return an error if the blkverify mode has invalid settings
22
qcow2: Remove BDS parameter from qcow2_cache_get_table_idx()
29
iotest: Test the blkverify mode of the Quorum driver
23
qcow2: Remove BDS parameter from qcow2_cache_table_release()
30
quorum: Forbid adding children in blkverify mode
24
qcow2: Remove BDS parameter from qcow2_cache_entry_mark_dirty()
31
iotest: Test x-blockdev-change on a Quorum
25
qcow2: Remove BDS parameter from qcow2_cache_put()
32
26
qcow2: Remove BDS parameter from qcow2_cache_destroy()
33
Cleber Rosa (1):
27
qcow2: Remove BDS parameter from qcow2_cache_clean_unused()
34
iotests: make 083 specific to raw
28
qcow2: Remove BDS parameter from qcow2_cache_discard()
29
qcow2: Remove BDS parameter from qcow2_cache_is_table_offset()
30
qcow2: Add offset_to_l1_index()
31
qcow2: Add l2_slice_size field to BDRVQcow2State
32
qcow2: Add offset_to_l2_slice_index()
33
qcow2: Update l2_load() to support L2 slices
34
qcow2: Prepare l2_allocate() for adding L2 slice support
35
qcow2: Update l2_allocate() to support L2 slices
36
qcow2: Refactor get_cluster_table()
37
qcow2: Update get_cluster_table() to support L2 slices
38
qcow2: Update qcow2_get_cluster_offset() to support L2 slices
39
qcow2: Update qcow2_alloc_cluster_link_l2() to support L2 slices
40
qcow2: Update handle_copied() to support L2 slices
41
qcow2: Update handle_alloc() to support L2 slices
42
qcow2: Update discard_single_l2() to support L2 slices
43
qcow2: Update zero_single_l2() to support L2 slices
44
qcow2: Prepare qcow2_update_snapshot_refcount() for adding L2 slice support
45
qcow2: Update qcow2_update_snapshot_refcount() to support L2 slices
46
qcow2: Read refcount before L2 table in expand_zero_clusters_in_l1()
47
qcow2: Prepare expand_zero_clusters_in_l1() for adding L2 slice support
48
qcow2: Update expand_zero_clusters_in_l1() to support L2 slices
49
qcow2: Update qcow2_truncate() to support L2 slices
50
qcow2: Rename l2_table in qcow2_alloc_compressed_cluster_offset()
51
qcow2: Rename l2_table in count_contiguous_clusters()
52
qcow2: Rename l2_table in count_contiguous_clusters_unallocated()
53
qcow2: Rename l2_table in count_cow_clusters()
54
qcow2: Allow configuring the L2 slice size
55
iotests: Test valid values of l2-cache-entry-size
56
iotests: Test downgrading an image using a small L2 slice size
57
iotests: Add l2-cache-entry-size to iotest 137
58
35
59
Daniel P. Berrangé (1):
36
Daniel P. Berrangé (1):
60
qemu-io: fix EOF Ctrl-D handling in qemu-io readline code
37
crypto: initialize sector size even when opening with no IO flag
61
38
62
Fam Zheng (4):
39
Kevin Wolf (12):
63
iotests: Fix CID for VMDK afl image
40
vpc: Don't leak opts in vpc_open()
64
qemu-img.texi: Clean up parameter list
41
block: Update flags in bdrv_set_read_only()
65
qemu-img: Document --force-share / -U
42
block: Add auto-read-only option
66
docs: Document share-rw property more thoroughly
43
rbd: Close image in qemu_rbd_open() error path
44
block: Require auto-read-only for existing fallbacks
45
nbd: Support auto-read-only option
46
file-posix: Support auto-read-only option
47
curl: Support auto-read-only option
48
gluster: Support auto-read-only option
49
iscsi: Support auto-read-only option
50
block: Make auto-read-only=on default for -drive
51
qemu-iotests: Test auto-read-only with -drive and -blockdev
67
52
68
Kevin Wolf (1):
53
Leonid Bloch (2):
69
Merge remote-tracking branch 'mreitz/tags/pull-block-2018-02-13' into queue-block
54
vdi: Use a literal number of bytes for DEFAULT_CLUSTER_SIZE
55
include: Add a comment to explain the origin of sizes' lookup table
70
56
71
Max Reitz (8):
57
Li Qiang (1):
72
iotests: Use virtio-blk in 155
58
block: change some function return type to bool
73
gluster: Move glfs_close() to create's clean-up
74
gluster: Pull truncation from qemu_gluster_create
75
gluster: Query current size in do_truncate()
76
gluster: Add preallocated truncation
77
sheepdog: Make sd_prealloc() take a BDS
78
sheepdog: Pass old and new size to sd_prealloc()
79
sheepdog: Allow fully preallocated truncation
80
59
81
Paolo Bonzini (1):
60
Max Reitz (5):
82
block: early check for blockers on drive-mirror
61
option: Make option help nicer to read
62
chardev: Indent list of chardevs
63
qdev-monitor: Make device options help nicer
64
object: Make option help nicer to read
65
fw_cfg: Drop newline in @file description
83
66
84
Vladimir Sementsov-Ogievskiy (1):
67
Peter Maydell (5):
85
block: maintain persistent disabled bitmaps
68
block/qcow2: Don't take address of fields in packed structs
69
block/qcow: Don't take address of fields in packed structs
70
block/qcow2-bitmap: Don't take address of fields in packed structs
71
block/vhdx: Don't take address of fields in packed structs
72
block/vdi: Don't take address of fields in packed structs
86
73
87
qapi/block-core.json | 12 +-
74
Stefan Weil (1):
88
block/qcow2.h | 33 +-
75
qemu-io-cmds: Fix two format strings
89
include/block/dirty-bitmap.h | 1 -
90
block/dirty-bitmap.c | 18 -
91
block/gluster.c | 116 +++---
92
block/qcow2-bitmap.c | 12 +-
93
block/qcow2-cache.c | 80 ++--
94
block/qcow2-cluster.c | 519 +++++++++++++------------
95
block/qcow2-refcount.c | 206 +++++-----
96
block/qcow2.c | 63 ++-
97
block/sheepdog.c | 56 ++-
98
blockdev.c | 15 +-
99
qemu-io.c | 27 +-
100
docs/qemu-block-drivers.texi | 10 +
101
qemu-doc.texi | 7 +
102
qemu-img.texi | 74 ++--
103
tests/qemu-iotests/059.out | 2 +-
104
tests/qemu-iotests/061 | 16 +
105
tests/qemu-iotests/061.out | 61 +++
106
tests/qemu-iotests/103 | 17 +
107
tests/qemu-iotests/103.out | 3 +
108
tests/qemu-iotests/137 | 5 +
109
tests/qemu-iotests/137.out | 2 +
110
tests/qemu-iotests/155 | 14 +-
111
tests/qemu-iotests/165 | 2 +-
112
tests/qemu-iotests/176 | 2 +-
113
tests/qemu-iotests/sample_images/afl9.vmdk.bz2 | Bin 178 -> 618 bytes
114
27 files changed, 816 insertions(+), 557 deletions(-)
115
76
77
Thomas Huth (1):
78
block/vvfat: Fix crash when reporting error about too many files in directory
79
80
qapi/block-core.json | 7 +
81
block/vhdx.h | 12 +-
82
include/block/block.h | 5 +-
83
include/qemu/option.h | 2 +-
84
include/qemu/units.h | 18 +
85
include/sysemu/block-backend.h | 6 +-
86
block.c | 60 ++-
87
block/block-backend.c | 8 +-
88
block/bochs.c | 17 +-
89
block/cloop.c | 16 +-
90
block/curl.c | 8 +-
91
block/dmg.c | 16 +-
92
block/file-posix.c | 19 +-
93
block/gluster.c | 12 +-
94
block/iscsi.c | 8 +-
95
block/nbd-client.c | 10 +-
96
block/qcow.c | 18 +-
97
block/qcow2-bitmap.c | 24 +-
98
block/qcow2.c | 66 +--
99
block/quorum.c | 45 +-
100
block/rbd.c | 14 +-
101
block/vdi.c | 68 +--
102
block/vhdx-endian.c | 118 ++---
103
block/vhdx-log.c | 4 +-
104
block/vhdx.c | 18 +-
105
block/vpc.c | 2 +
106
block/vvfat.c | 15 +-
107
blockdev.c | 3 +-
108
chardev/char.c | 2 +-
109
crypto/block-qcow.c | 2 +
110
qdev-monitor.c | 13 +-
111
qemu-img.c | 4 +-
112
qemu-io-cmds.c | 4 +-
113
util/qemu-option.c | 32 +-
114
vl.c | 15 +-
115
tests/qemu-iotests/081 | 116 +++++
116
tests/qemu-iotests/081.out | 70 +++
117
tests/qemu-iotests/082.out | 956 ++++++++++++++++++++---------------------
118
tests/qemu-iotests/083 | 2 +-
119
tests/qemu-iotests/232 | 147 +++++++
120
tests/qemu-iotests/232.out | 59 +++
121
tests/qemu-iotests/group | 1 +
122
42 files changed, 1266 insertions(+), 776 deletions(-)
123
create mode 100755 tests/qemu-iotests/232
124
create mode 100644 tests/qemu-iotests/232.out
125
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Thomas Huth <thuth@redhat.com>
2
2
3
This function doesn't need any changes to support L2 slices, but since
3
When using the vvfat driver with a directory that contains too many files,
4
it's now dealing with slices intead of full tables, the l2_table
4
QEMU currently crashes. This can be triggered like this for example:
5
variable is renamed for clarity.
6
5
7
Signed-off-by: Alberto Garcia <berto@igalia.com>
6
mkdir /tmp/vvfattest
8
Reviewed-by: Eric Blake <eblake@redhat.com>
7
cd /tmp/vvfattest
9
Reviewed-by: Max Reitz <mreitz@redhat.com>
8
for ((x=0;x<=513;x++)); do mkdir $x; done
10
Message-id: 6107001fc79e6739242f1de7d191375e4f130aac.1517840877.git.berto@igalia.com
9
qemu-system-x86_64 -drive \
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
file.driver=vvfat,file.dir=.,read-only=on,media=cdrom
11
12
Seems like read_directory() is changing the mapping->path variable. Make
13
sure we use the right pointer instead.
14
15
Signed-off-by: Thomas Huth <thuth@redhat.com>
16
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12
---
17
---
13
block/qcow2-cluster.c | 4 ++--
18
block/vvfat.c | 4 ++--
14
1 file changed, 2 insertions(+), 2 deletions(-)
19
1 file changed, 2 insertions(+), 2 deletions(-)
15
20
16
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
21
diff --git a/block/vvfat.c b/block/vvfat.c
17
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
18
--- a/block/qcow2-cluster.c
23
--- a/block/vvfat.c
19
+++ b/block/qcow2-cluster.c
24
+++ b/block/vvfat.c
20
@@ -XXX,XX +XXX,XX @@ err:
25
@@ -XXX,XX +XXX,XX @@ static int init_directories(BDRVVVFATState* s,
21
* which must copy from the backing file)
26
mapping = array_get(&(s->mapping), i);
22
*/
27
23
static int count_cow_clusters(BDRVQcow2State *s, int nb_clusters,
28
if (mapping->mode & MODE_DIRECTORY) {
24
- uint64_t *l2_table, int l2_index)
29
+ char *path = mapping->path;
25
+ uint64_t *l2_slice, int l2_index)
30
mapping->begin = cluster;
26
{
31
if(read_directory(s, i)) {
27
int i;
32
- error_setg(errp, "Could not read directory %s",
28
33
- mapping->path);
29
for (i = 0; i < nb_clusters; i++) {
34
+ error_setg(errp, "Could not read directory %s", path);
30
- uint64_t l2_entry = be64_to_cpu(l2_table[l2_index + i]);
35
return -1;
31
+ uint64_t l2_entry = be64_to_cpu(l2_slice[l2_index + i]);
36
}
32
QCow2ClusterType cluster_type = qcow2_get_cluster_type(l2_entry);
37
mapping = array_get(&(s->mapping), i);
33
34
switch(cluster_type) {
35
--
38
--
36
2.13.6
39
2.19.1
37
40
38
41
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Alberto Garcia <berto@igalia.com>
2
2
3
expand_zero_clusters_in_l1() expands zero clusters as a necessary step
3
Signed-off-by: Alberto Garcia <berto@igalia.com>
4
to downgrade qcow2 images to a version that doesn't support metadata
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
zero clusters. This function takes an L1 table (which may or may not
5
---
6
be active) and iterates over all its L2 tables looking for zero
6
block.c | 6 +++---
7
clusters.
7
1 file changed, 3 insertions(+), 3 deletions(-)
8
8
9
Since we'll be loading L2 slices instead of full tables we need to add
9
diff --git a/block.c b/block.c
10
an extra loop that iterates over all slices of each L2 table, and we
11
should also use the slice size when allocating the buffer used when
12
the L1 table is not active.
13
14
This function doesn't need any additional changes so apart from that
15
this patch simply updates the variable name from l2_table to l2_slice.
16
17
Finally, and since we have to touch the bdrv_read() / bdrv_write()
18
calls anyway, this patch takes the opportunity to replace them with
19
the byte-based bdrv_pread() / bdrv_pwrite().
20
21
Signed-off-by: Alberto Garcia <berto@igalia.com>
22
Reviewed-by: Eric Blake <eblake@redhat.com>
23
Reviewed-by: Max Reitz <mreitz@redhat.com>
24
Message-id: 43590976f730501688096cff103f2923b72b0f32.1517840877.git.berto@igalia.com
25
Signed-off-by: Max Reitz <mreitz@redhat.com>
26
---
27
block/qcow2-cluster.c | 51 ++++++++++++++++++++++++++++-----------------------
28
1 file changed, 28 insertions(+), 23 deletions(-)
29
30
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
31
index XXXXXXX..XXXXXXX 100644
10
index XXXXXXX..XXXXXXX 100644
32
--- a/block/qcow2-cluster.c
11
--- a/block.c
33
+++ b/block/qcow2-cluster.c
12
+++ b/block.c
34
@@ -XXX,XX +XXX,XX @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table,
13
@@ -XXX,XX +XXX,XX @@ QemuOptsList bdrv_runtime_opts = {
35
{
14
.help = "try to optimize zero writes (off, on, unmap)",
36
BDRVQcow2State *s = bs->opaque;
15
},
37
bool is_active_l1 = (l1_table == s->l1_table);
16
{
38
- uint64_t *l2_table = NULL;
17
- .name = "discard",
39
+ uint64_t *l2_slice = NULL;
18
+ .name = BDRV_OPT_DISCARD,
40
+ unsigned slice, slice_size2, n_slices;
19
.type = QEMU_OPT_STRING,
41
int ret;
20
.help = "discard operation (ignore/off, unmap/on)",
42
int i, j;
21
},
43
22
@@ -XXX,XX +XXX,XX @@ static int bdrv_open_common(BlockDriverState *bs, BlockBackend *file,
44
+ slice_size2 = s->l2_slice_size * sizeof(uint64_t);
45
+ n_slices = s->cluster_size / slice_size2;
46
+
47
if (!is_active_l1) {
48
/* inactive L2 tables require a buffer to be stored in when loading
49
* them from disk */
50
- l2_table = qemu_try_blockalign(bs->file->bs, s->cluster_size);
51
- if (l2_table == NULL) {
52
+ l2_slice = qemu_try_blockalign(bs->file->bs, slice_size2);
53
+ if (l2_slice == NULL) {
54
return -ENOMEM;
55
}
23
}
56
}
24
}
57
25
58
for (i = 0; i < l1_size; i++) {
26
- discard = qemu_opt_get(opts, "discard");
59
uint64_t l2_offset = l1_table[i] & L1E_OFFSET_MASK;
27
+ discard = qemu_opt_get(opts, BDRV_OPT_DISCARD);
60
- bool l2_dirty = false;
28
if (discard != NULL) {
61
uint64_t l2_refcount;
29
if (bdrv_parse_discard_flags(discard, &bs->open_flags) != 0) {
62
30
error_setg(errp, "Invalid discard option");
63
if (!l2_offset) {
31
@@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
64
@@ -XXX,XX +XXX,XX @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table,
32
65
goto fail;
33
update_flags_from_options(&reopen_state->flags, opts);
66
}
34
67
35
- discard = qemu_opt_get_del(opts, "discard");
68
- {
36
+ discard = qemu_opt_get_del(opts, BDRV_OPT_DISCARD);
69
+ for (slice = 0; slice < n_slices; slice++) {
37
if (discard != NULL) {
70
+ uint64_t slice_offset = l2_offset + slice * slice_size2;
38
if (bdrv_parse_discard_flags(discard, &reopen_state->flags) != 0) {
71
+ bool l2_dirty = false;
39
error_setg(errp, "Invalid discard option");
72
if (is_active_l1) {
73
/* get active L2 tables from cache */
74
- ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset,
75
- (void **)&l2_table);
76
+ ret = qcow2_cache_get(bs, s->l2_table_cache, slice_offset,
77
+ (void **)&l2_slice);
78
} else {
79
/* load inactive L2 tables from disk */
80
- ret = bdrv_read(bs->file, l2_offset / BDRV_SECTOR_SIZE,
81
- (void *)l2_table, s->cluster_sectors);
82
+ ret = bdrv_pread(bs->file, slice_offset, l2_slice, slice_size2);
83
}
84
if (ret < 0) {
85
goto fail;
86
}
87
88
- for (j = 0; j < s->l2_size; j++) {
89
- uint64_t l2_entry = be64_to_cpu(l2_table[j]);
90
+ for (j = 0; j < s->l2_slice_size; j++) {
91
+ uint64_t l2_entry = be64_to_cpu(l2_slice[j]);
92
int64_t offset = l2_entry & L2E_OFFSET_MASK;
93
QCow2ClusterType cluster_type =
94
qcow2_get_cluster_type(l2_entry);
95
@@ -XXX,XX +XXX,XX @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table,
96
if (!bs->backing) {
97
/* not backed; therefore we can simply deallocate the
98
* cluster */
99
- l2_table[j] = 0;
100
+ l2_slice[j] = 0;
101
l2_dirty = true;
102
continue;
103
}
104
@@ -XXX,XX +XXX,XX @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table,
105
}
106
107
if (offset_into_cluster(s, offset)) {
108
+ int l2_index = slice * s->l2_slice_size + j;
109
qcow2_signal_corruption(
110
bs, true, -1, -1,
111
"Cluster allocation offset "
112
"%#" PRIx64 " unaligned (L2 offset: %#"
113
PRIx64 ", L2 index: %#x)", offset,
114
- l2_offset, j);
115
+ l2_offset, l2_index);
116
if (cluster_type == QCOW2_CLUSTER_ZERO_PLAIN) {
117
qcow2_free_clusters(bs, offset, s->cluster_size,
118
QCOW2_DISCARD_ALWAYS);
119
@@ -XXX,XX +XXX,XX @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table,
120
}
121
122
if (l2_refcount == 1) {
123
- l2_table[j] = cpu_to_be64(offset | QCOW_OFLAG_COPIED);
124
+ l2_slice[j] = cpu_to_be64(offset | QCOW_OFLAG_COPIED);
125
} else {
126
- l2_table[j] = cpu_to_be64(offset);
127
+ l2_slice[j] = cpu_to_be64(offset);
128
}
129
l2_dirty = true;
130
}
131
132
if (is_active_l1) {
133
if (l2_dirty) {
134
- qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
135
+ qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice);
136
qcow2_cache_depends_on_flush(s->l2_table_cache);
137
}
138
- qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
139
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice);
140
} else {
141
if (l2_dirty) {
142
ret = qcow2_pre_write_overlap_check(
143
bs, QCOW2_OL_INACTIVE_L2 | QCOW2_OL_ACTIVE_L2,
144
- l2_offset, s->cluster_size);
145
+ slice_offset, slice_size2);
146
if (ret < 0) {
147
goto fail;
148
}
149
150
- ret = bdrv_write(bs->file, l2_offset / BDRV_SECTOR_SIZE,
151
- (void *)l2_table, s->cluster_sectors);
152
+ ret = bdrv_pwrite(bs->file, slice_offset,
153
+ l2_slice, slice_size2);
154
if (ret < 0) {
155
goto fail;
156
}
157
@@ -XXX,XX +XXX,XX @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table,
158
ret = 0;
159
160
fail:
161
- if (l2_table) {
162
+ if (l2_slice) {
163
if (!is_active_l1) {
164
- qemu_vfree(l2_table);
165
+ qemu_vfree(l2_slice);
166
} else {
167
- qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
168
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice);
169
}
170
}
171
return ret;
172
--
40
--
173
2.13.6
41
2.19.1
174
42
175
43
diff view generated by jsdifflib
1
From: Fam Zheng <famz@redhat.com>
1
From: Stefan Weil <sw@weilnetz.de>
2
2
3
This reverts commit 76bf133c4 which updated the reference output, and
3
Use %zu instead of %zd for unsigned numbers.
4
fixed the reference image, because the code path we want to exercise is
5
actually the invalid image size.
6
4
7
The descriptor block in the image, which includes the CID to verify, has been
5
This fixes two error messages from the LSTM static code analyzer:
8
invalid since the reference image was added. Since commit 9877860e7bd we report
9
this error earlier than the "file too large", so 059.out mismatches.
10
6
11
The binary change is generated along the operations of:
7
This argument should be of type 'ssize_t' but is of type 'unsigned long'
12
8
13
$ bunzip2 afl9.vmdk.bz2
9
Signed-off-by: Stefan Weil <sw@weilnetz.de>
14
$ qemu-img create -f vmdk fix.vmdk 1G
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
$ dd if=afl9.vmdk of=fix.vmdk bs=512 count=1 conv=notrunc
16
$ mv fix.vmdk afl9.vmdk
17
$ bzip2 afl9.vmdk
18
19
Signed-off-by: Fam Zheng <famz@redhat.com>
20
Reviewed-by: Eric Blake <eblake@redhat.com>
21
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
22
---
12
---
23
tests/qemu-iotests/059.out | 2 +-
13
qemu-io-cmds.c | 4 ++--
24
tests/qemu-iotests/sample_images/afl9.vmdk.bz2 | Bin 178 -> 618 bytes
14
1 file changed, 2 insertions(+), 2 deletions(-)
25
2 files changed, 1 insertion(+), 1 deletion(-)
26
15
27
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
16
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
28
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
29
--- a/tests/qemu-iotests/059.out
18
--- a/qemu-io-cmds.c
30
+++ b/tests/qemu-iotests/059.out
19
+++ b/qemu-io-cmds.c
31
@@ -XXX,XX +XXX,XX @@ Offset Length Mapped to File
20
@@ -XXX,XX +XXX,XX @@ static int readv_f(BlockBackend *blk, int argc, char **argv)
32
0x140000000 0x10000 0x50000 TEST_DIR/t-s003.vmdk
21
memset(cmp_buf, pattern, qiov.size);
33
22
if (memcmp(buf, cmp_buf, qiov.size)) {
34
=== Testing afl image with a very large capacity ===
23
printf("Pattern verification failed at offset %"
35
-qemu-img: Could not open 'TEST_DIR/afl9.IMGFMT': Could not open 'TEST_DIR/afl9.IMGFMT': Invalid argument
24
- PRId64 ", %zd bytes\n", offset, qiov.size);
36
+qemu-img: Can't get image size 'TEST_DIR/afl9.IMGFMT': File too large
25
+ PRId64 ", %zu bytes\n", offset, qiov.size);
37
*** done
26
ret = -EINVAL;
38
diff --git a/tests/qemu-iotests/sample_images/afl9.vmdk.bz2 b/tests/qemu-iotests/sample_images/afl9.vmdk.bz2
27
}
39
index XXXXXXX..XXXXXXX 100644
28
g_free(cmp_buf);
40
GIT binary patch
29
@@ -XXX,XX +XXX,XX @@ static void aio_read_done(void *opaque, int ret)
41
literal 618
30
memset(cmp_buf, ctx->pattern, ctx->qiov.size);
42
zcmV-w0+szjT4*^jL0KkKSvgW7ssIN3|NsBH-Q9UpfAhclU70`s-*NE~5QvC~h=_=Y
31
if (memcmp(ctx->buf, cmp_buf, ctx->qiov.size)) {
43
zh>D2n*q*=vygR634445h35k;?00h9835kMW00004$iPepVE{Bqk)uhJ^wfGLr=)3s
32
printf("Pattern verification failed at offset %"
44
zhM5CR88jLh7)B;cA*K)*6GmuECPU3o4NWG5O#pg>Ak#xY8Z^<M8Z>CrMt}oD38Ns$
33
- PRId64 ", %zd bytes\n", ctx->offset, ctx->qiov.size);
45
z02n}M0LdjZ&}cLPqd+nPKmn$j0iXe(02%-d27nnJriN-uE+X&cz@Bj4BBfd|yV!NB
34
+ PRId64 ", %zu bytes\n", ctx->offset, ctx->qiov.size);
46
zwqkL}nW3AI5x^jp=t%^F1pxqp)v#n#)j$zcm1xqv(!$2d*5%vF{5RPWnOV8-^tE<(
35
}
47
zU~%&}Y0uNu*9Wt=yS^8PkC&gPueZO%IG;aD{l#sG`<Af;l1Pnwpi9I75FkQ`LLhd8
36
g_free(cmp_buf);
48
z6(9f*2s+N5=%bwp80ddrD6>m4Ho*fsHXdM<jtl*zKvRiTx7Ugy1|Nl<Ns!z;1dvhy
37
}
49
z=`SDHh~{u|1ZodC(_lzezQ)I*Kv2z|PZ@!SJjlVzwGdx2iu#W}dI{t+T&dDWT^LPy
50
zg3NouEM=V~7GvZQS1CXy676F6mJXWGgW!KTr+E$OspGYCjWmuwa^<Bc>_(-i7fPIW
51
zA+~n9iy_f)g8B2RILhd%F)dZ5f?7pFLw)@;Ncl<JE}gvMrfh{elT#3gLjY6r8xY4O
52
z)UO#pv=WYptukn<DuoMH2ip%k?V^k!rjQirK^RC<Brw>3Bz9<|!xm0F{45K+gg8#n
53
z4FNAJ!<X|3Vq+lyV4=xZ;>AN0<K=%c4A2ruB!4rGvWm!KFrvd4PyfZ-kxmpO4pfM$
54
EfLnqQYXATM
55
56
literal 178
57
zcmV;j08RfwT4*^jL0KkKS>A08g#Z9x|HJ$H)ZJi0004xF0SE*D03g5s00IDLSQelF
58
ziVX^$pfWNUJrmRhn2k52pQ;Rs0EQC;(S%|!m`2~BZ@b++;etskRJUVl!Kt)wu7?VN
59
zl;%JdqX2?TgsNVJP?87M*MvL1qQnBkCES&?0@MeaN-bL4;bDzxmMm|da4fuh!=#fu
60
g@i9R@5z!av{9tA<GGr!3hi~HUNT&)C8_l7xpl%OKQ2+n{
61
62
--
38
--
63
2.13.6
39
2.19.1
64
40
65
41
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Peter Maydell <peter.maydell@linaro.org>
2
2
3
The BDRVQcow2State structure contains an l2_size field, which stores
3
Taking the address of a field in a packed struct is a bad idea, because
4
the number of 64-bit entries in an L2 table.
4
it might not be actually aligned enough for that pointer type (and
5
thus cause a crash on dereference on some host architectures). Newer
6
versions of clang warn about this. Avoid the bug by not using the
7
"modify in place" byte swapping functions.
5
8
6
For efficiency reasons we want to be able to load slices instead of
9
There are a few places where the in-place swap function is
7
full L2 tables, so we need to know how many entries an L2 slice can
10
used on something other than a packed struct field; we convert
8
hold.
11
those anyway, for consistency.
9
12
10
An L2 slice is the portion of an L2 table that is loaded by the qcow2
13
This patch was produced with the following spatch script
11
cache. At the moment that cache can only load complete tables,
14
(and hand-editing to fold a few resulting overlength lines):
12
therefore an L2 slice has the same size as an L2 table (one cluster)
13
and l2_size == l2_slice_size.
14
15
15
Later we'll allow smaller slices, but until then we have to use this
16
@@
16
new l2_slice_size field to make the rest of the code ready for that.
17
expression E;
18
@@
19
-be16_to_cpus(&E);
20
+E = be16_to_cpu(E);
21
@@
22
expression E;
23
@@
24
-be32_to_cpus(&E);
25
+E = be32_to_cpu(E);
26
@@
27
expression E;
28
@@
29
-be64_to_cpus(&E);
30
+E = be64_to_cpu(E);
31
@@
32
expression E;
33
@@
34
-cpu_to_be16s(&E);
35
+E = cpu_to_be16(E);
36
@@
37
expression E;
38
@@
39
-cpu_to_be32s(&E);
40
+E = cpu_to_be32(E);
41
@@
42
expression E;
43
@@
44
-cpu_to_be64s(&E);
45
+E = cpu_to_be64(E);
17
46
18
Signed-off-by: Alberto Garcia <berto@igalia.com>
47
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Reviewed-by: Eric Blake <eblake@redhat.com>
48
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20
Reviewed-by: Max Reitz <mreitz@redhat.com>
49
Tested-by: John Snow <jsnow@redhat.com>
21
Message-id: adb048595f9fb5dfb110c802a8b3c3be3b937f37.1517840877.git.berto@igalia.com
50
Reviewed-by: John Snow <jsnow@redhat.com>
22
Signed-off-by: Max Reitz <mreitz@redhat.com>
51
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
23
---
52
---
24
block/qcow2.h | 1 +
53
block/qcow2.c | 64 +++++++++++++++++++++++++++------------------------
25
block/qcow2.c | 3 +++
54
1 file changed, 34 insertions(+), 30 deletions(-)
26
2 files changed, 4 insertions(+)
27
55
28
diff --git a/block/qcow2.h b/block/qcow2.h
29
index XXXXXXX..XXXXXXX 100644
30
--- a/block/qcow2.h
31
+++ b/block/qcow2.h
32
@@ -XXX,XX +XXX,XX @@ typedef struct BDRVQcow2State {
33
int cluster_bits;
34
int cluster_size;
35
int cluster_sectors;
36
+ int l2_slice_size;
37
int l2_bits;
38
int l2_size;
39
int l1_size;
40
diff --git a/block/qcow2.c b/block/qcow2.c
56
diff --git a/block/qcow2.c b/block/qcow2.c
41
index XXXXXXX..XXXXXXX 100644
57
index XXXXXXX..XXXXXXX 100644
42
--- a/block/qcow2.c
58
--- a/block/qcow2.c
43
+++ b/block/qcow2.c
59
+++ b/block/qcow2.c
44
@@ -XXX,XX +XXX,XX @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts,
60
@@ -XXX,XX +XXX,XX @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset,
45
typedef struct Qcow2ReopenState {
61
"pread fail from offset %" PRIu64, offset);
46
Qcow2Cache *l2_table_cache;
62
return 1;
47
Qcow2Cache *refcount_block_cache;
63
}
48
+ int l2_slice_size; /* Number of entries in a slice of the L2 table */
64
- be32_to_cpus(&ext.magic);
49
bool use_lazy_refcounts;
65
- be32_to_cpus(&ext.len);
50
int overlap_check;
66
+ ext.magic = be32_to_cpu(ext.magic);
51
bool discard_passthrough[QCOW2_DISCARD_MAX];
67
+ ext.len = be32_to_cpu(ext.len);
52
@@ -XXX,XX +XXX,XX @@ static int qcow2_update_options_prepare(BlockDriverState *bs,
68
offset += sizeof(ext);
69
#ifdef DEBUG_EXT
70
printf("ext.magic = 0x%x\n", ext.magic);
71
@@ -XXX,XX +XXX,XX @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset,
72
"Unable to read CRYPTO header extension");
73
return ret;
74
}
75
- be64_to_cpus(&s->crypto_header.offset);
76
- be64_to_cpus(&s->crypto_header.length);
77
+ s->crypto_header.offset = be64_to_cpu(s->crypto_header.offset);
78
+ s->crypto_header.length = be64_to_cpu(s->crypto_header.length);
79
80
if ((s->crypto_header.offset % s->cluster_size) != 0) {
81
error_setg(errp, "Encryption header offset '%" PRIu64 "' is "
82
@@ -XXX,XX +XXX,XX @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset,
83
return -EINVAL;
84
}
85
86
- be32_to_cpus(&bitmaps_ext.nb_bitmaps);
87
- be64_to_cpus(&bitmaps_ext.bitmap_directory_size);
88
- be64_to_cpus(&bitmaps_ext.bitmap_directory_offset);
89
+ bitmaps_ext.nb_bitmaps = be32_to_cpu(bitmaps_ext.nb_bitmaps);
90
+ bitmaps_ext.bitmap_directory_size =
91
+ be64_to_cpu(bitmaps_ext.bitmap_directory_size);
92
+ bitmaps_ext.bitmap_directory_offset =
93
+ be64_to_cpu(bitmaps_ext.bitmap_directory_offset);
94
95
if (bitmaps_ext.nb_bitmaps > QCOW2_MAX_BITMAPS) {
96
error_setg(errp,
97
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
98
error_setg_errno(errp, -ret, "Could not read qcow2 header");
99
goto fail;
100
}
101
- be32_to_cpus(&header.magic);
102
- be32_to_cpus(&header.version);
103
- be64_to_cpus(&header.backing_file_offset);
104
- be32_to_cpus(&header.backing_file_size);
105
- be64_to_cpus(&header.size);
106
- be32_to_cpus(&header.cluster_bits);
107
- be32_to_cpus(&header.crypt_method);
108
- be64_to_cpus(&header.l1_table_offset);
109
- be32_to_cpus(&header.l1_size);
110
- be64_to_cpus(&header.refcount_table_offset);
111
- be32_to_cpus(&header.refcount_table_clusters);
112
- be64_to_cpus(&header.snapshots_offset);
113
- be32_to_cpus(&header.nb_snapshots);
114
+ header.magic = be32_to_cpu(header.magic);
115
+ header.version = be32_to_cpu(header.version);
116
+ header.backing_file_offset = be64_to_cpu(header.backing_file_offset);
117
+ header.backing_file_size = be32_to_cpu(header.backing_file_size);
118
+ header.size = be64_to_cpu(header.size);
119
+ header.cluster_bits = be32_to_cpu(header.cluster_bits);
120
+ header.crypt_method = be32_to_cpu(header.crypt_method);
121
+ header.l1_table_offset = be64_to_cpu(header.l1_table_offset);
122
+ header.l1_size = be32_to_cpu(header.l1_size);
123
+ header.refcount_table_offset = be64_to_cpu(header.refcount_table_offset);
124
+ header.refcount_table_clusters =
125
+ be32_to_cpu(header.refcount_table_clusters);
126
+ header.snapshots_offset = be64_to_cpu(header.snapshots_offset);
127
+ header.nb_snapshots = be32_to_cpu(header.nb_snapshots);
128
129
if (header.magic != QCOW_MAGIC) {
130
error_setg(errp, "Image is not in qcow2 format");
131
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
132
header.refcount_order = 4;
133
header.header_length = 72;
134
} else {
135
- be64_to_cpus(&header.incompatible_features);
136
- be64_to_cpus(&header.compatible_features);
137
- be64_to_cpus(&header.autoclear_features);
138
- be32_to_cpus(&header.refcount_order);
139
- be32_to_cpus(&header.header_length);
140
+ header.incompatible_features =
141
+ be64_to_cpu(header.incompatible_features);
142
+ header.compatible_features = be64_to_cpu(header.compatible_features);
143
+ header.autoclear_features = be64_to_cpu(header.autoclear_features);
144
+ header.refcount_order = be32_to_cpu(header.refcount_order);
145
+ header.header_length = be32_to_cpu(header.header_length);
146
147
if (header.header_length < 104) {
148
error_setg(errp, "qcow2 header too short");
149
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
150
goto fail;
151
}
152
for(i = 0;i < s->l1_size; i++) {
153
- be64_to_cpus(&s->l1_table[i]);
154
+ s->l1_table[i] = be64_to_cpu(s->l1_table[i]);
53
}
155
}
54
}
156
}
55
157
56
+ r->l2_slice_size = s->cluster_size / sizeof(uint64_t);
158
@@ -XXX,XX +XXX,XX @@ int qcow2_update_header(BlockDriverState *bs)
57
r->l2_table_cache = qcow2_cache_create(bs, l2_cache_size);
159
58
r->refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size);
160
/* Full disk encryption header pointer extension */
59
if (r->l2_table_cache == NULL || r->refcount_block_cache == NULL) {
161
if (s->crypto_header.offset != 0) {
60
@@ -XXX,XX +XXX,XX @@ static void qcow2_update_options_commit(BlockDriverState *bs,
162
- cpu_to_be64s(&s->crypto_header.offset);
61
}
163
- cpu_to_be64s(&s->crypto_header.length);
62
s->l2_table_cache = r->l2_table_cache;
164
+ s->crypto_header.offset = cpu_to_be64(s->crypto_header.offset);
63
s->refcount_block_cache = r->refcount_block_cache;
165
+ s->crypto_header.length = cpu_to_be64(s->crypto_header.length);
64
+ s->l2_slice_size = r->l2_slice_size;
166
ret = header_ext_add(buf, QCOW2_EXT_MAGIC_CRYPTO_HEADER,
65
167
&s->crypto_header, sizeof(s->crypto_header),
66
s->overlap_check = r->overlap_check;
168
buflen);
67
s->use_lazy_refcounts = r->use_lazy_refcounts;
169
- be64_to_cpus(&s->crypto_header.offset);
170
- be64_to_cpus(&s->crypto_header.length);
171
+ s->crypto_header.offset = be64_to_cpu(s->crypto_header.offset);
172
+ s->crypto_header.length = be64_to_cpu(s->crypto_header.length);
173
if (ret < 0) {
174
goto fail;
175
}
68
--
176
--
69
2.13.6
177
2.19.1
70
178
71
179
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Peter Maydell <peter.maydell@linaro.org>
2
2
3
handle_alloc() loads an L2 table and limits the number of checked
3
Taking the address of a field in a packed struct is a bad idea, because
4
clusters to the amount that fits inside that table. Since we'll be
4
it might not be actually aligned enough for that pointer type (and
5
loading L2 slices instead of full tables we need to update that limit.
5
thus cause a crash on dereference on some host architectures). Newer
6
versions of clang warn about this. Avoid the bug by not using the
7
"modify in place" byte swapping functions.
6
8
7
Apart from that, this function doesn't need any additional changes, so
9
There are a few places where the in-place swap function is
8
this patch simply updates the variable name from l2_table to l2_slice.
10
used on something other than a packed struct field; we convert
11
those anyway, for consistency.
9
12
10
Signed-off-by: Alberto Garcia <berto@igalia.com>
13
This patch was produced with the following spatch script:
11
Reviewed-by: Eric Blake <eblake@redhat.com>
14
12
Reviewed-by: Max Reitz <mreitz@redhat.com>
15
@@
13
Message-id: b243299c7136f7014c5af51665431ddbf5e99afd.1517840877.git.berto@igalia.com
16
expression E;
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
17
@@
18
-be16_to_cpus(&E);
19
+E = be16_to_cpu(E);
20
@@
21
expression E;
22
@@
23
-be32_to_cpus(&E);
24
+E = be32_to_cpu(E);
25
@@
26
expression E;
27
@@
28
-be64_to_cpus(&E);
29
+E = be64_to_cpu(E);
30
@@
31
expression E;
32
@@
33
-cpu_to_be16s(&E);
34
+E = cpu_to_be16(E);
35
@@
36
expression E;
37
@@
38
-cpu_to_be32s(&E);
39
+E = cpu_to_be32(E);
40
@@
41
expression E;
42
@@
43
-cpu_to_be64s(&E);
44
+E = cpu_to_be64(E);
45
46
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
47
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
48
Tested-by: John Snow <jsnow@redhat.com>
49
Reviewed-by: John Snow <jsnow@redhat.com>
50
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
15
---
51
---
16
block/qcow2-cluster.c | 18 +++++++++---------
52
block/qcow.c | 18 +++++++++---------
17
1 file changed, 9 insertions(+), 9 deletions(-)
53
1 file changed, 9 insertions(+), 9 deletions(-)
18
54
19
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
55
diff --git a/block/qcow.c b/block/qcow.c
20
index XXXXXXX..XXXXXXX 100644
56
index XXXXXXX..XXXXXXX 100644
21
--- a/block/qcow2-cluster.c
57
--- a/block/qcow.c
22
+++ b/block/qcow2-cluster.c
58
+++ b/block/qcow.c
23
@@ -XXX,XX +XXX,XX @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset,
59
@@ -XXX,XX +XXX,XX @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
24
{
25
BDRVQcow2State *s = bs->opaque;
26
int l2_index;
27
- uint64_t *l2_table;
28
+ uint64_t *l2_slice;
29
uint64_t entry;
30
uint64_t nb_clusters;
31
int ret;
32
@@ -XXX,XX +XXX,XX @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset,
33
assert(*bytes > 0);
34
35
/*
36
- * Calculate the number of clusters to look for. We stop at L2 table
37
+ * Calculate the number of clusters to look for. We stop at L2 slice
38
* boundaries to keep things simple.
39
*/
40
nb_clusters =
41
size_to_clusters(s, offset_into_cluster(s, guest_offset) + *bytes);
42
43
- l2_index = offset_to_l2_index(s, guest_offset);
44
- nb_clusters = MIN(nb_clusters, s->l2_size - l2_index);
45
+ l2_index = offset_to_l2_slice_index(s, guest_offset);
46
+ nb_clusters = MIN(nb_clusters, s->l2_slice_size - l2_index);
47
assert(nb_clusters <= INT_MAX);
48
49
/* Find L2 entry for the first involved cluster */
50
- ret = get_cluster_table(bs, guest_offset, &l2_table, &l2_index);
51
+ ret = get_cluster_table(bs, guest_offset, &l2_slice, &l2_index);
52
if (ret < 0) {
60
if (ret < 0) {
53
return ret;
61
goto fail;
54
}
62
}
55
63
- be32_to_cpus(&header.magic);
56
- entry = be64_to_cpu(l2_table[l2_index]);
64
- be32_to_cpus(&header.version);
57
+ entry = be64_to_cpu(l2_slice[l2_index]);
65
- be64_to_cpus(&header.backing_file_offset);
58
66
- be32_to_cpus(&header.backing_file_size);
59
/* For the moment, overwrite compressed clusters one by one */
67
- be32_to_cpus(&header.mtime);
60
if (entry & QCOW_OFLAG_COMPRESSED) {
68
- be64_to_cpus(&header.size);
61
nb_clusters = 1;
69
- be32_to_cpus(&header.crypt_method);
62
} else {
70
- be64_to_cpus(&header.l1_table_offset);
63
- nb_clusters = count_cow_clusters(s, nb_clusters, l2_table, l2_index);
71
+ header.magic = be32_to_cpu(header.magic);
64
+ nb_clusters = count_cow_clusters(s, nb_clusters, l2_slice, l2_index);
72
+ header.version = be32_to_cpu(header.version);
73
+ header.backing_file_offset = be64_to_cpu(header.backing_file_offset);
74
+ header.backing_file_size = be32_to_cpu(header.backing_file_size);
75
+ header.mtime = be32_to_cpu(header.mtime);
76
+ header.size = be64_to_cpu(header.size);
77
+ header.crypt_method = be32_to_cpu(header.crypt_method);
78
+ header.l1_table_offset = be64_to_cpu(header.l1_table_offset);
79
80
if (header.magic != QCOW_MAGIC) {
81
error_setg(errp, "Image not in qcow format");
82
@@ -XXX,XX +XXX,XX @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
65
}
83
}
66
84
67
/* This function is only called when there were no non-COW clusters, so if
85
for(i = 0;i < s->l1_size; i++) {
68
@@ -XXX,XX +XXX,XX @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset,
86
- be64_to_cpus(&s->l1_table[i]);
69
* nb_clusters already to a range of COW clusters */
87
+ s->l1_table[i] = be64_to_cpu(s->l1_table[i]);
70
preallocated_nb_clusters =
71
count_contiguous_clusters(nb_clusters, s->cluster_size,
72
- &l2_table[l2_index], QCOW_OFLAG_COPIED);
73
+ &l2_slice[l2_index], QCOW_OFLAG_COPIED);
74
assert(preallocated_nb_clusters > 0);
75
76
nb_clusters = preallocated_nb_clusters;
77
@@ -XXX,XX +XXX,XX @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset,
78
keep_old_clusters = true;
79
}
88
}
80
89
81
- qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
90
/* alloc L2 cache (max. 64k * 16 * 8 = 8 MB) */
82
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice);
83
84
if (!alloc_cluster_offset) {
85
/* Allocate, if necessary at a given offset in the image file */
86
--
91
--
87
2.13.6
92
2.19.1
88
93
89
94
diff view generated by jsdifflib
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
From: Peter Maydell <peter.maydell@linaro.org>
2
2
3
To maintain load/store disabled bitmap there is new approach:
3
Taking the address of a field in a packed struct is a bad idea, because
4
it might not be actually aligned enough for that pointer type (and
5
thus cause a crash on dereference on some host architectures). Newer
6
versions of clang warn about this. Avoid the bug by not using the
7
"modify in place" byte swapping functions.
4
8
5
- deprecate @autoload flag of block-dirty-bitmap-add, make it ignored
9
There are a few places where the in-place swap function is
6
- store enabled bitmaps as "auto" to qcow2
10
used on something other than a packed struct field; we convert
7
- store disabled bitmaps without "auto" flag to qcow2
11
those anyway, for consistency.
8
- on qcow2 open load "auto" bitmaps as enabled and others
9
as disabled (except in_use bitmaps)
10
12
11
Also, adjust iotests 165 and 176 appropriately.
13
This patch was produced with the following spatch script:
12
14
13
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
15
@@
14
Message-id: 20180202160752.143796-1-vsementsov@virtuozzo.com
16
expression E;
15
Signed-off-by: Max Reitz <mreitz@redhat.com>
17
@@
18
-be16_to_cpus(&E);
19
+E = be16_to_cpu(E);
20
@@
21
expression E;
22
@@
23
-be32_to_cpus(&E);
24
+E = be32_to_cpu(E);
25
@@
26
expression E;
27
@@
28
-be64_to_cpus(&E);
29
+E = be64_to_cpu(E);
30
@@
31
expression E;
32
@@
33
-cpu_to_be16s(&E);
34
+E = cpu_to_be16(E);
35
@@
36
expression E;
37
@@
38
-cpu_to_be32s(&E);
39
+E = cpu_to_be32(E);
40
@@
41
expression E;
42
@@
43
-cpu_to_be64s(&E);
44
+E = cpu_to_be64(E);
45
46
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
47
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
48
Tested-by: John Snow <jsnow@redhat.com>
49
Reviewed-by: John Snow <jsnow@redhat.com>
50
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
16
---
51
---
17
qapi/block-core.json | 6 +++---
52
block/qcow2-bitmap.c | 24 ++++++++++++------------
18
block/qcow2.h | 2 +-
53
1 file changed, 12 insertions(+), 12 deletions(-)
19
include/block/dirty-bitmap.h | 1 -
20
block/dirty-bitmap.c | 18 ------------------
21
block/qcow2-bitmap.c | 12 +++++++-----
22
block/qcow2.c | 2 +-
23
blockdev.c | 10 ++--------
24
qemu-doc.texi | 7 +++++++
25
tests/qemu-iotests/165 | 2 +-
26
tests/qemu-iotests/176 | 2 +-
27
10 files changed, 23 insertions(+), 39 deletions(-)
28
54
29
diff --git a/qapi/block-core.json b/qapi/block-core.json
30
index XXXXXXX..XXXXXXX 100644
31
--- a/qapi/block-core.json
32
+++ b/qapi/block-core.json
33
@@ -XXX,XX +XXX,XX @@
34
# Qcow2 disks support persistent bitmaps. Default is false for
35
# block-dirty-bitmap-add. (Since: 2.10)
36
#
37
-# @autoload: the bitmap will be automatically loaded when the image it is stored
38
-# in is opened. This flag may only be specified for persistent
39
-# bitmaps. Default is false for block-dirty-bitmap-add. (Since: 2.10)
40
+# @autoload: ignored and deprecated since 2.12.
41
+# Currently, all dirty tracking bitmaps are loaded from Qcow2 on
42
+# open.
43
#
44
# Since: 2.4
45
##
46
diff --git a/block/qcow2.h b/block/qcow2.h
47
index XXXXXXX..XXXXXXX 100644
48
--- a/block/qcow2.h
49
+++ b/block/qcow2.h
50
@@ -XXX,XX +XXX,XX @@ void qcow2_cache_discard(BlockDriverState *bs, Qcow2Cache *c, void *table);
51
int qcow2_check_bitmaps_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
52
void **refcount_table,
53
int64_t *refcount_table_size);
54
-bool qcow2_load_autoloading_dirty_bitmaps(BlockDriverState *bs, Error **errp);
55
+bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, Error **errp);
56
int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error **errp);
57
void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp);
58
int qcow2_reopen_bitmaps_ro(BlockDriverState *bs, Error **errp);
59
diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
60
index XXXXXXX..XXXXXXX 100644
61
--- a/include/block/dirty-bitmap.h
62
+++ b/include/block/dirty-bitmap.h
63
@@ -XXX,XX +XXX,XX @@ void bdrv_dirty_bitmap_deserialize_ones(BdrvDirtyBitmap *bitmap,
64
void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap *bitmap);
65
66
void bdrv_dirty_bitmap_set_readonly(BdrvDirtyBitmap *bitmap, bool value);
67
-void bdrv_dirty_bitmap_set_autoload(BdrvDirtyBitmap *bitmap, bool autoload);
68
void bdrv_dirty_bitmap_set_persistance(BdrvDirtyBitmap *bitmap,
69
bool persistent);
70
71
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
72
index XXXXXXX..XXXXXXX 100644
73
--- a/block/dirty-bitmap.c
74
+++ b/block/dirty-bitmap.c
75
@@ -XXX,XX +XXX,XX @@ struct BdrvDirtyBitmap {
76
Such operations must fail and both the image
77
and this bitmap must remain unchanged while
78
this flag is set. */
79
- bool autoload; /* For persistent bitmaps: bitmap must be
80
- autoloaded on image opening */
81
bool persistent; /* bitmap must be saved to owner disk image */
82
QLIST_ENTRY(BdrvDirtyBitmap) list;
83
};
84
@@ -XXX,XX +XXX,XX @@ void bdrv_dirty_bitmap_make_anon(BdrvDirtyBitmap *bitmap)
85
g_free(bitmap->name);
86
bitmap->name = NULL;
87
bitmap->persistent = false;
88
- bitmap->autoload = false;
89
}
90
91
/* Called with BQL taken. */
92
@@ -XXX,XX +XXX,XX @@ BdrvDirtyBitmap *bdrv_dirty_bitmap_abdicate(BlockDriverState *bs,
93
bitmap->successor = NULL;
94
successor->persistent = bitmap->persistent;
95
bitmap->persistent = false;
96
- successor->autoload = bitmap->autoload;
97
- bitmap->autoload = false;
98
bdrv_release_dirty_bitmap(bs, bitmap);
99
100
return successor;
101
@@ -XXX,XX +XXX,XX @@ bool bdrv_has_readonly_bitmaps(BlockDriverState *bs)
102
}
103
104
/* Called with BQL taken. */
105
-void bdrv_dirty_bitmap_set_autoload(BdrvDirtyBitmap *bitmap, bool autoload)
106
-{
107
- qemu_mutex_lock(bitmap->mutex);
108
- bitmap->autoload = autoload;
109
- qemu_mutex_unlock(bitmap->mutex);
110
-}
111
-
112
-bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap *bitmap)
113
-{
114
- return bitmap->autoload;
115
-}
116
-
117
-/* Called with BQL taken. */
118
void bdrv_dirty_bitmap_set_persistance(BdrvDirtyBitmap *bitmap, bool persistent)
119
{
120
qemu_mutex_lock(bitmap->mutex);
121
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
55
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
122
index XXXXXXX..XXXXXXX 100644
56
index XXXXXXX..XXXXXXX 100644
123
--- a/block/qcow2-bitmap.c
57
--- a/block/qcow2-bitmap.c
124
+++ b/block/qcow2-bitmap.c
58
+++ b/block/qcow2-bitmap.c
125
@@ -XXX,XX +XXX,XX @@ static void set_readonly_helper(gpointer bitmap, gpointer value)
59
@@ -XXX,XX +XXX,XX @@ static inline void bitmap_table_to_be(uint64_t *bitmap_table, size_t size)
126
bdrv_dirty_bitmap_set_readonly(bitmap, (bool)value);
60
size_t i;
61
62
for (i = 0; i < size; ++i) {
63
- cpu_to_be64s(&bitmap_table[i]);
64
+ bitmap_table[i] = cpu_to_be64(bitmap_table[i]);
65
}
127
}
66
}
128
67
129
-/* qcow2_load_autoloading_dirty_bitmaps()
68
@@ -XXX,XX +XXX,XX @@ static int bitmap_table_load(BlockDriverState *bs, Qcow2BitmapTable *tb,
130
+/* qcow2_load_dirty_bitmaps()
69
}
131
* Return value is a hint for caller: true means that the Qcow2 header was
70
132
* updated. (false doesn't mean that the header should be updated by the
71
for (i = 0; i < tb->size; ++i) {
133
* caller, it just means that updating was not needed or the image cannot be
72
- be64_to_cpus(&table[i]);
134
* written to).
73
+ table[i] = be64_to_cpu(table[i]);
135
* On failure the function returns false.
74
ret = check_table_entry(table[i], s->cluster_size);
136
*/
75
if (ret < 0) {
137
-bool qcow2_load_autoloading_dirty_bitmaps(BlockDriverState *bs, Error **errp)
76
goto fail;
138
+bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, Error **errp)
77
@@ -XXX,XX +XXX,XX @@ fail:
78
79
static inline void bitmap_dir_entry_to_cpu(Qcow2BitmapDirEntry *entry)
139
{
80
{
140
BDRVQcow2State *s = bs->opaque;
81
- be64_to_cpus(&entry->bitmap_table_offset);
141
Qcow2BitmapList *bm_list;
82
- be32_to_cpus(&entry->bitmap_table_size);
142
@@ -XXX,XX +XXX,XX @@ bool qcow2_load_autoloading_dirty_bitmaps(BlockDriverState *bs, Error **errp)
83
- be32_to_cpus(&entry->flags);
143
}
84
- be16_to_cpus(&entry->name_size);
144
85
- be32_to_cpus(&entry->extra_data_size);
145
QSIMPLEQ_FOREACH(bm, bm_list, entry) {
86
+ entry->bitmap_table_offset = be64_to_cpu(entry->bitmap_table_offset);
146
- if ((bm->flags & BME_FLAG_AUTO) && !(bm->flags & BME_FLAG_IN_USE)) {
87
+ entry->bitmap_table_size = be32_to_cpu(entry->bitmap_table_size);
147
+ if (!(bm->flags & BME_FLAG_IN_USE)) {
88
+ entry->flags = be32_to_cpu(entry->flags);
148
BdrvDirtyBitmap *bitmap = load_bitmap(bs, bm, errp);
89
+ entry->name_size = be16_to_cpu(entry->name_size);
149
if (bitmap == NULL) {
90
+ entry->extra_data_size = be32_to_cpu(entry->extra_data_size);
150
goto fail;
151
}
152
153
+ if (!(bm->flags & BME_FLAG_AUTO)) {
154
+ bdrv_disable_dirty_bitmap(bitmap);
155
+ }
156
bdrv_dirty_bitmap_set_persistance(bitmap, true);
157
- bdrv_dirty_bitmap_set_autoload(bitmap, true);
158
bm->flags |= BME_FLAG_IN_USE;
159
created_dirty_bitmaps =
160
g_slist_append(created_dirty_bitmaps, bitmap);
161
@@ -XXX,XX +XXX,XX @@ void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp)
162
bm->table.size = 0;
163
QSIMPLEQ_INSERT_TAIL(&drop_tables, tb, entry);
164
}
165
- bm->flags = bdrv_dirty_bitmap_get_autoload(bitmap) ? BME_FLAG_AUTO : 0;
166
+ bm->flags = bdrv_dirty_bitmap_enabled(bitmap) ? BME_FLAG_AUTO : 0;
167
bm->granularity_bits = ctz32(bdrv_dirty_bitmap_granularity(bitmap));
168
bm->dirty_bitmap = bitmap;
169
}
170
diff --git a/block/qcow2.c b/block/qcow2.c
171
index XXXXXXX..XXXXXXX 100644
172
--- a/block/qcow2.c
173
+++ b/block/qcow2.c
174
@@ -XXX,XX +XXX,XX @@ static int qcow2_do_open(BlockDriverState *bs, QDict *options, int flags,
175
s->autoclear_features &= QCOW2_AUTOCLEAR_MASK;
176
}
177
178
- if (qcow2_load_autoloading_dirty_bitmaps(bs, &local_err)) {
179
+ if (qcow2_load_dirty_bitmaps(bs, &local_err)) {
180
update_header = false;
181
}
182
if (local_err != NULL) {
183
diff --git a/blockdev.c b/blockdev.c
184
index XXXXXXX..XXXXXXX 100644
185
--- a/blockdev.c
186
+++ b/blockdev.c
187
@@ -XXX,XX +XXX,XX @@ void qmp_block_dirty_bitmap_add(const char *node, const char *name,
188
if (!has_persistent) {
189
persistent = false;
190
}
191
- if (!has_autoload) {
192
- autoload = false;
193
- }
194
195
- if (has_autoload && !persistent) {
196
- error_setg(errp, "Autoload flag must be used only for persistent "
197
- "bitmaps");
198
- return;
199
+ if (has_autoload) {
200
+ warn_report("Autoload option is deprecated and its value is ignored");
201
}
202
203
if (persistent &&
204
@@ -XXX,XX +XXX,XX @@ void qmp_block_dirty_bitmap_add(const char *node, const char *name,
205
}
206
207
bdrv_dirty_bitmap_set_persistance(bitmap, persistent);
208
- bdrv_dirty_bitmap_set_autoload(bitmap, autoload);
209
}
91
}
210
92
211
void qmp_block_dirty_bitmap_remove(const char *node, const char *name,
93
static inline void bitmap_dir_entry_to_be(Qcow2BitmapDirEntry *entry)
212
diff --git a/qemu-doc.texi b/qemu-doc.texi
94
{
213
index XXXXXXX..XXXXXXX 100644
95
- cpu_to_be64s(&entry->bitmap_table_offset);
214
--- a/qemu-doc.texi
96
- cpu_to_be32s(&entry->bitmap_table_size);
215
+++ b/qemu-doc.texi
97
- cpu_to_be32s(&entry->flags);
216
@@ -XXX,XX +XXX,XX @@ used and it will be removed with no replacement.
98
- cpu_to_be16s(&entry->name_size);
217
The ``convert -s snapshot_id_or_name'' argument is obsoleted
99
- cpu_to_be32s(&entry->extra_data_size);
218
by the ``convert -l snapshot_param'' argument instead.
100
+ entry->bitmap_table_offset = cpu_to_be64(entry->bitmap_table_offset);
219
101
+ entry->bitmap_table_size = cpu_to_be32(entry->bitmap_table_size);
220
+@section QEMU Machine Protocol (QMP) commands
102
+ entry->flags = cpu_to_be32(entry->flags);
221
+
103
+ entry->name_size = cpu_to_be16(entry->name_size);
222
+@subsection block-dirty-bitmap-add "autoload" parameter (since 2.12.0)
104
+ entry->extra_data_size = cpu_to_be32(entry->extra_data_size);
223
+
105
}
224
+"autoload" parameter is now ignored. All bitmaps are automatically loaded
106
225
+from qcow2 images.
107
static inline int calc_dir_entry_size(size_t name_size, size_t extra_data_size)
226
+
227
@section System emulator human monitor commands
228
229
@subsection host_net_add (since 2.10.0)
230
diff --git a/tests/qemu-iotests/165 b/tests/qemu-iotests/165
231
index XXXXXXX..XXXXXXX 100755
232
--- a/tests/qemu-iotests/165
233
+++ b/tests/qemu-iotests/165
234
@@ -XXX,XX +XXX,XX @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase):
235
236
def qmpAddBitmap(self):
237
self.vm.qmp('block-dirty-bitmap-add', node='drive0',
238
- name='bitmap0', persistent=True, autoload=True)
239
+ name='bitmap0', persistent=True)
240
241
def test_persistent(self):
242
self.vm = self.mkVm()
243
diff --git a/tests/qemu-iotests/176 b/tests/qemu-iotests/176
244
index XXXXXXX..XXXXXXX 100755
245
--- a/tests/qemu-iotests/176
246
+++ b/tests/qemu-iotests/176
247
@@ -XXX,XX +XXX,XX @@ case $reason in
248
"file": { "driver": "file", "filename": "$TEST_IMG" } } }
249
{ "execute": "block-dirty-bitmap-add",
250
"arguments": { "node": "drive0", "name": "bitmap0",
251
- "persistent": true, "autoload": true } }
252
+ "persistent": true } }
253
{ "execute": "quit" }
254
EOF
255
    ;;
256
--
108
--
257
2.13.6
109
2.19.1
258
110
259
111
diff view generated by jsdifflib
1
From: Fam Zheng <famz@redhat.com>
1
From: Daniel P. Berrangé <berrange@redhat.com>
2
2
3
Signed-off-by: Fam Zheng <famz@redhat.com>
3
The qcow2 block driver expects to see a valid sector size even when it
4
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
4
has opened the crypto layer with QCRYPTO_BLOCK_OPEN_NO_IO.
5
Reviewed-by: Kashyap Chamarthy <kchamart@redhat.com>
5
6
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7
Reviewed-by: Alberto Garcia <berto@igalia.com>
6
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7
---
9
---
8
qemu-img.texi | 8 ++++++++
10
crypto/block-qcow.c | 2 ++
9
1 file changed, 8 insertions(+)
11
1 file changed, 2 insertions(+)
10
12
11
diff --git a/qemu-img.texi b/qemu-img.texi
13
diff --git a/crypto/block-qcow.c b/crypto/block-qcow.c
12
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
13
--- a/qemu-img.texi
15
--- a/crypto/block-qcow.c
14
+++ b/qemu-img.texi
16
+++ b/crypto/block-qcow.c
15
@@ -XXX,XX +XXX,XX @@ exclusive with the @var{-O} parameters. It is currently required to also use
17
@@ -XXX,XX +XXX,XX @@ qcrypto_block_qcow_open(QCryptoBlock *block,
16
the @var{-n} parameter to skip image creation. This restriction may be relaxed
18
Error **errp)
17
in a future release.
19
{
18
20
if (flags & QCRYPTO_BLOCK_OPEN_NO_IO) {
19
+@item --force-share (-U)
21
+ block->sector_size = QCRYPTO_BLOCK_QCOW_SECTOR_SIZE;
20
+If specified, @code{qemu-img} will open the image in shared mode, allowing
22
+ block->payload_offset = 0;
21
+other QEMU processes to open it in write mode. For example, this can be used to
23
return 0;
22
+get the image information (with 'info' subcommand) when the image is used by a
24
} else {
23
+running guest. Note that this could produce inconsistent results because of
25
if (!options->u.qcow.key_secret) {
24
+concurrent metadata changes, etc. This option is only allowed when opening
25
+images in read-only mode.
26
+
27
@item --backing-chain
28
will enumerate information about backing files in a disk image chain. Refer
29
below for further description.
30
--
26
--
31
2.13.6
27
2.19.1
32
28
33
29
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Alberto Garcia <berto@igalia.com>
2
2
3
The qcow2_truncate() code is mostly independent from whether
3
This doesn't have any practical effect at the moment because the
4
we're using L2 slices or full L2 tables, but in full and
4
values of BDRV_SECTOR_SIZE, QCRYPTO_BLOCK_LUKS_SECTOR_SIZE and
5
falloc preallocation modes new L2 tables are allocated using
5
QCRYPTO_BLOCK_QCOW_SECTOR_SIZE are all the same (512 bytes), but
6
qcow2_alloc_cluster_link_l2(). Therefore the code needs to be
6
future encryption methods could have different requirements.
7
modified to ensure that all nb_clusters that are processed in each
8
call can be allocated with just one L2 slice.
9
7
10
Signed-off-by: Alberto Garcia <berto@igalia.com>
8
Signed-off-by: Alberto Garcia <berto@igalia.com>
11
Message-id: 1fd7d272b5e7b66254a090b74cf2bed1cc334c0e.1517840877.git.berto@igalia.com
9
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
12
Reviewed-by: Max Reitz <mreitz@redhat.com>
10
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13
Reviewed-by: Eric Blake <eblake@redhat.com>
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
11
---
16
block/qcow2.c | 6 +++---
12
block/qcow2.c | 2 +-
17
1 file changed, 3 insertions(+), 3 deletions(-)
13
1 file changed, 1 insertion(+), 1 deletion(-)
18
14
19
diff --git a/block/qcow2.c b/block/qcow2.c
15
diff --git a/block/qcow2.c b/block/qcow2.c
20
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
21
--- a/block/qcow2.c
17
--- a/block/qcow2.c
22
+++ b/block/qcow2.c
18
+++ b/block/qcow2.c
23
@@ -XXX,XX +XXX,XX @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset,
19
@@ -XXX,XX +XXX,XX @@ static void qcow2_refresh_limits(BlockDriverState *bs, Error **errp)
24
host_offset = allocation_start;
20
25
guest_offset = old_length;
21
if (bs->encrypted) {
26
while (nb_new_data_clusters) {
22
/* Encryption works on a sector granularity */
27
- int64_t guest_cluster = guest_offset >> s->cluster_bits;
23
- bs->bl.request_alignment = BDRV_SECTOR_SIZE;
28
- int64_t nb_clusters = MIN(nb_new_data_clusters,
24
+ bs->bl.request_alignment = qcrypto_block_get_sector_size(s->crypto);
29
- s->l2_size - guest_cluster % s->l2_size);
25
}
30
+ int64_t nb_clusters = MIN(
26
bs->bl.pwrite_zeroes_alignment = s->cluster_size;
31
+ nb_new_data_clusters,
27
bs->bl.pdiscard_alignment = s->cluster_size;
32
+ s->l2_slice_size - offset_to_l2_slice_index(s, guest_offset));
33
QCowL2Meta allocation = {
34
.offset = guest_offset,
35
.alloc_offset = host_offset,
36
--
28
--
37
2.13.6
29
2.19.1
38
30
39
31
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Li Qiang <liq3ea@163.com>
2
2
3
This function was only using the BlockDriverState parameter to get the
3
Signed-off-by: Li Qiang <liq3ea@163.com>
4
cache table size (since it was equal to the cluster size). This is no
4
Reviewed-by: Alberto Garcia <berto@igalia.com>
5
longer necessary so this parameter can be removed.
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
6
---
7
include/sysemu/block-backend.h | 6 +++---
8
block/block-backend.c | 8 ++++----
9
2 files changed, 7 insertions(+), 7 deletions(-)
6
10
7
Signed-off-by: Alberto Garcia <berto@igalia.com>
11
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
8
Reviewed-by: Eric Blake <eblake@redhat.com>
9
Reviewed-by: Max Reitz <mreitz@redhat.com>
10
Message-id: 7c1b262344375d52544525f85bbbf0548d5ba575.1517840876.git.berto@igalia.com
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
12
---
13
block/qcow2-cache.c | 9 ++++-----
14
1 file changed, 4 insertions(+), 5 deletions(-)
15
16
diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
17
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
18
--- a/block/qcow2-cache.c
13
--- a/include/sysemu/block-backend.h
19
+++ b/block/qcow2-cache.c
14
+++ b/include/sysemu/block-backend.h
20
@@ -XXX,XX +XXX,XX @@ static inline const char *qcow2_cache_get_name(BDRVQcow2State *s, Qcow2Cache *c)
15
@@ -XXX,XX +XXX,XX @@ BlockErrorAction blk_get_error_action(BlockBackend *blk, bool is_read,
16
int error);
17
void blk_error_action(BlockBackend *blk, BlockErrorAction action,
18
bool is_read, int error);
19
-int blk_is_read_only(BlockBackend *blk);
20
-int blk_is_sg(BlockBackend *blk);
21
-int blk_enable_write_cache(BlockBackend *blk);
22
+bool blk_is_read_only(BlockBackend *blk);
23
+bool blk_is_sg(BlockBackend *blk);
24
+bool blk_enable_write_cache(BlockBackend *blk);
25
void blk_set_enable_write_cache(BlockBackend *blk, bool wce);
26
void blk_invalidate_cache(BlockBackend *blk, Error **errp);
27
bool blk_is_inserted(BlockBackend *blk);
28
diff --git a/block/block-backend.c b/block/block-backend.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/block/block-backend.c
31
+++ b/block/block-backend.c
32
@@ -XXX,XX +XXX,XX @@ void blk_error_action(BlockBackend *blk, BlockErrorAction action,
21
}
33
}
22
}
34
}
23
35
24
-static void qcow2_cache_table_release(BlockDriverState *bs, Qcow2Cache *c,
36
-int blk_is_read_only(BlockBackend *blk)
25
- int i, int num_tables)
37
+bool blk_is_read_only(BlockBackend *blk)
26
+static void qcow2_cache_table_release(Qcow2Cache *c, int i, int num_tables)
27
{
38
{
28
/* Using MADV_DONTNEED to discard memory is a Linux-specific feature */
39
BlockDriverState *bs = blk_bs(blk);
29
#ifdef CONFIG_LINUX
40
30
@@ -XXX,XX +XXX,XX @@ void qcow2_cache_clean_unused(BlockDriverState *bs, Qcow2Cache *c)
41
@@ -XXX,XX +XXX,XX @@ int blk_is_read_only(BlockBackend *blk)
31
}
32
33
if (to_clean > 0) {
34
- qcow2_cache_table_release(bs, c, i - to_clean, to_clean);
35
+ qcow2_cache_table_release(c, i - to_clean, to_clean);
36
}
37
}
42
}
38
43
}
39
@@ -XXX,XX +XXX,XX @@ int qcow2_cache_empty(BlockDriverState *bs, Qcow2Cache *c)
44
40
c->entries[i].lru_counter = 0;
45
-int blk_is_sg(BlockBackend *blk)
46
+bool blk_is_sg(BlockBackend *blk)
47
{
48
BlockDriverState *bs = blk_bs(blk);
49
50
if (!bs) {
51
- return 0;
52
+ return false;
41
}
53
}
42
54
43
- qcow2_cache_table_release(bs, c, 0, c->size);
55
return bdrv_is_sg(bs);
44
+ qcow2_cache_table_release(c, 0, c->size);
56
}
45
57
46
c->lru_counter = 0;
58
-int blk_enable_write_cache(BlockBackend *blk)
47
59
+bool blk_enable_write_cache(BlockBackend *blk)
48
@@ -XXX,XX +XXX,XX @@ void qcow2_cache_discard(BlockDriverState *bs, Qcow2Cache *c, void *table)
60
{
49
c->entries[i].lru_counter = 0;
61
return blk->enable_write_cache;
50
c->entries[i].dirty = false;
51
52
- qcow2_cache_table_release(bs, c, i, 1);
53
+ qcow2_cache_table_release(c, i, 1);
54
}
62
}
55
--
63
--
56
2.13.6
64
2.19.1
57
65
58
66
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Cleber Rosa <crosa@redhat.com>
2
2
3
The l2-cache-entry-size setting can only contain values that are
3
While testing the Python 3 changes which touch the 083 test, I noticed
4
powers of two between 512 and the cluster size.
4
that it would fail with qcow2. Expanding the testing, I noticed it
5
had nothing to do with the Python 3 changes, and in fact, it would not
6
pass on anything but raw:
5
7
6
Signed-off-by: Alberto Garcia <berto@igalia.com>
8
raw: pass
7
Reviewed-by: Eric Blake <eblake@redhat.com>
9
bochs: not generic
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
10
cloop: not generic
9
Message-id: bd3547b670b8d0af11480c760991a22bcae5b48c.1517840877.git.berto@igalia.com
11
parallels: fail
10
[mreitz: Changed non-power-of-two test value from 300 to 4242]
12
qcow: fail
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
13
qcow2: fail
14
qed: fail
15
vdi: fail
16
vhdx: fail
17
vmdk: fail
18
vpc: fail
19
luks: fail
20
21
The errors are a mixture I/O and "image not in xxx format", such as:
22
23
=== Check disconnect before data ===
24
25
Unexpected end-of-file before all bytes were read
26
-read failed: Input/output error
27
+can't open device nbd+tcp://127.0.0.1:PORT/foo: Could not open 'nbd://127.0.0.1:PORT/foo': Input/output error
28
29
=== Check disconnect after data ===
30
31
-read 512/512 bytes at offset 0
32
-512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
33
+can't open device nbd+tcp://127.0.0.1:PORT/foo: Image not in qcow format
34
35
I'm not aware if there's a quick fix, so, for the time being, it looks
36
like the honest approach is to make the test known to work on raw
37
only.
38
39
Signed-off-by: Cleber Rosa <crosa@redhat.com>
40
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12
---
41
---
13
tests/qemu-iotests/103 | 17 +++++++++++++++++
42
tests/qemu-iotests/083 | 2 +-
14
tests/qemu-iotests/103.out | 3 +++
43
1 file changed, 1 insertion(+), 1 deletion(-)
15
2 files changed, 20 insertions(+)
16
44
17
diff --git a/tests/qemu-iotests/103 b/tests/qemu-iotests/103
45
diff --git a/tests/qemu-iotests/083 b/tests/qemu-iotests/083
18
index XXXXXXX..XXXXXXX 100755
46
index XXXXXXX..XXXXXXX 100755
19
--- a/tests/qemu-iotests/103
47
--- a/tests/qemu-iotests/083
20
+++ b/tests/qemu-iotests/103
48
+++ b/tests/qemu-iotests/083
21
@@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "open -o cache-size=1M,refcount-cache-size=2M $TEST_IMG" 2>&1 \
49
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
22
$QEMU_IO -c "open -o cache-size=0,l2-cache-size=0,refcount-cache-size=0 $TEST_IMG" \
50
. ./common.rc
23
2>&1 | _filter_testdir | _filter_imgfmt
51
. ./common.filter
24
52
25
+# Invalid cache entry sizes
53
-_supported_fmt generic
26
+$QEMU_IO -c "open -o l2-cache-entry-size=256 $TEST_IMG" \
54
+_supported_fmt raw
27
+ 2>&1 | _filter_testdir | _filter_imgfmt
55
_supported_proto nbd
28
+$QEMU_IO -c "open -o l2-cache-entry-size=4242 $TEST_IMG" \
56
_supported_os Linux
29
+ 2>&1 | _filter_testdir | _filter_imgfmt
30
+$QEMU_IO -c "open -o l2-cache-entry-size=128k $TEST_IMG" \
31
+ 2>&1 | _filter_testdir | _filter_imgfmt
32
+
33
echo
34
echo '=== Testing valid option combinations ==='
35
echo
36
@@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "open -o l2-cache-size=1M,refcount-cache-size=0.25M $TEST_IMG" \
37
-c 'read -P 42 0 64k' \
38
| _filter_qemu_io
39
40
+# Valid cache entry sizes
41
+$QEMU_IO -c "open -o l2-cache-entry-size=512 $TEST_IMG" \
42
+ 2>&1 | _filter_testdir | _filter_imgfmt
43
+$QEMU_IO -c "open -o l2-cache-entry-size=16k $TEST_IMG" \
44
+ 2>&1 | _filter_testdir | _filter_imgfmt
45
+$QEMU_IO -c "open -o l2-cache-entry-size=64k $TEST_IMG" \
46
+ 2>&1 | _filter_testdir | _filter_imgfmt
47
+
48
+
49
echo
50
echo '=== Testing minimal L2 cache and COW ==='
51
echo
52
diff --git a/tests/qemu-iotests/103.out b/tests/qemu-iotests/103.out
53
index XXXXXXX..XXXXXXX 100644
54
--- a/tests/qemu-iotests/103.out
55
+++ b/tests/qemu-iotests/103.out
56
@@ -XXX,XX +XXX,XX @@ can't open device TEST_DIR/t.IMGFMT: cache-size, l2-cache-size and refcount-cach
57
can't open device TEST_DIR/t.IMGFMT: l2-cache-size may not exceed cache-size
58
can't open device TEST_DIR/t.IMGFMT: refcount-cache-size may not exceed cache-size
59
can't open device TEST_DIR/t.IMGFMT: cache-size, l2-cache-size and refcount-cache-size may not be set the same time
60
+can't open device TEST_DIR/t.IMGFMT: L2 cache entry size must be a power of two between 512 and the cluster size (65536)
61
+can't open device TEST_DIR/t.IMGFMT: L2 cache entry size must be a power of two between 512 and the cluster size (65536)
62
+can't open device TEST_DIR/t.IMGFMT: L2 cache entry size must be a power of two between 512 and the cluster size (65536)
63
64
=== Testing valid option combinations ===
65
57
66
--
58
--
67
2.13.6
59
2.19.1
68
60
69
61
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2
Reviewed-by: Alberto Garcia <berto@igalia.com>
3
---
4
block/vpc.c | 2 ++
5
1 file changed, 2 insertions(+)
2
6
3
This patch updates get_cluster_table() to return L2 slices instead of
7
diff --git a/block/vpc.c b/block/vpc.c
4
full L2 tables.
5
6
The code itself needs almost no changes, it only needs to call
7
offset_to_l2_slice_index() instead of offset_to_l2_index(). This patch
8
also renames all the relevant variables and the documentation.
9
10
Signed-off-by: Alberto Garcia <berto@igalia.com>
11
Reviewed-by: Eric Blake <eblake@redhat.com>
12
Reviewed-by: Max Reitz <mreitz@redhat.com>
13
Message-id: 64cf064c0021ba315d3f3032da0f95db1b615f33.1517840877.git.berto@igalia.com
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
16
block/qcow2-cluster.c | 16 ++++++++--------
17
1 file changed, 8 insertions(+), 8 deletions(-)
18
19
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
20
index XXXXXXX..XXXXXXX 100644
8
index XXXXXXX..XXXXXXX 100644
21
--- a/block/qcow2-cluster.c
9
--- a/block/vpc.c
22
+++ b/block/qcow2-cluster.c
10
+++ b/block/vpc.c
23
@@ -XXX,XX +XXX,XX @@ fail:
11
@@ -XXX,XX +XXX,XX @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,
24
* get_cluster_table
25
*
26
* for a given disk offset, load (and allocate if needed)
27
- * the l2 table.
28
+ * the appropriate slice of its l2 table.
29
*
30
- * the cluster index in the l2 table is given to the caller.
31
+ * the cluster index in the l2 slice is given to the caller.
32
*
33
* Returns 0 on success, -errno in failure case
34
*/
35
static int get_cluster_table(BlockDriverState *bs, uint64_t offset,
36
- uint64_t **new_l2_table,
37
+ uint64_t **new_l2_slice,
38
int *new_l2_index)
39
{
40
BDRVQcow2State *s = bs->opaque;
41
unsigned int l2_index;
42
uint64_t l1_index, l2_offset;
43
- uint64_t *l2_table = NULL;
44
+ uint64_t *l2_slice = NULL;
45
int ret;
46
47
/* seek to the l2 offset in the l1 table */
48
@@ -XXX,XX +XXX,XX @@ static int get_cluster_table(BlockDriverState *bs, uint64_t offset,
49
assert(offset_into_cluster(s, l2_offset) == 0);
50
}
12
}
51
13
52
- /* load the l2 table in memory */
14
qemu_co_mutex_init(&s->lock);
53
- ret = l2_load(bs, offset, l2_offset, &l2_table);
15
+ qemu_opts_del(opts);
54
+ /* load the l2 slice in memory */
55
+ ret = l2_load(bs, offset, l2_offset, &l2_slice);
56
if (ret < 0) {
57
return ret;
58
}
59
60
/* find the cluster offset for the given disk offset */
61
62
- l2_index = offset_to_l2_index(s, offset);
63
+ l2_index = offset_to_l2_slice_index(s, offset);
64
65
- *new_l2_table = l2_table;
66
+ *new_l2_slice = l2_slice;
67
*new_l2_index = l2_index;
68
16
69
return 0;
17
return 0;
18
19
fail:
20
+ qemu_opts_del(opts);
21
qemu_vfree(s->pagetable);
22
#ifdef CACHE
23
g_free(s->pageentry_u8);
70
--
24
--
71
2.13.6
25
2.19.1
72
26
73
27
diff view generated by jsdifflib
1
From: Max Reitz <mreitz@redhat.com>
1
From: Peter Maydell <peter.maydell@linaro.org>
2
2
3
We want to use this function in sd_truncate() later on, so taking a
3
Taking the address of a field in a packed struct is a bad idea, because
4
filename is not exactly ideal.
4
it might not be actually aligned enough for that pointer type (and
5
5
thus cause a crash on dereference on some host architectures). Newer
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
6
versions of clang warn about this. Avoid the bug by not using the
7
Reviewed-by: Eric Blake <eblake@redhat.com>
7
"modify in place" byte swapping functions.
8
9
There are a few places where the in-place swap function is
10
used on something other than a packed struct field; we convert
11
those anyway, for consistency.
12
13
Patch produced with scripts/coccinelle/inplace-byteswaps.cocci.
14
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
17
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9
---
18
---
10
block/sheepdog.c | 29 +++++++++++++++++++++--------
19
block/vhdx.h | 12 ++---
11
1 file changed, 21 insertions(+), 8 deletions(-)
20
block/vhdx-endian.c | 118 ++++++++++++++++++++++----------------------
12
21
block/vhdx-log.c | 4 +-
13
diff --git a/block/sheepdog.c b/block/sheepdog.c
22
block/vhdx.c | 18 +++----
23
4 files changed, 76 insertions(+), 76 deletions(-)
24
25
diff --git a/block/vhdx.h b/block/vhdx.h
14
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
15
--- a/block/sheepdog.c
27
--- a/block/vhdx.h
16
+++ b/block/sheepdog.c
28
+++ b/block/vhdx.h
17
@@ -XXX,XX +XXX,XX @@ static int do_sd_create(BDRVSheepdogState *s, uint32_t *vdi_id, int snapshot,
29
@@ -XXX,XX +XXX,XX @@ int vhdx_log_write_and_flush(BlockDriverState *bs, BDRVVHDXState *s,
18
return 0;
30
19
}
31
static inline void leguid_to_cpus(MSGUID *guid)
20
32
{
21
-static int sd_prealloc(const char *filename, Error **errp)
33
- le32_to_cpus(&guid->data1);
22
+static int sd_prealloc(BlockDriverState *bs, Error **errp)
34
- le16_to_cpus(&guid->data2);
23
{
35
- le16_to_cpus(&guid->data3);
24
BlockBackend *blk = NULL;
36
+ guid->data1 = le32_to_cpu(guid->data1);
25
- BDRVSheepdogState *base = NULL;
37
+ guid->data2 = le16_to_cpu(guid->data2);
26
+ BDRVSheepdogState *base = bs->opaque;
38
+ guid->data3 = le16_to_cpu(guid->data3);
27
unsigned long buf_size;
39
}
28
uint32_t idx, max_idx;
40
29
uint32_t object_size;
41
static inline void cpu_to_leguids(MSGUID *guid)
30
@@ -XXX,XX +XXX,XX @@ static int sd_prealloc(const char *filename, Error **errp)
42
{
31
void *buf = NULL;
43
- cpu_to_le32s(&guid->data1);
32
int ret;
44
- cpu_to_le16s(&guid->data2);
33
45
- cpu_to_le16s(&guid->data3);
34
- blk = blk_new_open(filename, NULL, NULL,
46
+ guid->data1 = cpu_to_le32(guid->data1);
35
- BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL, errp);
47
+ guid->data2 = cpu_to_le16(guid->data2);
36
- if (blk == NULL) {
48
+ guid->data3 = cpu_to_le16(guid->data3);
37
- ret = -EIO;
49
}
38
+ blk = blk_new(BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE | BLK_PERM_RESIZE,
50
39
+ BLK_PERM_ALL);
51
void vhdx_header_le_import(VHDXHeader *h);
40
+
52
diff --git a/block/vhdx-endian.c b/block/vhdx-endian.c
41
+ ret = blk_insert_bs(blk, bs, errp);
53
index XXXXXXX..XXXXXXX 100644
42
+ if (ret < 0) {
54
--- a/block/vhdx-endian.c
43
goto out_with_err_set;
55
+++ b/block/vhdx-endian.c
56
@@ -XXX,XX +XXX,XX @@ void vhdx_header_le_import(VHDXHeader *h)
57
{
58
assert(h != NULL);
59
60
- le32_to_cpus(&h->signature);
61
- le32_to_cpus(&h->checksum);
62
- le64_to_cpus(&h->sequence_number);
63
+ h->signature = le32_to_cpu(h->signature);
64
+ h->checksum = le32_to_cpu(h->checksum);
65
+ h->sequence_number = le64_to_cpu(h->sequence_number);
66
67
leguid_to_cpus(&h->file_write_guid);
68
leguid_to_cpus(&h->data_write_guid);
69
leguid_to_cpus(&h->log_guid);
70
71
- le16_to_cpus(&h->log_version);
72
- le16_to_cpus(&h->version);
73
- le32_to_cpus(&h->log_length);
74
- le64_to_cpus(&h->log_offset);
75
+ h->log_version = le16_to_cpu(h->log_version);
76
+ h->version = le16_to_cpu(h->version);
77
+ h->log_length = le32_to_cpu(h->log_length);
78
+ h->log_offset = le64_to_cpu(h->log_offset);
79
}
80
81
void vhdx_header_le_export(VHDXHeader *orig_h, VHDXHeader *new_h)
82
@@ -XXX,XX +XXX,XX @@ void vhdx_log_desc_le_import(VHDXLogDescriptor *d)
83
{
84
assert(d != NULL);
85
86
- le32_to_cpus(&d->signature);
87
- le64_to_cpus(&d->file_offset);
88
- le64_to_cpus(&d->sequence_number);
89
+ d->signature = le32_to_cpu(d->signature);
90
+ d->file_offset = le64_to_cpu(d->file_offset);
91
+ d->sequence_number = le64_to_cpu(d->sequence_number);
92
}
93
94
void vhdx_log_desc_le_export(VHDXLogDescriptor *d)
95
{
96
assert(d != NULL);
97
98
- cpu_to_le32s(&d->signature);
99
- cpu_to_le32s(&d->trailing_bytes);
100
- cpu_to_le64s(&d->leading_bytes);
101
- cpu_to_le64s(&d->file_offset);
102
- cpu_to_le64s(&d->sequence_number);
103
+ d->signature = cpu_to_le32(d->signature);
104
+ d->trailing_bytes = cpu_to_le32(d->trailing_bytes);
105
+ d->leading_bytes = cpu_to_le64(d->leading_bytes);
106
+ d->file_offset = cpu_to_le64(d->file_offset);
107
+ d->sequence_number = cpu_to_le64(d->sequence_number);
108
}
109
110
void vhdx_log_data_le_import(VHDXLogDataSector *d)
111
{
112
assert(d != NULL);
113
114
- le32_to_cpus(&d->data_signature);
115
- le32_to_cpus(&d->sequence_high);
116
- le32_to_cpus(&d->sequence_low);
117
+ d->data_signature = le32_to_cpu(d->data_signature);
118
+ d->sequence_high = le32_to_cpu(d->sequence_high);
119
+ d->sequence_low = le32_to_cpu(d->sequence_low);
120
}
121
122
void vhdx_log_data_le_export(VHDXLogDataSector *d)
123
{
124
assert(d != NULL);
125
126
- cpu_to_le32s(&d->data_signature);
127
- cpu_to_le32s(&d->sequence_high);
128
- cpu_to_le32s(&d->sequence_low);
129
+ d->data_signature = cpu_to_le32(d->data_signature);
130
+ d->sequence_high = cpu_to_le32(d->sequence_high);
131
+ d->sequence_low = cpu_to_le32(d->sequence_low);
132
}
133
134
void vhdx_log_entry_hdr_le_import(VHDXLogEntryHeader *hdr)
135
{
136
assert(hdr != NULL);
137
138
- le32_to_cpus(&hdr->signature);
139
- le32_to_cpus(&hdr->checksum);
140
- le32_to_cpus(&hdr->entry_length);
141
- le32_to_cpus(&hdr->tail);
142
- le64_to_cpus(&hdr->sequence_number);
143
- le32_to_cpus(&hdr->descriptor_count);
144
+ hdr->signature = le32_to_cpu(hdr->signature);
145
+ hdr->checksum = le32_to_cpu(hdr->checksum);
146
+ hdr->entry_length = le32_to_cpu(hdr->entry_length);
147
+ hdr->tail = le32_to_cpu(hdr->tail);
148
+ hdr->sequence_number = le64_to_cpu(hdr->sequence_number);
149
+ hdr->descriptor_count = le32_to_cpu(hdr->descriptor_count);
150
leguid_to_cpus(&hdr->log_guid);
151
- le64_to_cpus(&hdr->flushed_file_offset);
152
- le64_to_cpus(&hdr->last_file_offset);
153
+ hdr->flushed_file_offset = le64_to_cpu(hdr->flushed_file_offset);
154
+ hdr->last_file_offset = le64_to_cpu(hdr->last_file_offset);
155
}
156
157
void vhdx_log_entry_hdr_le_export(VHDXLogEntryHeader *hdr)
158
{
159
assert(hdr != NULL);
160
161
- cpu_to_le32s(&hdr->signature);
162
- cpu_to_le32s(&hdr->checksum);
163
- cpu_to_le32s(&hdr->entry_length);
164
- cpu_to_le32s(&hdr->tail);
165
- cpu_to_le64s(&hdr->sequence_number);
166
- cpu_to_le32s(&hdr->descriptor_count);
167
+ hdr->signature = cpu_to_le32(hdr->signature);
168
+ hdr->checksum = cpu_to_le32(hdr->checksum);
169
+ hdr->entry_length = cpu_to_le32(hdr->entry_length);
170
+ hdr->tail = cpu_to_le32(hdr->tail);
171
+ hdr->sequence_number = cpu_to_le64(hdr->sequence_number);
172
+ hdr->descriptor_count = cpu_to_le32(hdr->descriptor_count);
173
cpu_to_leguids(&hdr->log_guid);
174
- cpu_to_le64s(&hdr->flushed_file_offset);
175
- cpu_to_le64s(&hdr->last_file_offset);
176
+ hdr->flushed_file_offset = cpu_to_le64(hdr->flushed_file_offset);
177
+ hdr->last_file_offset = cpu_to_le64(hdr->last_file_offset);
178
}
179
180
181
@@ -XXX,XX +XXX,XX @@ void vhdx_region_header_le_import(VHDXRegionTableHeader *hdr)
182
{
183
assert(hdr != NULL);
184
185
- le32_to_cpus(&hdr->signature);
186
- le32_to_cpus(&hdr->checksum);
187
- le32_to_cpus(&hdr->entry_count);
188
+ hdr->signature = le32_to_cpu(hdr->signature);
189
+ hdr->checksum = le32_to_cpu(hdr->checksum);
190
+ hdr->entry_count = le32_to_cpu(hdr->entry_count);
191
}
192
193
void vhdx_region_header_le_export(VHDXRegionTableHeader *hdr)
194
{
195
assert(hdr != NULL);
196
197
- cpu_to_le32s(&hdr->signature);
198
- cpu_to_le32s(&hdr->checksum);
199
- cpu_to_le32s(&hdr->entry_count);
200
+ hdr->signature = cpu_to_le32(hdr->signature);
201
+ hdr->checksum = cpu_to_le32(hdr->checksum);
202
+ hdr->entry_count = cpu_to_le32(hdr->entry_count);
203
}
204
205
void vhdx_region_entry_le_import(VHDXRegionTableEntry *e)
206
@@ -XXX,XX +XXX,XX @@ void vhdx_region_entry_le_import(VHDXRegionTableEntry *e)
207
assert(e != NULL);
208
209
leguid_to_cpus(&e->guid);
210
- le64_to_cpus(&e->file_offset);
211
- le32_to_cpus(&e->length);
212
- le32_to_cpus(&e->data_bits);
213
+ e->file_offset = le64_to_cpu(e->file_offset);
214
+ e->length = le32_to_cpu(e->length);
215
+ e->data_bits = le32_to_cpu(e->data_bits);
216
}
217
218
void vhdx_region_entry_le_export(VHDXRegionTableEntry *e)
219
@@ -XXX,XX +XXX,XX @@ void vhdx_region_entry_le_export(VHDXRegionTableEntry *e)
220
assert(e != NULL);
221
222
cpu_to_leguids(&e->guid);
223
- cpu_to_le64s(&e->file_offset);
224
- cpu_to_le32s(&e->length);
225
- cpu_to_le32s(&e->data_bits);
226
+ e->file_offset = cpu_to_le64(e->file_offset);
227
+ e->length = cpu_to_le32(e->length);
228
+ e->data_bits = cpu_to_le32(e->data_bits);
229
}
230
231
232
@@ -XXX,XX +XXX,XX @@ void vhdx_metadata_header_le_import(VHDXMetadataTableHeader *hdr)
233
{
234
assert(hdr != NULL);
235
236
- le64_to_cpus(&hdr->signature);
237
- le16_to_cpus(&hdr->entry_count);
238
+ hdr->signature = le64_to_cpu(hdr->signature);
239
+ hdr->entry_count = le16_to_cpu(hdr->entry_count);
240
}
241
242
void vhdx_metadata_header_le_export(VHDXMetadataTableHeader *hdr)
243
{
244
assert(hdr != NULL);
245
246
- cpu_to_le64s(&hdr->signature);
247
- cpu_to_le16s(&hdr->entry_count);
248
+ hdr->signature = cpu_to_le64(hdr->signature);
249
+ hdr->entry_count = cpu_to_le16(hdr->entry_count);
250
}
251
252
void vhdx_metadata_entry_le_import(VHDXMetadataTableEntry *e)
253
@@ -XXX,XX +XXX,XX @@ void vhdx_metadata_entry_le_import(VHDXMetadataTableEntry *e)
254
assert(e != NULL);
255
256
leguid_to_cpus(&e->item_id);
257
- le32_to_cpus(&e->offset);
258
- le32_to_cpus(&e->length);
259
- le32_to_cpus(&e->data_bits);
260
+ e->offset = le32_to_cpu(e->offset);
261
+ e->length = le32_to_cpu(e->length);
262
+ e->data_bits = le32_to_cpu(e->data_bits);
263
}
264
void vhdx_metadata_entry_le_export(VHDXMetadataTableEntry *e)
265
{
266
assert(e != NULL);
267
268
cpu_to_leguids(&e->item_id);
269
- cpu_to_le32s(&e->offset);
270
- cpu_to_le32s(&e->length);
271
- cpu_to_le32s(&e->data_bits);
272
+ e->offset = cpu_to_le32(e->offset);
273
+ e->length = cpu_to_le32(e->length);
274
+ e->data_bits = cpu_to_le32(e->data_bits);
275
}
276
diff --git a/block/vhdx-log.c b/block/vhdx-log.c
277
index XXXXXXX..XXXXXXX 100644
278
--- a/block/vhdx-log.c
279
+++ b/block/vhdx-log.c
280
@@ -XXX,XX +XXX,XX @@ static void vhdx_log_raw_to_le_sector(VHDXLogDescriptor *desc,
281
/* 8 + 4084 + 4 = 4096, 1 log sector */
282
memcpy(&desc->leading_bytes, data, 8);
283
data += 8;
284
- cpu_to_le64s(&desc->leading_bytes);
285
+ desc->leading_bytes = cpu_to_le64(desc->leading_bytes);
286
memcpy(sector->data, data, 4084);
287
data += 4084;
288
memcpy(&desc->trailing_bytes, data, 4);
289
- cpu_to_le32s(&desc->trailing_bytes);
290
+ desc->trailing_bytes = cpu_to_le32(desc->trailing_bytes);
291
data += 4;
292
293
sector->sequence_high = (uint32_t) (seq >> 32);
294
diff --git a/block/vhdx.c b/block/vhdx.c
295
index XXXXXXX..XXXXXXX 100644
296
--- a/block/vhdx.c
297
+++ b/block/vhdx.c
298
@@ -XXX,XX +XXX,XX @@ uint32_t vhdx_update_checksum(uint8_t *buf, size_t size, int crc_offset)
299
300
memset(buf + crc_offset, 0, sizeof(crc));
301
crc = crc32c(0xffffffff, buf, size);
302
- cpu_to_le32s(&crc);
303
+ crc = cpu_to_le32(crc);
304
memcpy(buf + crc_offset, &crc, sizeof(crc));
305
306
return crc;
307
@@ -XXX,XX +XXX,XX @@ static int vhdx_parse_metadata(BlockDriverState *bs, BDRVVHDXState *s)
308
goto exit;
44
}
309
}
45
310
46
@@ -XXX,XX +XXX,XX @@ static int sd_prealloc(const char *filename, Error **errp)
311
- le32_to_cpus(&s->params.block_size);
47
goto out;
312
- le32_to_cpus(&s->params.data_bits);
313
+ s->params.block_size = le32_to_cpu(s->params.block_size);
314
+ s->params.data_bits = le32_to_cpu(s->params.data_bits);
315
316
317
/* We now have the file parameters, so we can tell if this is a
318
@@ -XXX,XX +XXX,XX @@ static int vhdx_parse_metadata(BlockDriverState *bs, BDRVVHDXState *s)
319
goto exit;
48
}
320
}
49
321
50
- base = blk_bs(blk)->opaque;
322
- le64_to_cpus(&s->virtual_disk_size);
51
object_size = (UINT32_C(1) << base->inode.block_size_shift);
323
- le32_to_cpus(&s->logical_sector_size);
52
buf_size = MIN(object_size, SD_DATA_OBJ_SIZE);
324
- le32_to_cpus(&s->physical_sector_size);
53
buf = g_malloc0(buf_size);
325
+ s->virtual_disk_size = le64_to_cpu(s->virtual_disk_size);
54
@@ -XXX,XX +XXX,XX @@ static int sd_create(const char *filename, QemuOpts *opts,
326
+ s->logical_sector_size = le32_to_cpu(s->logical_sector_size);
327
+ s->physical_sector_size = le32_to_cpu(s->physical_sector_size);
328
329
if (s->params.block_size < VHDX_BLOCK_SIZE_MIN ||
330
s->params.block_size > VHDX_BLOCK_SIZE_MAX) {
331
@@ -XXX,XX +XXX,XX @@ static int vhdx_open(BlockDriverState *bs, QDict *options, int flags,
332
/* endian convert, and verify populated BAT field file offsets against
333
* region table and log entries */
334
for (i = 0; i < s->bat_entries; i++) {
335
- le64_to_cpus(&s->bat[i]);
336
+ s->bat[i] = le64_to_cpu(s->bat[i]);
337
if (payblocks--) {
338
/* payload bat entries */
339
if ((s->bat[i] & VHDX_BAT_STATE_BIT_MASK) ==
340
@@ -XXX,XX +XXX,XX @@ static int vhdx_create_new_metadata(BlockBackend *blk,
341
mt_file_params->block_size = cpu_to_le32(block_size);
342
if (type == VHDX_TYPE_FIXED) {
343
mt_file_params->data_bits |= VHDX_PARAMS_LEAVE_BLOCKS_ALLOCED;
344
- cpu_to_le32s(&mt_file_params->data_bits);
345
+ mt_file_params->data_bits = cpu_to_le32(mt_file_params->data_bits);
55
}
346
}
56
347
57
if (prealloc) {
348
vhdx_guid_generate(&mt_page83->page_83_data);
58
- ret = sd_prealloc(filename, errp);
349
@@ -XXX,XX +XXX,XX @@ static int vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s,
59
+ BlockDriverState *bs;
350
sinfo.file_offset = ROUND_UP(sinfo.file_offset, MiB);
60
+ QDict *opts;
351
vhdx_update_bat_table_entry(blk_bs(blk), s, &sinfo, &unused, &unused,
61
+
352
block_state);
62
+ opts = qdict_new();
353
- cpu_to_le64s(&s->bat[sinfo.bat_idx]);
63
+ qdict_put_str(opts, "driver", "sheepdog");
354
+ s->bat[sinfo.bat_idx] = cpu_to_le64(s->bat[sinfo.bat_idx]);
64
+ bs = bdrv_open(filename, NULL, opts, BDRV_O_PROTOCOL | BDRV_O_RDWR,
355
sector_num += s->sectors_per_block;
65
+ errp);
356
}
66
+ if (!bs) {
357
ret = blk_pwrite(blk, file_offset, s->bat, length, 0);
67
+ goto out;
68
+ }
69
+
70
+ ret = sd_prealloc(bs, errp);
71
+
72
+ bdrv_unref(bs);
73
}
74
out:
75
g_free(backing_file);
76
--
358
--
77
2.13.6
359
2.19.1
78
360
79
361
diff view generated by jsdifflib
1
From: Fam Zheng <famz@redhat.com>
1
From: Peter Maydell <peter.maydell@linaro.org>
2
2
3
Split options out of the "@table @var" section and create a "@table
3
Taking the address of a field in a packed struct is a bad idea, because
4
@option", then use whitespaces and blank lines consistently.
4
it might not be actually aligned enough for that pointer type (and
5
thus cause a crash on dereference on some host architectures). Newer
6
versions of clang warn about this. Avoid the bug by not using the
7
"modify in place" byte swapping functions.
5
8
6
Suggested-by: Kevin Wolf <kwolf@redhat.com>
9
There are a few places where the in-place swap function is
7
Signed-off-by: Fam Zheng <famz@redhat.com>
10
used on something other than a packed struct field; we convert
11
those anyway, for consistency.
12
13
Patch produced with scripts/coccinelle/inplace-byteswaps.cocci.
14
15
There are other places where we take the address of a packed member
16
in this file for other purposes than passing it to a byteswap
17
function (all the calls to qemu_uuid_*()); we leave those for now.
18
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
20
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Reviewed-by: Kashyap Chamarthy <kchamart@redhat.com>
10
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
21
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11
---
22
---
12
qemu-img.texi | 66 +++++++++++++++++++++++++++++++++++------------------------
23
block/vdi.c | 64 ++++++++++++++++++++++++++---------------------------
13
1 file changed, 39 insertions(+), 27 deletions(-)
24
1 file changed, 32 insertions(+), 32 deletions(-)
14
25
15
diff --git a/qemu-img.texi b/qemu-img.texi
26
diff --git a/block/vdi.c b/block/vdi.c
16
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
17
--- a/qemu-img.texi
28
--- a/block/vdi.c
18
+++ b/qemu-img.texi
29
+++ b/block/vdi.c
19
@@ -XXX,XX +XXX,XX @@ The following commands are supported:
30
@@ -XXX,XX +XXX,XX @@ typedef struct {
20
31
21
Command parameters:
32
static void vdi_header_to_cpu(VdiHeader *header)
22
@table @var
33
{
23
-@item filename
34
- le32_to_cpus(&header->signature);
24
- is a disk image filename
35
- le32_to_cpus(&header->version);
25
-
36
- le32_to_cpus(&header->header_size);
26
-@item --object @var{objectdef}
37
- le32_to_cpus(&header->image_type);
27
-
38
- le32_to_cpus(&header->image_flags);
28
-is a QEMU user creatable object definition. See the @code{qemu(1)} manual
39
- le32_to_cpus(&header->offset_bmap);
29
-page for a description of the object properties. The most common object
40
- le32_to_cpus(&header->offset_data);
30
-type is a @code{secret}, which is used to supply passwords and/or encryption
41
- le32_to_cpus(&header->cylinders);
31
-keys.
42
- le32_to_cpus(&header->heads);
32
-
43
- le32_to_cpus(&header->sectors);
33
-@item --image-opts
44
- le32_to_cpus(&header->sector_size);
34
-
45
- le64_to_cpus(&header->disk_size);
35
-Indicates that the source @var{filename} parameter is to be interpreted as a
46
- le32_to_cpus(&header->block_size);
36
-full option string, not a plain filename. This parameter is mutually
47
- le32_to_cpus(&header->block_extra);
37
-exclusive with the @var{-f} parameter.
48
- le32_to_cpus(&header->blocks_in_image);
38
-
49
- le32_to_cpus(&header->blocks_allocated);
39
-@item --target-image-opts
50
+ header->signature = le32_to_cpu(header->signature);
40
51
+ header->version = le32_to_cpu(header->version);
41
-Indicates that the @var{output_filename} parameter(s) are to be interpreted as
52
+ header->header_size = le32_to_cpu(header->header_size);
42
-a full option string, not a plain filename. This parameter is mutually
53
+ header->image_type = le32_to_cpu(header->image_type);
43
-exclusive with the @var{-O} parameters. It is currently required to also use
54
+ header->image_flags = le32_to_cpu(header->image_flags);
44
-the @var{-n} parameter to skip image creation. This restriction may be relaxed
55
+ header->offset_bmap = le32_to_cpu(header->offset_bmap);
45
-in a future release.
56
+ header->offset_data = le32_to_cpu(header->offset_data);
46
+@item filename
57
+ header->cylinders = le32_to_cpu(header->cylinders);
47
+is a disk image filename
58
+ header->heads = le32_to_cpu(header->heads);
48
59
+ header->sectors = le32_to_cpu(header->sectors);
49
@item fmt
60
+ header->sector_size = le32_to_cpu(header->sector_size);
50
is the disk image format. It is guessed automatically in most cases. See below
61
+ header->disk_size = le64_to_cpu(header->disk_size);
51
for a description of the supported disk formats.
62
+ header->block_size = le32_to_cpu(header->block_size);
52
63
+ header->block_extra = le32_to_cpu(header->block_extra);
53
-@item --backing-chain
64
+ header->blocks_in_image = le32_to_cpu(header->blocks_in_image);
54
-will enumerate information about backing files in a disk image chain. Refer
65
+ header->blocks_allocated = le32_to_cpu(header->blocks_allocated);
55
-below for further description.
66
qemu_uuid_bswap(&header->uuid_image);
56
-
67
qemu_uuid_bswap(&header->uuid_last_snap);
57
@item size
68
qemu_uuid_bswap(&header->uuid_link);
58
is the disk image size in bytes. Optional suffixes @code{k} or @code{K}
69
@@ -XXX,XX +XXX,XX @@ static void vdi_header_to_cpu(VdiHeader *header)
59
(kilobyte, 1024) @code{M} (megabyte, 1024k) and @code{G} (gigabyte, 1024M)
70
60
@@ -XXX,XX +XXX,XX @@ and T (terabyte, 1024G) are supported. @code{b} is ignored.
71
static void vdi_header_to_le(VdiHeader *header)
61
is the destination disk image filename
72
{
62
73
- cpu_to_le32s(&header->signature);
63
@item output_fmt
74
- cpu_to_le32s(&header->version);
64
- is the destination format
75
- cpu_to_le32s(&header->header_size);
65
+is the destination format
76
- cpu_to_le32s(&header->image_type);
66
+
77
- cpu_to_le32s(&header->image_flags);
67
@item options
78
- cpu_to_le32s(&header->offset_bmap);
68
is a comma separated list of format specific options in a
79
- cpu_to_le32s(&header->offset_data);
69
name=value format. Use @code{-o ?} for an overview of the options supported
80
- cpu_to_le32s(&header->cylinders);
70
by the used format or see the format descriptions below for details.
81
- cpu_to_le32s(&header->heads);
71
+
82
- cpu_to_le32s(&header->sectors);
72
@item snapshot_param
83
- cpu_to_le32s(&header->sector_size);
73
is param used for internal snapshot, format is
84
- cpu_to_le64s(&header->disk_size);
74
'snapshot.id=[ID],snapshot.name=[NAME]' or '[ID_OR_NAME]'
85
- cpu_to_le32s(&header->block_size);
75
+
86
- cpu_to_le32s(&header->block_extra);
76
@item snapshot_id_or_name
87
- cpu_to_le32s(&header->blocks_in_image);
77
is deprecated, use snapshot_param instead
88
- cpu_to_le32s(&header->blocks_allocated);
78
89
+ header->signature = cpu_to_le32(header->signature);
79
+@end table
90
+ header->version = cpu_to_le32(header->version);
80
+
91
+ header->header_size = cpu_to_le32(header->header_size);
81
+@table @option
92
+ header->image_type = cpu_to_le32(header->image_type);
82
+
93
+ header->image_flags = cpu_to_le32(header->image_flags);
83
+@item --object @var{objectdef}
94
+ header->offset_bmap = cpu_to_le32(header->offset_bmap);
84
+is a QEMU user creatable object definition. See the @code{qemu(1)} manual
95
+ header->offset_data = cpu_to_le32(header->offset_data);
85
+page for a description of the object properties. The most common object
96
+ header->cylinders = cpu_to_le32(header->cylinders);
86
+type is a @code{secret}, which is used to supply passwords and/or encryption
97
+ header->heads = cpu_to_le32(header->heads);
87
+keys.
98
+ header->sectors = cpu_to_le32(header->sectors);
88
+
99
+ header->sector_size = cpu_to_le32(header->sector_size);
89
+@item --image-opts
100
+ header->disk_size = cpu_to_le64(header->disk_size);
90
+Indicates that the source @var{filename} parameter is to be interpreted as a
101
+ header->block_size = cpu_to_le32(header->block_size);
91
+full option string, not a plain filename. This parameter is mutually
102
+ header->block_extra = cpu_to_le32(header->block_extra);
92
+exclusive with the @var{-f} parameter.
103
+ header->blocks_in_image = cpu_to_le32(header->blocks_in_image);
93
+
104
+ header->blocks_allocated = cpu_to_le32(header->blocks_allocated);
94
+@item --target-image-opts
105
qemu_uuid_bswap(&header->uuid_image);
95
+Indicates that the @var{output_filename} parameter(s) are to be interpreted as
106
qemu_uuid_bswap(&header->uuid_last_snap);
96
+a full option string, not a plain filename. This parameter is mutually
107
qemu_uuid_bswap(&header->uuid_link);
97
+exclusive with the @var{-O} parameters. It is currently required to also use
98
+the @var{-n} parameter to skip image creation. This restriction may be relaxed
99
+in a future release.
100
+
101
+@item --backing-chain
102
+will enumerate information about backing files in a disk image chain. Refer
103
+below for further description.
104
+
105
@item -c
106
indicates that target image must be compressed (qcow format only)
107
+
108
@item -h
109
with or without a command shows help and lists the supported formats
110
+
111
@item -p
112
display progress bar (compare, convert and rebase commands only).
113
If the @var{-p} option is not used for a command that supports it, the
114
progress is reported when the process receives a @code{SIGUSR1} or
115
@code{SIGINFO} signal.
116
+
117
@item -q
118
Quiet mode - do not print any output (except errors). There's no progress bar
119
in case both @var{-q} and @var{-p} options are used.
120
+
121
@item -S @var{size}
122
indicates the consecutive number of bytes that must contain only zeros
123
for qemu-img to create a sparse image during conversion. This value is rounded
124
down to the nearest 512 bytes. You may use the common size suffixes like
125
@code{k} for kilobytes.
126
+
127
@item -t @var{cache}
128
specifies the cache mode that should be used with the (destination) file. See
129
the documentation of the emulator's @code{-drive cache=...} option for allowed
130
values.
131
+
132
@item -T @var{src_cache}
133
specifies the cache mode that should be used with the source file(s). See
134
the documentation of the emulator's @code{-drive cache=...} option for allowed
135
values.
136
+
137
@end table
138
139
Parameters to snapshot subcommand:
140
--
108
--
141
2.13.6
109
2.19.1
142
110
143
111
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Alberto Garcia <berto@igalia.com>
2
2
3
This function was only using the BlockDriverState parameter to pass it
3
This is a static function with only one caller, so there's no need to
4
to qcow2_cache_get_table_idx(). This is no longer necessary so this
4
keep it. Inlining the code in quorum_compare() makes it much simpler.
5
parameter can be removed.
6
5
7
Signed-off-by: Alberto Garcia <berto@igalia.com>
6
Signed-off-by: Alberto Garcia <berto@igalia.com>
8
Reviewed-by: Eric Blake <eblake@redhat.com>
7
Reported-by: Markus Armbruster <armbru@redhat.com>
9
Reviewed-by: Max Reitz <mreitz@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10
Message-id: 6f98155489054a457563da77cdad1a66ebb3e896.1517840876.git.berto@igalia.com
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
12
---
9
---
13
block/qcow2.h | 2 +-
10
block/quorum.c | 24 +++++-------------------
14
block/qcow2-cache.c | 2 +-
11
1 file changed, 5 insertions(+), 19 deletions(-)
15
block/qcow2-cluster.c | 28 ++++++++++++++--------------
16
block/qcow2-refcount.c | 30 +++++++++++++++---------------
17
4 files changed, 31 insertions(+), 31 deletions(-)
18
12
19
diff --git a/block/qcow2.h b/block/qcow2.h
13
diff --git a/block/quorum.c b/block/quorum.c
20
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
21
--- a/block/qcow2.h
15
--- a/block/quorum.c
22
+++ b/block/qcow2.h
16
+++ b/block/quorum.c
23
@@ -XXX,XX +XXX,XX @@ int qcow2_cache_get(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset,
17
@@ -XXX,XX +XXX,XX @@ static bool quorum_iovec_compare(QEMUIOVector *a, QEMUIOVector *b)
24
void **table);
18
return true;
25
int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset,
26
void **table);
27
-void qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, void **table);
28
+void qcow2_cache_put(Qcow2Cache *c, void **table);
29
void *qcow2_cache_is_table_offset(BlockDriverState *bs, Qcow2Cache *c,
30
uint64_t offset);
31
void qcow2_cache_discard(BlockDriverState *bs, Qcow2Cache *c, void *table);
32
diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/block/qcow2-cache.c
35
+++ b/block/qcow2-cache.c
36
@@ -XXX,XX +XXX,XX @@ int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset,
37
return qcow2_cache_do_get(bs, c, offset, table, false);
38
}
19
}
39
20
40
-void qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, void **table)
21
-static void GCC_FMT_ATTR(2, 3) quorum_err(QuorumAIOCB *acb,
41
+void qcow2_cache_put(Qcow2Cache *c, void **table)
22
- const char *fmt, ...)
23
-{
24
- va_list ap;
25
-
26
- va_start(ap, fmt);
27
- fprintf(stderr, "quorum: offset=%" PRIu64 " bytes=%" PRIu64 " ",
28
- acb->offset, acb->bytes);
29
- vfprintf(stderr, fmt, ap);
30
- fprintf(stderr, "\n");
31
- va_end(ap);
32
- exit(1);
33
-}
34
-
35
-static bool quorum_compare(QuorumAIOCB *acb,
36
- QEMUIOVector *a,
37
- QEMUIOVector *b)
38
+static bool quorum_compare(QuorumAIOCB *acb, QEMUIOVector *a, QEMUIOVector *b)
42
{
39
{
43
int i = qcow2_cache_get_table_idx(c, *table);
40
BDRVQuorumState *s = acb->bs->opaque;
44
41
ssize_t offset;
45
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
42
@@ -XXX,XX +XXX,XX @@ static bool quorum_compare(QuorumAIOCB *acb,
46
index XXXXXXX..XXXXXXX 100644
43
if (s->is_blkverify) {
47
--- a/block/qcow2-cluster.c
44
offset = qemu_iovec_compare(a, b);
48
+++ b/block/qcow2-cluster.c
45
if (offset != -1) {
49
@@ -XXX,XX +XXX,XX @@ static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t **table)
46
- quorum_err(acb, "contents mismatch at offset %" PRIu64,
50
47
- acb->offset + offset);
51
memcpy(l2_table, old_table, s->cluster_size);
48
+ fprintf(stderr, "quorum: offset=%" PRIu64 " bytes=%" PRIu64
52
49
+ " contents mismatch at offset %" PRIu64 "\n",
53
- qcow2_cache_put(bs, s->l2_table_cache, (void **) &old_table);
50
+ acb->offset, acb->bytes, acb->offset + offset);
54
+ qcow2_cache_put(s->l2_table_cache, (void **) &old_table);
51
+ exit(1);
55
}
56
57
/* write the l2 table to the file */
58
@@ -XXX,XX +XXX,XX @@ static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t **table)
59
fail:
60
trace_qcow2_l2_allocate_done(bs, l1_index, ret);
61
if (l2_table != NULL) {
62
- qcow2_cache_put(bs, s->l2_table_cache, (void**) table);
63
+ qcow2_cache_put(s->l2_table_cache, (void **) table);
64
}
65
s->l1_table[l1_index] = old_l2_offset;
66
if (l2_offset > 0) {
67
@@ -XXX,XX +XXX,XX @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
68
abort();
69
}
70
71
- qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
72
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
73
74
bytes_available = (int64_t)c * s->cluster_size;
75
76
@@ -XXX,XX +XXX,XX @@ out:
77
return type;
78
79
fail:
80
- qcow2_cache_put(bs, s->l2_table_cache, (void **)&l2_table);
81
+ qcow2_cache_put(s->l2_table_cache, (void **)&l2_table);
82
return ret;
83
}
84
85
@@ -XXX,XX +XXX,XX @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
86
* allocated. */
87
cluster_offset = be64_to_cpu(l2_table[l2_index]);
88
if (cluster_offset & L2E_OFFSET_MASK) {
89
- qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
90
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
91
return 0;
92
}
93
94
cluster_offset = qcow2_alloc_bytes(bs, compressed_size);
95
if (cluster_offset < 0) {
96
- qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
97
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
98
return 0;
99
}
100
101
@@ -XXX,XX +XXX,XX @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
102
BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE_COMPRESSED);
103
qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
104
l2_table[l2_index] = cpu_to_be64(cluster_offset);
105
- qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table);
106
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
107
108
return cluster_offset;
109
}
110
@@ -XXX,XX +XXX,XX @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m)
111
}
112
113
114
- qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table);
115
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
116
117
/*
118
* If this was a COW, we need to decrease the refcount of the old cluster.
119
@@ -XXX,XX +XXX,XX @@ static int handle_copied(BlockDriverState *bs, uint64_t guest_offset,
120
121
/* Cleanup */
122
out:
123
- qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table);
124
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
125
126
/* Only return a host offset if we actually made progress. Otherwise we
127
* would make requirements for handle_alloc() that it can't fulfill */
128
@@ -XXX,XX +XXX,XX @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset,
129
keep_old_clusters = true;
130
}
131
132
- qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table);
133
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
134
135
if (!alloc_cluster_offset) {
136
/* Allocate, if necessary at a given offset in the image file */
137
@@ -XXX,XX +XXX,XX @@ static int discard_single_l2(BlockDriverState *bs, uint64_t offset,
138
qcow2_free_any_clusters(bs, old_l2_entry, 1, type);
139
}
140
141
- qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table);
142
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
143
144
return nb_clusters;
145
}
146
@@ -XXX,XX +XXX,XX @@ static int zero_single_l2(BlockDriverState *bs, uint64_t offset,
147
}
52
}
148
}
53
return true;
149
150
- qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table);
151
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
152
153
return nb_clusters;
154
}
155
@@ -XXX,XX +XXX,XX @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table,
156
qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
157
qcow2_cache_depends_on_flush(s->l2_table_cache);
158
}
159
- qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table);
160
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
161
} else {
162
if (l2_dirty) {
163
ret = qcow2_pre_write_overlap_check(bs,
164
@@ -XXX,XX +XXX,XX @@ fail:
165
if (!is_active_l1) {
166
qemu_vfree(l2_table);
167
} else {
168
- qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table);
169
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
170
}
171
}
172
return ret;
173
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
174
index XXXXXXX..XXXXXXX 100644
175
--- a/block/qcow2-refcount.c
176
+++ b/block/qcow2-refcount.c
177
@@ -XXX,XX +XXX,XX @@ int qcow2_get_refcount(BlockDriverState *bs, int64_t cluster_index,
178
block_index = cluster_index & (s->refcount_block_size - 1);
179
*refcount = s->get_refcount(refcount_block, block_index);
180
181
- qcow2_cache_put(bs, s->refcount_block_cache, &refcount_block);
182
+ qcow2_cache_put(s->refcount_block_cache, &refcount_block);
183
184
return 0;
185
}
186
@@ -XXX,XX +XXX,XX @@ static int alloc_refcount_block(BlockDriverState *bs,
187
return -EAGAIN;
188
}
189
190
- qcow2_cache_put(bs, s->refcount_block_cache, refcount_block);
191
+ qcow2_cache_put(s->refcount_block_cache, refcount_block);
192
193
/*
194
* If we come here, we need to grow the refcount table. Again, a new
195
@@ -XXX,XX +XXX,XX @@ static int alloc_refcount_block(BlockDriverState *bs,
196
197
fail:
198
if (*refcount_block != NULL) {
199
- qcow2_cache_put(bs, s->refcount_block_cache, refcount_block);
200
+ qcow2_cache_put(s->refcount_block_cache, refcount_block);
201
}
202
return ret;
203
}
204
@@ -XXX,XX +XXX,XX @@ int64_t qcow2_refcount_area(BlockDriverState *bs, uint64_t start_offset,
205
refblock_data);
206
}
207
208
- qcow2_cache_put(bs, s->refcount_block_cache, &refblock_data);
209
+ qcow2_cache_put(s->refcount_block_cache, &refblock_data);
210
}
211
212
assert(block_offset == table_offset);
213
@@ -XXX,XX +XXX,XX @@ static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
214
/* Load the refcount block and allocate it if needed */
215
if (table_index != old_table_index) {
216
if (refcount_block) {
217
- qcow2_cache_put(bs, s->refcount_block_cache, &refcount_block);
218
+ qcow2_cache_put(s->refcount_block_cache, &refcount_block);
219
}
220
ret = alloc_refcount_block(bs, cluster_index, &refcount_block);
221
if (ret < 0) {
222
@@ -XXX,XX +XXX,XX @@ static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
223
table = qcow2_cache_is_table_offset(bs, s->refcount_block_cache,
224
offset);
225
if (table != NULL) {
226
- qcow2_cache_put(bs, s->refcount_block_cache, &refcount_block);
227
+ qcow2_cache_put(s->refcount_block_cache, &refcount_block);
228
qcow2_cache_discard(bs, s->refcount_block_cache, table);
229
}
230
231
@@ -XXX,XX +XXX,XX @@ fail:
232
233
/* Write last changed block to disk */
234
if (refcount_block) {
235
- qcow2_cache_put(bs, s->refcount_block_cache, &refcount_block);
236
+ qcow2_cache_put(s->refcount_block_cache, &refcount_block);
237
}
238
239
/*
240
@@ -XXX,XX +XXX,XX @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
241
}
242
}
243
244
- qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table);
245
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
246
247
if (addend != 0) {
248
ret = qcow2_update_cluster_refcount(bs, l2_offset >>
249
@@ -XXX,XX +XXX,XX @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
250
ret = bdrv_flush(bs);
251
fail:
252
if (l2_table) {
253
- qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
254
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
255
}
256
257
s->cache_discards = false;
258
@@ -XXX,XX +XXX,XX @@ static int walk_over_reftable(BlockDriverState *bs, uint64_t **new_reftable,
259
new_reftable_size, new_refblock,
260
new_refblock_empty, allocated, errp);
261
if (ret < 0) {
262
- qcow2_cache_put(bs, s->refcount_block_cache, &refblock);
263
+ qcow2_cache_put(s->refcount_block_cache, &refblock);
264
return ret;
265
}
266
267
@@ -XXX,XX +XXX,XX @@ static int walk_over_reftable(BlockDriverState *bs, uint64_t **new_reftable,
268
if (new_refcount_bits < 64 && refcount >> new_refcount_bits) {
269
uint64_t offset;
270
271
- qcow2_cache_put(bs, s->refcount_block_cache, &refblock);
272
+ qcow2_cache_put(s->refcount_block_cache, &refblock);
273
274
offset = ((reftable_index << s->refcount_block_bits)
275
+ refblock_index) << s->cluster_bits;
276
@@ -XXX,XX +XXX,XX @@ static int walk_over_reftable(BlockDriverState *bs, uint64_t **new_reftable,
277
new_refblock_empty = new_refblock_empty && refcount == 0;
278
}
279
280
- qcow2_cache_put(bs, s->refcount_block_cache, &refblock);
281
+ qcow2_cache_put(s->refcount_block_cache, &refblock);
282
} else {
283
/* No refblock means every refcount is 0 */
284
for (refblock_index = 0; refblock_index < s->refcount_block_size;
285
@@ -XXX,XX +XXX,XX @@ static int qcow2_discard_refcount_block(BlockDriverState *bs,
286
offset_to_reftable_index(s, discard_block_offs),
287
discard_block_offs,
288
s->get_refcount(refblock, block_index));
289
- qcow2_cache_put(bs, s->refcount_block_cache, &refblock);
290
+ qcow2_cache_put(s->refcount_block_cache, &refblock);
291
return -EINVAL;
292
}
293
s->set_refcount(refblock, block_index, 0);
294
295
qcow2_cache_entry_mark_dirty(s->refcount_block_cache, refblock);
296
297
- qcow2_cache_put(bs, s->refcount_block_cache, &refblock);
298
+ qcow2_cache_put(s->refcount_block_cache, &refblock);
299
300
if (cluster_index < s->free_cluster_index) {
301
s->free_cluster_index = cluster_index;
302
@@ -XXX,XX +XXX,XX @@ int qcow2_shrink_reftable(BlockDriverState *bs)
303
} else {
304
unused_block = buffer_is_zero(refblock, s->cluster_size);
305
}
306
- qcow2_cache_put(bs, s->refcount_block_cache, &refblock);
307
+ qcow2_cache_put(s->refcount_block_cache, &refblock);
308
309
reftable_tmp[i] = unused_block ? 0 : cpu_to_be64(s->refcount_table[i]);
310
}
54
}
311
--
55
--
312
2.13.6
56
2.19.1
313
57
314
58
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Alberto Garcia <berto@igalia.com>
2
2
3
This function was only using the BlockDriverState parameter to get the
3
The blkverify mode of Quorum can only be enabled if the number of
4
cache table size (since it was equal to the cluster size). This is no
4
children is exactly two and the value of vote-threshold is also two.
5
longer necessary so this parameter can be removed.
5
6
If the user tries to enable it but the other settings are incorrect
7
then QEMU simply prints an error message to stderr and carries on
8
disabling the blkverify setting.
9
10
This patch makes quorum_open() fail and return an error in this case.
6
11
7
Signed-off-by: Alberto Garcia <berto@igalia.com>
12
Signed-off-by: Alberto Garcia <berto@igalia.com>
8
Reviewed-by: Eric Blake <eblake@redhat.com>
13
Reported-by: Markus Armbruster <armbru@redhat.com>
9
Reviewed-by: Max Reitz <mreitz@redhat.com>
14
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10
Message-id: e1f943a9e89e1deb876f45de1bb22419ccdb6ad3.1517840876.git.berto@igalia.com
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
12
---
15
---
13
block/qcow2-cache.c | 13 ++++++-------
16
block/quorum.c | 13 ++++++-------
14
1 file changed, 6 insertions(+), 7 deletions(-)
17
1 file changed, 6 insertions(+), 7 deletions(-)
15
18
16
diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
19
diff --git a/block/quorum.c b/block/quorum.c
17
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
18
--- a/block/qcow2-cache.c
21
--- a/block/quorum.c
19
+++ b/block/qcow2-cache.c
22
+++ b/block/quorum.c
20
@@ -XXX,XX +XXX,XX @@ struct Qcow2Cache {
23
@@ -XXX,XX +XXX,XX @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
21
uint64_t cache_clean_lru_counter;
24
s->read_pattern = ret;
22
};
25
23
26
if (s->read_pattern == QUORUM_READ_PATTERN_QUORUM) {
24
-static inline void *qcow2_cache_get_table_addr(BlockDriverState *bs,
27
- /* is the driver in blkverify mode */
25
- Qcow2Cache *c, int table)
28
- if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false) &&
26
+static inline void *qcow2_cache_get_table_addr(Qcow2Cache *c, int table)
29
- s->num_children == 2 && s->threshold == 2) {
27
{
30
- s->is_blkverify = true;
28
return (uint8_t *) c->table_array + (size_t) table * c->table_size;
31
- } else if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false)) {
29
}
32
- fprintf(stderr, "blkverify mode is set by setting blkverify=on "
30
@@ -XXX,XX +XXX,XX @@ static void qcow2_cache_table_release(BlockDriverState *bs, Qcow2Cache *c,
33
- "and using two files with vote_threshold=2\n");
31
{
34
+ s->is_blkverify = qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false);
32
/* Using MADV_DONTNEED to discard memory is a Linux-specific feature */
35
+ if (s->is_blkverify && (s->num_children != 2 || s->threshold != 2)) {
33
#ifdef CONFIG_LINUX
36
+ error_setg(&local_err, "blkverify=on can only be set if there are "
34
- void *t = qcow2_cache_get_table_addr(bs, c, i);
37
+ "exactly two files and vote-threshold is 2");
35
+ void *t = qcow2_cache_get_table_addr(c, i);
38
+ ret = -EINVAL;
36
int align = getpagesize();
39
+ goto exit;
37
size_t mem_size = (size_t) c->table_size * num_tables;
38
size_t offset = QEMU_ALIGN_UP((uintptr_t) t, align) - (uintptr_t) t;
39
@@ -XXX,XX +XXX,XX @@ static int qcow2_cache_entry_flush(BlockDriverState *bs, Qcow2Cache *c, int i)
40
}
41
42
ret = bdrv_pwrite(bs->file, c->entries[i].offset,
43
- qcow2_cache_get_table_addr(bs, c, i), c->table_size);
44
+ qcow2_cache_get_table_addr(c, i), c->table_size);
45
if (ret < 0) {
46
return ret;
47
}
48
@@ -XXX,XX +XXX,XX @@ static int qcow2_cache_do_get(BlockDriverState *bs, Qcow2Cache *c,
49
}
40
}
50
41
51
ret = bdrv_pread(bs->file, offset,
42
s->rewrite_corrupted = qemu_opt_get_bool(opts, QUORUM_OPT_REWRITE,
52
- qcow2_cache_get_table_addr(bs, c, i),
53
+ qcow2_cache_get_table_addr(c, i),
54
c->table_size);
55
if (ret < 0) {
56
return ret;
57
@@ -XXX,XX +XXX,XX @@ static int qcow2_cache_do_get(BlockDriverState *bs, Qcow2Cache *c,
58
/* And return the right table */
59
found:
60
c->entries[i].ref++;
61
- *table = qcow2_cache_get_table_addr(bs, c, i);
62
+ *table = qcow2_cache_get_table_addr(c, i);
63
64
trace_qcow2_cache_get_done(qemu_coroutine_self(),
65
c == s->l2_table_cache, i);
66
@@ -XXX,XX +XXX,XX @@ void *qcow2_cache_is_table_offset(BlockDriverState *bs, Qcow2Cache *c,
67
68
for (i = 0; i < c->size; i++) {
69
if (c->entries[i].offset == offset) {
70
- return qcow2_cache_get_table_addr(bs, c, i);
71
+ return qcow2_cache_get_table_addr(c, i);
72
}
73
}
74
return NULL;
75
--
43
--
76
2.13.6
44
2.19.1
77
45
78
46
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Alberto Garcia <berto@igalia.com>
2
2
3
expand_zero_clusters_in_l1() is used when downgrading qcow2 images
3
Signed-off-by: Alberto Garcia <berto@igalia.com>
4
from v3 to v2 (compat=0.10). This is one of the functions that needed
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
more changes to support L2 slices, so this patch extends iotest 061 to
5
---
6
test downgrading a qcow2 image using a smaller slice size.
6
tests/qemu-iotests/081 | 30 ++++++++++++++++++++++++++++++
7
tests/qemu-iotests/081.out | 16 ++++++++++++++++
8
2 files changed, 46 insertions(+)
7
9
8
Signed-off-by: Alberto Garcia <berto@igalia.com>
10
diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081
9
Reviewed-by: Eric Blake <eblake@redhat.com>
10
Reviewed-by: Max Reitz <mreitz@redhat.com>
11
Message-id: 3e5662dce5e4926c8fabbad4c0b9142b2a506dd4.1517840877.git.berto@igalia.com
12
Signed-off-by: Max Reitz <mreitz@redhat.com>
13
---
14
tests/qemu-iotests/061 | 16 ++++++++++++
15
tests/qemu-iotests/061.out | 61 ++++++++++++++++++++++++++++++++++++++++++++++
16
2 files changed, 77 insertions(+)
17
18
diff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061
19
index XXXXXXX..XXXXXXX 100755
11
index XXXXXXX..XXXXXXX 100755
20
--- a/tests/qemu-iotests/061
12
--- a/tests/qemu-iotests/081
21
+++ b/tests/qemu-iotests/061
13
+++ b/tests/qemu-iotests/081
22
@@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
14
@@ -XXX,XX +XXX,XX @@ echo "== checking that quorum is broken =="
23
_check_test_img
15
24
16
$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io
25
echo
17
26
+echo "=== Testing version downgrade with zero expansion and 4K cache entries ==="
27
+echo
18
+echo
28
+IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M
19
+echo "== checking the blkverify mode with broken content =="
29
+$QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io
20
+
30
+$QEMU_IO -c "write -z 32M 128k" "$TEST_IMG" | _filter_qemu_io
21
+quorum="driver=raw,file.driver=quorum,file.vote-threshold=2,file.blkverify=on"
31
+$QEMU_IO -c map "$TEST_IMG" | _filter_qemu_io
22
+quorum="$quorum,file.children.0.file.filename=$TEST_DIR/1.raw"
32
+$PYTHON qcow2.py "$TEST_IMG" dump-header
23
+quorum="$quorum,file.children.1.file.filename=$TEST_DIR/2.raw"
33
+$QEMU_IMG amend -o "compat=0.10" --image-opts \
24
+quorum="$quorum,file.children.0.driver=raw"
34
+ driver=qcow2,file.filename=$TEST_IMG,l2-cache-entry-size=4096
25
+quorum="$quorum,file.children.1.driver=raw"
35
+$PYTHON qcow2.py "$TEST_IMG" dump-header
26
+
36
+$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io
27
+$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io
37
+$QEMU_IO -c "read -P 0 32M 128k" "$TEST_IMG" | _filter_qemu_io
38
+$QEMU_IO -c map "$TEST_IMG" | _filter_qemu_io
39
+_check_test_img
40
+
28
+
41
+echo
29
+echo
42
echo "=== Testing dirty version downgrade ==="
30
+echo "== writing the same data to both files =="
43
echo
31
+
44
IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M
32
+$QEMU_IO -c "write -P 0x32 0 $size" "$TEST_DIR/1.raw" | _filter_qemu_io
45
diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out
33
+$QEMU_IO -c "write -P 0x32 0 $size" "$TEST_DIR/2.raw" | _filter_qemu_io
34
+
35
+echo
36
+echo "== checking the blkverify mode with valid content =="
37
+
38
+$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io
39
+
40
+echo
41
+echo "== checking the blkverify mode with invalid settings =="
42
+
43
+quorum="$quorum,file.children.2.file.filename=$TEST_DIR/3.raw"
44
+quorum="$quorum,file.children.2.driver=raw"
45
+
46
+$QEMU_IO -c "open -o $quorum" | _filter_qemu_io
47
+
48
# success, all done
49
echo "*** done"
50
rm -f $seq.full
51
diff --git a/tests/qemu-iotests/081.out b/tests/qemu-iotests/081.out
46
index XXXXXXX..XXXXXXX 100644
52
index XXXXXXX..XXXXXXX 100644
47
--- a/tests/qemu-iotests/061.out
53
--- a/tests/qemu-iotests/081.out
48
+++ b/tests/qemu-iotests/061.out
54
+++ b/tests/qemu-iotests/081.out
49
@@ -XXX,XX +XXX,XX @@ read 131072/131072 bytes at offset 0
55
@@ -XXX,XX +XXX,XX @@ wrote 10485760/10485760 bytes at offset 0
50
128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
56
51
No errors were found on the image.
57
== checking that quorum is broken ==
52
58
read failed: Input/output error
53
+=== Testing version downgrade with zero expansion and 4K cache entries ===
54
+
59
+
55
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
60
+== checking the blkverify mode with broken content ==
56
+wrote 131072/131072 bytes at offset 0
61
+quorum: offset=0 bytes=10485760 contents mismatch at offset 0
57
+128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
58
+wrote 131072/131072 bytes at offset 33554432
59
+128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
60
+128 KiB (0x20000) bytes allocated at offset 0 bytes (0x0)
61
+31.875 MiB (0x1fe0000) bytes not allocated at offset 128 KiB (0x20000)
62
+128 KiB (0x20000) bytes allocated at offset 32 MiB (0x2000000)
63
+31.875 MiB (0x1fe0000) bytes not allocated at offset 32.125 MiB (0x2020000)
64
+magic 0x514649fb
65
+version 3
66
+backing_file_offset 0x0
67
+backing_file_size 0x0
68
+cluster_bits 16
69
+size 67108864
70
+crypt_method 0
71
+l1_size 1
72
+l1_table_offset 0x30000
73
+refcount_table_offset 0x10000
74
+refcount_table_clusters 1
75
+nb_snapshots 0
76
+snapshot_offset 0x0
77
+incompatible_features 0x0
78
+compatible_features 0x1
79
+autoclear_features 0x0
80
+refcount_order 4
81
+header_length 104
82
+
62
+
83
+Header extension:
63
+== writing the same data to both files ==
84
+magic 0x6803f857
64
+wrote 10485760/10485760 bytes at offset 0
85
+length 144
65
+10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
86
+data <binary>
66
+wrote 10485760/10485760 bytes at offset 0
67
+10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
87
+
68
+
88
+magic 0x514649fb
69
+== checking the blkverify mode with valid content ==
89
+version 2
70
+read 10485760/10485760 bytes at offset 0
90
+backing_file_offset 0x0
71
+10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
91
+backing_file_size 0x0
92
+cluster_bits 16
93
+size 67108864
94
+crypt_method 0
95
+l1_size 1
96
+l1_table_offset 0x30000
97
+refcount_table_offset 0x10000
98
+refcount_table_clusters 1
99
+nb_snapshots 0
100
+snapshot_offset 0x0
101
+incompatible_features 0x0
102
+compatible_features 0x0
103
+autoclear_features 0x0
104
+refcount_order 4
105
+header_length 72
106
+
72
+
107
+read 131072/131072 bytes at offset 0
73
+== checking the blkverify mode with invalid settings ==
108
+128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
74
+can't open: blkverify=on can only be set if there are exactly two files and vote-threshold is 2
109
+read 131072/131072 bytes at offset 33554432
75
*** done
110
+128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
111
+64 MiB (0x4000000) bytes not allocated at offset 0 bytes (0x0)
112
+No errors were found on the image.
113
+
114
=== Testing dirty version downgrade ===
115
116
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
117
--
76
--
118
2.13.6
77
2.19.1
119
78
120
79
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Alberto Garcia <berto@igalia.com>
2
2
3
qcow2_update_snapshot_refcount() increases the refcount of all
3
The blkverify mode of Quorum only works when the number of children is
4
clusters of a given snapshot. In order to do that it needs to load all
4
exactly two, so any attempt to add a new one must return an error.
5
its L2 tables and iterate over their entries. Since we'll be loading
6
L2 slices instead of full tables we need to add an extra loop that
7
iterates over all slices of each L2 table.
8
5
9
This function doesn't need any additional changes so apart from that
6
quorum_del_child() on the other hand doesn't need any additional check
10
this patch simply updates the variable name from l2_table to l2_slice.
7
because decreasing the number of children would make it go under the
8
vote threshold.
11
9
12
Signed-off-by: Alberto Garcia <berto@igalia.com>
10
Signed-off-by: Alberto Garcia <berto@igalia.com>
13
Message-id: 5f4db199b9637f4833b58487135124d70add8cf0.1517840877.git.berto@igalia.com
11
Reported-by: Kevin Wolf <kwolf@redhat.com>
14
Reviewed-by: Max Reitz <mreitz@redhat.com>
12
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
15
Reviewed-by: Eric Blake <eblake@redhat.com>
16
Signed-off-by: Max Reitz <mreitz@redhat.com>
17
---
13
---
18
block/qcow2-refcount.c | 32 ++++++++++++++++++--------------
14
block/quorum.c | 8 ++++++++
19
1 file changed, 18 insertions(+), 14 deletions(-)
15
1 file changed, 8 insertions(+)
20
16
21
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
17
diff --git a/block/quorum.c b/block/quorum.c
22
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
23
--- a/block/qcow2-refcount.c
19
--- a/block/quorum.c
24
+++ b/block/qcow2-refcount.c
20
+++ b/block/quorum.c
25
@@ -XXX,XX +XXX,XX @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
21
@@ -XXX,XX +XXX,XX @@ static void quorum_add_child(BlockDriverState *bs, BlockDriverState *child_bs,
26
int64_t l1_table_offset, int l1_size, int addend)
22
char indexstr[32];
27
{
28
BDRVQcow2State *s = bs->opaque;
29
- uint64_t *l1_table, *l2_table, l2_offset, entry, l1_size2, refcount;
30
+ uint64_t *l1_table, *l2_slice, l2_offset, entry, l1_size2, refcount;
31
bool l1_allocated = false;
32
int64_t old_entry, old_l2_offset;
33
+ unsigned slice, slice_size2, n_slices;
34
int i, j, l1_modified = 0, nb_csectors;
35
int ret;
23
int ret;
36
24
37
assert(addend >= -1 && addend <= 1);
25
+ if (s->is_blkverify) {
38
26
+ error_setg(errp, "Cannot add a child to a quorum in blkverify mode");
39
- l2_table = NULL;
27
+ return;
40
+ l2_slice = NULL;
28
+ }
41
l1_table = NULL;
29
+
42
l1_size2 = l1_size * sizeof(uint64_t);
30
assert(s->num_children <= INT_MAX / sizeof(BdrvChild *));
43
+ slice_size2 = s->l2_slice_size * sizeof(uint64_t);
31
if (s->num_children == INT_MAX / sizeof(BdrvChild *) ||
44
+ n_slices = s->cluster_size / slice_size2;
32
s->next_child_index == UINT_MAX) {
45
33
@@ -XXX,XX +XXX,XX @@ static void quorum_del_child(BlockDriverState *bs, BdrvChild *child,
46
s->cache_discards = true;
34
return;
47
48
@@ -XXX,XX +XXX,XX @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
49
goto fail;
50
}
51
52
- {
53
+ for (slice = 0; slice < n_slices; slice++) {
54
ret = qcow2_cache_get(bs, s->l2_table_cache,
55
- l2_offset,
56
- (void **) &l2_table);
57
+ l2_offset + slice * slice_size2,
58
+ (void **) &l2_slice);
59
if (ret < 0) {
60
goto fail;
61
}
62
63
- for (j = 0; j < s->l2_size; j++) {
64
+ for (j = 0; j < s->l2_slice_size; j++) {
65
uint64_t cluster_index;
66
uint64_t offset;
67
68
- entry = be64_to_cpu(l2_table[j]);
69
+ entry = be64_to_cpu(l2_slice[j]);
70
old_entry = entry;
71
entry &= ~QCOW_OFLAG_COPIED;
72
offset = entry & L2E_OFFSET_MASK;
73
@@ -XXX,XX +XXX,XX @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
74
case QCOW2_CLUSTER_NORMAL:
75
case QCOW2_CLUSTER_ZERO_ALLOC:
76
if (offset_into_cluster(s, offset)) {
77
+ /* Here l2_index means table (not slice) index */
78
+ int l2_index = slice * s->l2_slice_size + j;
79
qcow2_signal_corruption(
80
bs, true, -1, -1, "Cluster "
81
"allocation offset %#" PRIx64
82
" unaligned (L2 offset: %#"
83
PRIx64 ", L2 index: %#x)",
84
- offset, l2_offset, j);
85
+ offset, l2_offset, l2_index);
86
ret = -EIO;
87
goto fail;
88
}
89
@@ -XXX,XX +XXX,XX @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
90
qcow2_cache_set_dependency(bs, s->l2_table_cache,
91
s->refcount_block_cache);
92
}
93
- l2_table[j] = cpu_to_be64(entry);
94
+ l2_slice[j] = cpu_to_be64(entry);
95
qcow2_cache_entry_mark_dirty(s->l2_table_cache,
96
- l2_table);
97
+ l2_slice);
98
}
99
}
100
101
- qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
102
-
103
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice);
104
}
105
106
if (addend != 0) {
107
@@ -XXX,XX +XXX,XX @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
108
109
ret = bdrv_flush(bs);
110
fail:
111
- if (l2_table) {
112
- qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
113
+ if (l2_slice) {
114
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice);
115
}
35
}
116
36
117
s->cache_discards = false;
37
+ /* We know now that num_children > threshold, so blkverify must be false */
38
+ assert(!s->is_blkverify);
39
+
40
bdrv_drained_begin(bs);
41
42
/* We can safely remove this child now */
118
--
43
--
119
2.13.6
44
2.19.1
120
45
121
46
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Alberto Garcia <berto@igalia.com>
2
2
3
g_realloc() aborts the program if it fails to allocate the required
3
This patch tests that you can add and remove drives from a Quorum
4
amount of memory. We want to detect that scenario and return an error
4
using the x-blockdev-change command.
5
instead, so let's use g_try_realloc().
6
5
7
Signed-off-by: Alberto Garcia <berto@igalia.com>
6
Signed-off-by: Alberto Garcia <berto@igalia.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9
---
8
---
10
block/qcow2-cluster.c | 10 +++++++++-
9
tests/qemu-iotests/081 | 86 ++++++++++++++++++++++++++++++++++++++
11
1 file changed, 9 insertions(+), 1 deletion(-)
10
tests/qemu-iotests/081.out | 54 ++++++++++++++++++++++++
11
2 files changed, 140 insertions(+)
12
12
13
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
13
diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081
14
index XXXXXXX..XXXXXXX 100755
15
--- a/tests/qemu-iotests/081
16
+++ b/tests/qemu-iotests/081
17
@@ -XXX,XX +XXX,XX @@ quorum="$quorum,file.children.2.driver=raw"
18
19
$QEMU_IO -c "open -o $quorum" | _filter_qemu_io
20
21
+echo
22
+echo "== dynamically adding a child to a quorum =="
23
+
24
+for verify in false true; do
25
+ run_qemu <<EOF
26
+ { "execute": "qmp_capabilities" }
27
+ { "execute": "blockdev-add",
28
+ "arguments": {
29
+ "driver": "quorum",
30
+ "node-name": "drive0-quorum",
31
+ "vote-threshold": 2,
32
+ "blkverify": ${verify},
33
+ "children": [
34
+ {
35
+ "driver": "$IMGFMT",
36
+ "file": {
37
+ "driver": "file",
38
+ "filename": "$TEST_DIR/1.raw"
39
+ }
40
+ },
41
+ {
42
+ "driver": "$IMGFMT",
43
+ "file": {
44
+ "driver": "file",
45
+ "filename": "$TEST_DIR/2.raw"
46
+ }
47
+ }
48
+ ]
49
+ }
50
+ }
51
+ { "execute": "blockdev-add",
52
+ "arguments": {
53
+ "node-name": "drive3",
54
+ "driver": "$IMGFMT",
55
+ "file": {
56
+ "driver": "file",
57
+ "filename": "$TEST_DIR/2.raw"
58
+ }
59
+ }
60
+ }
61
+ { "execute": "x-blockdev-change",
62
+ "arguments": { "parent": "drive0-quorum",
63
+ "node": "drive3" } }
64
+ { "execute": "quit" }
65
+EOF
66
+done
67
+
68
+echo
69
+echo "== dynamically removing a child from a quorum =="
70
+
71
+for verify in false true; do
72
+ for vote_threshold in 1 2; do
73
+ run_qemu <<EOF
74
+ { "execute": "qmp_capabilities" }
75
+ { "execute": "blockdev-add",
76
+ "arguments": {
77
+ "driver": "quorum",
78
+ "node-name": "drive0-quorum",
79
+ "vote-threshold": ${vote_threshold},
80
+ "blkverify": ${verify},
81
+ "children": [
82
+ {
83
+ "driver": "$IMGFMT",
84
+ "file": {
85
+ "driver": "file",
86
+ "filename": "$TEST_DIR/1.raw"
87
+ }
88
+ },
89
+ {
90
+ "driver": "$IMGFMT",
91
+ "file": {
92
+ "driver": "file",
93
+ "filename": "$TEST_DIR/2.raw"
94
+ }
95
+ }
96
+ ]
97
+ }
98
+ }
99
+ { "execute": "x-blockdev-change",
100
+ "arguments": { "parent": "drive0-quorum",
101
+ "child": "children.1" } }
102
+ { "execute": "quit" }
103
+EOF
104
+ done
105
+done
106
+
107
# success, all done
108
echo "*** done"
109
rm -f $seq.full
110
diff --git a/tests/qemu-iotests/081.out b/tests/qemu-iotests/081.out
14
index XXXXXXX..XXXXXXX 100644
111
index XXXXXXX..XXXXXXX 100644
15
--- a/block/qcow2-cluster.c
112
--- a/tests/qemu-iotests/081.out
16
+++ b/block/qcow2-cluster.c
113
+++ b/tests/qemu-iotests/081.out
17
@@ -XXX,XX +XXX,XX @@ int qcow2_expand_zero_clusters(BlockDriverState *bs,
114
@@ -XXX,XX +XXX,XX @@ read 10485760/10485760 bytes at offset 0
18
int l1_sectors = DIV_ROUND_UP(s->snapshots[i].l1_size *
115
19
sizeof(uint64_t), BDRV_SECTOR_SIZE);
116
== checking the blkverify mode with invalid settings ==
20
117
can't open: blkverify=on can only be set if there are exactly two files and vote-threshold is 2
21
- l1_table = g_realloc(l1_table, l1_sectors * BDRV_SECTOR_SIZE);
22
+ uint64_t *new_l1_table =
23
+ g_try_realloc(l1_table, l1_sectors * BDRV_SECTOR_SIZE);
24
+
118
+
25
+ if (!new_l1_table) {
119
+== dynamically adding a child to a quorum ==
26
+ ret = -ENOMEM;
120
+Testing:
27
+ goto fail;
121
+QMP_VERSION
28
+ }
122
+{"return": {}}
123
+{"return": {}}
124
+{"return": {}}
125
+{"return": {}}
126
+{"return": {}}
127
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
29
+
128
+
30
+ l1_table = new_l1_table;
129
+Testing:
31
130
+QMP_VERSION
32
ret = bdrv_read(bs->file,
131
+{"return": {}}
33
s->snapshots[i].l1_table_offset / BDRV_SECTOR_SIZE,
132
+{"return": {}}
133
+{"return": {}}
134
+{"error": {"class": "GenericError", "desc": "Cannot add a child to a quorum in blkverify mode"}}
135
+{"return": {}}
136
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
137
+
138
+
139
+== dynamically removing a child from a quorum ==
140
+Testing:
141
+QMP_VERSION
142
+{"return": {}}
143
+{"return": {}}
144
+{"return": {}}
145
+{"return": {}}
146
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
147
+
148
+Testing:
149
+QMP_VERSION
150
+{"return": {}}
151
+{"return": {}}
152
+{"error": {"class": "GenericError", "desc": "The number of children cannot be lower than the vote threshold 2"}}
153
+{"return": {}}
154
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
155
+
156
+Testing:
157
+QMP_VERSION
158
+{"return": {}}
159
+{"error": {"class": "GenericError", "desc": "blkverify=on can only be set if there are exactly two files and vote-threshold is 2"}}
160
+{"error": {"class": "GenericError", "desc": "Cannot find device=drive0-quorum nor node_name=drive0-quorum"}}
161
+{"return": {}}
162
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
163
+
164
+Testing:
165
+QMP_VERSION
166
+{"return": {}}
167
+{"return": {}}
168
+{"error": {"class": "GenericError", "desc": "The number of children cannot be lower than the vote threshold 2"}}
169
+{"return": {}}
170
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
171
+
172
*** done
34
--
173
--
35
2.13.6
174
2.19.1
36
175
37
176
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
To fully change the read-only state of a node, we must not only change
2
bs->read_only, but also update bs->open_flags.
2
3
3
qcow2_get_cluster_offset() checks how many contiguous bytes are
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4
available at a given offset. The returned number of bytes is limited
5
Reviewed-by: Eric Blake <eblake@redhat.com>
5
by the amount that can be addressed without having to load more than
6
Reviewed-by: Alberto Garcia <berto@igalia.com>
6
one L2 table.
7
---
8
block.c | 7 +++++++
9
1 file changed, 7 insertions(+)
7
10
8
Since we'll be loading L2 slices instead of full tables this patch
11
diff --git a/block.c b/block.c
9
changes the limit accordingly using the size of the L2 slice for the
10
calculations instead of the full table size.
11
12
One consequence of this is that with small L2 slices operations such
13
as 'qemu-img map' will need to iterate in more steps because each
14
qcow2_get_cluster_offset() call will potentially return a smaller
15
number. However the code is already prepared for that so this doesn't
16
break semantics.
17
18
The l2_table variable is also renamed to l2_slice to reflect this, and
19
offset_to_l2_index() is replaced with offset_to_l2_slice_index().
20
21
Signed-off-by: Alberto Garcia <berto@igalia.com>
22
Reviewed-by: Eric Blake <eblake@redhat.com>
23
Reviewed-by: Max Reitz <mreitz@redhat.com>
24
Message-id: 6b602260acb33da56ed6af9611731cb7acd110eb.1517840877.git.berto@igalia.com
25
Signed-off-by: Max Reitz <mreitz@redhat.com>
26
---
27
block/qcow2-cluster.c | 30 +++++++++++++++---------------
28
1 file changed, 15 insertions(+), 15 deletions(-)
29
30
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
31
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
32
--- a/block/qcow2-cluster.c
13
--- a/block.c
33
+++ b/block/qcow2-cluster.c
14
+++ b/block.c
34
@@ -XXX,XX +XXX,XX @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
15
@@ -XXX,XX +XXX,XX @@ int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
35
{
36
BDRVQcow2State *s = bs->opaque;
37
unsigned int l2_index;
38
- uint64_t l1_index, l2_offset, *l2_table;
39
- int l1_bits, c;
40
+ uint64_t l1_index, l2_offset, *l2_slice;
41
+ int c;
42
unsigned int offset_in_cluster;
43
uint64_t bytes_available, bytes_needed, nb_clusters;
44
QCow2ClusterType type;
45
@@ -XXX,XX +XXX,XX @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
46
offset_in_cluster = offset_into_cluster(s, offset);
47
bytes_needed = (uint64_t) *bytes + offset_in_cluster;
48
49
- l1_bits = s->l2_bits + s->cluster_bits;
50
-
51
/* compute how many bytes there are between the start of the cluster
52
- * containing offset and the end of the l1 entry */
53
- bytes_available = (1ULL << l1_bits) - (offset & ((1ULL << l1_bits) - 1))
54
- + offset_in_cluster;
55
+ * containing offset and the end of the l2 slice that contains
56
+ * the entry pointing to it */
57
+ bytes_available =
58
+ ((uint64_t) (s->l2_slice_size - offset_to_l2_slice_index(s, offset)))
59
+ << s->cluster_bits;
60
61
if (bytes_needed > bytes_available) {
62
bytes_needed = bytes_available;
63
@@ -XXX,XX +XXX,XX @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
64
return -EIO;
65
}
16
}
66
17
67
- /* load the l2 table in memory */
18
bs->read_only = read_only;
68
+ /* load the l2 slice in memory */
19
+
69
20
+ if (read_only) {
70
- ret = l2_load(bs, offset, l2_offset, &l2_table);
21
+ bs->open_flags &= ~BDRV_O_RDWR;
71
+ ret = l2_load(bs, offset, l2_offset, &l2_slice);
22
+ } else {
72
if (ret < 0) {
23
+ bs->open_flags |= BDRV_O_RDWR;
73
return ret;
24
+ }
74
}
25
+
75
26
return 0;
76
/* find the cluster offset for the given disk offset */
77
78
- l2_index = offset_to_l2_index(s, offset);
79
- *cluster_offset = be64_to_cpu(l2_table[l2_index]);
80
+ l2_index = offset_to_l2_slice_index(s, offset);
81
+ *cluster_offset = be64_to_cpu(l2_slice[l2_index]);
82
83
nb_clusters = size_to_clusters(s, bytes_needed);
84
/* bytes_needed <= *bytes + offset_in_cluster, both of which are unsigned
85
@@ -XXX,XX +XXX,XX @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
86
case QCOW2_CLUSTER_UNALLOCATED:
87
/* how many empty clusters ? */
88
c = count_contiguous_clusters_unallocated(nb_clusters,
89
- &l2_table[l2_index], type);
90
+ &l2_slice[l2_index], type);
91
*cluster_offset = 0;
92
break;
93
case QCOW2_CLUSTER_ZERO_ALLOC:
94
case QCOW2_CLUSTER_NORMAL:
95
/* how many allocated clusters ? */
96
c = count_contiguous_clusters(nb_clusters, s->cluster_size,
97
- &l2_table[l2_index], QCOW_OFLAG_ZERO);
98
+ &l2_slice[l2_index], QCOW_OFLAG_ZERO);
99
*cluster_offset &= L2E_OFFSET_MASK;
100
if (offset_into_cluster(s, *cluster_offset)) {
101
qcow2_signal_corruption(bs, true, -1, -1,
102
@@ -XXX,XX +XXX,XX @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
103
abort();
104
}
105
106
- qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
107
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice);
108
109
bytes_available = (int64_t)c * s->cluster_size;
110
111
@@ -XXX,XX +XXX,XX @@ out:
112
return type;
113
114
fail:
115
- qcow2_cache_put(s->l2_table_cache, (void **)&l2_table);
116
+ qcow2_cache_put(s->l2_table_cache, (void **)&l2_slice);
117
return ret;
118
}
27
}
119
28
120
--
29
--
121
2.13.6
30
2.19.1
122
31
123
32
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
If a management application builds the block graph node by node, the
2
protocol layer doesn't inherit its read-only option from the format
3
layer any more, so it must be set explicitly.
2
4
3
Now that the code is ready to handle L2 slices we can finally add an
5
Backing files should work on read-only storage, but at the same time, a
4
option to allow configuring their size.
6
block job like commit should be able to reopen them read-write if they
7
are on read-write storage. However, without option inheritance, reopen
8
only changes the read-only option for the root node (typically the
9
format layer), but not the protocol layer, so reopening fails (the
10
format layer wants to get write permissions, but the protocol layer is
11
still read-only).
5
12
6
An L2 slice is the portion of an L2 table that is read by the qcow2
13
A simple workaround for the problem in the management tool would be to
7
cache. Until now the cache was always reading full L2 tables, and
14
open the protocol layer always read-write and to make only the format
8
since the L2 table size is equal to the cluster size this was not very
15
layer read-only for backing files. However, sometimes the file is
9
efficient with large clusters. Here's a more detailed explanation of
16
actually stored on read-only storage and we don't know whether the image
10
why it makes sense to have smaller cache entries in order to load L2
17
can be opened read-write (for example, for NBD it depends on the server
11
data:
18
we're trying to connect to). This adds an option that makes QEMU try to
19
open the image read-write, but allows it to degrade to a read-only mode
20
without returning an error.
12
21
13
https://lists.gnu.org/archive/html/qemu-block/2017-09/msg00635.html
22
The documentation for this option is consciously phrased in a way that
23
allows QEMU to switch to a better model eventually: Instead of trying
24
when the image is first opened, making the read-only flag dynamic and
25
changing it automatically whenever the first BLK_PERM_WRITE user is
26
attached or the last one is detached would be much more useful
27
behaviour.
14
28
15
This patch introduces a new command-line option to the qcow2 driver
29
Unfortunately, this more useful behaviour is also a lot harder to
16
named l2-cache-entry-size (cf. l2-cache-size). The cache entry size
30
implement, and libvirt needs a solution now before it can switch to
17
has the same restrictions as the cluster size: it must be a power of
31
-blockdev, so let's start with this easier approach for now.
18
two and it has the same range of allowed values, with the additional
19
requirement that it must not be larger than the cluster size.
20
32
21
The L2 cache entry size (L2 slice size) remains equal to the cluster
33
Instead of adding a new auto-read-only option, turning the existing
22
size for now by default, so this feature must be explicitly enabled.
34
read-only into an enum (with a bool alternate for compatibility) was
23
Although my tests show that 4KB slices consistently improve
35
considered, but it complicated the implementation to the point that it
24
performance and give the best results, let's wait and make more tests
36
didn't seem to be worth it.
25
with different cluster sizes before deciding on an optimal default.
26
37
27
Now that the cache entry size is not necessarily equal to the cluster
38
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
28
size we need to reflect that in the MIN_L2_CACHE_SIZE documentation.
29
That minimum value is a requirement of the COW algorithm: we need to
30
read two L2 slices (and not two L2 tables) in order to do COW, see
31
l2_allocate() for the actual code.
32
33
Signed-off-by: Alberto Garcia <berto@igalia.com>
34
Reviewed-by: Eric Blake <eblake@redhat.com>
39
Reviewed-by: Eric Blake <eblake@redhat.com>
35
Reviewed-by: Max Reitz <mreitz@redhat.com>
36
Message-id: c73e5611ff4a9ec5d20de68a6c289553a13d2354.1517840877.git.berto@igalia.com
37
Signed-off-by: Max Reitz <mreitz@redhat.com>
38
---
40
---
39
qapi/block-core.json | 6 ++++++
41
qapi/block-core.json | 7 +++++++
40
block/qcow2.h | 6 ++++--
42
include/block/block.h | 2 ++
41
block/qcow2-cache.c | 10 ++++++++--
43
block.c | 17 +++++++++++++++++
42
block/qcow2.c | 34 +++++++++++++++++++++++++++-------
44
block/vvfat.c | 1 +
43
4 files changed, 45 insertions(+), 11 deletions(-)
45
blockdev.c | 2 +-
46
5 files changed, 28 insertions(+), 1 deletion(-)
44
47
45
diff --git a/qapi/block-core.json b/qapi/block-core.json
48
diff --git a/qapi/block-core.json b/qapi/block-core.json
46
index XXXXXXX..XXXXXXX 100644
49
index XXXXXXX..XXXXXXX 100644
47
--- a/qapi/block-core.json
50
--- a/qapi/block-core.json
48
+++ b/qapi/block-core.json
51
+++ b/qapi/block-core.json
49
@@ -XXX,XX +XXX,XX @@
52
@@ -XXX,XX +XXX,XX @@
50
# @l2-cache-size: the maximum size of the L2 table cache in
53
# either generally or in certain configurations. In this case,
51
# bytes (since 2.2)
54
# the default value does not work and the option must be
52
#
55
# specified explicitly.
53
+# @l2-cache-entry-size: the size of each entry in the L2 cache in
56
+# @auto-read-only: if true and @read-only is false, QEMU may automatically
54
+# bytes. It must be a power of two between 512
57
+# decide not to open the image read-write as requested, but
55
+# and the cluster size. The default value is
58
+# fall back to read-only instead (and switch between the modes
56
+# the cluster size (since 2.12)
59
+# later), e.g. depending on whether the image file is writable
57
+#
60
+# or whether a writing user is attached to the node
58
# @refcount-cache-size: the maximum size of the refcount block cache
61
+# (default: false, since 3.1)
59
# in bytes (since 2.2)
62
# @detect-zeroes: detect and optimize zero writes (Since 2.1)
60
#
63
# (default: off)
64
# @force-share: force share all permission on added nodes.
61
@@ -XXX,XX +XXX,XX @@
65
@@ -XXX,XX +XXX,XX @@
62
'*overlap-check': 'Qcow2OverlapChecks',
66
'*discard': 'BlockdevDiscardOptions',
63
'*cache-size': 'int',
67
'*cache': 'BlockdevCacheOptions',
64
'*l2-cache-size': 'int',
68
'*read-only': 'bool',
65
+ '*l2-cache-entry-size': 'int',
69
+ '*auto-read-only': 'bool',
66
'*refcount-cache-size': 'int',
70
'*force-share': 'bool',
67
'*cache-clean-interval': 'int',
71
'*detect-zeroes': 'BlockdevDetectZeroesOptions' },
68
'*encrypt': 'BlockdevQcow2Encryption' } }
72
'discriminator': 'driver',
69
diff --git a/block/qcow2.h b/block/qcow2.h
73
diff --git a/include/block/block.h b/include/block/block.h
70
index XXXXXXX..XXXXXXX 100644
74
index XXXXXXX..XXXXXXX 100644
71
--- a/block/qcow2.h
75
--- a/include/block/block.h
72
+++ b/block/qcow2.h
76
+++ b/include/block/block.h
73
@@ -XXX,XX +XXX,XX @@
77
@@ -XXX,XX +XXX,XX @@ typedef struct HDGeometry {
74
#define MAX_CLUSTER_BITS 21
78
select an appropriate protocol driver,
75
79
ignoring the format layer */
76
/* Must be at least 2 to cover COW */
80
#define BDRV_O_NO_IO 0x10000 /* don't initialize for I/O */
77
-#define MIN_L2_CACHE_SIZE 2 /* clusters */
81
+#define BDRV_O_AUTO_RDONLY 0x20000 /* degrade to read-only if opening read-write fails */
78
+#define MIN_L2_CACHE_SIZE 2 /* cache entries */
82
79
83
#define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_NO_FLUSH)
80
/* Must be at least 4 to cover all cases of refcount table growth */
84
81
#define MIN_REFCOUNT_CACHE_SIZE 4 /* clusters */
85
@@ -XXX,XX +XXX,XX @@ typedef struct HDGeometry {
82
@@ -XXX,XX +XXX,XX @@
86
#define BDRV_OPT_CACHE_DIRECT "cache.direct"
83
#define QCOW2_OPT_OVERLAP_INACTIVE_L2 "overlap-check.inactive-l2"
87
#define BDRV_OPT_CACHE_NO_FLUSH "cache.no-flush"
84
#define QCOW2_OPT_CACHE_SIZE "cache-size"
88
#define BDRV_OPT_READ_ONLY "read-only"
85
#define QCOW2_OPT_L2_CACHE_SIZE "l2-cache-size"
89
+#define BDRV_OPT_AUTO_READ_ONLY "auto-read-only"
86
+#define QCOW2_OPT_L2_CACHE_ENTRY_SIZE "l2-cache-entry-size"
90
#define BDRV_OPT_DISCARD "discard"
87
#define QCOW2_OPT_REFCOUNT_CACHE_SIZE "refcount-cache-size"
91
#define BDRV_OPT_FORCE_SHARE "force-share"
88
#define QCOW2_OPT_CACHE_CLEAN_INTERVAL "cache-clean-interval"
92
89
93
diff --git a/block.c b/block.c
90
@@ -XXX,XX +XXX,XX @@ void qcow2_free_snapshots(BlockDriverState *bs);
91
int qcow2_read_snapshots(BlockDriverState *bs);
92
93
/* qcow2-cache.c functions */
94
-Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables);
95
+Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables,
96
+ unsigned table_size);
97
int qcow2_cache_destroy(Qcow2Cache *c);
98
99
void qcow2_cache_entry_mark_dirty(Qcow2Cache *c, void *table);
100
diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
101
index XXXXXXX..XXXXXXX 100644
94
index XXXXXXX..XXXXXXX 100644
102
--- a/block/qcow2-cache.c
95
--- a/block.c
103
+++ b/block/qcow2-cache.c
96
+++ b/block.c
104
@@ -XXX,XX +XXX,XX @@ void qcow2_cache_clean_unused(Qcow2Cache *c)
97
@@ -XXX,XX +XXX,XX @@ static void bdrv_inherited_options(int *child_flags, QDict *child_options,
105
c->cache_clean_lru_counter = c->lru_counter;
98
106
}
99
/* Inherit the read-only option from the parent if it's not set */
107
100
qdict_copy_default(child_options, parent_options, BDRV_OPT_READ_ONLY);
108
-Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables)
101
+ qdict_copy_default(child_options, parent_options, BDRV_OPT_AUTO_READ_ONLY);
109
+Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables,
102
110
+ unsigned table_size)
103
/* Our block drivers take care to send flushes and respect unmap policy,
111
{
104
* so we can default to enable both on lower layers regardless of the
112
BDRVQcow2State *s = bs->opaque;
105
@@ -XXX,XX +XXX,XX @@ static void bdrv_backing_options(int *child_flags, QDict *child_options,
113
Qcow2Cache *c;
106
114
107
/* backing files always opened read-only */
115
+ assert(num_tables > 0);
108
qdict_set_default_str(child_options, BDRV_OPT_READ_ONLY, "on");
116
+ assert(is_power_of_2(table_size));
109
+ qdict_set_default_str(child_options, BDRV_OPT_AUTO_READ_ONLY, "off");
117
+ assert(table_size >= (1 << MIN_CLUSTER_BITS));
110
flags &= ~BDRV_O_COPY_ON_READ;
118
+ assert(table_size <= s->cluster_size);
111
119
+
112
/* snapshot=on is handled on the top layer */
120
c = g_new0(Qcow2Cache, 1);
113
@@ -XXX,XX +XXX,XX @@ static void update_flags_from_options(int *flags, QemuOpts *opts)
121
c->size = num_tables;
114
*flags |= BDRV_O_RDWR;
122
- c->table_size = s->cluster_size;
123
+ c->table_size = table_size;
124
c->entries = g_try_new0(Qcow2CachedTable, num_tables);
125
c->table_array = qemu_try_blockalign(bs->file->bs,
126
(size_t) num_tables * c->table_size);
127
diff --git a/block/qcow2.c b/block/qcow2.c
128
index XXXXXXX..XXXXXXX 100644
129
--- a/block/qcow2.c
130
+++ b/block/qcow2.c
131
@@ -XXX,XX +XXX,XX @@ static QemuOptsList qcow2_runtime_opts = {
132
.help = "Maximum L2 table cache size",
133
},
134
{
135
+ .name = QCOW2_OPT_L2_CACHE_ENTRY_SIZE,
136
+ .type = QEMU_OPT_SIZE,
137
+ .help = "Size of each entry in the L2 cache",
138
+ },
139
+ {
140
.name = QCOW2_OPT_REFCOUNT_CACHE_SIZE,
141
.type = QEMU_OPT_SIZE,
142
.help = "Maximum refcount block cache size",
143
@@ -XXX,XX +XXX,XX @@ static void qcow2_attach_aio_context(BlockDriverState *bs,
144
145
static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts,
146
uint64_t *l2_cache_size,
147
+ uint64_t *l2_cache_entry_size,
148
uint64_t *refcount_cache_size, Error **errp)
149
{
150
BDRVQcow2State *s = bs->opaque;
151
@@ -XXX,XX +XXX,XX @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts,
152
*refcount_cache_size = qemu_opt_get_size(opts,
153
QCOW2_OPT_REFCOUNT_CACHE_SIZE, 0);
154
155
+ *l2_cache_entry_size = qemu_opt_get_size(
156
+ opts, QCOW2_OPT_L2_CACHE_ENTRY_SIZE, s->cluster_size);
157
+
158
if (combined_cache_size_set) {
159
if (l2_cache_size_set && refcount_cache_size_set) {
160
error_setg(errp, QCOW2_OPT_CACHE_SIZE ", " QCOW2_OPT_L2_CACHE_SIZE
161
@@ -XXX,XX +XXX,XX @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts,
162
/ DEFAULT_L2_REFCOUNT_SIZE_RATIO;
163
}
164
}
115
}
165
+
116
166
+ if (*l2_cache_entry_size < (1 << MIN_CLUSTER_BITS) ||
117
+ assert(qemu_opt_find(opts, BDRV_OPT_AUTO_READ_ONLY));
167
+ *l2_cache_entry_size > s->cluster_size ||
118
+ if (qemu_opt_get_bool_del(opts, BDRV_OPT_AUTO_READ_ONLY, false)) {
168
+ !is_power_of_2(*l2_cache_entry_size)) {
119
+ *flags |= BDRV_O_AUTO_RDONLY;
169
+ error_setg(errp, "L2 cache entry size must be a power of two "
170
+ "between %d and the cluster size (%d)",
171
+ 1 << MIN_CLUSTER_BITS, s->cluster_size);
172
+ return;
173
+ }
120
+ }
174
}
121
}
175
122
176
typedef struct Qcow2ReopenState {
123
static void update_options_from_flags(QDict *options, int flags)
177
@@ -XXX,XX +XXX,XX @@ static int qcow2_update_options_prepare(BlockDriverState *bs,
124
@@ -XXX,XX +XXX,XX @@ static void update_options_from_flags(QDict *options, int flags)
178
QemuOpts *opts = NULL;
125
if (!qdict_haskey(options, BDRV_OPT_READ_ONLY)) {
179
const char *opt_overlap_check, *opt_overlap_check_template;
126
qdict_put_bool(options, BDRV_OPT_READ_ONLY, !(flags & BDRV_O_RDWR));
180
int overlap_check_template = 0;
181
- uint64_t l2_cache_size, refcount_cache_size;
182
+ uint64_t l2_cache_size, l2_cache_entry_size, refcount_cache_size;
183
int i;
184
const char *encryptfmt;
185
QDict *encryptopts = NULL;
186
@@ -XXX,XX +XXX,XX @@ static int qcow2_update_options_prepare(BlockDriverState *bs,
187
}
127
}
188
128
+ if (!qdict_haskey(options, BDRV_OPT_AUTO_READ_ONLY)) {
189
/* get L2 table/refcount block cache size from command line options */
129
+ qdict_put_bool(options, BDRV_OPT_AUTO_READ_ONLY,
190
- read_cache_sizes(bs, opts, &l2_cache_size, &refcount_cache_size,
130
+ flags & BDRV_O_AUTO_RDONLY);
191
- &local_err);
131
+ }
192
+ read_cache_sizes(bs, opts, &l2_cache_size, &l2_cache_entry_size,
132
}
193
+ &refcount_cache_size, &local_err);
133
194
if (local_err) {
134
static void bdrv_assign_node_name(BlockDriverState *bs,
195
error_propagate(errp, local_err);
135
@@ -XXX,XX +XXX,XX @@ QemuOptsList bdrv_runtime_opts = {
196
ret = -EINVAL;
136
.type = QEMU_OPT_BOOL,
197
goto fail;
137
.help = "Node is opened in read-only mode",
138
},
139
+ {
140
+ .name = BDRV_OPT_AUTO_READ_ONLY,
141
+ .type = QEMU_OPT_BOOL,
142
+ .help = "Node can become read-only if opening read-write fails",
143
+ },
144
{
145
.name = "detect-zeroes",
146
.type = QEMU_OPT_STRING,
147
@@ -XXX,XX +XXX,XX @@ BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp)
148
qdict_set_default_str(qdict, BDRV_OPT_CACHE_DIRECT, "off");
149
qdict_set_default_str(qdict, BDRV_OPT_CACHE_NO_FLUSH, "off");
150
qdict_set_default_str(qdict, BDRV_OPT_READ_ONLY, "off");
151
+ qdict_set_default_str(qdict, BDRV_OPT_AUTO_READ_ONLY, "off");
152
+
198
}
153
}
199
154
200
- l2_cache_size /= s->cluster_size;
155
bs = bdrv_open_inherit(NULL, reference, qdict, 0, NULL, NULL, errp);
201
+ l2_cache_size /= l2_cache_entry_size;
156
diff --git a/block/vvfat.c b/block/vvfat.c
202
if (l2_cache_size < MIN_L2_CACHE_SIZE) {
157
index XXXXXXX..XXXXXXX 100644
203
l2_cache_size = MIN_L2_CACHE_SIZE;
158
--- a/block/vvfat.c
204
}
159
+++ b/block/vvfat.c
205
@@ -XXX,XX +XXX,XX @@ static int qcow2_update_options_prepare(BlockDriverState *bs,
160
@@ -XXX,XX +XXX,XX @@ static void vvfat_qcow_options(int *child_flags, QDict *child_options,
206
}
161
int parent_flags, QDict *parent_options)
207
}
162
{
208
163
qdict_set_default_str(child_options, BDRV_OPT_READ_ONLY, "off");
209
- r->l2_slice_size = s->cluster_size / sizeof(uint64_t);
164
+ qdict_set_default_str(child_options, BDRV_OPT_AUTO_READ_ONLY, "off");
210
- r->l2_table_cache = qcow2_cache_create(bs, l2_cache_size);
165
qdict_set_default_str(child_options, BDRV_OPT_CACHE_NO_FLUSH, "on");
211
- r->refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size);
166
}
212
+ r->l2_slice_size = l2_cache_entry_size / sizeof(uint64_t);
167
213
+ r->l2_table_cache = qcow2_cache_create(bs, l2_cache_size,
168
diff --git a/blockdev.c b/blockdev.c
214
+ l2_cache_entry_size);
169
index XXXXXXX..XXXXXXX 100644
215
+ r->refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size,
170
--- a/blockdev.c
216
+ s->cluster_size);
171
+++ b/blockdev.c
217
if (r->l2_table_cache == NULL || r->refcount_block_cache == NULL) {
172
@@ -XXX,XX +XXX,XX @@ void qmp_blockdev_change_medium(bool has_device, const char *device,
218
error_setg(errp, "Could not allocate metadata caches");
173
219
ret = -ENOMEM;
174
bdrv_flags = blk_get_open_flags_from_root_state(blk);
175
bdrv_flags &= ~(BDRV_O_TEMPORARY | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING |
176
- BDRV_O_PROTOCOL);
177
+ BDRV_O_PROTOCOL | BDRV_O_AUTO_RDONLY);
178
179
if (!has_read_only) {
180
read_only = BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN;
220
--
181
--
221
2.13.6
182
2.19.1
222
183
223
184
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
Commit e2b8247a322 introduced an error path in qemu_rbd_open() after
2
calling rbd_open(), but neglected to close the image again in this error
3
path. The error path should contain everything that the regular close
4
function qemu_rbd_close() contains.
2
5
3
This test tries reopening a qcow2 image with valid and invalid
6
This adds the missing rbd_close() call.
4
options. This patch adds l2-cache-entry-size to the set.
5
7
6
Signed-off-by: Alberto Garcia <berto@igalia.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7
Reviewed-by: Eric Blake <eblake@redhat.com>
9
Reviewed-by: Eric Blake <eblake@redhat.com>
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
9
Message-id: 3d3b7d2dbfc020deaef60fb58739b0801eb9517c.1517840877.git.berto@igalia.com
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
---
10
---
12
tests/qemu-iotests/137 | 5 +++++
11
block/rbd.c | 1 +
13
tests/qemu-iotests/137.out | 2 ++
12
1 file changed, 1 insertion(+)
14
2 files changed, 7 insertions(+)
15
13
16
diff --git a/tests/qemu-iotests/137 b/tests/qemu-iotests/137
14
diff --git a/block/rbd.c b/block/rbd.c
17
index XXXXXXX..XXXXXXX 100755
18
--- a/tests/qemu-iotests/137
19
+++ b/tests/qemu-iotests/137
20
@@ -XXX,XX +XXX,XX @@ $QEMU_IO \
21
-c "reopen -o overlap-check.inactive-l2=off" \
22
-c "reopen -o cache-size=1M" \
23
-c "reopen -o l2-cache-size=512k" \
24
+ -c "reopen -o l2-cache-entry-size=512" \
25
+ -c "reopen -o l2-cache-entry-size=4k" \
26
+ -c "reopen -o l2-cache-entry-size=64k" \
27
-c "reopen -o refcount-cache-size=128k" \
28
-c "reopen -o cache-clean-interval=5" \
29
-c "reopen -o cache-clean-interval=0" \
30
@@ -XXX,XX +XXX,XX @@ $QEMU_IO \
31
-c "reopen -o cache-size=1M,l2-cache-size=2M" \
32
-c "reopen -o cache-size=1M,refcount-cache-size=2M" \
33
-c "reopen -o l2-cache-size=256T" \
34
+ -c "reopen -o l2-cache-entry-size=33k" \
35
+ -c "reopen -o l2-cache-entry-size=128k" \
36
-c "reopen -o refcount-cache-size=256T" \
37
-c "reopen -o overlap-check=constant,overlap-check.template=all" \
38
-c "reopen -o overlap-check=blubb" \
39
diff --git a/tests/qemu-iotests/137.out b/tests/qemu-iotests/137.out
40
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
41
--- a/tests/qemu-iotests/137.out
16
--- a/block/rbd.c
42
+++ b/tests/qemu-iotests/137.out
17
+++ b/block/rbd.c
43
@@ -XXX,XX +XXX,XX @@ cache-size, l2-cache-size and refcount-cache-size may not be set the same time
18
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
44
l2-cache-size may not exceed cache-size
19
"automatically marking the image read-only.");
45
refcount-cache-size may not exceed cache-size
20
r = bdrv_set_read_only(bs, true, &local_err);
46
L2 cache size too big
21
if (r < 0) {
47
+L2 cache entry size must be a power of two between 512 and the cluster size (65536)
22
+ rbd_close(s->image);
48
+L2 cache entry size must be a power of two between 512 and the cluster size (65536)
23
error_propagate(errp, local_err);
49
L2 cache size too big
24
goto failed_open;
50
Conflicting values for qcow2 options 'overlap-check' ('constant') and 'overlap-check.template' ('all')
25
}
51
Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all
52
--
26
--
53
2.13.6
27
2.19.1
54
28
55
29
diff view generated by jsdifflib
1
From: Max Reitz <mreitz@redhat.com>
1
Some block drivers have traditionally changed their node to read-only
2
2
mode without asking the user. This behaviour has been marked deprecated
3
sd_prealloc() will now preallocate the area [old_size, new_size). As
3
since 2.11, expecting users to provide an explicit read-only=on option.
4
before, it rounds to buf_size and may thus overshoot and preallocate
4
5
areas that were not requested to be preallocated. For image creation,
5
Now that we have auto-read-only=on, enable these drivers to make use of
6
this is no change in behavior. For truncation, this is in accordance
6
the option.
7
with the documentation for preallocated truncation.
7
8
8
This is the only use of bdrv_set_read_only(), so we can make it a bit
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
more specific and turn it into a bdrv_apply_auto_read_only() that is
10
more convenient for drivers to use.
11
12
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10
Reviewed-by: Eric Blake <eblake@redhat.com>
13
Reviewed-by: Eric Blake <eblake@redhat.com>
11
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12
---
14
---
13
block/sheepdog.c | 16 +++++-----------
15
include/block/block.h | 3 ++-
14
1 file changed, 5 insertions(+), 11 deletions(-)
16
block.c | 42 +++++++++++++++++++++++++++---------------
15
17
block/bochs.c | 17 ++++++-----------
16
diff --git a/block/sheepdog.c b/block/sheepdog.c
18
block/cloop.c | 16 +++++-----------
17
index XXXXXXX..XXXXXXX 100644
19
block/dmg.c | 16 +++++-----------
18
--- a/block/sheepdog.c
20
block/rbd.c | 15 ++++-----------
19
+++ b/block/sheepdog.c
21
block/vvfat.c | 10 ++--------
20
@@ -XXX,XX +XXX,XX @@ static int do_sd_create(BDRVSheepdogState *s, uint32_t *vdi_id, int snapshot,
22
7 files changed, 51 insertions(+), 68 deletions(-)
23
24
diff --git a/include/block/block.h b/include/block/block.h
25
index XXXXXXX..XXXXXXX 100644
26
--- a/include/block/block.h
27
+++ b/include/block/block.h
28
@@ -XXX,XX +XXX,XX @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
29
bool bdrv_is_read_only(BlockDriverState *bs);
30
int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only,
31
bool ignore_allow_rdw, Error **errp);
32
-int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp);
33
+int bdrv_apply_auto_read_only(BlockDriverState *bs, const char *errmsg,
34
+ Error **errp);
35
bool bdrv_is_writable(BlockDriverState *bs);
36
bool bdrv_is_sg(BlockDriverState *bs);
37
bool bdrv_is_inserted(BlockDriverState *bs);
38
diff --git a/block.c b/block.c
39
index XXXXXXX..XXXXXXX 100644
40
--- a/block.c
41
+++ b/block.c
42
@@ -XXX,XX +XXX,XX @@ int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only,
21
return 0;
43
return 0;
22
}
44
}
23
45
24
-static int sd_prealloc(BlockDriverState *bs, Error **errp)
46
-/* TODO Remove (deprecated since 2.11)
25
+static int sd_prealloc(BlockDriverState *bs, int64_t old_size, int64_t new_size,
47
- * Block drivers are not supposed to automatically change bs->read_only.
26
+ Error **errp)
48
- * Instead, they should just check whether they can provide what the user
49
- * explicitly requested and error out if read-write is requested, but they can
50
- * only provide read-only access. */
51
-int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
52
+/*
53
+ * Called by a driver that can only provide a read-only image.
54
+ *
55
+ * Returns 0 if the node is already read-only or it could switch the node to
56
+ * read-only because BDRV_O_AUTO_RDONLY is set.
57
+ *
58
+ * Returns -EACCES if the node is read-write and BDRV_O_AUTO_RDONLY is not set
59
+ * or bdrv_can_set_read_only() forbids making the node read-only. If @errmsg
60
+ * is not NULL, it is used as the error message for the Error object.
61
+ */
62
+int bdrv_apply_auto_read_only(BlockDriverState *bs, const char *errmsg,
63
+ Error **errp)
27
{
64
{
28
BlockBackend *blk = NULL;
65
int ret = 0;
29
BDRVSheepdogState *base = bs->opaque;
66
30
unsigned long buf_size;
67
- ret = bdrv_can_set_read_only(bs, read_only, false, errp);
31
uint32_t idx, max_idx;
68
- if (ret < 0) {
32
uint32_t object_size;
69
- return ret;
33
- int64_t vdi_size;
70
+ if (!(bs->open_flags & BDRV_O_RDWR)) {
34
void *buf = NULL;
71
+ return 0;
72
+ }
73
+ if (!(bs->open_flags & BDRV_O_AUTO_RDONLY)) {
74
+ goto fail;
75
}
76
77
- bs->read_only = read_only;
78
-
79
- if (read_only) {
80
- bs->open_flags &= ~BDRV_O_RDWR;
81
- } else {
82
- bs->open_flags |= BDRV_O_RDWR;
83
+ ret = bdrv_can_set_read_only(bs, true, false, NULL);
84
+ if (ret < 0) {
85
+ goto fail;
86
}
87
88
+ bs->read_only = true;
89
+ bs->open_flags &= ~BDRV_O_RDWR;
90
+
91
return 0;
92
+
93
+fail:
94
+ error_setg(errp, "%s", errmsg ?: "Image is read-only");
95
+ return -EACCES;
96
}
97
98
void bdrv_get_full_backing_filename_from_filename(const char *backed,
99
diff --git a/block/bochs.c b/block/bochs.c
100
index XXXXXXX..XXXXXXX 100644
101
--- a/block/bochs.c
102
+++ b/block/bochs.c
103
@@ -XXX,XX +XXX,XX @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
104
struct bochs_header bochs;
35
int ret;
105
int ret;
36
106
37
@@ -XXX,XX +XXX,XX @@ static int sd_prealloc(BlockDriverState *bs, Error **errp)
107
+ /* No write support yet */
38
108
+ ret = bdrv_apply_auto_read_only(bs, NULL, errp);
39
blk_set_allow_write_beyond_eof(blk, true);
109
+ if (ret < 0) {
40
110
+ return ret;
41
- vdi_size = blk_getlength(blk);
111
+ }
42
- if (vdi_size < 0) {
112
+
43
- ret = vdi_size;
113
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
44
- goto out;
114
false, errp);
115
if (!bs->file) {
116
return -EINVAL;
117
}
118
119
- if (!bdrv_is_read_only(bs)) {
120
- error_report("Opening bochs images without an explicit read-only=on "
121
- "option is deprecated. Future versions will refuse to "
122
- "open the image instead of automatically marking the "
123
- "image read-only.");
124
- ret = bdrv_set_read_only(bs, true, errp); /* no write support yet */
125
- if (ret < 0) {
126
- return ret;
127
- }
45
- }
128
- }
46
-
129
-
47
object_size = (UINT32_C(1) << base->inode.block_size_shift);
130
ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs));
48
buf_size = MIN(object_size, SD_DATA_OBJ_SIZE);
131
if (ret < 0) {
49
buf = g_malloc0(buf_size);
132
return ret;
50
133
diff --git a/block/cloop.c b/block/cloop.c
51
- max_idx = DIV_ROUND_UP(vdi_size, buf_size);
134
index XXXXXXX..XXXXXXX 100644
52
+ max_idx = DIV_ROUND_UP(new_size, buf_size);
135
--- a/block/cloop.c
53
136
+++ b/block/cloop.c
54
- for (idx = 0; idx < max_idx; idx++) {
137
@@ -XXX,XX +XXX,XX @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags,
55
+ for (idx = old_size / buf_size; idx < max_idx; idx++) {
138
uint32_t offsets_size, max_compressed_block_size = 1, i;
56
/*
139
int ret;
57
* The created image can be a cloned image, so we need to read
140
58
* a data from the source image.
141
+ ret = bdrv_apply_auto_read_only(bs, NULL, errp);
59
@@ -XXX,XX +XXX,XX @@ static int sd_create(const char *filename, QemuOpts *opts,
142
+ if (ret < 0) {
60
goto out;
143
+ return ret;
144
+ }
145
+
146
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
147
false, errp);
148
if (!bs->file) {
149
return -EINVAL;
150
}
151
152
- if (!bdrv_is_read_only(bs)) {
153
- error_report("Opening cloop images without an explicit read-only=on "
154
- "option is deprecated. Future versions will refuse to "
155
- "open the image instead of automatically marking the "
156
- "image read-only.");
157
- ret = bdrv_set_read_only(bs, true, errp);
158
- if (ret < 0) {
159
- return ret;
160
- }
161
- }
162
-
163
/* read header */
164
ret = bdrv_pread(bs->file, 128, &s->block_size, 4);
165
if (ret < 0) {
166
diff --git a/block/dmg.c b/block/dmg.c
167
index XXXXXXX..XXXXXXX 100644
168
--- a/block/dmg.c
169
+++ b/block/dmg.c
170
@@ -XXX,XX +XXX,XX @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags,
171
int64_t offset;
172
int ret;
173
174
+ ret = bdrv_apply_auto_read_only(bs, NULL, errp);
175
+ if (ret < 0) {
176
+ return ret;
177
+ }
178
+
179
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
180
false, errp);
181
if (!bs->file) {
182
return -EINVAL;
183
}
184
185
- if (!bdrv_is_read_only(bs)) {
186
- error_report("Opening dmg images without an explicit read-only=on "
187
- "option is deprecated. Future versions will refuse to "
188
- "open the image instead of automatically marking the "
189
- "image read-only.");
190
- ret = bdrv_set_read_only(bs, true, errp);
191
- if (ret < 0) {
192
- return ret;
193
- }
194
- }
195
-
196
block_module_load_one("dmg-bz2");
197
198
s->n_chunks = 0;
199
diff --git a/block/rbd.c b/block/rbd.c
200
index XXXXXXX..XXXXXXX 100644
201
--- a/block/rbd.c
202
+++ b/block/rbd.c
203
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
204
/* If we are using an rbd snapshot, we must be r/o, otherwise
205
* leave as-is */
206
if (s->snap != NULL) {
207
- if (!bdrv_is_read_only(bs)) {
208
- error_report("Opening rbd snapshots without an explicit "
209
- "read-only=on option is deprecated. Future versions "
210
- "will refuse to open the image instead of "
211
- "automatically marking the image read-only.");
212
- r = bdrv_set_read_only(bs, true, &local_err);
213
- if (r < 0) {
214
- rbd_close(s->image);
215
- error_propagate(errp, local_err);
216
- goto failed_open;
217
- }
218
+ r = bdrv_apply_auto_read_only(bs, "rbd snapshots are read-only", errp);
219
+ if (r < 0) {
220
+ rbd_close(s->image);
221
+ goto failed_open;
61
}
222
}
62
223
}
63
- ret = sd_prealloc(bs, errp);
224
64
+ ret = sd_prealloc(bs, 0, s->inode.vdi_size, errp);
225
diff --git a/block/vvfat.c b/block/vvfat.c
65
226
index XXXXXXX..XXXXXXX 100644
66
bdrv_unref(bs);
227
--- a/block/vvfat.c
228
+++ b/block/vvfat.c
229
@@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
230
"Unable to set VVFAT to 'rw' when drive is read-only");
231
goto fail;
232
}
233
- } else if (!bdrv_is_read_only(bs)) {
234
- error_report("Opening non-rw vvfat images without an explicit "
235
- "read-only=on option is deprecated. Future versions "
236
- "will refuse to open the image instead of "
237
- "automatically marking the image read-only.");
238
- /* read only is the default for safety */
239
- ret = bdrv_set_read_only(bs, true, &local_err);
240
+ } else {
241
+ ret = bdrv_apply_auto_read_only(bs, NULL, errp);
242
if (ret < 0) {
243
- error_propagate(errp, local_err);
244
goto fail;
245
}
67
}
246
}
68
--
247
--
69
2.13.6
248
2.19.1
70
249
71
250
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
If read-only=off, but auto-read-only=on is given, open a read-write NBD
2
connection if the server provides a read-write export, but instead of
3
erroring out for read-only exports, just degrade to read-only.
2
4
3
This patch updates l2_allocate() to support the qcow2 cache returning
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4
L2 slices instead of full L2 tables.
6
Reviewed-by: Eric Blake <eblake@redhat.com>
7
---
8
block/nbd-client.c | 10 +++++-----
9
1 file changed, 5 insertions(+), 5 deletions(-)
5
10
6
The old code simply gets an L2 table from the cache and initializes it
11
diff --git a/block/nbd-client.c b/block/nbd-client.c
7
with zeroes or with the contents of an existing table. With a cache
8
that returns slices instead of tables the idea remains the same, but
9
the code must now iterate over all the slices that are contained in an
10
L2 table.
11
12
Since now we're operating with slices the function can no longer
13
return the newly-allocated table, so it's up to the caller to retrieve
14
the appropriate L2 slice after calling l2_allocate() (note that with
15
this patch the caller is still loading full L2 tables, but we'll deal
16
with that in a separate patch).
17
18
Signed-off-by: Alberto Garcia <berto@igalia.com>
19
Reviewed-by: Eric Blake <eblake@redhat.com>
20
Message-id: 20fc0415bf0e011e29f6487ec86eb06a11f37445.1517840877.git.berto@igalia.com
21
Reviewed-by: Max Reitz <mreitz@redhat.com>
22
Signed-off-by: Max Reitz <mreitz@redhat.com>
23
---
24
block/qcow2-cluster.c | 56 +++++++++++++++++++++++++++++++--------------------
25
1 file changed, 34 insertions(+), 22 deletions(-)
26
27
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
28
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
29
--- a/block/qcow2-cluster.c
13
--- a/block/nbd-client.c
30
+++ b/block/qcow2-cluster.c
14
+++ b/block/nbd-client.c
31
@@ -XXX,XX +XXX,XX @@ int qcow2_write_l1_entry(BlockDriverState *bs, int l1_index)
15
@@ -XXX,XX +XXX,XX @@ int nbd_client_init(BlockDriverState *bs,
32
*
16
logout("Failed to negotiate with the NBD server\n");
33
*/
17
return ret;
34
35
-static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t **table)
36
+static int l2_allocate(BlockDriverState *bs, int l1_index)
37
{
38
BDRVQcow2State *s = bs->opaque;
39
uint64_t old_l2_offset;
40
- uint64_t *l2_table = NULL;
41
+ uint64_t *l2_slice = NULL;
42
+ unsigned slice, slice_size2, n_slices;
43
int64_t l2_offset;
44
int ret;
45
46
@@ -XXX,XX +XXX,XX @@ static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t **table)
47
48
/* allocate a new entry in the l2 cache */
49
50
+ slice_size2 = s->l2_slice_size * sizeof(uint64_t);
51
+ n_slices = s->cluster_size / slice_size2;
52
+
53
trace_qcow2_l2_allocate_get_empty(bs, l1_index);
54
- {
55
+ for (slice = 0; slice < n_slices; slice++) {
56
ret = qcow2_cache_get_empty(bs, s->l2_table_cache,
57
- l2_offset,
58
- (void **) table);
59
+ l2_offset + slice * slice_size2,
60
+ (void **) &l2_slice);
61
if (ret < 0) {
62
goto fail;
63
}
64
65
- l2_table = *table;
66
-
67
if ((old_l2_offset & L1E_OFFSET_MASK) == 0) {
68
- /* if there was no old l2 table, clear the new table */
69
- memset(l2_table, 0, s->l2_size * sizeof(uint64_t));
70
+ /* if there was no old l2 table, clear the new slice */
71
+ memset(l2_slice, 0, slice_size2);
72
} else {
73
- uint64_t *old_table;
74
+ uint64_t *old_slice;
75
+ uint64_t old_l2_slice_offset =
76
+ (old_l2_offset & L1E_OFFSET_MASK) + slice * slice_size2;
77
78
- /* if there was an old l2 table, read it from the disk */
79
+ /* if there was an old l2 table, read a slice from the disk */
80
BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_COW_READ);
81
- ret = qcow2_cache_get(bs, s->l2_table_cache,
82
- old_l2_offset & L1E_OFFSET_MASK,
83
- (void **) &old_table);
84
+ ret = qcow2_cache_get(bs, s->l2_table_cache, old_l2_slice_offset,
85
+ (void **) &old_slice);
86
if (ret < 0) {
87
goto fail;
88
}
89
90
- memcpy(l2_table, old_table, s->cluster_size);
91
+ memcpy(l2_slice, old_slice, slice_size2);
92
93
- qcow2_cache_put(s->l2_table_cache, (void **) &old_table);
94
+ qcow2_cache_put(s->l2_table_cache, (void **) &old_slice);
95
}
96
97
- /* write the l2 table to the file */
98
+ /* write the l2 slice to the file */
99
BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_WRITE);
100
101
trace_qcow2_l2_allocate_write_l2(bs, l1_index);
102
- qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
103
+ qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice);
104
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice);
105
}
18
}
106
19
- if (client->info.flags & NBD_FLAG_READ_ONLY &&
107
ret = qcow2_cache_flush(bs, s->l2_table_cache);
20
- !bdrv_is_read_only(bs)) {
108
@@ -XXX,XX +XXX,XX @@ static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t **table)
21
- error_setg(errp,
109
goto fail;
22
- "request for write access conflicts with read-only export");
110
}
23
- return -EACCES;
111
24
+ if (client->info.flags & NBD_FLAG_READ_ONLY) {
112
- *table = l2_table;
25
+ ret = bdrv_apply_auto_read_only(bs, "NBD export is read-only", errp);
113
trace_qcow2_l2_allocate_done(bs, l1_index, 0);
114
return 0;
115
116
fail:
117
trace_qcow2_l2_allocate_done(bs, l1_index, ret);
118
- if (l2_table != NULL) {
119
- qcow2_cache_put(s->l2_table_cache, (void **) table);
120
+ if (l2_slice != NULL) {
121
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice);
122
}
123
s->l1_table[l1_index] = old_l2_offset;
124
if (l2_offset > 0) {
125
@@ -XXX,XX +XXX,XX @@ static int get_cluster_table(BlockDriverState *bs, uint64_t offset,
126
}
127
} else {
128
/* First allocate a new L2 table (and do COW if needed) */
129
- ret = l2_allocate(bs, l1_index, &l2_table);
130
+ ret = l2_allocate(bs, l1_index);
131
if (ret < 0) {
132
return ret;
133
}
134
@@ -XXX,XX +XXX,XX @@ static int get_cluster_table(BlockDriverState *bs, uint64_t offset,
135
qcow2_free_clusters(bs, l2_offset, s->l2_size * sizeof(uint64_t),
136
QCOW2_DISCARD_OTHER);
137
}
138
+
139
+ /* Get the offset of the newly-allocated l2 table */
140
+ l2_offset = s->l1_table[l1_index] & L1E_OFFSET_MASK;
141
+ assert(offset_into_cluster(s, l2_offset) == 0);
142
+ /* Load the l2 table in memory */
143
+ ret = l2_load(bs, offset, l2_offset, &l2_table);
144
+ if (ret < 0) {
26
+ if (ret < 0) {
145
+ return ret;
27
+ return ret;
146
+ }
28
+ }
147
}
29
}
148
30
if (client->info.flags & NBD_FLAG_SEND_FUA) {
149
/* find the cluster offset for the given disk offset */
31
bs->supported_write_flags = BDRV_REQ_FUA;
150
--
32
--
151
2.13.6
33
2.19.1
152
34
153
35
diff view generated by jsdifflib
1
From: "Daniel P. Berrange" <berrange@redhat.com>
1
If read-only=off, but auto-read-only=on is given, open the file
2
read-write if we have the permissions, but instead of erroring out for
3
read-only files, just degrade to read-only.
2
4
3
qemu-io puts the TTY into non-canonical mode, which means no EOF processing is
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4
done and thus getchar() will never return the EOF constant. Instead we have to
6
Reviewed-by: Eric Blake <eblake@redhat.com>
5
query the TTY attributes to determine the configured EOF character (usually
7
---
6
Ctrl-D / 0x4), and then explicitly check for that value. This fixes the
8
block/file-posix.c | 19 ++++++++++++++++---
7
regression that prevented Ctrl-D from triggering an exit of qemu-io that has
9
1 file changed, 16 insertions(+), 3 deletions(-)
8
existed since readline was first added in
9
10
10
commit 0cf17e181798063c3824c8200ba46f25f54faa1a
11
diff --git a/block/file-posix.c b/block/file-posix.c
11
Author: Stefan Hajnoczi <stefanha@redhat.com>
12
Date: Thu Nov 14 11:54:17 2013 +0100
13
14
qemu-io: use readline.c
15
16
It also ensures that a newline is printed when exiting, to complete the
17
line output by the "qemu-io> " prompt.
18
19
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
20
Reviewed-by: Eric Blake <eblake@redhat.com>
21
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
22
---
23
qemu-io.c | 27 ++++++++++++++++++++++++++-
24
1 file changed, 26 insertions(+), 1 deletion(-)
25
26
diff --git a/qemu-io.c b/qemu-io.c
27
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
28
--- a/qemu-io.c
13
--- a/block/file-posix.c
29
+++ b/qemu-io.c
14
+++ b/block/file-posix.c
30
@@ -XXX,XX +XXX,XX @@
15
@@ -XXX,XX +XXX,XX @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
31
#include "qemu/osdep.h"
16
32
#include <getopt.h>
17
s->fd = -1;
33
#include <libgen.h>
18
fd = qemu_open(filename, s->open_flags, 0644);
34
+#ifndef _WIN32
19
- if (fd < 0) {
35
+#include <termios.h>
20
- ret = -errno;
36
+#endif
21
- error_setg_errno(errp, errno, "Could not open '%s'", filename);
37
22
+ ret = fd < 0 ? -errno : 0;
38
#include "qapi/error.h"
39
#include "qemu-io.h"
40
@@ -XXX,XX +XXX,XX @@ static bool imageOpts;
41
42
static ReadLineState *readline_state;
43
44
+static int ttyEOF;
45
+
23
+
46
+static int get_eof_char(void)
24
+ if (ret == -EACCES || ret == -EROFS) {
47
+{
25
+ /* Try to degrade to read-only, but if it doesn't work, still use the
48
+#ifdef _WIN32
26
+ * normal error message. */
49
+ return 0x4; /* Ctrl-D */
27
+ if (bdrv_apply_auto_read_only(bs, NULL, NULL) == 0) {
50
+#else
28
+ bdrv_flags &= ~BDRV_O_RDWR;
51
+ struct termios tty;
29
+ raw_parse_flags(bdrv_flags, &s->open_flags);
52
+ if (tcgetattr(STDIN_FILENO, &tty) != 0) {
30
+ assert(!(s->open_flags & O_CREAT));
53
+ if (errno == ENOTTY) {
31
+ fd = qemu_open(filename, s->open_flags);
54
+ return 0x0; /* just expect read() == 0 */
32
+ ret = fd < 0 ? -errno : 0;
55
+ } else {
56
+ return 0x4; /* Ctrl-D */
57
+ }
33
+ }
58
+ }
34
+ }
59
+
35
+
60
+ return tty.c_cc[VEOF];
36
+ if (ret < 0) {
61
+#endif
37
+ error_setg_errno(errp, -ret, "Could not open '%s'", filename);
62
+}
38
if (ret == -EROFS) {
63
+
39
ret = -EACCES;
64
static int close_f(BlockBackend *blk, int argc, char **argv)
65
{
66
blk_unref(qemuio_blk);
67
@@ -XXX,XX +XXX,XX @@ static char *fetchline_readline(void)
68
readline_start(readline_state, get_prompt(), 0, readline_func, &line);
69
while (!line) {
70
int ch = getchar();
71
- if (ch == EOF) {
72
+ if (ttyEOF != 0x0 && ch == ttyEOF) {
73
+ printf("\n");
74
break;
75
}
40
}
76
readline_handle_byte(readline_state, ch);
77
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv)
78
qemuio_add_command(&close_cmd);
79
80
if (isatty(STDIN_FILENO)) {
81
+ ttyEOF = get_eof_char();
82
readline_state = readline_init(readline_printf_func,
83
readline_flush_func,
84
NULL,
85
--
41
--
86
2.13.6
42
2.19.1
87
43
88
44
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
If read-only=off, but auto-read-only=on is given, just degrade to
2
read-only.
2
3
3
After the previous patch we're now always using l2_load() in
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4
get_cluster_table() regardless of whether a new L2 table has to be
5
Reviewed-by: Eric Blake <eblake@redhat.com>
5
allocated or not.
6
---
7
block/curl.c | 8 ++++----
8
1 file changed, 4 insertions(+), 4 deletions(-)
6
9
7
This patch refactors that part of the code to use one single l2_load()
10
diff --git a/block/curl.c b/block/curl.c
8
call.
9
10
Signed-off-by: Alberto Garcia <berto@igalia.com>
11
Reviewed-by: Eric Blake <eblake@redhat.com>
12
Reviewed-by: Max Reitz <mreitz@redhat.com>
13
Message-id: ce31758c4a1fadccea7a6ccb93951eb01d95fd4c.1517840877.git.berto@igalia.com
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
16
block/qcow2-cluster.c | 21 +++++++--------------
17
1 file changed, 7 insertions(+), 14 deletions(-)
18
19
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
20
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
21
--- a/block/qcow2-cluster.c
12
--- a/block/curl.c
22
+++ b/block/qcow2-cluster.c
13
+++ b/block/curl.c
23
@@ -XXX,XX +XXX,XX @@ static int get_cluster_table(BlockDriverState *bs, uint64_t offset,
14
@@ -XXX,XX +XXX,XX @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
24
return -EIO;
15
const char *protocol_delimiter;
25
}
16
int ret;
26
17
27
- /* seek the l2 table of the given l2 offset */
28
-
18
-
29
- if (s->l1_table[l1_index] & QCOW_OFLAG_COPIED) {
19
- if (flags & BDRV_O_RDWR) {
30
- /* load the l2 table in memory */
20
- error_setg(errp, "curl block device does not support writes");
31
- ret = l2_load(bs, offset, l2_offset, &l2_table);
21
- return -EROFS;
32
- if (ret < 0) {
22
+ ret = bdrv_apply_auto_read_only(bs, "curl driver does not support writes",
33
- return ret;
23
+ errp);
34
- }
35
- } else {
36
+ if (!(s->l1_table[l1_index] & QCOW_OFLAG_COPIED)) {
37
/* First allocate a new L2 table (and do COW if needed) */
38
ret = l2_allocate(bs, l1_index);
39
if (ret < 0) {
40
@@ -XXX,XX +XXX,XX @@ static int get_cluster_table(BlockDriverState *bs, uint64_t offset,
41
/* Get the offset of the newly-allocated l2 table */
42
l2_offset = s->l1_table[l1_index] & L1E_OFFSET_MASK;
43
assert(offset_into_cluster(s, l2_offset) == 0);
44
- /* Load the l2 table in memory */
45
- ret = l2_load(bs, offset, l2_offset, &l2_table);
46
- if (ret < 0) {
47
- return ret;
48
- }
49
+ }
50
+
51
+ /* load the l2 table in memory */
52
+ ret = l2_load(bs, offset, l2_offset, &l2_table);
53
+ if (ret < 0) {
24
+ if (ret < 0) {
54
+ return ret;
25
+ return ret;
55
}
26
}
56
27
57
/* find the cluster offset for the given disk offset */
28
if (!libcurl_initialized) {
58
--
29
--
59
2.13.6
30
2.19.1
60
31
61
32
diff view generated by jsdifflib
1
From: Max Reitz <mreitz@redhat.com>
1
If read-only=off, but auto-read-only=on is given, open the file
2
read-write if we have the permissions, but instead of erroring out for
3
read-only files, just degrade to read-only.
2
4
3
Pull out the truncation code from the qemu_cluster_create() function so
4
we can later reuse it in qemu_gluster_truncate().
5
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
Reviewed-by: Eric Blake <eblake@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
6
Reviewed-by: Niels de Vos <ndevos@redhat.com>
9
---
7
---
10
block/gluster.c | 74 +++++++++++++++++++++++++++++++--------------------------
8
block/gluster.c | 12 ++++++++++--
11
1 file changed, 40 insertions(+), 34 deletions(-)
9
1 file changed, 10 insertions(+), 2 deletions(-)
12
10
13
diff --git a/block/gluster.c b/block/gluster.c
11
diff --git a/block/gluster.c b/block/gluster.c
14
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
15
--- a/block/gluster.c
13
--- a/block/gluster.c
16
+++ b/block/gluster.c
14
+++ b/block/gluster.c
17
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int qemu_gluster_co_pwrite_zeroes(BlockDriverState *bs,
15
@@ -XXX,XX +XXX,XX @@ static int qemu_gluster_open(BlockDriverState *bs, QDict *options,
18
}
16
qemu_gluster_parse_flags(bdrv_flags, &open_flags);
19
#endif
17
20
18
s->fd = glfs_open(s->glfs, gconf->path, open_flags);
21
+static int qemu_gluster_do_truncate(struct glfs_fd *fd, int64_t offset,
19
- if (!s->fd) {
22
+ PreallocMode prealloc, Error **errp)
20
- ret = -errno;
23
+{
21
+ ret = s->fd ? 0 : -errno;
24
+ switch (prealloc) {
22
+
25
+#ifdef CONFIG_GLUSTERFS_FALLOCATE
23
+ if (ret == -EACCES || ret == -EROFS) {
26
+ case PREALLOC_MODE_FALLOC:
24
+ /* Try to degrade to read-only, but if it doesn't work, still use the
27
+ if (glfs_fallocate(fd, 0, 0, offset)) {
25
+ * normal error message. */
28
+ error_setg_errno(errp, errno, "Could not preallocate data");
26
+ if (bdrv_apply_auto_read_only(bs, NULL, NULL) == 0) {
29
+ return -errno;
27
+ open_flags = (open_flags & ~O_RDWR) | O_RDONLY;
28
+ s->fd = glfs_open(s->glfs, gconf->path, open_flags);
29
+ ret = s->fd ? 0 : -errno;
30
+ }
30
+ }
31
+ break;
32
+#endif /* CONFIG_GLUSTERFS_FALLOCATE */
33
+#ifdef CONFIG_GLUSTERFS_ZEROFILL
34
+ case PREALLOC_MODE_FULL:
35
+ if (glfs_ftruncate(fd, offset)) {
36
+ error_setg_errno(errp, errno, "Could not resize file");
37
+ return -errno;
38
+ }
39
+ if (glfs_zerofill(fd, 0, offset)) {
40
+ error_setg_errno(errp, errno, "Could not zerofill the new area");
41
+ return -errno;
42
+ }
43
+ break;
44
+#endif /* CONFIG_GLUSTERFS_ZEROFILL */
45
+ case PREALLOC_MODE_OFF:
46
+ if (glfs_ftruncate(fd, offset)) {
47
+ error_setg_errno(errp, errno, "Could not resize file");
48
+ return -errno;
49
+ }
50
+ break;
51
+ default:
52
+ error_setg(errp, "Unsupported preallocation mode: %s",
53
+ PreallocMode_str(prealloc));
54
+ return -EINVAL;
55
+ }
56
+
57
+ return 0;
58
+}
59
+
60
static int qemu_gluster_create(const char *filename,
61
QemuOpts *opts, Error **errp)
62
{
63
@@ -XXX,XX +XXX,XX @@ static int qemu_gluster_create(const char *filename,
64
goto out;
65
}
31
}
66
32
67
- switch (prealloc) {
33
s->supports_seek_data = qemu_gluster_test_seek(s->fd);
68
-#ifdef CONFIG_GLUSTERFS_FALLOCATE
69
- case PREALLOC_MODE_FALLOC:
70
- if (glfs_fallocate(fd, 0, 0, total_size)) {
71
- error_setg(errp, "Could not preallocate data for the new file");
72
- ret = -errno;
73
- }
74
- break;
75
-#endif /* CONFIG_GLUSTERFS_FALLOCATE */
76
-#ifdef CONFIG_GLUSTERFS_ZEROFILL
77
- case PREALLOC_MODE_FULL:
78
- if (!glfs_ftruncate(fd, total_size)) {
79
- if (glfs_zerofill(fd, 0, total_size)) {
80
- error_setg(errp, "Could not zerofill the new file");
81
- ret = -errno;
82
- }
83
- } else {
84
- error_setg(errp, "Could not resize file");
85
- ret = -errno;
86
- }
87
- break;
88
-#endif /* CONFIG_GLUSTERFS_ZEROFILL */
89
- case PREALLOC_MODE_OFF:
90
- if (glfs_ftruncate(fd, total_size) != 0) {
91
- ret = -errno;
92
- error_setg(errp, "Could not resize file");
93
- }
94
- break;
95
- default:
96
- ret = -EINVAL;
97
- error_setg(errp, "Unsupported preallocation mode: %s",
98
- PreallocMode_str(prealloc));
99
- break;
100
- }
101
+ ret = qemu_gluster_do_truncate(fd, total_size, prealloc, errp);
102
103
out:
104
if (fd) {
105
--
34
--
106
2.13.6
35
2.19.1
107
36
108
37
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
If read-only=off, but auto-read-only=on is given, open the volume
2
read-write if we have the permissions, but instead of erroring out for
3
read-only volumes, just degrade to read-only.
2
4
3
This function doesn't need any changes to support L2 slices, but since
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4
it's now dealing with slices instead of full tables, the l2_table
6
Reviewed-by: Eric Blake <eblake@redhat.com>
5
variable is renamed for clarity.
7
---
8
block/iscsi.c | 8 +++++---
9
1 file changed, 5 insertions(+), 3 deletions(-)
6
10
7
Signed-off-by: Alberto Garcia <berto@igalia.com>
11
diff --git a/block/iscsi.c b/block/iscsi.c
8
Reviewed-by: Eric Blake <eblake@redhat.com>
9
Reviewed-by: Max Reitz <mreitz@redhat.com>
10
Message-id: 0c5d4b9bf163aa3b49ec19cc512a50d83563f2ad.1517840877.git.berto@igalia.com
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
12
---
13
block/qcow2-cluster.c | 16 ++++++++--------
14
1 file changed, 8 insertions(+), 8 deletions(-)
15
16
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
17
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
18
--- a/block/qcow2-cluster.c
13
--- a/block/iscsi.c
19
+++ b/block/qcow2-cluster.c
14
+++ b/block/iscsi.c
20
@@ -XXX,XX +XXX,XX @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
15
@@ -XXX,XX +XXX,XX @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
21
{
16
/* Check the write protect flag of the LUN if we want to write */
22
BDRVQcow2State *s = bs->opaque;
17
if (iscsilun->type == TYPE_DISK && (flags & BDRV_O_RDWR) &&
23
int l2_index, ret;
18
iscsilun->write_protected) {
24
- uint64_t *l2_table;
19
- error_setg(errp, "Cannot open a write protected LUN as read-write");
25
+ uint64_t *l2_slice;
20
- ret = -EACCES;
26
int64_t cluster_offset;
21
- goto out;
27
int nb_csectors;
22
+ ret = bdrv_apply_auto_read_only(bs, "LUN is write protected", errp);
28
23
+ if (ret < 0) {
29
- ret = get_cluster_table(bs, offset, &l2_table, &l2_index);
24
+ goto out;
30
+ ret = get_cluster_table(bs, offset, &l2_slice, &l2_index);
25
+ }
31
if (ret < 0) {
26
+ flags &= ~BDRV_O_RDWR;
32
return 0;
33
}
27
}
34
28
35
/* Compression can't overwrite anything. Fail if the cluster was already
29
iscsi_readcapacity_sync(iscsilun, &local_err);
36
* allocated. */
37
- cluster_offset = be64_to_cpu(l2_table[l2_index]);
38
+ cluster_offset = be64_to_cpu(l2_slice[l2_index]);
39
if (cluster_offset & L2E_OFFSET_MASK) {
40
- qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
41
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice);
42
return 0;
43
}
44
45
cluster_offset = qcow2_alloc_bytes(bs, compressed_size);
46
if (cluster_offset < 0) {
47
- qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
48
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice);
49
return 0;
50
}
51
52
@@ -XXX,XX +XXX,XX @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
53
/* compressed clusters never have the copied flag */
54
55
BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE_COMPRESSED);
56
- qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
57
- l2_table[l2_index] = cpu_to_be64(cluster_offset);
58
- qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
59
+ qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice);
60
+ l2_slice[l2_index] = cpu_to_be64(cluster_offset);
61
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice);
62
63
return cluster_offset;
64
}
65
--
30
--
66
2.13.6
31
2.19.1
67
32
68
33
diff view generated by jsdifflib
1
From: Paolo Bonzini <pbonzini@redhat.com>
1
While we want machine interfaces like -blockdev and QMP blockdev-add to
2
add as little auto-detection as possible so that management tools are
3
explicit about their needs, -drive is a convenience option for human
4
users. Enabling auto-read-only=on by default there enables users to use
5
read-only images for read-only guest devices without having to specify
6
read-only=on explicitly. If they try to attach the image to a read-write
7
device, they will still get an error message.
2
8
3
Even if an op blocker is present for BLOCK_OP_TYPE_MIRROR_SOURCE,
4
it is checked a bit late and the result is that the target is
5
created even if drive-mirror subsequently fails. Add an early
6
check to avoid this.
7
8
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9
Reviewed-by: Fam Zheng <famz@redhat.com>
10
Reviewed-by: Alberto Garcia <berto@igalia.com>
11
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10
Reviewed-by: Eric Blake <eblake@redhat.com>
12
---
11
---
13
blockdev.c | 5 +++++
12
blockdev.c | 1 +
14
1 file changed, 5 insertions(+)
13
1 file changed, 1 insertion(+)
15
14
16
diff --git a/blockdev.c b/blockdev.c
15
diff --git a/blockdev.c b/blockdev.c
17
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
18
--- a/blockdev.c
17
--- a/blockdev.c
19
+++ b/blockdev.c
18
+++ b/blockdev.c
20
@@ -XXX,XX +XXX,XX @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
19
@@ -XXX,XX +XXX,XX @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
21
return;
20
qdict_set_default_str(bs_opts, BDRV_OPT_CACHE_NO_FLUSH, "off");
22
}
21
qdict_set_default_str(bs_opts, BDRV_OPT_READ_ONLY,
23
22
read_only ? "on" : "off");
24
+ /* Early check to avoid creating target */
23
+ qdict_set_default_str(bs_opts, BDRV_OPT_AUTO_READ_ONLY, "on");
25
+ if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_MIRROR_SOURCE, errp)) {
24
assert((bdrv_flags & BDRV_O_CACHE_MASK) == 0);
26
+ return;
25
27
+ }
26
if (runstate_check(RUN_STATE_INMIGRATE)) {
28
+
29
aio_context = bdrv_get_aio_context(bs);
30
aio_context_acquire(aio_context);
31
32
--
27
--
33
2.13.6
28
2.19.1
34
29
35
30
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2
Reviewed-by: Eric Blake <eblake@redhat.com>
3
---
4
tests/qemu-iotests/232 | 147 +++++++++++++++++++++++++++++++++++++
5
tests/qemu-iotests/232.out | 59 +++++++++++++++
6
tests/qemu-iotests/group | 1 +
7
3 files changed, 207 insertions(+)
8
create mode 100755 tests/qemu-iotests/232
9
create mode 100644 tests/qemu-iotests/232.out
2
10
3
This function doesn't need any changes to support L2 slices, but since
11
diff --git a/tests/qemu-iotests/232 b/tests/qemu-iotests/232
4
it's now dealing with slices instead of full tables, the l2_table
12
new file mode 100755
5
variable is renamed for clarity.
13
index XXXXXXX..XXXXXXX
6
14
--- /dev/null
7
Signed-off-by: Alberto Garcia <berto@igalia.com>
15
+++ b/tests/qemu-iotests/232
8
Reviewed-by: Eric Blake <eblake@redhat.com>
16
@@ -XXX,XX +XXX,XX @@
9
Reviewed-by: Max Reitz <mreitz@redhat.com>
17
+#!/bin/bash
10
Message-id: 78bcc54bc632574dd0b900a77a00a1b6ffc359e6.1517840877.git.berto@igalia.com
18
+#
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
19
+# Test for auto-read-only
12
---
20
+#
13
block/qcow2-cluster.c | 6 +++---
21
+# Copyright (C) 2018 Red Hat, Inc.
14
1 file changed, 3 insertions(+), 3 deletions(-)
22
+#
15
23
+# This program is free software; you can redistribute it and/or modify
16
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
24
+# it under the terms of the GNU General Public License as published by
25
+# the Free Software Foundation; either version 2 of the License, or
26
+# (at your option) any later version.
27
+#
28
+# This program is distributed in the hope that it will be useful,
29
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
30
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31
+# GNU General Public License for more details.
32
+#
33
+# You should have received a copy of the GNU General Public License
34
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
35
+#
36
+
37
+# creator
38
+owner=kwolf@redhat.com
39
+
40
+seq=`basename $0`
41
+echo "QA output created by $seq"
42
+
43
+here=`pwd`
44
+status=1    # failure is the default!
45
+
46
+_cleanup()
47
+{
48
+ _cleanup_test_img
49
+ rm -f $TEST_IMG.snap
50
+}
51
+trap "_cleanup; exit \$status" 0 1 2 3 15
52
+
53
+# get standard environment, filters and checks
54
+. ./common.rc
55
+. ./common.filter
56
+
57
+_supported_fmt generic
58
+_supported_proto file
59
+_supported_os Linux
60
+
61
+function do_run_qemu()
62
+{
63
+ echo Testing: "$@"
64
+ (
65
+ if ! test -t 0; then
66
+ while read cmd; do
67
+ echo $cmd
68
+ done
69
+ fi
70
+ echo quit
71
+ ) | $QEMU -nographic -monitor stdio -nodefaults "$@"
72
+ echo
73
+}
74
+
75
+function run_qemu()
76
+{
77
+ do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp |
78
+ _filter_generated_node_ids | _filter_imgfmt
79
+}
80
+
81
+function run_qemu_info_block()
82
+{
83
+ echo "info block -n" | run_qemu "$@" | grep -e "(file" -e "QEMU_PROG"
84
+}
85
+
86
+size=128M
87
+
88
+_make_test_img $size
89
+
90
+echo
91
+echo "=== -drive with read-write image: read-only/auto-read-only combinations ==="
92
+echo
93
+
94
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=off
95
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=on
96
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on
97
+echo
98
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=off
99
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=on
100
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off
101
+echo
102
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=off
103
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=on
104
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none
105
+
106
+echo
107
+echo "=== -drive with read-only image: read-only/auto-read-only combinations ==="
108
+echo
109
+
110
+chmod a-w $TEST_IMG
111
+
112
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=off
113
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=on
114
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on
115
+echo
116
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=off
117
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=on
118
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off
119
+echo
120
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=off
121
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=on
122
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none
123
+
124
+echo
125
+echo "=== -blockdev with read-write image: read-only/auto-read-only combinations ==="
126
+echo
127
+
128
+chmod a+w $TEST_IMG
129
+
130
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=off
131
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=on
132
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on
133
+echo
134
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=off
135
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=on
136
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off
137
+echo
138
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=off
139
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=on
140
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0
141
+
142
+echo
143
+echo "=== -blockdev with read-only image: read-only/auto-read-only combinations ==="
144
+echo
145
+
146
+chmod a-w $TEST_IMG
147
+
148
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=off
149
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=on
150
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on
151
+echo
152
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=off
153
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=on
154
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off
155
+echo
156
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=off
157
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=on
158
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0
159
+
160
+# success, all done
161
+echo "*** done"
162
+rm -f $seq.full
163
+status=0
164
diff --git a/tests/qemu-iotests/232.out b/tests/qemu-iotests/232.out
165
new file mode 100644
166
index XXXXXXX..XXXXXXX
167
--- /dev/null
168
+++ b/tests/qemu-iotests/232.out
169
@@ -XXX,XX +XXX,XX @@
170
+QA output created by 232
171
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
172
+
173
+=== -drive with read-write image: read-only/auto-read-only combinations ===
174
+
175
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
176
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
177
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
178
+
179
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
180
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
181
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
182
+
183
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
184
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
185
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
186
+
187
+=== -drive with read-only image: read-only/auto-read-only combinations ===
188
+
189
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
190
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
191
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
192
+
193
+QEMU_PROG: -drive driver=file,file=TEST_DIR/t.IMGFMT,if=none,read-only=off,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
194
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
195
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
196
+
197
+QEMU_PROG: -drive driver=file,file=TEST_DIR/t.IMGFMT,if=none,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
198
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
199
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
200
+
201
+=== -blockdev with read-write image: read-only/auto-read-only combinations ===
202
+
203
+node0: TEST_DIR/t.IMGFMT (file, read-only)
204
+node0: TEST_DIR/t.IMGFMT (file, read-only)
205
+node0: TEST_DIR/t.IMGFMT (file, read-only)
206
+
207
+node0: TEST_DIR/t.IMGFMT (file)
208
+node0: TEST_DIR/t.IMGFMT (file)
209
+node0: TEST_DIR/t.IMGFMT (file)
210
+
211
+node0: TEST_DIR/t.IMGFMT (file)
212
+node0: TEST_DIR/t.IMGFMT (file)
213
+node0: TEST_DIR/t.IMGFMT (file)
214
+
215
+=== -blockdev with read-only image: read-only/auto-read-only combinations ===
216
+
217
+node0: TEST_DIR/t.IMGFMT (file, read-only)
218
+node0: TEST_DIR/t.IMGFMT (file, read-only)
219
+node0: TEST_DIR/t.IMGFMT (file, read-only)
220
+
221
+QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,read-only=off,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
222
+node0: TEST_DIR/t.IMGFMT (file, read-only)
223
+QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
224
+
225
+QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
226
+node0: TEST_DIR/t.IMGFMT (file, read-only)
227
+QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
228
+*** done
229
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
17
index XXXXXXX..XXXXXXX 100644
230
index XXXXXXX..XXXXXXX 100644
18
--- a/block/qcow2-cluster.c
231
--- a/tests/qemu-iotests/group
19
+++ b/block/qcow2-cluster.c
232
+++ b/tests/qemu-iotests/group
20
@@ -XXX,XX +XXX,XX @@ static int count_contiguous_clusters(int nb_clusters, int cluster_size,
233
@@ -XXX,XX +XXX,XX @@
21
234
227 auto quick
22
/*
235
229 auto quick
23
* Checks how many consecutive unallocated clusters in a given L2
236
231 auto quick
24
- * table have the same cluster type.
237
+232 auto quick
25
+ * slice have the same cluster type.
26
*/
27
static int count_contiguous_clusters_unallocated(int nb_clusters,
28
- uint64_t *l2_table,
29
+ uint64_t *l2_slice,
30
QCow2ClusterType wanted_type)
31
{
32
int i;
33
@@ -XXX,XX +XXX,XX @@ static int count_contiguous_clusters_unallocated(int nb_clusters,
34
assert(wanted_type == QCOW2_CLUSTER_ZERO_PLAIN ||
35
wanted_type == QCOW2_CLUSTER_UNALLOCATED);
36
for (i = 0; i < nb_clusters; i++) {
37
- uint64_t entry = be64_to_cpu(l2_table[i]);
38
+ uint64_t entry = be64_to_cpu(l2_slice[i]);
39
QCow2ClusterType type = qcow2_get_cluster_type(entry);
40
41
if (type != wanted_type) {
42
--
238
--
43
2.13.6
239
2.19.1
44
240
45
241
diff view generated by jsdifflib
1
From: Max Reitz <mreitz@redhat.com>
1
From: Max Reitz <mreitz@redhat.com>
2
2
3
This adds some whitespace into the option help (including indentation)
4
and puts angle brackets around the type names. Furthermore, the list
5
name is no longer printed as part of every line, but only once in
6
advance, and only if the caller did not print a caption already.
7
8
This patch also restores the description alignment we had before commit
9
9cbef9d68ee1d8d0, just at 24 instead of 16 characters like we used to.
10
This increase is because now we have the type and two spaces of
11
indentation before the description, and with a usual type name length of
12
three chracters, this sums up to eight additional characters -- which
13
means that we now need 24 characters to get the same amount of padding
14
for most options. Also, 24 is a third of 80, which makes it kind of a
15
round number in terminal terms.
16
17
Finally, this patch amends the reference output of iotest 082 to match
18
the changes (and thus makes it pass again).
19
3
Signed-off-by: Max Reitz <mreitz@redhat.com>
20
Signed-off-by: Max Reitz <mreitz@redhat.com>
4
Reviewed-by: Eric Blake <eblake@redhat.com>
21
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
22
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
6
---
23
---
7
block/sheepdog.c | 15 ++++++++++++---
24
include/qemu/option.h | 2 +-
8
1 file changed, 12 insertions(+), 3 deletions(-)
25
qemu-img.c | 4 +-
26
util/qemu-option.c | 32 +-
27
tests/qemu-iotests/082.out | 956 ++++++++++++++++++-------------------
28
4 files changed, 507 insertions(+), 487 deletions(-)
9
29
10
diff --git a/block/sheepdog.c b/block/sheepdog.c
30
diff --git a/include/qemu/option.h b/include/qemu/option.h
11
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
12
--- a/block/sheepdog.c
32
--- a/include/qemu/option.h
13
+++ b/block/sheepdog.c
33
+++ b/include/qemu/option.h
14
@@ -XXX,XX +XXX,XX @@ static int sd_truncate(BlockDriverState *bs, int64_t offset,
34
@@ -XXX,XX +XXX,XX @@ typedef int (*qemu_opts_loopfunc)(void *opaque, QemuOpts *opts, Error **errp);
15
int ret, fd;
35
int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func,
16
unsigned int datalen;
36
void *opaque, Error **errp);
17
uint64_t max_vdi_size;
37
void qemu_opts_print(QemuOpts *opts, const char *sep);
18
+ int64_t old_size = s->inode.vdi_size;
38
-void qemu_opts_print_help(QemuOptsList *list);
19
39
+void qemu_opts_print_help(QemuOptsList *list, bool print_caption);
20
- if (prealloc != PREALLOC_MODE_OFF) {
40
void qemu_opts_free(QemuOptsList *list);
21
+ if (prealloc != PREALLOC_MODE_OFF && prealloc != PREALLOC_MODE_FULL) {
41
QemuOptsList *qemu_opts_append(QemuOptsList *dst, QemuOptsList *list);
22
error_setg(errp, "Unsupported preallocation mode '%s'",
42
23
PreallocMode_str(prealloc));
43
diff --git a/qemu-img.c b/qemu-img.c
24
return -ENOTSUP;
44
index XXXXXXX..XXXXXXX 100644
45
--- a/qemu-img.c
46
+++ b/qemu-img.c
47
@@ -XXX,XX +XXX,XX @@ static int print_block_option_help(const char *filename, const char *fmt)
25
}
48
}
26
49
27
max_vdi_size = (UINT64_C(1) << s->inode.block_size_shift) * MAX_DATA_OBJS;
50
printf("Supported options:\n");
28
- if (offset < s->inode.vdi_size) {
51
- qemu_opts_print_help(create_opts);
29
+ if (offset < old_size) {
52
+ qemu_opts_print_help(create_opts, false);
30
error_setg(errp, "shrinking is not supported");
53
qemu_opts_free(create_opts);
31
return -EINVAL;
54
return 0;
32
} else if (offset > max_vdi_size) {
55
}
33
@@ -XXX,XX +XXX,XX @@ static int sd_truncate(BlockDriverState *bs, int64_t offset,
56
@@ -XXX,XX +XXX,XX @@ static int print_amend_option_help(const char *format)
34
57
assert(drv->create_opts);
35
if (ret < 0) {
58
36
error_setg_errno(errp, -ret, "failed to update an inode");
59
printf("Creation options for '%s':\n", format);
37
+ return ret;
60
- qemu_opts_print_help(drv->create_opts);
61
+ qemu_opts_print_help(drv->create_opts, false);
62
printf("\nNote that not all of these options may be amendable.\n");
63
return 0;
64
}
65
diff --git a/util/qemu-option.c b/util/qemu-option.c
66
index XXXXXXX..XXXXXXX 100644
67
--- a/util/qemu-option.c
68
+++ b/util/qemu-option.c
69
@@ -XXX,XX +XXX,XX @@ static const char *opt_type_to_string(enum QemuOptType type)
70
g_assert_not_reached();
71
}
72
73
-void qemu_opts_print_help(QemuOptsList *list)
74
+/**
75
+ * Print the list of options available in the given list. If
76
+ * @print_caption is true, a caption (including the list name, if it
77
+ * exists) is printed. The options itself will be indented, so
78
+ * @print_caption should only be set to false if the caller prints its
79
+ * own custom caption (so that the indentation makes sense).
80
+ */
81
+void qemu_opts_print_help(QemuOptsList *list, bool print_caption)
82
{
83
QemuOptDesc *desc;
84
int i;
85
@@ -XXX,XX +XXX,XX @@ void qemu_opts_print_help(QemuOptsList *list)
86
desc = list->desc;
87
while (desc && desc->name) {
88
GString *str = g_string_new(NULL);
89
- if (list->name) {
90
- g_string_append_printf(str, "%s.", list->name);
91
- }
92
- g_string_append_printf(str, "%s=%s", desc->name,
93
+ g_string_append_printf(str, " %s=<%s>", desc->name,
94
opt_type_to_string(desc->type));
95
if (desc->help) {
96
+ if (str->len < 24) {
97
+ g_string_append_printf(str, "%*s", 24 - (int)str->len, "");
98
+ }
99
g_string_append_printf(str, " - %s", desc->help);
100
}
101
g_ptr_array_add(array, g_string_free(str, false));
102
@@ -XXX,XX +XXX,XX @@ void qemu_opts_print_help(QemuOptsList *list)
38
}
103
}
39
104
40
- return ret;
105
g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0);
41
+ if (prealloc == PREALLOC_MODE_FULL) {
106
+ if (print_caption && array->len > 0) {
42
+ ret = sd_prealloc(bs, old_size, offset, errp);
107
+ if (list->name) {
43
+ if (ret < 0) {
108
+ printf("%s options:\n", list->name);
44
+ return ret;
109
+ } else {
110
+ printf("Options:\n");
111
+ }
112
+ } else if (array->len == 0) {
113
+ if (list->name) {
114
+ printf("There are no options for %s.\n", list->name);
115
+ } else {
116
+ printf("No options available.\n");
45
+ }
117
+ }
46
+ }
118
+ }
47
+
119
for (i = 0; i < array->len; i++) {
48
+ return 0;
120
printf("%s\n", (char *)array->pdata[i]);
49
}
121
}
50
122
@@ -XXX,XX +XXX,XX @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params,
51
/*
123
opts = opts_parse(list, params, permit_abbrev, false, &invalidp, &err);
124
if (err) {
125
if (invalidp && has_help_option(params)) {
126
- qemu_opts_print_help(list);
127
+ qemu_opts_print_help(list, true);
128
error_free(err);
129
} else {
130
error_report_err(err);
131
diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out
132
index XXXXXXX..XXXXXXX 100644
133
--- a/tests/qemu-iotests/082.out
134
+++ b/tests/qemu-iotests/082.out
135
@@ -XXX,XX +XXX,XX @@ cluster_size: 8192
136
137
Testing: create -f qcow2 -o help TEST_DIR/t.qcow2 128M
138
Supported options:
139
-size Virtual disk size
140
-compat Compatibility level (0.10 or 1.1)
141
-backing_file File name of a base image
142
-backing_fmt Image format of the base image
143
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
144
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
145
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
146
-encrypt.cipher-alg Name of encryption cipher algorithm
147
-encrypt.cipher-mode Name of encryption cipher mode
148
-encrypt.ivgen-alg Name of IV generator algorithm
149
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
150
-encrypt.hash-alg Name of encryption hash algorithm
151
-encrypt.iter-time Time to spend in PBKDF in milliseconds
152
-cluster_size qcow2 cluster size
153
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
154
-lazy_refcounts Postpone refcount updates
155
-refcount_bits Width of a reference count entry in bits
156
-nocow Turn off copy-on-write (valid only on btrfs)
157
+ backing_file=<str> - File name of a base image
158
+ backing_fmt=<str> - Image format of the base image
159
+ cluster_size=<size> - qcow2 cluster size
160
+ compat=<str> - Compatibility level (0.10 or 1.1)
161
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
162
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
163
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
164
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
165
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
166
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
167
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
168
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
169
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
170
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
171
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
172
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
173
+ refcount_bits=<num> - Width of a reference count entry in bits
174
+ size=<size> - Virtual disk size
175
176
Testing: create -f qcow2 -o ? TEST_DIR/t.qcow2 128M
177
Supported options:
178
-size Virtual disk size
179
-compat Compatibility level (0.10 or 1.1)
180
-backing_file File name of a base image
181
-backing_fmt Image format of the base image
182
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
183
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
184
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
185
-encrypt.cipher-alg Name of encryption cipher algorithm
186
-encrypt.cipher-mode Name of encryption cipher mode
187
-encrypt.ivgen-alg Name of IV generator algorithm
188
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
189
-encrypt.hash-alg Name of encryption hash algorithm
190
-encrypt.iter-time Time to spend in PBKDF in milliseconds
191
-cluster_size qcow2 cluster size
192
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
193
-lazy_refcounts Postpone refcount updates
194
-refcount_bits Width of a reference count entry in bits
195
-nocow Turn off copy-on-write (valid only on btrfs)
196
+ backing_file=<str> - File name of a base image
197
+ backing_fmt=<str> - Image format of the base image
198
+ cluster_size=<size> - qcow2 cluster size
199
+ compat=<str> - Compatibility level (0.10 or 1.1)
200
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
201
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
202
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
203
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
204
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
205
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
206
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
207
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
208
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
209
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
210
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
211
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
212
+ refcount_bits=<num> - Width of a reference count entry in bits
213
+ size=<size> - Virtual disk size
214
215
Testing: create -f qcow2 -o cluster_size=4k,help TEST_DIR/t.qcow2 128M
216
Supported options:
217
-size Virtual disk size
218
-compat Compatibility level (0.10 or 1.1)
219
-backing_file File name of a base image
220
-backing_fmt Image format of the base image
221
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
222
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
223
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
224
-encrypt.cipher-alg Name of encryption cipher algorithm
225
-encrypt.cipher-mode Name of encryption cipher mode
226
-encrypt.ivgen-alg Name of IV generator algorithm
227
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
228
-encrypt.hash-alg Name of encryption hash algorithm
229
-encrypt.iter-time Time to spend in PBKDF in milliseconds
230
-cluster_size qcow2 cluster size
231
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
232
-lazy_refcounts Postpone refcount updates
233
-refcount_bits Width of a reference count entry in bits
234
-nocow Turn off copy-on-write (valid only on btrfs)
235
+ backing_file=<str> - File name of a base image
236
+ backing_fmt=<str> - Image format of the base image
237
+ cluster_size=<size> - qcow2 cluster size
238
+ compat=<str> - Compatibility level (0.10 or 1.1)
239
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
240
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
241
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
242
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
243
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
244
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
245
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
246
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
247
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
248
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
249
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
250
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
251
+ refcount_bits=<num> - Width of a reference count entry in bits
252
+ size=<size> - Virtual disk size
253
254
Testing: create -f qcow2 -o cluster_size=4k,? TEST_DIR/t.qcow2 128M
255
Supported options:
256
-size Virtual disk size
257
-compat Compatibility level (0.10 or 1.1)
258
-backing_file File name of a base image
259
-backing_fmt Image format of the base image
260
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
261
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
262
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
263
-encrypt.cipher-alg Name of encryption cipher algorithm
264
-encrypt.cipher-mode Name of encryption cipher mode
265
-encrypt.ivgen-alg Name of IV generator algorithm
266
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
267
-encrypt.hash-alg Name of encryption hash algorithm
268
-encrypt.iter-time Time to spend in PBKDF in milliseconds
269
-cluster_size qcow2 cluster size
270
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
271
-lazy_refcounts Postpone refcount updates
272
-refcount_bits Width of a reference count entry in bits
273
-nocow Turn off copy-on-write (valid only on btrfs)
274
+ backing_file=<str> - File name of a base image
275
+ backing_fmt=<str> - Image format of the base image
276
+ cluster_size=<size> - qcow2 cluster size
277
+ compat=<str> - Compatibility level (0.10 or 1.1)
278
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
279
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
280
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
281
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
282
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
283
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
284
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
285
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
286
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
287
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
288
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
289
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
290
+ refcount_bits=<num> - Width of a reference count entry in bits
291
+ size=<size> - Virtual disk size
292
293
Testing: create -f qcow2 -o help,cluster_size=4k TEST_DIR/t.qcow2 128M
294
Supported options:
295
-size Virtual disk size
296
-compat Compatibility level (0.10 or 1.1)
297
-backing_file File name of a base image
298
-backing_fmt Image format of the base image
299
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
300
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
301
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
302
-encrypt.cipher-alg Name of encryption cipher algorithm
303
-encrypt.cipher-mode Name of encryption cipher mode
304
-encrypt.ivgen-alg Name of IV generator algorithm
305
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
306
-encrypt.hash-alg Name of encryption hash algorithm
307
-encrypt.iter-time Time to spend in PBKDF in milliseconds
308
-cluster_size qcow2 cluster size
309
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
310
-lazy_refcounts Postpone refcount updates
311
-refcount_bits Width of a reference count entry in bits
312
-nocow Turn off copy-on-write (valid only on btrfs)
313
+ backing_file=<str> - File name of a base image
314
+ backing_fmt=<str> - Image format of the base image
315
+ cluster_size=<size> - qcow2 cluster size
316
+ compat=<str> - Compatibility level (0.10 or 1.1)
317
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
318
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
319
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
320
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
321
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
322
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
323
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
324
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
325
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
326
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
327
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
328
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
329
+ refcount_bits=<num> - Width of a reference count entry in bits
330
+ size=<size> - Virtual disk size
331
332
Testing: create -f qcow2 -o ?,cluster_size=4k TEST_DIR/t.qcow2 128M
333
Supported options:
334
-size Virtual disk size
335
-compat Compatibility level (0.10 or 1.1)
336
-backing_file File name of a base image
337
-backing_fmt Image format of the base image
338
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
339
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
340
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
341
-encrypt.cipher-alg Name of encryption cipher algorithm
342
-encrypt.cipher-mode Name of encryption cipher mode
343
-encrypt.ivgen-alg Name of IV generator algorithm
344
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
345
-encrypt.hash-alg Name of encryption hash algorithm
346
-encrypt.iter-time Time to spend in PBKDF in milliseconds
347
-cluster_size qcow2 cluster size
348
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
349
-lazy_refcounts Postpone refcount updates
350
-refcount_bits Width of a reference count entry in bits
351
-nocow Turn off copy-on-write (valid only on btrfs)
352
+ backing_file=<str> - File name of a base image
353
+ backing_fmt=<str> - Image format of the base image
354
+ cluster_size=<size> - qcow2 cluster size
355
+ compat=<str> - Compatibility level (0.10 or 1.1)
356
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
357
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
358
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
359
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
360
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
361
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
362
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
363
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
364
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
365
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
366
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
367
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
368
+ refcount_bits=<num> - Width of a reference count entry in bits
369
+ size=<size> - Virtual disk size
370
371
Testing: create -f qcow2 -o cluster_size=4k -o help TEST_DIR/t.qcow2 128M
372
Supported options:
373
-size Virtual disk size
374
-compat Compatibility level (0.10 or 1.1)
375
-backing_file File name of a base image
376
-backing_fmt Image format of the base image
377
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
378
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
379
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
380
-encrypt.cipher-alg Name of encryption cipher algorithm
381
-encrypt.cipher-mode Name of encryption cipher mode
382
-encrypt.ivgen-alg Name of IV generator algorithm
383
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
384
-encrypt.hash-alg Name of encryption hash algorithm
385
-encrypt.iter-time Time to spend in PBKDF in milliseconds
386
-cluster_size qcow2 cluster size
387
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
388
-lazy_refcounts Postpone refcount updates
389
-refcount_bits Width of a reference count entry in bits
390
-nocow Turn off copy-on-write (valid only on btrfs)
391
+ backing_file=<str> - File name of a base image
392
+ backing_fmt=<str> - Image format of the base image
393
+ cluster_size=<size> - qcow2 cluster size
394
+ compat=<str> - Compatibility level (0.10 or 1.1)
395
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
396
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
397
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
398
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
399
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
400
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
401
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
402
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
403
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
404
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
405
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
406
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
407
+ refcount_bits=<num> - Width of a reference count entry in bits
408
+ size=<size> - Virtual disk size
409
410
Testing: create -f qcow2 -o cluster_size=4k -o ? TEST_DIR/t.qcow2 128M
411
Supported options:
412
-size Virtual disk size
413
-compat Compatibility level (0.10 or 1.1)
414
-backing_file File name of a base image
415
-backing_fmt Image format of the base image
416
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
417
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
418
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
419
-encrypt.cipher-alg Name of encryption cipher algorithm
420
-encrypt.cipher-mode Name of encryption cipher mode
421
-encrypt.ivgen-alg Name of IV generator algorithm
422
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
423
-encrypt.hash-alg Name of encryption hash algorithm
424
-encrypt.iter-time Time to spend in PBKDF in milliseconds
425
-cluster_size qcow2 cluster size
426
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
427
-lazy_refcounts Postpone refcount updates
428
-refcount_bits Width of a reference count entry in bits
429
-nocow Turn off copy-on-write (valid only on btrfs)
430
+ backing_file=<str> - File name of a base image
431
+ backing_fmt=<str> - Image format of the base image
432
+ cluster_size=<size> - qcow2 cluster size
433
+ compat=<str> - Compatibility level (0.10 or 1.1)
434
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
435
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
436
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
437
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
438
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
439
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
440
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
441
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
442
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
443
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
444
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
445
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
446
+ refcount_bits=<num> - Width of a reference count entry in bits
447
+ size=<size> - Virtual disk size
448
449
Testing: create -f qcow2 -u -o backing_file=TEST_DIR/t.qcow2,,help TEST_DIR/t.qcow2 128M
450
Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/t.qcow2,,help cluster_size=65536 lazy_refcounts=off refcount_bits=16
451
@@ -XXX,XX +XXX,XX @@ qemu-img: Invalid option list: ,,
452
453
Testing: create -f qcow2 -o help
454
Supported options:
455
-size Virtual disk size
456
-compat Compatibility level (0.10 or 1.1)
457
-backing_file File name of a base image
458
-backing_fmt Image format of the base image
459
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
460
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
461
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
462
-encrypt.cipher-alg Name of encryption cipher algorithm
463
-encrypt.cipher-mode Name of encryption cipher mode
464
-encrypt.ivgen-alg Name of IV generator algorithm
465
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
466
-encrypt.hash-alg Name of encryption hash algorithm
467
-encrypt.iter-time Time to spend in PBKDF in milliseconds
468
-cluster_size qcow2 cluster size
469
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
470
-lazy_refcounts Postpone refcount updates
471
-refcount_bits Width of a reference count entry in bits
472
+ backing_file=<str> - File name of a base image
473
+ backing_fmt=<str> - Image format of the base image
474
+ cluster_size=<size> - qcow2 cluster size
475
+ compat=<str> - Compatibility level (0.10 or 1.1)
476
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
477
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
478
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
479
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
480
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
481
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
482
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
483
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
484
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
485
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
486
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
487
+ refcount_bits=<num> - Width of a reference count entry in bits
488
+ size=<size> - Virtual disk size
489
490
Testing: create -o help
491
Supported options:
492
-size Virtual disk size
493
+ size=<size> - Virtual disk size
494
495
Testing: create -f bochs -o help
496
qemu-img: Format driver 'bochs' does not support image creation
497
@@ -XXX,XX +XXX,XX @@ cluster_size: 8192
498
499
Testing: convert -O qcow2 -o help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
500
Supported options:
501
-size Virtual disk size
502
-compat Compatibility level (0.10 or 1.1)
503
-backing_file File name of a base image
504
-backing_fmt Image format of the base image
505
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
506
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
507
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
508
-encrypt.cipher-alg Name of encryption cipher algorithm
509
-encrypt.cipher-mode Name of encryption cipher mode
510
-encrypt.ivgen-alg Name of IV generator algorithm
511
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
512
-encrypt.hash-alg Name of encryption hash algorithm
513
-encrypt.iter-time Time to spend in PBKDF in milliseconds
514
-cluster_size qcow2 cluster size
515
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
516
-lazy_refcounts Postpone refcount updates
517
-refcount_bits Width of a reference count entry in bits
518
-nocow Turn off copy-on-write (valid only on btrfs)
519
+ backing_file=<str> - File name of a base image
520
+ backing_fmt=<str> - Image format of the base image
521
+ cluster_size=<size> - qcow2 cluster size
522
+ compat=<str> - Compatibility level (0.10 or 1.1)
523
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
524
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
525
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
526
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
527
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
528
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
529
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
530
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
531
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
532
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
533
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
534
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
535
+ refcount_bits=<num> - Width of a reference count entry in bits
536
+ size=<size> - Virtual disk size
537
538
Testing: convert -O qcow2 -o ? TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
539
Supported options:
540
-size Virtual disk size
541
-compat Compatibility level (0.10 or 1.1)
542
-backing_file File name of a base image
543
-backing_fmt Image format of the base image
544
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
545
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
546
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
547
-encrypt.cipher-alg Name of encryption cipher algorithm
548
-encrypt.cipher-mode Name of encryption cipher mode
549
-encrypt.ivgen-alg Name of IV generator algorithm
550
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
551
-encrypt.hash-alg Name of encryption hash algorithm
552
-encrypt.iter-time Time to spend in PBKDF in milliseconds
553
-cluster_size qcow2 cluster size
554
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
555
-lazy_refcounts Postpone refcount updates
556
-refcount_bits Width of a reference count entry in bits
557
-nocow Turn off copy-on-write (valid only on btrfs)
558
+ backing_file=<str> - File name of a base image
559
+ backing_fmt=<str> - Image format of the base image
560
+ cluster_size=<size> - qcow2 cluster size
561
+ compat=<str> - Compatibility level (0.10 or 1.1)
562
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
563
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
564
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
565
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
566
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
567
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
568
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
569
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
570
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
571
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
572
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
573
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
574
+ refcount_bits=<num> - Width of a reference count entry in bits
575
+ size=<size> - Virtual disk size
576
577
Testing: convert -O qcow2 -o cluster_size=4k,help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
578
Supported options:
579
-size Virtual disk size
580
-compat Compatibility level (0.10 or 1.1)
581
-backing_file File name of a base image
582
-backing_fmt Image format of the base image
583
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
584
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
585
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
586
-encrypt.cipher-alg Name of encryption cipher algorithm
587
-encrypt.cipher-mode Name of encryption cipher mode
588
-encrypt.ivgen-alg Name of IV generator algorithm
589
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
590
-encrypt.hash-alg Name of encryption hash algorithm
591
-encrypt.iter-time Time to spend in PBKDF in milliseconds
592
-cluster_size qcow2 cluster size
593
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
594
-lazy_refcounts Postpone refcount updates
595
-refcount_bits Width of a reference count entry in bits
596
-nocow Turn off copy-on-write (valid only on btrfs)
597
+ backing_file=<str> - File name of a base image
598
+ backing_fmt=<str> - Image format of the base image
599
+ cluster_size=<size> - qcow2 cluster size
600
+ compat=<str> - Compatibility level (0.10 or 1.1)
601
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
602
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
603
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
604
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
605
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
606
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
607
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
608
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
609
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
610
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
611
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
612
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
613
+ refcount_bits=<num> - Width of a reference count entry in bits
614
+ size=<size> - Virtual disk size
615
616
Testing: convert -O qcow2 -o cluster_size=4k,? TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
617
Supported options:
618
-size Virtual disk size
619
-compat Compatibility level (0.10 or 1.1)
620
-backing_file File name of a base image
621
-backing_fmt Image format of the base image
622
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
623
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
624
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
625
-encrypt.cipher-alg Name of encryption cipher algorithm
626
-encrypt.cipher-mode Name of encryption cipher mode
627
-encrypt.ivgen-alg Name of IV generator algorithm
628
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
629
-encrypt.hash-alg Name of encryption hash algorithm
630
-encrypt.iter-time Time to spend in PBKDF in milliseconds
631
-cluster_size qcow2 cluster size
632
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
633
-lazy_refcounts Postpone refcount updates
634
-refcount_bits Width of a reference count entry in bits
635
-nocow Turn off copy-on-write (valid only on btrfs)
636
+ backing_file=<str> - File name of a base image
637
+ backing_fmt=<str> - Image format of the base image
638
+ cluster_size=<size> - qcow2 cluster size
639
+ compat=<str> - Compatibility level (0.10 or 1.1)
640
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
641
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
642
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
643
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
644
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
645
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
646
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
647
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
648
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
649
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
650
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
651
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
652
+ refcount_bits=<num> - Width of a reference count entry in bits
653
+ size=<size> - Virtual disk size
654
655
Testing: convert -O qcow2 -o help,cluster_size=4k TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
656
Supported options:
657
-size Virtual disk size
658
-compat Compatibility level (0.10 or 1.1)
659
-backing_file File name of a base image
660
-backing_fmt Image format of the base image
661
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
662
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
663
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
664
-encrypt.cipher-alg Name of encryption cipher algorithm
665
-encrypt.cipher-mode Name of encryption cipher mode
666
-encrypt.ivgen-alg Name of IV generator algorithm
667
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
668
-encrypt.hash-alg Name of encryption hash algorithm
669
-encrypt.iter-time Time to spend in PBKDF in milliseconds
670
-cluster_size qcow2 cluster size
671
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
672
-lazy_refcounts Postpone refcount updates
673
-refcount_bits Width of a reference count entry in bits
674
-nocow Turn off copy-on-write (valid only on btrfs)
675
+ backing_file=<str> - File name of a base image
676
+ backing_fmt=<str> - Image format of the base image
677
+ cluster_size=<size> - qcow2 cluster size
678
+ compat=<str> - Compatibility level (0.10 or 1.1)
679
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
680
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
681
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
682
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
683
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
684
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
685
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
686
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
687
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
688
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
689
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
690
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
691
+ refcount_bits=<num> - Width of a reference count entry in bits
692
+ size=<size> - Virtual disk size
693
694
Testing: convert -O qcow2 -o ?,cluster_size=4k TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
695
Supported options:
696
-size Virtual disk size
697
-compat Compatibility level (0.10 or 1.1)
698
-backing_file File name of a base image
699
-backing_fmt Image format of the base image
700
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
701
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
702
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
703
-encrypt.cipher-alg Name of encryption cipher algorithm
704
-encrypt.cipher-mode Name of encryption cipher mode
705
-encrypt.ivgen-alg Name of IV generator algorithm
706
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
707
-encrypt.hash-alg Name of encryption hash algorithm
708
-encrypt.iter-time Time to spend in PBKDF in milliseconds
709
-cluster_size qcow2 cluster size
710
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
711
-lazy_refcounts Postpone refcount updates
712
-refcount_bits Width of a reference count entry in bits
713
-nocow Turn off copy-on-write (valid only on btrfs)
714
+ backing_file=<str> - File name of a base image
715
+ backing_fmt=<str> - Image format of the base image
716
+ cluster_size=<size> - qcow2 cluster size
717
+ compat=<str> - Compatibility level (0.10 or 1.1)
718
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
719
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
720
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
721
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
722
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
723
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
724
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
725
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
726
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
727
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
728
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
729
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
730
+ refcount_bits=<num> - Width of a reference count entry in bits
731
+ size=<size> - Virtual disk size
732
733
Testing: convert -O qcow2 -o cluster_size=4k -o help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
734
Supported options:
735
-size Virtual disk size
736
-compat Compatibility level (0.10 or 1.1)
737
-backing_file File name of a base image
738
-backing_fmt Image format of the base image
739
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
740
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
741
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
742
-encrypt.cipher-alg Name of encryption cipher algorithm
743
-encrypt.cipher-mode Name of encryption cipher mode
744
-encrypt.ivgen-alg Name of IV generator algorithm
745
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
746
-encrypt.hash-alg Name of encryption hash algorithm
747
-encrypt.iter-time Time to spend in PBKDF in milliseconds
748
-cluster_size qcow2 cluster size
749
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
750
-lazy_refcounts Postpone refcount updates
751
-refcount_bits Width of a reference count entry in bits
752
-nocow Turn off copy-on-write (valid only on btrfs)
753
+ backing_file=<str> - File name of a base image
754
+ backing_fmt=<str> - Image format of the base image
755
+ cluster_size=<size> - qcow2 cluster size
756
+ compat=<str> - Compatibility level (0.10 or 1.1)
757
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
758
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
759
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
760
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
761
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
762
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
763
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
764
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
765
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
766
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
767
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
768
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
769
+ refcount_bits=<num> - Width of a reference count entry in bits
770
+ size=<size> - Virtual disk size
771
772
Testing: convert -O qcow2 -o cluster_size=4k -o ? TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
773
Supported options:
774
-size Virtual disk size
775
-compat Compatibility level (0.10 or 1.1)
776
-backing_file File name of a base image
777
-backing_fmt Image format of the base image
778
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
779
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
780
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
781
-encrypt.cipher-alg Name of encryption cipher algorithm
782
-encrypt.cipher-mode Name of encryption cipher mode
783
-encrypt.ivgen-alg Name of IV generator algorithm
784
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
785
-encrypt.hash-alg Name of encryption hash algorithm
786
-encrypt.iter-time Time to spend in PBKDF in milliseconds
787
-cluster_size qcow2 cluster size
788
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
789
-lazy_refcounts Postpone refcount updates
790
-refcount_bits Width of a reference count entry in bits
791
-nocow Turn off copy-on-write (valid only on btrfs)
792
+ backing_file=<str> - File name of a base image
793
+ backing_fmt=<str> - Image format of the base image
794
+ cluster_size=<size> - qcow2 cluster size
795
+ compat=<str> - Compatibility level (0.10 or 1.1)
796
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
797
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
798
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
799
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
800
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
801
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
802
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
803
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
804
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
805
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
806
+ nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
807
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
808
+ refcount_bits=<num> - Width of a reference count entry in bits
809
+ size=<size> - Virtual disk size
810
811
Testing: convert -O qcow2 -o backing_file=TEST_DIR/t.qcow2,,help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
812
qemu-img: Could not open 'TEST_DIR/t.qcow2.base': Could not open backing file: Could not open 'TEST_DIR/t.qcow2,help': No such file or directory
813
@@ -XXX,XX +XXX,XX @@ qemu-img: Invalid option list: ,,
814
815
Testing: convert -O qcow2 -o help
816
Supported options:
817
-size Virtual disk size
818
-compat Compatibility level (0.10 or 1.1)
819
-backing_file File name of a base image
820
-backing_fmt Image format of the base image
821
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
822
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
823
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
824
-encrypt.cipher-alg Name of encryption cipher algorithm
825
-encrypt.cipher-mode Name of encryption cipher mode
826
-encrypt.ivgen-alg Name of IV generator algorithm
827
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
828
-encrypt.hash-alg Name of encryption hash algorithm
829
-encrypt.iter-time Time to spend in PBKDF in milliseconds
830
-cluster_size qcow2 cluster size
831
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
832
-lazy_refcounts Postpone refcount updates
833
-refcount_bits Width of a reference count entry in bits
834
+ backing_file=<str> - File name of a base image
835
+ backing_fmt=<str> - Image format of the base image
836
+ cluster_size=<size> - qcow2 cluster size
837
+ compat=<str> - Compatibility level (0.10 or 1.1)
838
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
839
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
840
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
841
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
842
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
843
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
844
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
845
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
846
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
847
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
848
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
849
+ refcount_bits=<num> - Width of a reference count entry in bits
850
+ size=<size> - Virtual disk size
851
852
Testing: convert -o help
853
Supported options:
854
-size Virtual disk size
855
+ size=<size> - Virtual disk size
856
857
Testing: convert -O bochs -o help
858
qemu-img: Format driver 'bochs' does not support image creation
859
@@ -XXX,XX +XXX,XX @@ cluster_size: 65536
860
861
Testing: amend -f qcow2 -o help TEST_DIR/t.qcow2
862
Creation options for 'qcow2':
863
-size Virtual disk size
864
-compat Compatibility level (0.10 or 1.1)
865
-backing_file File name of a base image
866
-backing_fmt Image format of the base image
867
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
868
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
869
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
870
-encrypt.cipher-alg Name of encryption cipher algorithm
871
-encrypt.cipher-mode Name of encryption cipher mode
872
-encrypt.ivgen-alg Name of IV generator algorithm
873
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
874
-encrypt.hash-alg Name of encryption hash algorithm
875
-encrypt.iter-time Time to spend in PBKDF in milliseconds
876
-cluster_size qcow2 cluster size
877
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
878
-lazy_refcounts Postpone refcount updates
879
-refcount_bits Width of a reference count entry in bits
880
+ backing_file=<str> - File name of a base image
881
+ backing_fmt=<str> - Image format of the base image
882
+ cluster_size=<size> - qcow2 cluster size
883
+ compat=<str> - Compatibility level (0.10 or 1.1)
884
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
885
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
886
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
887
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
888
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
889
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
890
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
891
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
892
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
893
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
894
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
895
+ refcount_bits=<num> - Width of a reference count entry in bits
896
+ size=<size> - Virtual disk size
897
898
Note that not all of these options may be amendable.
899
900
Testing: amend -f qcow2 -o ? TEST_DIR/t.qcow2
901
Creation options for 'qcow2':
902
-size Virtual disk size
903
-compat Compatibility level (0.10 or 1.1)
904
-backing_file File name of a base image
905
-backing_fmt Image format of the base image
906
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
907
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
908
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
909
-encrypt.cipher-alg Name of encryption cipher algorithm
910
-encrypt.cipher-mode Name of encryption cipher mode
911
-encrypt.ivgen-alg Name of IV generator algorithm
912
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
913
-encrypt.hash-alg Name of encryption hash algorithm
914
-encrypt.iter-time Time to spend in PBKDF in milliseconds
915
-cluster_size qcow2 cluster size
916
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
917
-lazy_refcounts Postpone refcount updates
918
-refcount_bits Width of a reference count entry in bits
919
+ backing_file=<str> - File name of a base image
920
+ backing_fmt=<str> - Image format of the base image
921
+ cluster_size=<size> - qcow2 cluster size
922
+ compat=<str> - Compatibility level (0.10 or 1.1)
923
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
924
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
925
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
926
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
927
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
928
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
929
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
930
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
931
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
932
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
933
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
934
+ refcount_bits=<num> - Width of a reference count entry in bits
935
+ size=<size> - Virtual disk size
936
937
Note that not all of these options may be amendable.
938
939
Testing: amend -f qcow2 -o cluster_size=4k,help TEST_DIR/t.qcow2
940
Creation options for 'qcow2':
941
-size Virtual disk size
942
-compat Compatibility level (0.10 or 1.1)
943
-backing_file File name of a base image
944
-backing_fmt Image format of the base image
945
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
946
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
947
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
948
-encrypt.cipher-alg Name of encryption cipher algorithm
949
-encrypt.cipher-mode Name of encryption cipher mode
950
-encrypt.ivgen-alg Name of IV generator algorithm
951
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
952
-encrypt.hash-alg Name of encryption hash algorithm
953
-encrypt.iter-time Time to spend in PBKDF in milliseconds
954
-cluster_size qcow2 cluster size
955
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
956
-lazy_refcounts Postpone refcount updates
957
-refcount_bits Width of a reference count entry in bits
958
+ backing_file=<str> - File name of a base image
959
+ backing_fmt=<str> - Image format of the base image
960
+ cluster_size=<size> - qcow2 cluster size
961
+ compat=<str> - Compatibility level (0.10 or 1.1)
962
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
963
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
964
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
965
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
966
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
967
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
968
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
969
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
970
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
971
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
972
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
973
+ refcount_bits=<num> - Width of a reference count entry in bits
974
+ size=<size> - Virtual disk size
975
976
Note that not all of these options may be amendable.
977
978
Testing: amend -f qcow2 -o cluster_size=4k,? TEST_DIR/t.qcow2
979
Creation options for 'qcow2':
980
-size Virtual disk size
981
-compat Compatibility level (0.10 or 1.1)
982
-backing_file File name of a base image
983
-backing_fmt Image format of the base image
984
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
985
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
986
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
987
-encrypt.cipher-alg Name of encryption cipher algorithm
988
-encrypt.cipher-mode Name of encryption cipher mode
989
-encrypt.ivgen-alg Name of IV generator algorithm
990
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
991
-encrypt.hash-alg Name of encryption hash algorithm
992
-encrypt.iter-time Time to spend in PBKDF in milliseconds
993
-cluster_size qcow2 cluster size
994
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
995
-lazy_refcounts Postpone refcount updates
996
-refcount_bits Width of a reference count entry in bits
997
+ backing_file=<str> - File name of a base image
998
+ backing_fmt=<str> - Image format of the base image
999
+ cluster_size=<size> - qcow2 cluster size
1000
+ compat=<str> - Compatibility level (0.10 or 1.1)
1001
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
1002
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
1003
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
1004
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
1005
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
1006
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
1007
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
1008
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
1009
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
1010
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
1011
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
1012
+ refcount_bits=<num> - Width of a reference count entry in bits
1013
+ size=<size> - Virtual disk size
1014
1015
Note that not all of these options may be amendable.
1016
1017
Testing: amend -f qcow2 -o help,cluster_size=4k TEST_DIR/t.qcow2
1018
Creation options for 'qcow2':
1019
-size Virtual disk size
1020
-compat Compatibility level (0.10 or 1.1)
1021
-backing_file File name of a base image
1022
-backing_fmt Image format of the base image
1023
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
1024
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
1025
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
1026
-encrypt.cipher-alg Name of encryption cipher algorithm
1027
-encrypt.cipher-mode Name of encryption cipher mode
1028
-encrypt.ivgen-alg Name of IV generator algorithm
1029
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
1030
-encrypt.hash-alg Name of encryption hash algorithm
1031
-encrypt.iter-time Time to spend in PBKDF in milliseconds
1032
-cluster_size qcow2 cluster size
1033
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
1034
-lazy_refcounts Postpone refcount updates
1035
-refcount_bits Width of a reference count entry in bits
1036
+ backing_file=<str> - File name of a base image
1037
+ backing_fmt=<str> - Image format of the base image
1038
+ cluster_size=<size> - qcow2 cluster size
1039
+ compat=<str> - Compatibility level (0.10 or 1.1)
1040
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
1041
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
1042
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
1043
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
1044
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
1045
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
1046
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
1047
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
1048
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
1049
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
1050
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
1051
+ refcount_bits=<num> - Width of a reference count entry in bits
1052
+ size=<size> - Virtual disk size
1053
1054
Note that not all of these options may be amendable.
1055
1056
Testing: amend -f qcow2 -o ?,cluster_size=4k TEST_DIR/t.qcow2
1057
Creation options for 'qcow2':
1058
-size Virtual disk size
1059
-compat Compatibility level (0.10 or 1.1)
1060
-backing_file File name of a base image
1061
-backing_fmt Image format of the base image
1062
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
1063
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
1064
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
1065
-encrypt.cipher-alg Name of encryption cipher algorithm
1066
-encrypt.cipher-mode Name of encryption cipher mode
1067
-encrypt.ivgen-alg Name of IV generator algorithm
1068
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
1069
-encrypt.hash-alg Name of encryption hash algorithm
1070
-encrypt.iter-time Time to spend in PBKDF in milliseconds
1071
-cluster_size qcow2 cluster size
1072
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
1073
-lazy_refcounts Postpone refcount updates
1074
-refcount_bits Width of a reference count entry in bits
1075
+ backing_file=<str> - File name of a base image
1076
+ backing_fmt=<str> - Image format of the base image
1077
+ cluster_size=<size> - qcow2 cluster size
1078
+ compat=<str> - Compatibility level (0.10 or 1.1)
1079
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
1080
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
1081
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
1082
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
1083
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
1084
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
1085
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
1086
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
1087
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
1088
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
1089
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
1090
+ refcount_bits=<num> - Width of a reference count entry in bits
1091
+ size=<size> - Virtual disk size
1092
1093
Note that not all of these options may be amendable.
1094
1095
Testing: amend -f qcow2 -o cluster_size=4k -o help TEST_DIR/t.qcow2
1096
Creation options for 'qcow2':
1097
-size Virtual disk size
1098
-compat Compatibility level (0.10 or 1.1)
1099
-backing_file File name of a base image
1100
-backing_fmt Image format of the base image
1101
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
1102
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
1103
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
1104
-encrypt.cipher-alg Name of encryption cipher algorithm
1105
-encrypt.cipher-mode Name of encryption cipher mode
1106
-encrypt.ivgen-alg Name of IV generator algorithm
1107
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
1108
-encrypt.hash-alg Name of encryption hash algorithm
1109
-encrypt.iter-time Time to spend in PBKDF in milliseconds
1110
-cluster_size qcow2 cluster size
1111
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
1112
-lazy_refcounts Postpone refcount updates
1113
-refcount_bits Width of a reference count entry in bits
1114
+ backing_file=<str> - File name of a base image
1115
+ backing_fmt=<str> - Image format of the base image
1116
+ cluster_size=<size> - qcow2 cluster size
1117
+ compat=<str> - Compatibility level (0.10 or 1.1)
1118
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
1119
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
1120
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
1121
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
1122
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
1123
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
1124
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
1125
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
1126
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
1127
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
1128
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
1129
+ refcount_bits=<num> - Width of a reference count entry in bits
1130
+ size=<size> - Virtual disk size
1131
1132
Note that not all of these options may be amendable.
1133
1134
Testing: amend -f qcow2 -o cluster_size=4k -o ? TEST_DIR/t.qcow2
1135
Creation options for 'qcow2':
1136
-size Virtual disk size
1137
-compat Compatibility level (0.10 or 1.1)
1138
-backing_file File name of a base image
1139
-backing_fmt Image format of the base image
1140
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
1141
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
1142
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
1143
-encrypt.cipher-alg Name of encryption cipher algorithm
1144
-encrypt.cipher-mode Name of encryption cipher mode
1145
-encrypt.ivgen-alg Name of IV generator algorithm
1146
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
1147
-encrypt.hash-alg Name of encryption hash algorithm
1148
-encrypt.iter-time Time to spend in PBKDF in milliseconds
1149
-cluster_size qcow2 cluster size
1150
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
1151
-lazy_refcounts Postpone refcount updates
1152
-refcount_bits Width of a reference count entry in bits
1153
+ backing_file=<str> - File name of a base image
1154
+ backing_fmt=<str> - Image format of the base image
1155
+ cluster_size=<size> - qcow2 cluster size
1156
+ compat=<str> - Compatibility level (0.10 or 1.1)
1157
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
1158
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
1159
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
1160
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
1161
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
1162
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
1163
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
1164
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
1165
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
1166
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
1167
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
1168
+ refcount_bits=<num> - Width of a reference count entry in bits
1169
+ size=<size> - Virtual disk size
1170
1171
Note that not all of these options may be amendable.
1172
1173
@@ -XXX,XX +XXX,XX @@ qemu-img: Invalid option list: ,,
1174
1175
Testing: amend -f qcow2 -o help
1176
Creation options for 'qcow2':
1177
-size Virtual disk size
1178
-compat Compatibility level (0.10 or 1.1)
1179
-backing_file File name of a base image
1180
-backing_fmt Image format of the base image
1181
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
1182
-encrypt.format Encrypt the image, format choices: 'aes', 'luks'
1183
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
1184
-encrypt.cipher-alg Name of encryption cipher algorithm
1185
-encrypt.cipher-mode Name of encryption cipher mode
1186
-encrypt.ivgen-alg Name of IV generator algorithm
1187
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
1188
-encrypt.hash-alg Name of encryption hash algorithm
1189
-encrypt.iter-time Time to spend in PBKDF in milliseconds
1190
-cluster_size qcow2 cluster size
1191
-preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
1192
-lazy_refcounts Postpone refcount updates
1193
-refcount_bits Width of a reference count entry in bits
1194
+ backing_file=<str> - File name of a base image
1195
+ backing_fmt=<str> - Image format of the base image
1196
+ cluster_size=<size> - qcow2 cluster size
1197
+ compat=<str> - Compatibility level (0.10 or 1.1)
1198
+ encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
1199
+ encrypt.cipher-mode=<str> - Name of encryption cipher mode
1200
+ encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
1201
+ encrypt.hash-alg=<str> - Name of encryption hash algorithm
1202
+ encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds
1203
+ encrypt.ivgen-alg=<str> - Name of IV generator algorithm
1204
+ encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
1205
+ encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
1206
+ encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
1207
+ lazy_refcounts=<bool (on/off)> - Postpone refcount updates
1208
+ preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
1209
+ refcount_bits=<num> - Width of a reference count entry in bits
1210
+ size=<size> - Virtual disk size
1211
1212
Note that not all of these options may be amendable.
1213
1214
Testing: convert -o help
1215
Supported options:
1216
-size Virtual disk size
1217
+ size=<size> - Virtual disk size
1218
1219
Testing: amend -f bochs -o help
1220
qemu-img: Format driver 'bochs' does not support option amendment
52
--
1221
--
53
2.13.6
1222
2.19.1
54
1223
55
1224
diff view generated by jsdifflib
1
From: Max Reitz <mreitz@redhat.com>
1
From: Max Reitz <mreitz@redhat.com>
2
2
3
By using qemu_do_cluster_truncate() in qemu_cluster_truncate(), we now
3
Following the example of qemu_opts_print_help(), indent all entries in
4
automatically have preallocated truncation.
4
the list of character devices.
5
5
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
Reviewed-by: Eric Blake <eblake@redhat.com>
7
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9
---
9
---
10
block/gluster.c | 17 +----------------
10
chardev/char.c | 2 +-
11
1 file changed, 1 insertion(+), 16 deletions(-)
11
1 file changed, 1 insertion(+), 1 deletion(-)
12
12
13
diff --git a/block/gluster.c b/block/gluster.c
13
diff --git a/chardev/char.c b/chardev/char.c
14
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
15
--- a/block/gluster.c
15
--- a/chardev/char.c
16
+++ b/block/gluster.c
16
+++ b/chardev/char.c
17
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int qemu_gluster_co_rw(BlockDriverState *bs,
17
@@ -XXX,XX +XXX,XX @@ help_string_append(const char *name, void *opaque)
18
static int qemu_gluster_truncate(BlockDriverState *bs, int64_t offset,
19
PreallocMode prealloc, Error **errp)
20
{
18
{
21
- int ret;
19
GString *str = opaque;
22
BDRVGlusterState *s = bs->opaque;
20
23
-
21
- g_string_append_printf(str, "\n%s", name);
24
- if (prealloc != PREALLOC_MODE_OFF) {
22
+ g_string_append_printf(str, "\n %s", name);
25
- error_setg(errp, "Unsupported preallocation mode '%s'",
26
- PreallocMode_str(prealloc));
27
- return -ENOTSUP;
28
- }
29
-
30
- ret = glfs_ftruncate(s->fd, offset);
31
- if (ret < 0) {
32
- ret = -errno;
33
- error_setg_errno(errp, -ret, "Failed to truncate file");
34
- return ret;
35
- }
36
-
37
- return 0;
38
+ return qemu_gluster_do_truncate(s->fd, offset, prealloc, errp);
39
}
23
}
40
24
41
static coroutine_fn int qemu_gluster_co_readv(BlockDriverState *bs,
25
static const char *chardev_alias_translate(const char *name)
42
--
26
--
43
2.13.6
27
2.19.1
44
28
45
29
diff view generated by jsdifflib
1
From: Max Reitz <mreitz@redhat.com>
1
From: Max Reitz <mreitz@redhat.com>
2
2
3
glfs_close() is a classical clean-up operation, as can be seen by the
3
Just like in qemu_opts_print_help(), print the device name as a caption
4
fact that it is executed even if the truncation before it failed.
4
instead of on every single line, indent all options, add angle brackets
5
Also, moving it to clean-up makes it more clear that if it fails, we do
5
around types, and align the descriptions after 24 characters. Also,
6
not want it to overwrite the current ret value if that signifies an
6
separate the descriptions with " - " instead of putting them in
7
error already.
7
parentheses, because that is what we do everywhere else. This does look
8
a bit funny here because basically all bits have the description
9
"on/off", but funny does not mean it is less readable.
8
10
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
Reviewed-by: Eric Blake <eblake@redhat.com>
12
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
11
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12
---
14
---
13
block/gluster.c | 10 ++++++----
15
qdev-monitor.c | 13 +++++++++++--
14
1 file changed, 6 insertions(+), 4 deletions(-)
16
1 file changed, 11 insertions(+), 2 deletions(-)
15
17
16
diff --git a/block/gluster.c b/block/gluster.c
18
diff --git a/qdev-monitor.c b/qdev-monitor.c
17
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
18
--- a/block/gluster.c
20
--- a/qdev-monitor.c
19
+++ b/block/gluster.c
21
+++ b/qdev-monitor.c
20
@@ -XXX,XX +XXX,XX @@ static int qemu_gluster_create(const char *filename,
22
@@ -XXX,XX +XXX,XX @@ int qdev_device_help(QemuOpts *opts)
21
{
23
goto error;
22
BlockdevOptionsGluster *gconf;
23
struct glfs *glfs;
24
- struct glfs_fd *fd;
25
+ struct glfs_fd *fd = NULL;
26
int ret = 0;
27
PreallocMode prealloc;
28
int64_t total_size = 0;
29
@@ -XXX,XX +XXX,XX @@ static int qemu_gluster_create(const char *filename,
30
break;
31
}
24
}
32
25
33
- if (glfs_close(fd) != 0) {
26
+ if (prop_list) {
34
- ret = -errno;
27
+ out_printf("%s options:\n", driver);
35
- }
28
+ } else {
36
out:
29
+ out_printf("There are no options for %s.\n", driver);
37
+ if (fd) {
38
+ if (glfs_close(fd) != 0 && ret == 0) {
39
+ ret = -errno;
40
+ }
41
+ }
30
+ }
42
qapi_free_BlockdevOptionsGluster(gconf);
31
for (prop = prop_list; prop; prop = prop->next) {
43
glfs_clear_preopened(glfs);
32
- out_printf("%s.%s=%s", driver, prop->value->name, prop->value->type);
44
return ret;
33
+ int len;
34
+ out_printf(" %s=<%s>%n", prop->value->name, prop->value->type, &len);
35
if (prop->value->has_description) {
36
- out_printf(" (%s)\n", prop->value->description);
37
+ if (len < 24) {
38
+ out_printf("%*s", 24 - len, "");
39
+ }
40
+ out_printf(" - %s\n", prop->value->description);
41
} else {
42
out_printf("\n");
43
}
45
--
44
--
46
2.13.6
45
2.19.1
47
46
48
47
diff view generated by jsdifflib
1
From: Max Reitz <mreitz@redhat.com>
1
From: Max Reitz <mreitz@redhat.com>
2
2
3
Instead of expecting the current size to be 0, query it and allocate
3
Just like in qemu_opts_print_help(), print the object name as a caption
4
only the area [current_size, offset) if preallocation is requested.
4
instead of on every single line, indent all options, add angle brackets
5
around types, and align the descriptions after 24 characters.
6
7
Also, indent every object name in the list of available objects.
5
8
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
Reviewed-by: Eric Blake <eblake@redhat.com>
10
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9
---
12
---
10
block/gluster.c | 21 +++++++++++++++++++--
13
vl.c | 13 ++++++++++---
11
1 file changed, 19 insertions(+), 2 deletions(-)
14
1 file changed, 10 insertions(+), 3 deletions(-)
12
15
13
diff --git a/block/gluster.c b/block/gluster.c
16
diff --git a/vl.c b/vl.c
14
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
15
--- a/block/gluster.c
18
--- a/vl.c
16
+++ b/block/gluster.c
19
+++ b/vl.c
17
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int qemu_gluster_co_pwrite_zeroes(BlockDriverState *bs,
20
@@ -XXX,XX +XXX,XX @@ static bool object_create_initial(const char *type, QemuOpts *opts)
18
static int qemu_gluster_do_truncate(struct glfs_fd *fd, int64_t offset,
21
list = object_class_get_list_sorted(TYPE_USER_CREATABLE, false);
19
PreallocMode prealloc, Error **errp)
22
for (l = list; l != NULL; l = l->next) {
20
{
23
ObjectClass *oc = OBJECT_CLASS(l->data);
21
+ int64_t current_length;
24
- printf("%s\n", object_class_get_name(oc));
22
+
25
+ printf(" %s\n", object_class_get_name(oc));
23
+ current_length = glfs_lseek(fd, 0, SEEK_END);
24
+ if (current_length < 0) {
25
+ error_setg_errno(errp, errno, "Failed to determine current size");
26
+ return -errno;
27
+ }
28
+
29
+ if (current_length > offset && prealloc != PREALLOC_MODE_OFF) {
30
+ error_setg(errp, "Cannot use preallocation for shrinking files");
31
+ return -ENOTSUP;
32
+ }
33
+
34
+ if (current_length == offset) {
35
+ return 0;
36
+ }
37
+
38
switch (prealloc) {
39
#ifdef CONFIG_GLUSTERFS_FALLOCATE
40
case PREALLOC_MODE_FALLOC:
41
- if (glfs_fallocate(fd, 0, 0, offset)) {
42
+ if (glfs_fallocate(fd, 0, current_length, offset - current_length)) {
43
error_setg_errno(errp, errno, "Could not preallocate data");
44
return -errno;
45
}
26
}
46
@@ -XXX,XX +XXX,XX @@ static int qemu_gluster_do_truncate(struct glfs_fd *fd, int64_t offset,
27
g_slist_free(list);
47
error_setg_errno(errp, errno, "Could not resize file");
28
exit(0);
48
return -errno;
29
@@ -XXX,XX +XXX,XX @@ static bool object_create_initial(const char *type, QemuOpts *opts)
30
}
31
32
str = g_string_new(NULL);
33
- g_string_append_printf(str, "%s.%s=%s", type,
34
- prop->name, prop->type);
35
+ g_string_append_printf(str, " %s=<%s>", prop->name, prop->type);
36
if (prop->description) {
37
+ if (str->len < 24) {
38
+ g_string_append_printf(str, "%*s", 24 - (int)str->len, "");
39
+ }
40
g_string_append_printf(str, " - %s", prop->description);
41
}
42
g_ptr_array_add(array, g_string_free(str, false));
49
}
43
}
50
- if (glfs_zerofill(fd, 0, offset)) {
44
g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0);
51
+ if (glfs_zerofill(fd, current_length, offset - current_length)) {
45
+ if (array->len > 0) {
52
error_setg_errno(errp, errno, "Could not zerofill the new area");
46
+ printf("%s options:\n", type);
53
return -errno;
47
+ } else {
48
+ printf("There are no options for %s.\n", type);
49
+ }
50
for (i = 0; i < array->len; i++) {
51
printf("%s\n", (char *)array->pdata[i]);
54
}
52
}
55
--
53
--
56
2.13.6
54
2.19.1
57
55
58
56
diff view generated by jsdifflib
1
From: Max Reitz <mreitz@redhat.com>
1
From: Max Reitz <mreitz@redhat.com>
2
2
3
Only a few select machine types support floppy drives and there is
3
There is no good reason why there should be a newline in this
4
actually nothing preventing us from using virtio here, so let's do it.
4
description, so remove it.
5
5
6
Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
7
Signed-off-by: Max Reitz <mreitz@redhat.com>
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
8
Tested-by: Christian Borntraeger <borntraeger@de.ibm.com>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10
---
10
---
11
tests/qemu-iotests/155 | 14 +++++++++-----
11
vl.c | 2 +-
12
1 file changed, 9 insertions(+), 5 deletions(-)
12
1 file changed, 1 insertion(+), 1 deletion(-)
13
13
14
diff --git a/tests/qemu-iotests/155 b/tests/qemu-iotests/155
14
diff --git a/vl.c b/vl.c
15
index XXXXXXX..XXXXXXX 100755
15
index XXXXXXX..XXXXXXX 100644
16
--- a/tests/qemu-iotests/155
16
--- a/vl.c
17
+++ b/tests/qemu-iotests/155
17
+++ b/vl.c
18
@@ -XXX,XX +XXX,XX @@ class BaseClass(iotests.QMPTestCase):
18
@@ -XXX,XX +XXX,XX @@ static QemuOptsList qemu_fw_cfg_opts = {
19
'file': {'driver': 'file',
19
}, {
20
'filename': source_img}}
20
.name = "file",
21
self.vm.add_blockdev(self.qmp_to_opts(blockdev))
21
.type = QEMU_OPT_STRING,
22
- self.vm.add_device('floppy,id=qdev0,drive=source')
22
- .help = "Sets the name of the file from which\n"
23
+ self.vm.add_device('virtio-blk,id=qdev0,drive=source')
23
+ .help = "Sets the name of the file from which "
24
self.vm.launch()
24
"the fw_cfg blob will be loaded",
25
25
}, {
26
self.assertIntactSourceBackingChain()
26
.name = "string",
27
@@ -XXX,XX +XXX,XX @@ class MirrorBaseClass(BaseClass):
28
def testFull(self):
29
self.runMirror('full')
30
31
- node = self.findBlockNode('target', 'qdev0')
32
+ node = self.findBlockNode('target',
33
+ '/machine/peripheral/qdev0/virtio-backend')
34
self.assertCorrectBackingImage(node, None)
35
self.assertIntactSourceBackingChain()
36
37
def testTop(self):
38
self.runMirror('top')
39
40
- node = self.findBlockNode('target', 'qdev0')
41
+ node = self.findBlockNode('target',
42
+ '/machine/peripheral/qdev0/virtio-backend')
43
self.assertCorrectBackingImage(node, back2_img)
44
self.assertIntactSourceBackingChain()
45
46
def testNone(self):
47
self.runMirror('none')
48
49
- node = self.findBlockNode('target', 'qdev0')
50
+ node = self.findBlockNode('target',
51
+ '/machine/peripheral/qdev0/virtio-backend')
52
self.assertCorrectBackingImage(node, source_img)
53
self.assertIntactSourceBackingChain()
54
55
@@ -XXX,XX +XXX,XX @@ class TestCommit(BaseClass):
56
57
self.vm.event_wait('BLOCK_JOB_COMPLETED')
58
59
- node = self.findBlockNode(None, 'qdev0')
60
+ node = self.findBlockNode(None,
61
+ '/machine/peripheral/qdev0/virtio-backend')
62
self.assert_qmp(node, 'image' + '/backing-image' * 0 + '/filename',
63
back1_img)
64
self.assert_qmp(node, 'image' + '/backing-image' * 1 + '/filename',
65
--
27
--
66
2.13.6
28
2.19.1
67
29
68
30
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Leonid Bloch <lbloch@janustech.com>
2
2
3
Adding support for L2 slices to l2_allocate() needs (among other
3
If an expression is used to define DEFAULT_CLUSTER_SIZE, when compiled,
4
things) an extra loop that iterates over all slices of a new L2 table.
4
it will be embedded as a literal expression in the binary (as the
5
default value) because it is stringified to mark the size of the default
6
value. Now this is fixed by using a defined number to define this value.
5
7
6
Putting all changes in one patch would make it hard to read because
8
Signed-off-by: Leonid Bloch <lbloch@janustech.com>
7
all semantic changes would be mixed with pure indentation changes.
9
Reviewed-by: Stefan Weil <sw@weilnetz.de>
10
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11
---
12
block/vdi.c | 4 ++--
13
1 file changed, 2 insertions(+), 2 deletions(-)
8
14
9
To make things easier this patch simply creates a new block and
15
diff --git a/block/vdi.c b/block/vdi.c
10
changes the indentation of all lines of code inside it. Thus, all
11
modifications in this patch are cosmetic. There are no semantic
12
changes and no variables are renamed yet. The next patch will take
13
care of that.
14
15
Signed-off-by: Alberto Garcia <berto@igalia.com>
16
Reviewed-by: Eric Blake <eblake@redhat.com>
17
Reviewed-by: Max Reitz <mreitz@redhat.com>
18
Message-id: d0d7dca8520db304524f52f49d8157595a707a35.1517840877.git.berto@igalia.com
19
Signed-off-by: Max Reitz <mreitz@redhat.com>
20
---
21
block/qcow2-cluster.c | 53 ++++++++++++++++++++++++++++-----------------------
22
1 file changed, 29 insertions(+), 24 deletions(-)
23
24
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
25
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
26
--- a/block/qcow2-cluster.c
17
--- a/block/vdi.c
27
+++ b/block/qcow2-cluster.c
18
+++ b/block/vdi.c
28
@@ -XXX,XX +XXX,XX @@ static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t **table)
19
@@ -XXX,XX +XXX,XX @@
29
/* allocate a new entry in the l2 cache */
20
#define BLOCK_OPT_STATIC "static"
30
21
31
trace_qcow2_l2_allocate_get_empty(bs, l1_index);
22
#define SECTOR_SIZE 512
32
- ret = qcow2_cache_get_empty(bs, s->l2_table_cache, l2_offset, (void**) table);
23
-#define DEFAULT_CLUSTER_SIZE (1 * MiB)
33
- if (ret < 0) {
24
+#define DEFAULT_CLUSTER_SIZE S_1MiB
34
- goto fail;
25
35
- }
26
#if defined(CONFIG_VDI_DEBUG)
36
+ {
27
#define VDI_DEBUG 1
37
+ ret = qcow2_cache_get_empty(bs, s->l2_table_cache,
28
@@ -XXX,XX +XXX,XX @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
38
+ l2_offset,
29
goto fail;
39
+ (void **) table);
30
} else if (header.block_size != DEFAULT_CLUSTER_SIZE) {
40
+ if (ret < 0) {
31
error_setg(errp, "unsupported VDI image (block size %" PRIu32
41
+ goto fail;
32
- " is not %" PRIu64 ")",
42
+ }
33
+ " is not %" PRIu32 ")",
43
34
header.block_size, DEFAULT_CLUSTER_SIZE);
44
- l2_table = *table;
35
ret = -ENOTSUP;
45
+ l2_table = *table;
46
47
- if ((old_l2_offset & L1E_OFFSET_MASK) == 0) {
48
- /* if there was no old l2 table, clear the new table */
49
- memset(l2_table, 0, s->l2_size * sizeof(uint64_t));
50
- } else {
51
- uint64_t* old_table;
52
+ if ((old_l2_offset & L1E_OFFSET_MASK) == 0) {
53
+ /* if there was no old l2 table, clear the new table */
54
+ memset(l2_table, 0, s->l2_size * sizeof(uint64_t));
55
+ } else {
56
+ uint64_t *old_table;
57
58
- /* if there was an old l2 table, read it from the disk */
59
- BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_COW_READ);
60
- ret = qcow2_cache_get(bs, s->l2_table_cache,
61
- old_l2_offset & L1E_OFFSET_MASK,
62
- (void**) &old_table);
63
- if (ret < 0) {
64
- goto fail;
65
+ /* if there was an old l2 table, read it from the disk */
66
+ BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_COW_READ);
67
+ ret = qcow2_cache_get(bs, s->l2_table_cache,
68
+ old_l2_offset & L1E_OFFSET_MASK,
69
+ (void **) &old_table);
70
+ if (ret < 0) {
71
+ goto fail;
72
+ }
73
+
74
+ memcpy(l2_table, old_table, s->cluster_size);
75
+
76
+ qcow2_cache_put(s->l2_table_cache, (void **) &old_table);
77
}
78
79
- memcpy(l2_table, old_table, s->cluster_size);
80
+ /* write the l2 table to the file */
81
+ BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_WRITE);
82
83
- qcow2_cache_put(s->l2_table_cache, (void **) &old_table);
84
+ trace_qcow2_l2_allocate_write_l2(bs, l1_index);
85
+ qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
86
}
87
88
- /* write the l2 table to the file */
89
- BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_WRITE);
90
-
91
- trace_qcow2_l2_allocate_write_l2(bs, l1_index);
92
- qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
93
ret = qcow2_cache_flush(bs, s->l2_table_cache);
94
if (ret < 0) {
95
goto fail;
36
goto fail;
96
--
37
--
97
2.13.6
38
2.19.1
98
39
99
40
diff view generated by jsdifflib
1
From: Fam Zheng <famz@redhat.com>
1
From: Leonid Bloch <lbloch@janustech.com>
2
2
3
Suggested-by: Stefan Hajnoczi <stefanha@redhat.com>
3
The lookup table for power-of-two sizes was added in commit 540b8492618eb
4
Signed-off-by: Fam Zheng <famz@redhat.com>
4
for the purpose of having convenient shortcuts for these sizes in cases
5
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
5
when the literal number has to be present at compile time, and
6
Reviewed-by: Kashyap Chamarthy <kchamart@redhat.com>
6
expressions as '(1 * KiB)' can not be used. One such case is the
7
stringification of sizes. Beyond that, it is convenient to use these
8
shortcuts for all power-of-two sizes, even if they don't have to be
9
literal numbers.
10
11
Despite its convenience, this table introduced 55 lines of "dumb" code,
12
the purpose and origin of which are obscure without reading the message
13
of the commit which introduced it. This patch fixes that by adding a
14
comment to the code itself with a brief explanation for the reasoning
15
behind this table. This comment includes the short AWK script that
16
generated the table, so that anyone who's interested could make sure
17
that the values in it are correct (otherwise these values look as if
18
they were typed manually).
19
20
Signed-off-by: Leonid Bloch <lbloch@janustech.com>
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
21
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
---
22
---
9
docs/qemu-block-drivers.texi | 10 ++++++++++
23
include/qemu/units.h | 18 ++++++++++++++++++
10
1 file changed, 10 insertions(+)
24
1 file changed, 18 insertions(+)
11
25
12
diff --git a/docs/qemu-block-drivers.texi b/docs/qemu-block-drivers.texi
26
diff --git a/include/qemu/units.h b/include/qemu/units.h
13
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
14
--- a/docs/qemu-block-drivers.texi
28
--- a/include/qemu/units.h
15
+++ b/docs/qemu-block-drivers.texi
29
+++ b/include/qemu/units.h
16
@@ -XXX,XX +XXX,XX @@ QEMU transparently handles lock handover during shared storage migration. For
30
@@ -XXX,XX +XXX,XX @@
17
shared virtual disk images between multiple VMs, the "share-rw" device option
31
#define PiB (INT64_C(1) << 50)
18
should be used.
32
#define EiB (INT64_C(1) << 60)
19
33
20
+By default, the guest has exclusive write access to its disk image. If the
34
+/*
21
+guest can safely share the disk image with other writers the @code{-device
35
+ * The following lookup table is intended to be used when a literal string of
22
+...,share-rw=on} parameter can be used. This is only safe if the guest is
36
+ * the number of bytes is required (for example if it needs to be stringified).
23
+running software, such as a cluster file system, that coordinates disk accesses
37
+ * It can also be used for generic shortcuts of power-of-two sizes.
24
+to avoid corruption.
38
+ * This table is generated using the AWK script below:
39
+ *
40
+ * BEGIN {
41
+ * suffix="KMGTPE";
42
+ * for(i=10; i<64; i++) {
43
+ * val=2**i;
44
+ * s=substr(suffix, int(i/10), 1);
45
+ * n=2**(i%10);
46
+ * pad=21-int(log(n)/log(10));
47
+ * printf("#define S_%d%siB %*d\n", n, s, pad, val);
48
+ * }
49
+ * }
50
+ */
25
+
51
+
26
+Note that share-rw=on only declares the guest's ability to share the disk.
52
#define S_1KiB 1024
27
+Some QEMU features, such as image file formats, require exclusive write access
53
#define S_2KiB 2048
28
+to the disk image and this is unaffected by the share-rw=on option.
54
#define S_4KiB 4096
29
+
30
Alternatively, locking can be fully disabled by "locking=off" block device
31
option. In the command line, the option is usually in the form of
32
"file.locking=off" as the protocol driver is normally placed as a "file" child
33
--
55
--
34
2.13.6
56
2.19.1
35
57
36
58
diff view generated by jsdifflib
Deleted patch
1
From: Alberto Garcia <berto@igalia.com>
2
1
3
This function has not been returning the offset of the L2 table since
4
commit 3948d1d4876065160583e79533bf604481063833
5
6
Signed-off-by: Alberto Garcia <berto@igalia.com>
7
Reviewed-by: Eric Blake <eblake@redhat.com>
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
9
Message-id: b498733b6706a859a03678d74ecbd26aeba129aa.1517840876.git.berto@igalia.com
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
---
12
block/qcow2-cluster.c | 3 +--
13
1 file changed, 1 insertion(+), 2 deletions(-)
14
15
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/block/qcow2-cluster.c
18
+++ b/block/qcow2-cluster.c
19
@@ -XXX,XX +XXX,XX @@ fail:
20
* for a given disk offset, load (and allocate if needed)
21
* the l2 table.
22
*
23
- * the l2 table offset in the qcow2 file and the cluster index
24
- * in the l2 table are given to the caller.
25
+ * the cluster index in the l2 table is given to the caller.
26
*
27
* Returns 0 on success, -errno in failure case
28
*/
29
--
30
2.13.6
31
32
diff view generated by jsdifflib
Deleted patch
1
From: Alberto Garcia <berto@igalia.com>
2
1
3
The table size in the qcow2 cache is currently equal to the cluster
4
size. This doesn't allow us to use the cache memory efficiently,
5
particularly with large cluster sizes, so we need to be able to have
6
smaller cache tables that are independent from the cluster size. This
7
patch adds a new field to Qcow2Cache that we can use instead of the
8
cluster size.
9
10
The current table size is still being initialized to the cluster size,
11
so there are no semantic changes yet, but this patch will allow us to
12
prepare the rest of the code and simplify a few function calls.
13
14
Signed-off-by: Alberto Garcia <berto@igalia.com>
15
Reviewed-by: Eric Blake <eblake@redhat.com>
16
Reviewed-by: Max Reitz <mreitz@redhat.com>
17
Message-id: 67a1bf9e55f417005c567bead95a018dc34bc687.1517840876.git.berto@igalia.com
18
Signed-off-by: Max Reitz <mreitz@redhat.com>
19
---
20
block/qcow2-cache.c | 29 ++++++++++++++---------------
21
1 file changed, 14 insertions(+), 15 deletions(-)
22
23
diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
24
index XXXXXXX..XXXXXXX 100644
25
--- a/block/qcow2-cache.c
26
+++ b/block/qcow2-cache.c
27
@@ -XXX,XX +XXX,XX @@ struct Qcow2Cache {
28
Qcow2CachedTable *entries;
29
struct Qcow2Cache *depends;
30
int size;
31
+ int table_size;
32
bool depends_on_flush;
33
void *table_array;
34
uint64_t lru_counter;
35
@@ -XXX,XX +XXX,XX @@ struct Qcow2Cache {
36
static inline void *qcow2_cache_get_table_addr(BlockDriverState *bs,
37
Qcow2Cache *c, int table)
38
{
39
- BDRVQcow2State *s = bs->opaque;
40
- return (uint8_t *) c->table_array + (size_t) table * s->cluster_size;
41
+ return (uint8_t *) c->table_array + (size_t) table * c->table_size;
42
}
43
44
static inline int qcow2_cache_get_table_idx(BlockDriverState *bs,
45
Qcow2Cache *c, void *table)
46
{
47
- BDRVQcow2State *s = bs->opaque;
48
ptrdiff_t table_offset = (uint8_t *) table - (uint8_t *) c->table_array;
49
- int idx = table_offset / s->cluster_size;
50
- assert(idx >= 0 && idx < c->size && table_offset % s->cluster_size == 0);
51
+ int idx = table_offset / c->table_size;
52
+ assert(idx >= 0 && idx < c->size && table_offset % c->table_size == 0);
53
return idx;
54
}
55
56
@@ -XXX,XX +XXX,XX @@ static void qcow2_cache_table_release(BlockDriverState *bs, Qcow2Cache *c,
57
{
58
/* Using MADV_DONTNEED to discard memory is a Linux-specific feature */
59
#ifdef CONFIG_LINUX
60
- BDRVQcow2State *s = bs->opaque;
61
void *t = qcow2_cache_get_table_addr(bs, c, i);
62
int align = getpagesize();
63
- size_t mem_size = (size_t) s->cluster_size * num_tables;
64
+ size_t mem_size = (size_t) c->table_size * num_tables;
65
size_t offset = QEMU_ALIGN_UP((uintptr_t) t, align) - (uintptr_t) t;
66
size_t length = QEMU_ALIGN_DOWN(mem_size - offset, align);
67
if (mem_size > offset && length > 0) {
68
@@ -XXX,XX +XXX,XX @@ Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables)
69
70
c = g_new0(Qcow2Cache, 1);
71
c->size = num_tables;
72
+ c->table_size = s->cluster_size;
73
c->entries = g_try_new0(Qcow2CachedTable, num_tables);
74
c->table_array = qemu_try_blockalign(bs->file->bs,
75
- (size_t) num_tables * s->cluster_size);
76
+ (size_t) num_tables * c->table_size);
77
78
if (!c->entries || !c->table_array) {
79
qemu_vfree(c->table_array);
80
@@ -XXX,XX +XXX,XX @@ static int qcow2_cache_entry_flush(BlockDriverState *bs, Qcow2Cache *c, int i)
81
82
if (c == s->refcount_block_cache) {
83
ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_REFCOUNT_BLOCK,
84
- c->entries[i].offset, s->cluster_size);
85
+ c->entries[i].offset, c->table_size);
86
} else if (c == s->l2_table_cache) {
87
ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_ACTIVE_L2,
88
- c->entries[i].offset, s->cluster_size);
89
+ c->entries[i].offset, c->table_size);
90
} else {
91
ret = qcow2_pre_write_overlap_check(bs, 0,
92
- c->entries[i].offset, s->cluster_size);
93
+ c->entries[i].offset, c->table_size);
94
}
95
96
if (ret < 0) {
97
@@ -XXX,XX +XXX,XX @@ static int qcow2_cache_entry_flush(BlockDriverState *bs, Qcow2Cache *c, int i)
98
}
99
100
ret = bdrv_pwrite(bs->file, c->entries[i].offset,
101
- qcow2_cache_get_table_addr(bs, c, i), s->cluster_size);
102
+ qcow2_cache_get_table_addr(bs, c, i), c->table_size);
103
if (ret < 0) {
104
return ret;
105
}
106
@@ -XXX,XX +XXX,XX @@ static int qcow2_cache_do_get(BlockDriverState *bs, Qcow2Cache *c,
107
trace_qcow2_cache_get(qemu_coroutine_self(), c == s->l2_table_cache,
108
offset, read_from_disk);
109
110
- if (offset_into_cluster(s, offset)) {
111
+ if (!QEMU_IS_ALIGNED(offset, c->table_size)) {
112
qcow2_signal_corruption(bs, true, -1, -1, "Cannot get entry from %s "
113
"cache: Offset %#" PRIx64 " is unaligned",
114
qcow2_cache_get_name(s, c), offset);
115
@@ -XXX,XX +XXX,XX @@ static int qcow2_cache_do_get(BlockDriverState *bs, Qcow2Cache *c,
116
}
117
118
/* Check if the table is already cached */
119
- i = lookup_index = (offset / s->cluster_size * 4) % c->size;
120
+ i = lookup_index = (offset / c->table_size * 4) % c->size;
121
do {
122
const Qcow2CachedTable *t = &c->entries[i];
123
if (t->offset == offset) {
124
@@ -XXX,XX +XXX,XX @@ static int qcow2_cache_do_get(BlockDriverState *bs, Qcow2Cache *c,
125
126
ret = bdrv_pread(bs->file, offset,
127
qcow2_cache_get_table_addr(bs, c, i),
128
- s->cluster_size);
129
+ c->table_size);
130
if (ret < 0) {
131
return ret;
132
}
133
--
134
2.13.6
135
136
diff view generated by jsdifflib
Deleted patch
1
From: Alberto Garcia <berto@igalia.com>
2
1
3
This function was only using the BlockDriverState parameter to get the
4
cache table size (since it was equal to the cluster size). This is no
5
longer necessary so this parameter can be removed.
6
7
Signed-off-by: Alberto Garcia <berto@igalia.com>
8
Reviewed-by: Eric Blake <eblake@redhat.com>
9
Reviewed-by: Max Reitz <mreitz@redhat.com>
10
Message-id: da3575d47c9a181a2cfd4715e53dd84a2c651017.1517840876.git.berto@igalia.com
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
12
---
13
block/qcow2-cache.c | 9 ++++-----
14
1 file changed, 4 insertions(+), 5 deletions(-)
15
16
diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/block/qcow2-cache.c
19
+++ b/block/qcow2-cache.c
20
@@ -XXX,XX +XXX,XX @@ static inline void *qcow2_cache_get_table_addr(Qcow2Cache *c, int table)
21
return (uint8_t *) c->table_array + (size_t) table * c->table_size;
22
}
23
24
-static inline int qcow2_cache_get_table_idx(BlockDriverState *bs,
25
- Qcow2Cache *c, void *table)
26
+static inline int qcow2_cache_get_table_idx(Qcow2Cache *c, void *table)
27
{
28
ptrdiff_t table_offset = (uint8_t *) table - (uint8_t *) c->table_array;
29
int idx = table_offset / c->table_size;
30
@@ -XXX,XX +XXX,XX @@ int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset,
31
32
void qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, void **table)
33
{
34
- int i = qcow2_cache_get_table_idx(bs, c, *table);
35
+ int i = qcow2_cache_get_table_idx(c, *table);
36
37
c->entries[i].ref--;
38
*table = NULL;
39
@@ -XXX,XX +XXX,XX @@ void qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, void **table)
40
void qcow2_cache_entry_mark_dirty(BlockDriverState *bs, Qcow2Cache *c,
41
void *table)
42
{
43
- int i = qcow2_cache_get_table_idx(bs, c, table);
44
+ int i = qcow2_cache_get_table_idx(c, table);
45
assert(c->entries[i].offset != 0);
46
c->entries[i].dirty = true;
47
}
48
@@ -XXX,XX +XXX,XX @@ void *qcow2_cache_is_table_offset(BlockDriverState *bs, Qcow2Cache *c,
49
50
void qcow2_cache_discard(BlockDriverState *bs, Qcow2Cache *c, void *table)
51
{
52
- int i = qcow2_cache_get_table_idx(bs, c, table);
53
+ int i = qcow2_cache_get_table_idx(c, table);
54
55
assert(c->entries[i].ref == 0);
56
57
--
58
2.13.6
59
60
diff view generated by jsdifflib
Deleted patch
1
From: Alberto Garcia <berto@igalia.com>
2
1
3
This function was only using the BlockDriverState parameter to pass it
4
to qcow2_cache_get_table_idx(). This is no longer necessary so this
5
parameter can be removed.
6
7
Signed-off-by: Alberto Garcia <berto@igalia.com>
8
Reviewed-by: Eric Blake <eblake@redhat.com>
9
Reviewed-by: Max Reitz <mreitz@redhat.com>
10
Message-id: 5c40516a91782b083c1428b7b6a41bb9e2679bfb.1517840876.git.berto@igalia.com
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
12
---
13
block/qcow2.h | 3 +--
14
block/qcow2-cache.c | 3 +--
15
block/qcow2-cluster.c | 12 ++++++------
16
block/qcow2-refcount.c | 14 ++++++--------
17
4 files changed, 14 insertions(+), 18 deletions(-)
18
19
diff --git a/block/qcow2.h b/block/qcow2.h
20
index XXXXXXX..XXXXXXX 100644
21
--- a/block/qcow2.h
22
+++ b/block/qcow2.h
23
@@ -XXX,XX +XXX,XX @@ int qcow2_read_snapshots(BlockDriverState *bs);
24
Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables);
25
int qcow2_cache_destroy(BlockDriverState* bs, Qcow2Cache *c);
26
27
-void qcow2_cache_entry_mark_dirty(BlockDriverState *bs, Qcow2Cache *c,
28
- void *table);
29
+void qcow2_cache_entry_mark_dirty(Qcow2Cache *c, void *table);
30
int qcow2_cache_flush(BlockDriverState *bs, Qcow2Cache *c);
31
int qcow2_cache_write(BlockDriverState *bs, Qcow2Cache *c);
32
int qcow2_cache_set_dependency(BlockDriverState *bs, Qcow2Cache *c,
33
diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/block/qcow2-cache.c
36
+++ b/block/qcow2-cache.c
37
@@ -XXX,XX +XXX,XX @@ void qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, void **table)
38
assert(c->entries[i].ref >= 0);
39
}
40
41
-void qcow2_cache_entry_mark_dirty(BlockDriverState *bs, Qcow2Cache *c,
42
- void *table)
43
+void qcow2_cache_entry_mark_dirty(Qcow2Cache *c, void *table)
44
{
45
int i = qcow2_cache_get_table_idx(c, table);
46
assert(c->entries[i].offset != 0);
47
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/block/qcow2-cluster.c
50
+++ b/block/qcow2-cluster.c
51
@@ -XXX,XX +XXX,XX @@ static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t **table)
52
BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_WRITE);
53
54
trace_qcow2_l2_allocate_write_l2(bs, l1_index);
55
- qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table);
56
+ qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
57
ret = qcow2_cache_flush(bs, s->l2_table_cache);
58
if (ret < 0) {
59
goto fail;
60
@@ -XXX,XX +XXX,XX @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
61
/* compressed clusters never have the copied flag */
62
63
BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE_COMPRESSED);
64
- qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table);
65
+ qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
66
l2_table[l2_index] = cpu_to_be64(cluster_offset);
67
qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table);
68
69
@@ -XXX,XX +XXX,XX @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m)
70
if (ret < 0) {
71
goto err;
72
}
73
- qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table);
74
+ qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
75
76
assert(l2_index + m->nb_clusters <= s->l2_size);
77
for (i = 0; i < m->nb_clusters; i++) {
78
@@ -XXX,XX +XXX,XX @@ static int discard_single_l2(BlockDriverState *bs, uint64_t offset,
79
}
80
81
/* First remove L2 entries */
82
- qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table);
83
+ qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
84
if (!full_discard && s->qcow_version >= 3) {
85
l2_table[l2_index + i] = cpu_to_be64(QCOW_OFLAG_ZERO);
86
} else {
87
@@ -XXX,XX +XXX,XX @@ static int zero_single_l2(BlockDriverState *bs, uint64_t offset,
88
continue;
89
}
90
91
- qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table);
92
+ qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
93
if (cluster_type == QCOW2_CLUSTER_COMPRESSED || unmap) {
94
l2_table[l2_index + i] = cpu_to_be64(QCOW_OFLAG_ZERO);
95
qcow2_free_any_clusters(bs, old_offset, 1, QCOW2_DISCARD_REQUEST);
96
@@ -XXX,XX +XXX,XX @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table,
97
98
if (is_active_l1) {
99
if (l2_dirty) {
100
- qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table);
101
+ qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
102
qcow2_cache_depends_on_flush(s->l2_table_cache);
103
}
104
qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table);
105
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
106
index XXXXXXX..XXXXXXX 100644
107
--- a/block/qcow2-refcount.c
108
+++ b/block/qcow2-refcount.c
109
@@ -XXX,XX +XXX,XX @@ static int alloc_refcount_block(BlockDriverState *bs,
110
111
/* Now the new refcount block needs to be written to disk */
112
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE);
113
- qcow2_cache_entry_mark_dirty(bs, s->refcount_block_cache, *refcount_block);
114
+ qcow2_cache_entry_mark_dirty(s->refcount_block_cache, *refcount_block);
115
ret = qcow2_cache_flush(bs, s->refcount_block_cache);
116
if (ret < 0) {
117
goto fail;
118
@@ -XXX,XX +XXX,XX @@ int64_t qcow2_refcount_area(BlockDriverState *bs, uint64_t start_offset,
119
goto fail;
120
}
121
memset(refblock_data, 0, s->cluster_size);
122
- qcow2_cache_entry_mark_dirty(bs, s->refcount_block_cache,
123
+ qcow2_cache_entry_mark_dirty(s->refcount_block_cache,
124
refblock_data);
125
126
new_table[i] = block_offset;
127
@@ -XXX,XX +XXX,XX @@ int64_t qcow2_refcount_area(BlockDriverState *bs, uint64_t start_offset,
128
s->set_refcount(refblock_data, j, 1);
129
}
130
131
- qcow2_cache_entry_mark_dirty(bs, s->refcount_block_cache,
132
+ qcow2_cache_entry_mark_dirty(s->refcount_block_cache,
133
refblock_data);
134
}
135
136
@@ -XXX,XX +XXX,XX @@ static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
137
}
138
old_table_index = table_index;
139
140
- qcow2_cache_entry_mark_dirty(bs, s->refcount_block_cache,
141
- refcount_block);
142
+ qcow2_cache_entry_mark_dirty(s->refcount_block_cache, refcount_block);
143
144
/* we can update the count and save it */
145
block_index = cluster_index & (s->refcount_block_size - 1);
146
@@ -XXX,XX +XXX,XX @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
147
s->refcount_block_cache);
148
}
149
l2_table[j] = cpu_to_be64(entry);
150
- qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache,
151
- l2_table);
152
+ qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
153
}
154
}
155
156
@@ -XXX,XX +XXX,XX @@ static int qcow2_discard_refcount_block(BlockDriverState *bs,
157
}
158
s->set_refcount(refblock, block_index, 0);
159
160
- qcow2_cache_entry_mark_dirty(bs, s->refcount_block_cache, refblock);
161
+ qcow2_cache_entry_mark_dirty(s->refcount_block_cache, refblock);
162
163
qcow2_cache_put(bs, s->refcount_block_cache, &refblock);
164
165
--
166
2.13.6
167
168
diff view generated by jsdifflib
Deleted patch
1
From: Alberto Garcia <berto@igalia.com>
2
1
3
This function was never using the BlockDriverState parameter so it can
4
be safely removed.
5
6
Signed-off-by: Alberto Garcia <berto@igalia.com>
7
Reviewed-by: Eric Blake <eblake@redhat.com>
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
9
Message-id: 49c74fe8b3aead9056e61a85b145ce787d06262b.1517840876.git.berto@igalia.com
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
---
12
block/qcow2.h | 2 +-
13
block/qcow2-cache.c | 2 +-
14
block/qcow2.c | 16 ++++++++--------
15
3 files changed, 10 insertions(+), 10 deletions(-)
16
17
diff --git a/block/qcow2.h b/block/qcow2.h
18
index XXXXXXX..XXXXXXX 100644
19
--- a/block/qcow2.h
20
+++ b/block/qcow2.h
21
@@ -XXX,XX +XXX,XX @@ int qcow2_read_snapshots(BlockDriverState *bs);
22
23
/* qcow2-cache.c functions */
24
Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables);
25
-int qcow2_cache_destroy(BlockDriverState* bs, Qcow2Cache *c);
26
+int qcow2_cache_destroy(Qcow2Cache *c);
27
28
void qcow2_cache_entry_mark_dirty(Qcow2Cache *c, void *table);
29
int qcow2_cache_flush(BlockDriverState *bs, Qcow2Cache *c);
30
diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/block/qcow2-cache.c
33
+++ b/block/qcow2-cache.c
34
@@ -XXX,XX +XXX,XX @@ Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables)
35
return c;
36
}
37
38
-int qcow2_cache_destroy(BlockDriverState *bs, Qcow2Cache *c)
39
+int qcow2_cache_destroy(Qcow2Cache *c)
40
{
41
int i;
42
43
diff --git a/block/qcow2.c b/block/qcow2.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/block/qcow2.c
46
+++ b/block/qcow2.c
47
@@ -XXX,XX +XXX,XX @@ static void qcow2_update_options_commit(BlockDriverState *bs,
48
int i;
49
50
if (s->l2_table_cache) {
51
- qcow2_cache_destroy(bs, s->l2_table_cache);
52
+ qcow2_cache_destroy(s->l2_table_cache);
53
}
54
if (s->refcount_block_cache) {
55
- qcow2_cache_destroy(bs, s->refcount_block_cache);
56
+ qcow2_cache_destroy(s->refcount_block_cache);
57
}
58
s->l2_table_cache = r->l2_table_cache;
59
s->refcount_block_cache = r->refcount_block_cache;
60
@@ -XXX,XX +XXX,XX @@ static void qcow2_update_options_abort(BlockDriverState *bs,
61
Qcow2ReopenState *r)
62
{
63
if (r->l2_table_cache) {
64
- qcow2_cache_destroy(bs, r->l2_table_cache);
65
+ qcow2_cache_destroy(r->l2_table_cache);
66
}
67
if (r->refcount_block_cache) {
68
- qcow2_cache_destroy(bs, r->refcount_block_cache);
69
+ qcow2_cache_destroy(r->refcount_block_cache);
70
}
71
qapi_free_QCryptoBlockOpenOptions(r->crypto_opts);
72
}
73
@@ -XXX,XX +XXX,XX @@ static int qcow2_do_open(BlockDriverState *bs, QDict *options, int flags,
74
s->l1_table = NULL;
75
cache_clean_timer_del(bs);
76
if (s->l2_table_cache) {
77
- qcow2_cache_destroy(bs, s->l2_table_cache);
78
+ qcow2_cache_destroy(s->l2_table_cache);
79
}
80
if (s->refcount_block_cache) {
81
- qcow2_cache_destroy(bs, s->refcount_block_cache);
82
+ qcow2_cache_destroy(s->refcount_block_cache);
83
}
84
qcrypto_block_free(s->crypto);
85
qapi_free_QCryptoBlockOpenOptions(s->crypto_opts);
86
@@ -XXX,XX +XXX,XX @@ static void qcow2_close(BlockDriverState *bs)
87
}
88
89
cache_clean_timer_del(bs);
90
- qcow2_cache_destroy(bs, s->l2_table_cache);
91
- qcow2_cache_destroy(bs, s->refcount_block_cache);
92
+ qcow2_cache_destroy(s->l2_table_cache);
93
+ qcow2_cache_destroy(s->refcount_block_cache);
94
95
qcrypto_block_free(s->crypto);
96
s->crypto = NULL;
97
--
98
2.13.6
99
100
diff view generated by jsdifflib
Deleted patch
1
From: Alberto Garcia <berto@igalia.com>
2
1
3
This function was only using the BlockDriverState parameter to pass it
4
to qcow2_cache_table_release(). This is no longer necessary so this
5
parameter can be removed.
6
7
Signed-off-by: Alberto Garcia <berto@igalia.com>
8
Reviewed-by: Eric Blake <eblake@redhat.com>
9
Reviewed-by: Max Reitz <mreitz@redhat.com>
10
Message-id: b74f17591af52f201de0ea3a3b2dd0a81932334d.1517840876.git.berto@igalia.com
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
12
---
13
block/qcow2.h | 2 +-
14
block/qcow2-cache.c | 2 +-
15
block/qcow2.c | 4 ++--
16
3 files changed, 4 insertions(+), 4 deletions(-)
17
18
diff --git a/block/qcow2.h b/block/qcow2.h
19
index XXXXXXX..XXXXXXX 100644
20
--- a/block/qcow2.h
21
+++ b/block/qcow2.h
22
@@ -XXX,XX +XXX,XX @@ int qcow2_cache_set_dependency(BlockDriverState *bs, Qcow2Cache *c,
23
Qcow2Cache *dependency);
24
void qcow2_cache_depends_on_flush(Qcow2Cache *c);
25
26
-void qcow2_cache_clean_unused(BlockDriverState *bs, Qcow2Cache *c);
27
+void qcow2_cache_clean_unused(Qcow2Cache *c);
28
int qcow2_cache_empty(BlockDriverState *bs, Qcow2Cache *c);
29
30
int qcow2_cache_get(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset,
31
diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/block/qcow2-cache.c
34
+++ b/block/qcow2-cache.c
35
@@ -XXX,XX +XXX,XX @@ static inline bool can_clean_entry(Qcow2Cache *c, int i)
36
t->lru_counter <= c->cache_clean_lru_counter;
37
}
38
39
-void qcow2_cache_clean_unused(BlockDriverState *bs, Qcow2Cache *c)
40
+void qcow2_cache_clean_unused(Qcow2Cache *c)
41
{
42
int i = 0;
43
while (i < c->size) {
44
diff --git a/block/qcow2.c b/block/qcow2.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/block/qcow2.c
47
+++ b/block/qcow2.c
48
@@ -XXX,XX +XXX,XX @@ static void cache_clean_timer_cb(void *opaque)
49
{
50
BlockDriverState *bs = opaque;
51
BDRVQcow2State *s = bs->opaque;
52
- qcow2_cache_clean_unused(bs, s->l2_table_cache);
53
- qcow2_cache_clean_unused(bs, s->refcount_block_cache);
54
+ qcow2_cache_clean_unused(s->l2_table_cache);
55
+ qcow2_cache_clean_unused(s->refcount_block_cache);
56
timer_mod(s->cache_clean_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) +
57
(int64_t) s->cache_clean_interval * 1000);
58
}
59
--
60
2.13.6
61
62
diff view generated by jsdifflib
Deleted patch
1
From: Alberto Garcia <berto@igalia.com>
2
1
3
This function was only using the BlockDriverState parameter to pass it
4
to qcow2_cache_get_table_idx() and qcow2_cache_table_release(). This
5
is no longer necessary so this parameter can be removed.
6
7
Signed-off-by: Alberto Garcia <berto@igalia.com>
8
Reviewed-by: Eric Blake <eblake@redhat.com>
9
Reviewed-by: Max Reitz <mreitz@redhat.com>
10
Message-id: 9724f7e38e763ad3be32627c6b7fe8df9edb1476.1517840877.git.berto@igalia.com
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
12
---
13
block/qcow2.h | 2 +-
14
block/qcow2-cache.c | 2 +-
15
block/qcow2-refcount.c | 6 +++---
16
3 files changed, 5 insertions(+), 5 deletions(-)
17
18
diff --git a/block/qcow2.h b/block/qcow2.h
19
index XXXXXXX..XXXXXXX 100644
20
--- a/block/qcow2.h
21
+++ b/block/qcow2.h
22
@@ -XXX,XX +XXX,XX @@ int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset,
23
void qcow2_cache_put(Qcow2Cache *c, void **table);
24
void *qcow2_cache_is_table_offset(BlockDriverState *bs, Qcow2Cache *c,
25
uint64_t offset);
26
-void qcow2_cache_discard(BlockDriverState *bs, Qcow2Cache *c, void *table);
27
+void qcow2_cache_discard(Qcow2Cache *c, void *table);
28
29
/* qcow2-bitmap.c functions */
30
int qcow2_check_bitmaps_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
31
diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/block/qcow2-cache.c
34
+++ b/block/qcow2-cache.c
35
@@ -XXX,XX +XXX,XX @@ void *qcow2_cache_is_table_offset(BlockDriverState *bs, Qcow2Cache *c,
36
return NULL;
37
}
38
39
-void qcow2_cache_discard(BlockDriverState *bs, Qcow2Cache *c, void *table)
40
+void qcow2_cache_discard(Qcow2Cache *c, void *table)
41
{
42
int i = qcow2_cache_get_table_idx(c, table);
43
44
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/block/qcow2-refcount.c
47
+++ b/block/qcow2-refcount.c
48
@@ -XXX,XX +XXX,XX @@ static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
49
offset);
50
if (table != NULL) {
51
qcow2_cache_put(s->refcount_block_cache, &refcount_block);
52
- qcow2_cache_discard(bs, s->refcount_block_cache, table);
53
+ qcow2_cache_discard(s->refcount_block_cache, table);
54
}
55
56
table = qcow2_cache_is_table_offset(bs, s->l2_table_cache, offset);
57
if (table != NULL) {
58
- qcow2_cache_discard(bs, s->l2_table_cache, table);
59
+ qcow2_cache_discard(s->l2_table_cache, table);
60
}
61
62
if (s->discard_passthrough[type]) {
63
@@ -XXX,XX +XXX,XX @@ static int qcow2_discard_refcount_block(BlockDriverState *bs,
64
discard_block_offs);
65
if (refblock) {
66
/* discard refblock from the cache if refblock is cached */
67
- qcow2_cache_discard(bs, s->refcount_block_cache, refblock);
68
+ qcow2_cache_discard(s->refcount_block_cache, refblock);
69
}
70
update_refcount_discard(bs, discard_block_offs, s->cluster_size);
71
72
--
73
2.13.6
74
75
diff view generated by jsdifflib
Deleted patch
1
From: Alberto Garcia <berto@igalia.com>
2
1
3
This function was only using the BlockDriverState parameter to pass it
4
to qcow2_cache_get_table_addr(). This is no longer necessary so this
5
parameter can be removed.
6
7
Signed-off-by: Alberto Garcia <berto@igalia.com>
8
Reviewed-by: Eric Blake <eblake@redhat.com>
9
Reviewed-by: Max Reitz <mreitz@redhat.com>
10
Message-id: eb0ed90affcf302e5a954bafb5931b5215483d3a.1517840877.git.berto@igalia.com
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
12
---
13
block/qcow2.h | 3 +--
14
block/qcow2-cache.c | 3 +--
15
block/qcow2-refcount.c | 6 +++---
16
3 files changed, 5 insertions(+), 7 deletions(-)
17
18
diff --git a/block/qcow2.h b/block/qcow2.h
19
index XXXXXXX..XXXXXXX 100644
20
--- a/block/qcow2.h
21
+++ b/block/qcow2.h
22
@@ -XXX,XX +XXX,XX @@ int qcow2_cache_get(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset,
23
int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset,
24
void **table);
25
void qcow2_cache_put(Qcow2Cache *c, void **table);
26
-void *qcow2_cache_is_table_offset(BlockDriverState *bs, Qcow2Cache *c,
27
- uint64_t offset);
28
+void *qcow2_cache_is_table_offset(Qcow2Cache *c, uint64_t offset);
29
void qcow2_cache_discard(Qcow2Cache *c, void *table);
30
31
/* qcow2-bitmap.c functions */
32
diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/block/qcow2-cache.c
35
+++ b/block/qcow2-cache.c
36
@@ -XXX,XX +XXX,XX @@ void qcow2_cache_entry_mark_dirty(Qcow2Cache *c, void *table)
37
c->entries[i].dirty = true;
38
}
39
40
-void *qcow2_cache_is_table_offset(BlockDriverState *bs, Qcow2Cache *c,
41
- uint64_t offset)
42
+void *qcow2_cache_is_table_offset(Qcow2Cache *c, uint64_t offset)
43
{
44
int i;
45
46
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
47
index XXXXXXX..XXXXXXX 100644
48
--- a/block/qcow2-refcount.c
49
+++ b/block/qcow2-refcount.c
50
@@ -XXX,XX +XXX,XX @@ static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
51
if (refcount == 0) {
52
void *table;
53
54
- table = qcow2_cache_is_table_offset(bs, s->refcount_block_cache,
55
+ table = qcow2_cache_is_table_offset(s->refcount_block_cache,
56
offset);
57
if (table != NULL) {
58
qcow2_cache_put(s->refcount_block_cache, &refcount_block);
59
qcow2_cache_discard(s->refcount_block_cache, table);
60
}
61
62
- table = qcow2_cache_is_table_offset(bs, s->l2_table_cache, offset);
63
+ table = qcow2_cache_is_table_offset(s->l2_table_cache, offset);
64
if (table != NULL) {
65
qcow2_cache_discard(s->l2_table_cache, table);
66
}
67
@@ -XXX,XX +XXX,XX @@ static int qcow2_discard_refcount_block(BlockDriverState *bs,
68
s->free_cluster_index = cluster_index;
69
}
70
71
- refblock = qcow2_cache_is_table_offset(bs, s->refcount_block_cache,
72
+ refblock = qcow2_cache_is_table_offset(s->refcount_block_cache,
73
discard_block_offs);
74
if (refblock) {
75
/* discard refblock from the cache if refblock is cached */
76
--
77
2.13.6
78
79
diff view generated by jsdifflib
Deleted patch
1
From: Alberto Garcia <berto@igalia.com>
2
1
3
Similar to offset_to_l2_index(), this function returns the index in
4
the L1 table for a given guest offset. This is only used in a couple
5
of places and it's not a particularly complex calculation, but it
6
makes the code a bit more readable.
7
8
Although in the qcow2_get_cluster_offset() case the old code was
9
taking advantage of the l1_bits variable, we're going to get rid of
10
the other uses of l1_bits in a later patch anyway, so it doesn't make
11
sense to keep it just for this.
12
13
Signed-off-by: Alberto Garcia <berto@igalia.com>
14
Reviewed-by: Eric Blake <eblake@redhat.com>
15
Reviewed-by: Max Reitz <mreitz@redhat.com>
16
Message-id: a5f626fed526b7459a0425fad06d823d18df8522.1517840877.git.berto@igalia.com
17
Signed-off-by: Max Reitz <mreitz@redhat.com>
18
---
19
block/qcow2.h | 5 +++++
20
block/qcow2-cluster.c | 4 ++--
21
2 files changed, 7 insertions(+), 2 deletions(-)
22
23
diff --git a/block/qcow2.h b/block/qcow2.h
24
index XXXXXXX..XXXXXXX 100644
25
--- a/block/qcow2.h
26
+++ b/block/qcow2.h
27
@@ -XXX,XX +XXX,XX @@ static inline int64_t size_to_l1(BDRVQcow2State *s, int64_t size)
28
return (size + (1ULL << shift) - 1) >> shift;
29
}
30
31
+static inline int offset_to_l1_index(BDRVQcow2State *s, uint64_t offset)
32
+{
33
+ return offset >> (s->l2_bits + s->cluster_bits);
34
+}
35
+
36
static inline int offset_to_l2_index(BDRVQcow2State *s, int64_t offset)
37
{
38
return (offset >> s->cluster_bits) & (s->l2_size - 1);
39
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
40
index XXXXXXX..XXXXXXX 100644
41
--- a/block/qcow2-cluster.c
42
+++ b/block/qcow2-cluster.c
43
@@ -XXX,XX +XXX,XX @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
44
45
/* seek to the l2 offset in the l1 table */
46
47
- l1_index = offset >> l1_bits;
48
+ l1_index = offset_to_l1_index(s, offset);
49
if (l1_index >= s->l1_size) {
50
type = QCOW2_CLUSTER_UNALLOCATED;
51
goto out;
52
@@ -XXX,XX +XXX,XX @@ static int get_cluster_table(BlockDriverState *bs, uint64_t offset,
53
54
/* seek to the l2 offset in the l1 table */
55
56
- l1_index = offset >> (s->l2_bits + s->cluster_bits);
57
+ l1_index = offset_to_l1_index(s, offset);
58
if (l1_index >= s->l1_size) {
59
ret = qcow2_grow_l1_table(bs, l1_index + 1, false);
60
if (ret < 0) {
61
--
62
2.13.6
63
64
diff view generated by jsdifflib
Deleted patch
1
From: Alberto Garcia <berto@igalia.com>
2
1
3
Similar to offset_to_l2_index(), this function takes a guest offset
4
and returns the index in the L2 slice that contains its L2 entry.
5
6
An L2 slice has currently the same size as an L2 table (one cluster),
7
so both functions return the same value for now.
8
9
Signed-off-by: Alberto Garcia <berto@igalia.com>
10
Reviewed-by: Eric Blake <eblake@redhat.com>
11
Reviewed-by: Max Reitz <mreitz@redhat.com>
12
Message-id: a1c45c5c5a76146dd1712d8d1e7b409ad539c718.1517840877.git.berto@igalia.com
13
Signed-off-by: Max Reitz <mreitz@redhat.com>
14
---
15
block/qcow2.h | 5 +++++
16
1 file changed, 5 insertions(+)
17
18
diff --git a/block/qcow2.h b/block/qcow2.h
19
index XXXXXXX..XXXXXXX 100644
20
--- a/block/qcow2.h
21
+++ b/block/qcow2.h
22
@@ -XXX,XX +XXX,XX @@ static inline int offset_to_l2_index(BDRVQcow2State *s, int64_t offset)
23
return (offset >> s->cluster_bits) & (s->l2_size - 1);
24
}
25
26
+static inline int offset_to_l2_slice_index(BDRVQcow2State *s, int64_t offset)
27
+{
28
+ return (offset >> s->cluster_bits) & (s->l2_slice_size - 1);
29
+}
30
+
31
static inline int64_t align_offset(int64_t offset, int n)
32
{
33
offset = (offset + n - 1) & ~(n - 1);
34
--
35
2.13.6
36
37
diff view generated by jsdifflib
Deleted patch
1
From: Alberto Garcia <berto@igalia.com>
2
1
3
Each entry in the qcow2 L2 cache stores a full L2 table (which uses a
4
complete cluster in the qcow2 image). A cluster is usually too large
5
to be used efficiently as the size for a cache entry, so we want to
6
decouple both values by allowing smaller cache entries. Therefore the
7
qcow2 L2 cache will no longer return full L2 tables but slices
8
instead.
9
10
This patch updates l2_load() so it can handle L2 slices correctly.
11
Apart from the offset of the L2 table (which we already had) we also
12
need the guest offset in order to calculate which one of the slices
13
we need.
14
15
An L2 slice has currently the same size as an L2 table (one cluster),
16
so for now this function will load exactly the same data as before.
17
18
This patch also removes a stale comment about the return value being
19
a pointer to the L2 table. This function returns an error code since
20
55c17e9821c474d5fcdebdc82ed2fc096777d611.
21
22
Signed-off-by: Alberto Garcia <berto@igalia.com>
23
Reviewed-by: Eric Blake <eblake@redhat.com>
24
Reviewed-by: Max Reitz <mreitz@redhat.com>
25
Message-id: b830aa1fc5b6f8e3cb331d006853fe22facca847.1517840877.git.berto@igalia.com
26
Signed-off-by: Max Reitz <mreitz@redhat.com>
27
---
28
block/qcow2-cluster.c | 28 +++++++++++++++++-----------
29
1 file changed, 17 insertions(+), 11 deletions(-)
30
31
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/block/qcow2-cluster.c
34
+++ b/block/qcow2-cluster.c
35
@@ -XXX,XX +XXX,XX @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size,
36
/*
37
* l2_load
38
*
39
- * Loads a L2 table into memory. If the table is in the cache, the cache
40
- * is used; otherwise the L2 table is loaded from the image file.
41
+ * @bs: The BlockDriverState
42
+ * @offset: A guest offset, used to calculate what slice of the L2
43
+ * table to load.
44
+ * @l2_offset: Offset to the L2 table in the image file.
45
+ * @l2_slice: Location to store the pointer to the L2 slice.
46
*
47
- * Returns a pointer to the L2 table on success, or NULL if the read from
48
- * the image file failed.
49
+ * Loads a L2 slice into memory (L2 slices are the parts of L2 tables
50
+ * that are loaded by the qcow2 cache). If the slice is in the cache,
51
+ * the cache is used; otherwise the L2 slice is loaded from the image
52
+ * file.
53
*/
54
-
55
-static int l2_load(BlockDriverState *bs, uint64_t l2_offset,
56
- uint64_t **l2_table)
57
+static int l2_load(BlockDriverState *bs, uint64_t offset,
58
+ uint64_t l2_offset, uint64_t **l2_slice)
59
{
60
BDRVQcow2State *s = bs->opaque;
61
+ int start_of_slice = sizeof(uint64_t) *
62
+ (offset_to_l2_index(s, offset) - offset_to_l2_slice_index(s, offset));
63
64
- return qcow2_cache_get(bs, s->l2_table_cache, l2_offset,
65
- (void **)l2_table);
66
+ return qcow2_cache_get(bs, s->l2_table_cache, l2_offset + start_of_slice,
67
+ (void **)l2_slice);
68
}
69
70
/*
71
@@ -XXX,XX +XXX,XX @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
72
73
/* load the l2 table in memory */
74
75
- ret = l2_load(bs, l2_offset, &l2_table);
76
+ ret = l2_load(bs, offset, l2_offset, &l2_table);
77
if (ret < 0) {
78
return ret;
79
}
80
@@ -XXX,XX +XXX,XX @@ static int get_cluster_table(BlockDriverState *bs, uint64_t offset,
81
82
if (s->l1_table[l1_index] & QCOW_OFLAG_COPIED) {
83
/* load the l2 table in memory */
84
- ret = l2_load(bs, l2_offset, &l2_table);
85
+ ret = l2_load(bs, offset, l2_offset, &l2_table);
86
if (ret < 0) {
87
return ret;
88
}
89
--
90
2.13.6
91
92
diff view generated by jsdifflib
Deleted patch
1
From: Alberto Garcia <berto@igalia.com>
2
1
3
There's a loop in this function that iterates over the L2 entries in a
4
table, so now we need to assert that it remains within the limits of
5
an L2 slice.
6
7
Apart from that, this function doesn't need any additional changes, so
8
this patch simply updates the variable name from l2_table to l2_slice.
9
10
Signed-off-by: Alberto Garcia <berto@igalia.com>
11
Reviewed-by: Eric Blake <eblake@redhat.com>
12
Reviewed-by: Max Reitz <mreitz@redhat.com>
13
Message-id: f9846a1c2efc51938e877e2a25852d9ab14797ff.1517840877.git.berto@igalia.com
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
16
block/qcow2-cluster.c | 16 ++++++++--------
17
1 file changed, 8 insertions(+), 8 deletions(-)
18
19
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/block/qcow2-cluster.c
22
+++ b/block/qcow2-cluster.c
23
@@ -XXX,XX +XXX,XX @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m)
24
{
25
BDRVQcow2State *s = bs->opaque;
26
int i, j = 0, l2_index, ret;
27
- uint64_t *old_cluster, *l2_table;
28
+ uint64_t *old_cluster, *l2_slice;
29
uint64_t cluster_offset = m->alloc_offset;
30
31
trace_qcow2_cluster_link_l2(qemu_coroutine_self(), m->nb_clusters);
32
@@ -XXX,XX +XXX,XX @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m)
33
s->refcount_block_cache);
34
}
35
36
- ret = get_cluster_table(bs, m->offset, &l2_table, &l2_index);
37
+ ret = get_cluster_table(bs, m->offset, &l2_slice, &l2_index);
38
if (ret < 0) {
39
goto err;
40
}
41
- qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
42
+ qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice);
43
44
- assert(l2_index + m->nb_clusters <= s->l2_size);
45
+ assert(l2_index + m->nb_clusters <= s->l2_slice_size);
46
for (i = 0; i < m->nb_clusters; i++) {
47
/* if two concurrent writes happen to the same unallocated cluster
48
* each write allocates separate cluster and writes data concurrently.
49
@@ -XXX,XX +XXX,XX @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m)
50
* cluster the second one has to do RMW (which is done above by
51
* perform_cow()), update l2 table with its cluster pointer and free
52
* old cluster. This is what this loop does */
53
- if (l2_table[l2_index + i] != 0) {
54
- old_cluster[j++] = l2_table[l2_index + i];
55
+ if (l2_slice[l2_index + i] != 0) {
56
+ old_cluster[j++] = l2_slice[l2_index + i];
57
}
58
59
- l2_table[l2_index + i] = cpu_to_be64((cluster_offset +
60
+ l2_slice[l2_index + i] = cpu_to_be64((cluster_offset +
61
(i << s->cluster_bits)) | QCOW_OFLAG_COPIED);
62
}
63
64
65
- qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
66
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice);
67
68
/*
69
* If this was a COW, we need to decrease the refcount of the old cluster.
70
--
71
2.13.6
72
73
diff view generated by jsdifflib
Deleted patch
1
From: Alberto Garcia <berto@igalia.com>
2
1
3
handle_copied() loads an L2 table and limits the number of checked
4
clusters to the amount that fits inside that table. Since we'll be
5
loading L2 slices instead of full tables we need to update that limit.
6
7
Apart from that, this function doesn't need any additional changes, so
8
this patch simply updates the variable name from l2_table to l2_slice.
9
10
Signed-off-by: Alberto Garcia <berto@igalia.com>
11
Reviewed-by: Eric Blake <eblake@redhat.com>
12
Reviewed-by: Max Reitz <mreitz@redhat.com>
13
Message-id: 541ac001a7d6b86bab2392554bee53c2b312148c.1517840877.git.berto@igalia.com
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
16
block/qcow2-cluster.c | 16 ++++++++--------
17
1 file changed, 8 insertions(+), 8 deletions(-)
18
19
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/block/qcow2-cluster.c
22
+++ b/block/qcow2-cluster.c
23
@@ -XXX,XX +XXX,XX @@ static int handle_copied(BlockDriverState *bs, uint64_t guest_offset,
24
BDRVQcow2State *s = bs->opaque;
25
int l2_index;
26
uint64_t cluster_offset;
27
- uint64_t *l2_table;
28
+ uint64_t *l2_slice;
29
uint64_t nb_clusters;
30
unsigned int keep_clusters;
31
int ret;
32
@@ -XXX,XX +XXX,XX @@ static int handle_copied(BlockDriverState *bs, uint64_t guest_offset,
33
== offset_into_cluster(s, *host_offset));
34
35
/*
36
- * Calculate the number of clusters to look for. We stop at L2 table
37
+ * Calculate the number of clusters to look for. We stop at L2 slice
38
* boundaries to keep things simple.
39
*/
40
nb_clusters =
41
size_to_clusters(s, offset_into_cluster(s, guest_offset) + *bytes);
42
43
- l2_index = offset_to_l2_index(s, guest_offset);
44
- nb_clusters = MIN(nb_clusters, s->l2_size - l2_index);
45
+ l2_index = offset_to_l2_slice_index(s, guest_offset);
46
+ nb_clusters = MIN(nb_clusters, s->l2_slice_size - l2_index);
47
assert(nb_clusters <= INT_MAX);
48
49
/* Find L2 entry for the first involved cluster */
50
- ret = get_cluster_table(bs, guest_offset, &l2_table, &l2_index);
51
+ ret = get_cluster_table(bs, guest_offset, &l2_slice, &l2_index);
52
if (ret < 0) {
53
return ret;
54
}
55
56
- cluster_offset = be64_to_cpu(l2_table[l2_index]);
57
+ cluster_offset = be64_to_cpu(l2_slice[l2_index]);
58
59
/* Check how many clusters are already allocated and don't need COW */
60
if (qcow2_get_cluster_type(cluster_offset) == QCOW2_CLUSTER_NORMAL
61
@@ -XXX,XX +XXX,XX @@ static int handle_copied(BlockDriverState *bs, uint64_t guest_offset,
62
/* We keep all QCOW_OFLAG_COPIED clusters */
63
keep_clusters =
64
count_contiguous_clusters(nb_clusters, s->cluster_size,
65
- &l2_table[l2_index],
66
+ &l2_slice[l2_index],
67
QCOW_OFLAG_COPIED | QCOW_OFLAG_ZERO);
68
assert(keep_clusters <= nb_clusters);
69
70
@@ -XXX,XX +XXX,XX @@ static int handle_copied(BlockDriverState *bs, uint64_t guest_offset,
71
72
/* Cleanup */
73
out:
74
- qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
75
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice);
76
77
/* Only return a host offset if we actually made progress. Otherwise we
78
* would make requirements for handle_alloc() that it can't fulfill */
79
--
80
2.13.6
81
82
diff view generated by jsdifflib
Deleted patch
1
From: Alberto Garcia <berto@igalia.com>
2
1
3
discard_single_l2() limits the number of clusters to be discarded
4
to the amount that fits inside an L2 table. Since we'll be loading
5
L2 slices instead of full tables we need to update that limit. The
6
function is renamed to discard_in_l2_slice() for clarity.
7
8
Apart from that, this function doesn't need any additional changes, so
9
this patch simply updates the variable name from l2_table to l2_slice.
10
11
Signed-off-by: Alberto Garcia <berto@igalia.com>
12
Message-id: 1cb44a5b68be5334cb01b97a3db3a3c5a43396e5.1517840877.git.berto@igalia.com
13
Reviewed-by: Eric Blake <eblake@redhat.com>
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
16
block/qcow2-cluster.c | 32 ++++++++++++++++----------------
17
1 file changed, 16 insertions(+), 16 deletions(-)
18
19
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/block/qcow2-cluster.c
22
+++ b/block/qcow2-cluster.c
23
@@ -XXX,XX +XXX,XX @@ int qcow2_decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset)
24
25
/*
26
* This discards as many clusters of nb_clusters as possible at once (i.e.
27
- * all clusters in the same L2 table) and returns the number of discarded
28
+ * all clusters in the same L2 slice) and returns the number of discarded
29
* clusters.
30
*/
31
-static int discard_single_l2(BlockDriverState *bs, uint64_t offset,
32
- uint64_t nb_clusters, enum qcow2_discard_type type,
33
- bool full_discard)
34
+static int discard_in_l2_slice(BlockDriverState *bs, uint64_t offset,
35
+ uint64_t nb_clusters,
36
+ enum qcow2_discard_type type, bool full_discard)
37
{
38
BDRVQcow2State *s = bs->opaque;
39
- uint64_t *l2_table;
40
+ uint64_t *l2_slice;
41
int l2_index;
42
int ret;
43
int i;
44
45
- ret = get_cluster_table(bs, offset, &l2_table, &l2_index);
46
+ ret = get_cluster_table(bs, offset, &l2_slice, &l2_index);
47
if (ret < 0) {
48
return ret;
49
}
50
51
- /* Limit nb_clusters to one L2 table */
52
- nb_clusters = MIN(nb_clusters, s->l2_size - l2_index);
53
+ /* Limit nb_clusters to one L2 slice */
54
+ nb_clusters = MIN(nb_clusters, s->l2_slice_size - l2_index);
55
assert(nb_clusters <= INT_MAX);
56
57
for (i = 0; i < nb_clusters; i++) {
58
uint64_t old_l2_entry;
59
60
- old_l2_entry = be64_to_cpu(l2_table[l2_index + i]);
61
+ old_l2_entry = be64_to_cpu(l2_slice[l2_index + i]);
62
63
/*
64
* If full_discard is false, make sure that a discarded area reads back
65
@@ -XXX,XX +XXX,XX @@ static int discard_single_l2(BlockDriverState *bs, uint64_t offset,
66
}
67
68
/* First remove L2 entries */
69
- qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
70
+ qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice);
71
if (!full_discard && s->qcow_version >= 3) {
72
- l2_table[l2_index + i] = cpu_to_be64(QCOW_OFLAG_ZERO);
73
+ l2_slice[l2_index + i] = cpu_to_be64(QCOW_OFLAG_ZERO);
74
} else {
75
- l2_table[l2_index + i] = cpu_to_be64(0);
76
+ l2_slice[l2_index + i] = cpu_to_be64(0);
77
}
78
79
/* Then decrease the refcount */
80
qcow2_free_any_clusters(bs, old_l2_entry, 1, type);
81
}
82
83
- qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
84
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice);
85
86
return nb_clusters;
87
}
88
@@ -XXX,XX +XXX,XX @@ int qcow2_cluster_discard(BlockDriverState *bs, uint64_t offset,
89
90
s->cache_discards = true;
91
92
- /* Each L2 table is handled by its own loop iteration */
93
+ /* Each L2 slice is handled by its own loop iteration */
94
while (nb_clusters > 0) {
95
- cleared = discard_single_l2(bs, offset, nb_clusters, type,
96
- full_discard);
97
+ cleared = discard_in_l2_slice(bs, offset, nb_clusters, type,
98
+ full_discard);
99
if (cleared < 0) {
100
ret = cleared;
101
goto fail;
102
--
103
2.13.6
104
105
diff view generated by jsdifflib
Deleted patch
1
From: Alberto Garcia <berto@igalia.com>
2
1
3
zero_single_l2() limits the number of clusters to be zeroed to the
4
amount that fits inside an L2 table. Since we'll be loading L2 slices
5
instead of full tables we need to update that limit. The function is
6
renamed to zero_in_l2_slice() for clarity.
7
8
Apart from that, this function doesn't need any additional changes, so
9
this patch simply updates the variable name from l2_table to l2_slice.
10
11
Signed-off-by: Alberto Garcia <berto@igalia.com>
12
Message-id: ebc16e7e79fa6969d8975ef487d679794de4fbcc.1517840877.git.berto@igalia.com
13
Reviewed-by: Eric Blake <eblake@redhat.com>
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
16
block/qcow2-cluster.c | 28 ++++++++++++++--------------
17
1 file changed, 14 insertions(+), 14 deletions(-)
18
19
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/block/qcow2-cluster.c
22
+++ b/block/qcow2-cluster.c
23
@@ -XXX,XX +XXX,XX @@ fail:
24
25
/*
26
* This zeroes as many clusters of nb_clusters as possible at once (i.e.
27
- * all clusters in the same L2 table) and returns the number of zeroed
28
+ * all clusters in the same L2 slice) and returns the number of zeroed
29
* clusters.
30
*/
31
-static int zero_single_l2(BlockDriverState *bs, uint64_t offset,
32
- uint64_t nb_clusters, int flags)
33
+static int zero_in_l2_slice(BlockDriverState *bs, uint64_t offset,
34
+ uint64_t nb_clusters, int flags)
35
{
36
BDRVQcow2State *s = bs->opaque;
37
- uint64_t *l2_table;
38
+ uint64_t *l2_slice;
39
int l2_index;
40
int ret;
41
int i;
42
bool unmap = !!(flags & BDRV_REQ_MAY_UNMAP);
43
44
- ret = get_cluster_table(bs, offset, &l2_table, &l2_index);
45
+ ret = get_cluster_table(bs, offset, &l2_slice, &l2_index);
46
if (ret < 0) {
47
return ret;
48
}
49
50
- /* Limit nb_clusters to one L2 table */
51
- nb_clusters = MIN(nb_clusters, s->l2_size - l2_index);
52
+ /* Limit nb_clusters to one L2 slice */
53
+ nb_clusters = MIN(nb_clusters, s->l2_slice_size - l2_index);
54
assert(nb_clusters <= INT_MAX);
55
56
for (i = 0; i < nb_clusters; i++) {
57
uint64_t old_offset;
58
QCow2ClusterType cluster_type;
59
60
- old_offset = be64_to_cpu(l2_table[l2_index + i]);
61
+ old_offset = be64_to_cpu(l2_slice[l2_index + i]);
62
63
/*
64
* Minimize L2 changes if the cluster already reads back as
65
@@ -XXX,XX +XXX,XX @@ static int zero_single_l2(BlockDriverState *bs, uint64_t offset,
66
continue;
67
}
68
69
- qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
70
+ qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice);
71
if (cluster_type == QCOW2_CLUSTER_COMPRESSED || unmap) {
72
- l2_table[l2_index + i] = cpu_to_be64(QCOW_OFLAG_ZERO);
73
+ l2_slice[l2_index + i] = cpu_to_be64(QCOW_OFLAG_ZERO);
74
qcow2_free_any_clusters(bs, old_offset, 1, QCOW2_DISCARD_REQUEST);
75
} else {
76
- l2_table[l2_index + i] |= cpu_to_be64(QCOW_OFLAG_ZERO);
77
+ l2_slice[l2_index + i] |= cpu_to_be64(QCOW_OFLAG_ZERO);
78
}
79
}
80
81
- qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
82
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice);
83
84
return nb_clusters;
85
}
86
@@ -XXX,XX +XXX,XX @@ int qcow2_cluster_zeroize(BlockDriverState *bs, uint64_t offset,
87
return -ENOTSUP;
88
}
89
90
- /* Each L2 table is handled by its own loop iteration */
91
+ /* Each L2 slice is handled by its own loop iteration */
92
nb_clusters = size_to_clusters(s, bytes);
93
94
s->cache_discards = true;
95
96
while (nb_clusters > 0) {
97
- cleared = zero_single_l2(bs, offset, nb_clusters, flags);
98
+ cleared = zero_in_l2_slice(bs, offset, nb_clusters, flags);
99
if (cleared < 0) {
100
ret = cleared;
101
goto fail;
102
--
103
2.13.6
104
105
diff view generated by jsdifflib
Deleted patch
1
From: Alberto Garcia <berto@igalia.com>
2
1
3
Adding support for L2 slices to qcow2_update_snapshot_refcount() needs
4
(among other things) an extra loop that iterates over all slices of
5
each L2 table.
6
7
Putting all changes in one patch would make it hard to read because
8
all semantic changes would be mixed with pure indentation changes.
9
10
To make things easier this patch simply creates a new block and
11
changes the indentation of all lines of code inside it. Thus, all
12
modifications in this patch are cosmetic. There are no semantic
13
changes and no variables are renamed yet. The next patch will take
14
care of that.
15
16
Signed-off-by: Alberto Garcia <berto@igalia.com>
17
Reviewed-by: Eric Blake <eblake@redhat.com>
18
Reviewed-by: Max Reitz <mreitz@redhat.com>
19
Message-id: 8ffaa5e55bd51121f80e498f4045b64902a94293.1517840877.git.berto@igalia.com
20
Signed-off-by: Max Reitz <mreitz@redhat.com>
21
---
22
block/qcow2-refcount.c | 144 +++++++++++++++++++++++++------------------------
23
1 file changed, 75 insertions(+), 69 deletions(-)
24
25
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
26
index XXXXXXX..XXXXXXX 100644
27
--- a/block/qcow2-refcount.c
28
+++ b/block/qcow2-refcount.c
29
@@ -XXX,XX +XXX,XX @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
30
goto fail;
31
}
32
33
- ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset,
34
- (void**) &l2_table);
35
- if (ret < 0) {
36
- goto fail;
37
- }
38
+ {
39
+ ret = qcow2_cache_get(bs, s->l2_table_cache,
40
+ l2_offset,
41
+ (void **) &l2_table);
42
+ if (ret < 0) {
43
+ goto fail;
44
+ }
45
46
- for (j = 0; j < s->l2_size; j++) {
47
- uint64_t cluster_index;
48
- uint64_t offset;
49
-
50
- entry = be64_to_cpu(l2_table[j]);
51
- old_entry = entry;
52
- entry &= ~QCOW_OFLAG_COPIED;
53
- offset = entry & L2E_OFFSET_MASK;
54
-
55
- switch (qcow2_get_cluster_type(entry)) {
56
- case QCOW2_CLUSTER_COMPRESSED:
57
- nb_csectors = ((entry >> s->csize_shift) &
58
- s->csize_mask) + 1;
59
- if (addend != 0) {
60
- ret = update_refcount(bs,
61
- (entry & s->cluster_offset_mask) & ~511,
62
+ for (j = 0; j < s->l2_size; j++) {
63
+ uint64_t cluster_index;
64
+ uint64_t offset;
65
+
66
+ entry = be64_to_cpu(l2_table[j]);
67
+ old_entry = entry;
68
+ entry &= ~QCOW_OFLAG_COPIED;
69
+ offset = entry & L2E_OFFSET_MASK;
70
+
71
+ switch (qcow2_get_cluster_type(entry)) {
72
+ case QCOW2_CLUSTER_COMPRESSED:
73
+ nb_csectors = ((entry >> s->csize_shift) &
74
+ s->csize_mask) + 1;
75
+ if (addend != 0) {
76
+ ret = update_refcount(
77
+ bs, (entry & s->cluster_offset_mask) & ~511,
78
nb_csectors * 512, abs(addend), addend < 0,
79
QCOW2_DISCARD_SNAPSHOT);
80
- if (ret < 0) {
81
+ if (ret < 0) {
82
+ goto fail;
83
+ }
84
+ }
85
+ /* compressed clusters are never modified */
86
+ refcount = 2;
87
+ break;
88
+
89
+ case QCOW2_CLUSTER_NORMAL:
90
+ case QCOW2_CLUSTER_ZERO_ALLOC:
91
+ if (offset_into_cluster(s, offset)) {
92
+ qcow2_signal_corruption(
93
+ bs, true, -1, -1, "Cluster "
94
+ "allocation offset %#" PRIx64
95
+ " unaligned (L2 offset: %#"
96
+ PRIx64 ", L2 index: %#x)",
97
+ offset, l2_offset, j);
98
+ ret = -EIO;
99
goto fail;
100
}
101
- }
102
- /* compressed clusters are never modified */
103
- refcount = 2;
104
- break;
105
-
106
- case QCOW2_CLUSTER_NORMAL:
107
- case QCOW2_CLUSTER_ZERO_ALLOC:
108
- if (offset_into_cluster(s, offset)) {
109
- qcow2_signal_corruption(bs, true, -1, -1, "Cluster "
110
- "allocation offset %#" PRIx64
111
- " unaligned (L2 offset: %#"
112
- PRIx64 ", L2 index: %#x)",
113
- offset, l2_offset, j);
114
- ret = -EIO;
115
- goto fail;
116
- }
117
118
- cluster_index = offset >> s->cluster_bits;
119
- assert(cluster_index);
120
- if (addend != 0) {
121
- ret = qcow2_update_cluster_refcount(bs,
122
- cluster_index, abs(addend), addend < 0,
123
- QCOW2_DISCARD_SNAPSHOT);
124
+ cluster_index = offset >> s->cluster_bits;
125
+ assert(cluster_index);
126
+ if (addend != 0) {
127
+ ret = qcow2_update_cluster_refcount(
128
+ bs, cluster_index, abs(addend), addend < 0,
129
+ QCOW2_DISCARD_SNAPSHOT);
130
+ if (ret < 0) {
131
+ goto fail;
132
+ }
133
+ }
134
+
135
+ ret = qcow2_get_refcount(bs, cluster_index, &refcount);
136
if (ret < 0) {
137
goto fail;
138
}
139
- }
140
+ break;
141
142
- ret = qcow2_get_refcount(bs, cluster_index, &refcount);
143
- if (ret < 0) {
144
- goto fail;
145
- }
146
- break;
147
-
148
- case QCOW2_CLUSTER_ZERO_PLAIN:
149
- case QCOW2_CLUSTER_UNALLOCATED:
150
- refcount = 0;
151
- break;
152
+ case QCOW2_CLUSTER_ZERO_PLAIN:
153
+ case QCOW2_CLUSTER_UNALLOCATED:
154
+ refcount = 0;
155
+ break;
156
157
- default:
158
- abort();
159
- }
160
+ default:
161
+ abort();
162
+ }
163
164
- if (refcount == 1) {
165
- entry |= QCOW_OFLAG_COPIED;
166
- }
167
- if (entry != old_entry) {
168
- if (addend > 0) {
169
- qcow2_cache_set_dependency(bs, s->l2_table_cache,
170
- s->refcount_block_cache);
171
+ if (refcount == 1) {
172
+ entry |= QCOW_OFLAG_COPIED;
173
+ }
174
+ if (entry != old_entry) {
175
+ if (addend > 0) {
176
+ qcow2_cache_set_dependency(bs, s->l2_table_cache,
177
+ s->refcount_block_cache);
178
+ }
179
+ l2_table[j] = cpu_to_be64(entry);
180
+ qcow2_cache_entry_mark_dirty(s->l2_table_cache,
181
+ l2_table);
182
}
183
- l2_table[j] = cpu_to_be64(entry);
184
- qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
185
}
186
- }
187
188
- qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
189
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
190
+
191
+ }
192
193
if (addend != 0) {
194
ret = qcow2_update_cluster_refcount(bs, l2_offset >>
195
--
196
2.13.6
197
198
diff view generated by jsdifflib
Deleted patch
1
From: Alberto Garcia <berto@igalia.com>
2
1
3
At the moment it doesn't really make a difference whether we call
4
qcow2_get_refcount() before of after reading the L2 table, but if we
5
want to support L2 slices we'll need to read the refcount first.
6
7
This patch simply changes the order of those two operations to prepare
8
for that. The patch with the actual semantic changes will be easier to
9
read because of this.
10
11
Signed-off-by: Alberto Garcia <berto@igalia.com>
12
Reviewed-by: Eric Blake <eblake@redhat.com>
13
Reviewed-by: Max Reitz <mreitz@redhat.com>
14
Message-id: 947a91d934053a2dbfef979aeb9568f57ef57c5d.1517840877.git.berto@igalia.com
15
Signed-off-by: Max Reitz <mreitz@redhat.com>
16
---
17
block/qcow2-cluster.c | 12 ++++++------
18
1 file changed, 6 insertions(+), 6 deletions(-)
19
20
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/block/qcow2-cluster.c
23
+++ b/block/qcow2-cluster.c
24
@@ -XXX,XX +XXX,XX @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table,
25
goto fail;
26
}
27
28
+ ret = qcow2_get_refcount(bs, l2_offset >> s->cluster_bits,
29
+ &l2_refcount);
30
+ if (ret < 0) {
31
+ goto fail;
32
+ }
33
+
34
if (is_active_l1) {
35
/* get active L2 tables from cache */
36
ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset,
37
@@ -XXX,XX +XXX,XX @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table,
38
goto fail;
39
}
40
41
- ret = qcow2_get_refcount(bs, l2_offset >> s->cluster_bits,
42
- &l2_refcount);
43
- if (ret < 0) {
44
- goto fail;
45
- }
46
-
47
for (j = 0; j < s->l2_size; j++) {
48
uint64_t l2_entry = be64_to_cpu(l2_table[j]);
49
int64_t offset = l2_entry & L2E_OFFSET_MASK;
50
--
51
2.13.6
52
53
diff view generated by jsdifflib
Deleted patch
1
From: Alberto Garcia <berto@igalia.com>
2
1
3
Adding support for L2 slices to expand_zero_clusters_in_l1() needs
4
(among other things) an extra loop that iterates over all slices of
5
each L2 table.
6
7
Putting all changes in one patch would make it hard to read because
8
all semantic changes would be mixed with pure indentation changes.
9
10
To make things easier this patch simply creates a new block and
11
changes the indentation of all lines of code inside it. Thus, all
12
modifications in this patch are cosmetic. There are no semantic
13
changes and no variables are renamed yet. The next patch will take
14
care of that.
15
16
Signed-off-by: Alberto Garcia <berto@igalia.com>
17
Reviewed-by: Eric Blake <eblake@redhat.com>
18
Reviewed-by: Max Reitz <mreitz@redhat.com>
19
Message-id: c2ae9f31ed5b6e591477ad4654448badd1c89d73.1517840877.git.berto@igalia.com
20
Signed-off-by: Max Reitz <mreitz@redhat.com>
21
---
22
block/qcow2-cluster.c | 187 ++++++++++++++++++++++++++------------------------
23
1 file changed, 96 insertions(+), 91 deletions(-)
24
25
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
26
index XXXXXXX..XXXXXXX 100644
27
--- a/block/qcow2-cluster.c
28
+++ b/block/qcow2-cluster.c
29
@@ -XXX,XX +XXX,XX @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table,
30
goto fail;
31
}
32
33
- if (is_active_l1) {
34
- /* get active L2 tables from cache */
35
- ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset,
36
- (void **)&l2_table);
37
- } else {
38
- /* load inactive L2 tables from disk */
39
- ret = bdrv_read(bs->file, l2_offset / BDRV_SECTOR_SIZE,
40
- (void *)l2_table, s->cluster_sectors);
41
- }
42
- if (ret < 0) {
43
- goto fail;
44
- }
45
-
46
- for (j = 0; j < s->l2_size; j++) {
47
- uint64_t l2_entry = be64_to_cpu(l2_table[j]);
48
- int64_t offset = l2_entry & L2E_OFFSET_MASK;
49
- QCow2ClusterType cluster_type = qcow2_get_cluster_type(l2_entry);
50
-
51
- if (cluster_type != QCOW2_CLUSTER_ZERO_PLAIN &&
52
- cluster_type != QCOW2_CLUSTER_ZERO_ALLOC) {
53
- continue;
54
+ {
55
+ if (is_active_l1) {
56
+ /* get active L2 tables from cache */
57
+ ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset,
58
+ (void **)&l2_table);
59
+ } else {
60
+ /* load inactive L2 tables from disk */
61
+ ret = bdrv_read(bs->file, l2_offset / BDRV_SECTOR_SIZE,
62
+ (void *)l2_table, s->cluster_sectors);
63
+ }
64
+ if (ret < 0) {
65
+ goto fail;
66
}
67
68
- if (cluster_type == QCOW2_CLUSTER_ZERO_PLAIN) {
69
- if (!bs->backing) {
70
- /* not backed; therefore we can simply deallocate the
71
- * cluster */
72
- l2_table[j] = 0;
73
- l2_dirty = true;
74
+ for (j = 0; j < s->l2_size; j++) {
75
+ uint64_t l2_entry = be64_to_cpu(l2_table[j]);
76
+ int64_t offset = l2_entry & L2E_OFFSET_MASK;
77
+ QCow2ClusterType cluster_type =
78
+ qcow2_get_cluster_type(l2_entry);
79
+
80
+ if (cluster_type != QCOW2_CLUSTER_ZERO_PLAIN &&
81
+ cluster_type != QCOW2_CLUSTER_ZERO_ALLOC) {
82
continue;
83
}
84
85
- offset = qcow2_alloc_clusters(bs, s->cluster_size);
86
- if (offset < 0) {
87
- ret = offset;
88
- goto fail;
89
- }
90
+ if (cluster_type == QCOW2_CLUSTER_ZERO_PLAIN) {
91
+ if (!bs->backing) {
92
+ /* not backed; therefore we can simply deallocate the
93
+ * cluster */
94
+ l2_table[j] = 0;
95
+ l2_dirty = true;
96
+ continue;
97
+ }
98
+
99
+ offset = qcow2_alloc_clusters(bs, s->cluster_size);
100
+ if (offset < 0) {
101
+ ret = offset;
102
+ goto fail;
103
+ }
104
105
- if (l2_refcount > 1) {
106
- /* For shared L2 tables, set the refcount accordingly (it is
107
- * already 1 and needs to be l2_refcount) */
108
- ret = qcow2_update_cluster_refcount(bs,
109
- offset >> s->cluster_bits,
110
+ if (l2_refcount > 1) {
111
+ /* For shared L2 tables, set the refcount accordingly
112
+ * (it is already 1 and needs to be l2_refcount) */
113
+ ret = qcow2_update_cluster_refcount(
114
+ bs, offset >> s->cluster_bits,
115
refcount_diff(1, l2_refcount), false,
116
QCOW2_DISCARD_OTHER);
117
- if (ret < 0) {
118
- qcow2_free_clusters(bs, offset, s->cluster_size,
119
- QCOW2_DISCARD_OTHER);
120
- goto fail;
121
+ if (ret < 0) {
122
+ qcow2_free_clusters(bs, offset, s->cluster_size,
123
+ QCOW2_DISCARD_OTHER);
124
+ goto fail;
125
+ }
126
}
127
}
128
- }
129
130
- if (offset_into_cluster(s, offset)) {
131
- qcow2_signal_corruption(bs, true, -1, -1,
132
- "Cluster allocation offset "
133
- "%#" PRIx64 " unaligned (L2 offset: %#"
134
- PRIx64 ", L2 index: %#x)", offset,
135
- l2_offset, j);
136
- if (cluster_type == QCOW2_CLUSTER_ZERO_PLAIN) {
137
- qcow2_free_clusters(bs, offset, s->cluster_size,
138
- QCOW2_DISCARD_ALWAYS);
139
+ if (offset_into_cluster(s, offset)) {
140
+ qcow2_signal_corruption(
141
+ bs, true, -1, -1,
142
+ "Cluster allocation offset "
143
+ "%#" PRIx64 " unaligned (L2 offset: %#"
144
+ PRIx64 ", L2 index: %#x)", offset,
145
+ l2_offset, j);
146
+ if (cluster_type == QCOW2_CLUSTER_ZERO_PLAIN) {
147
+ qcow2_free_clusters(bs, offset, s->cluster_size,
148
+ QCOW2_DISCARD_ALWAYS);
149
+ }
150
+ ret = -EIO;
151
+ goto fail;
152
}
153
- ret = -EIO;
154
- goto fail;
155
- }
156
157
- ret = qcow2_pre_write_overlap_check(bs, 0, offset, s->cluster_size);
158
- if (ret < 0) {
159
- if (cluster_type == QCOW2_CLUSTER_ZERO_PLAIN) {
160
- qcow2_free_clusters(bs, offset, s->cluster_size,
161
- QCOW2_DISCARD_ALWAYS);
162
+ ret = qcow2_pre_write_overlap_check(bs, 0, offset,
163
+ s->cluster_size);
164
+ if (ret < 0) {
165
+ if (cluster_type == QCOW2_CLUSTER_ZERO_PLAIN) {
166
+ qcow2_free_clusters(bs, offset, s->cluster_size,
167
+ QCOW2_DISCARD_ALWAYS);
168
+ }
169
+ goto fail;
170
}
171
- goto fail;
172
- }
173
174
- ret = bdrv_pwrite_zeroes(bs->file, offset, s->cluster_size, 0);
175
- if (ret < 0) {
176
- if (cluster_type == QCOW2_CLUSTER_ZERO_PLAIN) {
177
- qcow2_free_clusters(bs, offset, s->cluster_size,
178
- QCOW2_DISCARD_ALWAYS);
179
+ ret = bdrv_pwrite_zeroes(bs->file, offset, s->cluster_size, 0);
180
+ if (ret < 0) {
181
+ if (cluster_type == QCOW2_CLUSTER_ZERO_PLAIN) {
182
+ qcow2_free_clusters(bs, offset, s->cluster_size,
183
+ QCOW2_DISCARD_ALWAYS);
184
+ }
185
+ goto fail;
186
}
187
- goto fail;
188
- }
189
190
- if (l2_refcount == 1) {
191
- l2_table[j] = cpu_to_be64(offset | QCOW_OFLAG_COPIED);
192
- } else {
193
- l2_table[j] = cpu_to_be64(offset);
194
+ if (l2_refcount == 1) {
195
+ l2_table[j] = cpu_to_be64(offset | QCOW_OFLAG_COPIED);
196
+ } else {
197
+ l2_table[j] = cpu_to_be64(offset);
198
+ }
199
+ l2_dirty = true;
200
}
201
- l2_dirty = true;
202
- }
203
204
- if (is_active_l1) {
205
- if (l2_dirty) {
206
- qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
207
- qcow2_cache_depends_on_flush(s->l2_table_cache);
208
- }
209
- qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
210
- } else {
211
- if (l2_dirty) {
212
- ret = qcow2_pre_write_overlap_check(bs,
213
- QCOW2_OL_INACTIVE_L2 | QCOW2_OL_ACTIVE_L2, l2_offset,
214
- s->cluster_size);
215
- if (ret < 0) {
216
- goto fail;
217
+ if (is_active_l1) {
218
+ if (l2_dirty) {
219
+ qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
220
+ qcow2_cache_depends_on_flush(s->l2_table_cache);
221
}
222
+ qcow2_cache_put(s->l2_table_cache, (void **) &l2_table);
223
+ } else {
224
+ if (l2_dirty) {
225
+ ret = qcow2_pre_write_overlap_check(
226
+ bs, QCOW2_OL_INACTIVE_L2 | QCOW2_OL_ACTIVE_L2,
227
+ l2_offset, s->cluster_size);
228
+ if (ret < 0) {
229
+ goto fail;
230
+ }
231
232
- ret = bdrv_write(bs->file, l2_offset / BDRV_SECTOR_SIZE,
233
- (void *)l2_table, s->cluster_sectors);
234
- if (ret < 0) {
235
- goto fail;
236
+ ret = bdrv_write(bs->file, l2_offset / BDRV_SECTOR_SIZE,
237
+ (void *)l2_table, s->cluster_sectors);
238
+ if (ret < 0) {
239
+ goto fail;
240
+ }
241
}
242
}
243
}
244
--
245
2.13.6
246
247
diff view generated by jsdifflib
Deleted patch
1
From: Alberto Garcia <berto@igalia.com>
2
1
3
This function doesn't need any changes to support L2 slices, but since
4
it's now dealing with slices intead of full tables, the l2_table
5
variable is renamed for clarity.
6
7
Signed-off-by: Alberto Garcia <berto@igalia.com>
8
Reviewed-by: Eric Blake <eblake@redhat.com>
9
Reviewed-by: Max Reitz <mreitz@redhat.com>
10
Message-id: 812b0c3505bb1687e51285dccf1a94f0cecb1f74.1517840877.git.berto@igalia.com
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
12
---
13
block/qcow2-cluster.c | 8 ++++----
14
1 file changed, 4 insertions(+), 4 deletions(-)
15
16
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/block/qcow2-cluster.c
19
+++ b/block/qcow2-cluster.c
20
@@ -XXX,XX +XXX,XX @@ fail:
21
}
22
23
/*
24
- * Checks how many clusters in a given L2 table are contiguous in the image
25
+ * Checks how many clusters in a given L2 slice are contiguous in the image
26
* file. As soon as one of the flags in the bitmask stop_flags changes compared
27
* to the first cluster, the search is stopped and the cluster is not counted
28
* as contiguous. (This allows it, for example, to stop at the first compressed
29
* cluster which may require a different handling)
30
*/
31
static int count_contiguous_clusters(int nb_clusters, int cluster_size,
32
- uint64_t *l2_table, uint64_t stop_flags)
33
+ uint64_t *l2_slice, uint64_t stop_flags)
34
{
35
int i;
36
QCow2ClusterType first_cluster_type;
37
uint64_t mask = stop_flags | L2E_OFFSET_MASK | QCOW_OFLAG_COMPRESSED;
38
- uint64_t first_entry = be64_to_cpu(l2_table[0]);
39
+ uint64_t first_entry = be64_to_cpu(l2_slice[0]);
40
uint64_t offset = first_entry & mask;
41
42
if (!offset) {
43
@@ -XXX,XX +XXX,XX @@ static int count_contiguous_clusters(int nb_clusters, int cluster_size,
44
first_cluster_type == QCOW2_CLUSTER_ZERO_ALLOC);
45
46
for (i = 0; i < nb_clusters; i++) {
47
- uint64_t l2_entry = be64_to_cpu(l2_table[i]) & mask;
48
+ uint64_t l2_entry = be64_to_cpu(l2_slice[i]) & mask;
49
if (offset + (uint64_t) i * cluster_size != l2_entry) {
50
break;
51
}
52
--
53
2.13.6
54
55
diff view generated by jsdifflib