1
The following changes since commit b34181056c04e05db6c632063012beaee7006a37:
1
The following changes since commit b2f7a038bb4c4fc5ce6b8486e8513dfd97665e2a:
2
2
3
Merge remote-tracking branch 'remotes/rth/tags/pull-sh4-20180709' into staging (2018-07-09 22:44:22 +0100)
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 cd47d792d7a27a57f4b621e2ff1ed8f4e83de1e9:
9
for you to fetch changes up to 1240ac558d348f6c7a5752b1a57c1da58e4efe3e:
10
10
11
block: Use common write req handling in truncate (2018-07-10 16:46:22 +0200)
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
15
16
- Copy offloading fixes for when the copy increases the image size
16
- auto-read-only option to fix commit job when used with -blockdev
17
- Temporary revert of the removal of deprecated -drive options
17
- Fix help text related qemu-iotests failure (by improving the help text
18
- Fix request serialisation in the image fleecing scenario
18
and updating the reference output)
19
- Fix copy-on-read crash with unaligned image size
19
- quorum: Add missing checks when adding/removing child nodes
20
- Fix another drain crash
20
- Don't take address of fields in packed structs
21
- vvfat: Fix crash when reporting error about too many files in directory
21
22
22
----------------------------------------------------------------
23
----------------------------------------------------------------
23
Ari Sundholm (2):
24
Alberto Garcia (7):
24
qapi/block-core.json: Add missing documentation for blklogwrites log-append option
25
block: replace "discard" literal with BDRV_OPT_DISCARD macro
25
block/blklogwrites: Make sure the log sector size is not too small
26
qcow2: Get the request alignment for encrypted images from QCryptoBlock
27
quorum: Remove quorum_err()
28
quorum: Return an error if the blkverify mode has invalid settings
29
iotest: Test the blkverify mode of the Quorum driver
30
quorum: Forbid adding children in blkverify mode
31
iotest: Test x-blockdev-change on a Quorum
26
32
27
Cornelia Huck (4):
33
Cleber Rosa (1):
28
Revert "block: Remove dead deprecation warning code"
34
iotests: make 083 specific to raw
29
Revert "block: Remove deprecated -drive option serial"
30
Revert "block: Remove deprecated -drive option addr"
31
Revert "block: Remove deprecated -drive geometry options"
32
35
33
Fam Zheng (11):
36
Daniel P. Berrangé (1):
34
iotests: 222: Don't run with luks
37
crypto: initialize sector size even when opening with no IO flag
35
block: Prefix file driver trace points with "file_"
36
block: Add copy offloading trace points
37
block: Use BdrvChild to discard
38
block: Use uint64_t for BdrvTrackedRequest byte fields
39
block: Extract common write req handling
40
block: Fix handling of image enlarging write
41
block: Use common req handling for discard
42
block: Use common req handling in copy offloading
43
block: Fix bdrv_co_truncate overlap check
44
block: Use common write req handling in truncate
45
38
46
Kevin Wolf (3):
39
Kevin Wolf (12):
47
block: Poll after drain on attaching a node
40
vpc: Don't leak opts in vpc_open()
48
test-bdrv-drain: Test bdrv_append() to drained node
41
block: Update flags in bdrv_set_read_only()
49
block: Fix copy-on-read crash with partial final cluster
42
block: Add auto-read-only option
43
rbd: Close image in qemu_rbd_open() error path
44
block: Require auto-read-only for existing fallbacks
45
nbd: Support auto-read-only option
46
file-posix: Support auto-read-only option
47
curl: Support auto-read-only option
48
gluster: Support auto-read-only option
49
iscsi: Support auto-read-only option
50
block: Make auto-read-only=on default for -drive
51
qemu-iotests: Test auto-read-only with -drive and -blockdev
50
52
51
Vladimir Sementsov-Ogievskiy (4):
53
Leonid Bloch (2):
52
block/io: fix copy_range
54
vdi: Use a literal number of bytes for DEFAULT_CLUSTER_SIZE
53
block: split flags in copy_range
55
include: Add a comment to explain the origin of sizes' lookup table
54
block: add BDRV_REQ_SERIALISING flag
55
block/backup: fix fleecing scheme: use serialized writes
56
56
57
qapi/block-core.json | 2 +
57
Li Qiang (1):
58
include/block/block.h | 41 +++++-
58
block: change some function return type to bool
59
include/block/block_int.h | 21 ++-
59
60
include/hw/block/block.h | 1 +
60
Max Reitz (5):
61
include/sysemu/block-backend.h | 3 +-
61
option: Make option help nicer to read
62
include/sysemu/blockdev.h | 3 +
62
chardev: Indent list of chardevs
63
block.c | 2 +-
63
qdev-monitor: Make device options help nicer
64
block/backup.c | 20 ++-
64
object: Make option help nicer to read
65
block/blkdebug.c | 2 +-
65
fw_cfg: Drop newline in @file description
66
block/blklogwrites.c | 7 +-
66
67
block/blkreplay.c | 2 +-
67
Peter Maydell (5):
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
73
74
Stefan Weil (1):
75
qemu-io-cmds: Fix two format strings
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 ++-
68
block/block-backend.c | 8 +-
87
block/block-backend.c | 8 +-
69
block/copy-on-read.c | 2 +-
88
block/bochs.c | 17 +-
70
block/file-posix.c | 25 ++--
89
block/cloop.c | 16 +-
71
block/file-win32.c | 2 +-
90
block/curl.c | 8 +-
72
block/io.c | 318 ++++++++++++++++++++++++++++-------------
91
block/dmg.c | 16 +-
73
block/iscsi.c | 12 +-
92
block/file-posix.c | 19 +-
74
block/mirror.c | 2 +-
93
block/gluster.c | 12 +-
75
block/qcow2-refcount.c | 2 +-
94
block/iscsi.c | 8 +-
76
block/qcow2.c | 20 +--
95
block/nbd-client.c | 10 +-
77
block/raw-format.c | 26 ++--
96
block/qcow.c | 18 +-
78
block/throttle.c | 2 +-
97
block/qcow2-bitmap.c | 24 +-
79
blockdev.c | 110 ++++++++++++++
98
block/qcow2.c | 66 +--
80
device-hotplug.c | 4 +
99
block/quorum.c | 45 +-
81
hw/block/block.c | 27 ++++
100
block/rbd.c | 14 +-
82
hw/block/nvme.c | 1 +
101
block/vdi.c | 68 +--
83
hw/block/virtio-blk.c | 1 +
102
block/vhdx-endian.c | 118 ++---
84
hw/ide/qdev.c | 1 +
103
block/vhdx-log.c | 4 +-
85
hw/scsi/scsi-disk.c | 1 +
104
block/vhdx.c | 18 +-
86
hw/usb/dev-storage.c | 1 +
105
block/vpc.c | 2 +
87
qemu-img.c | 2 +-
106
block/vvfat.c | 15 +-
88
tests/ahci-test.c | 6 +-
107
blockdev.c | 3 +-
89
tests/hd-geo-test.c | 37 ++++-
108
chardev/char.c | 2 +-
90
tests/ide-test.c | 8 +-
109
crypto/block-qcow.c | 2 +
91
tests/test-bdrv-drain.c | 43 ++++++
110
qdev-monitor.c | 13 +-
92
block/trace-events | 10 +-
111
qemu-img.c | 4 +-
93
hmp-commands.hx | 1 +
112
qemu-io-cmds.c | 4 +-
94
qemu-doc.texi | 15 ++
113
util/qemu-option.c | 32 +-
95
qemu-options.hx | 14 +-
114
vl.c | 15 +-
96
tests/qemu-iotests/197 | 9 ++
115
tests/qemu-iotests/081 | 116 +++++
97
tests/qemu-iotests/197.out | 8 ++
116
tests/qemu-iotests/081.out | 70 +++
98
tests/qemu-iotests/222 | 2 +
117
tests/qemu-iotests/082.out | 956 ++++++++++++++++++++---------------------
99
42 files changed, 647 insertions(+), 177 deletions(-)
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
100
125
diff view generated by jsdifflib
New patch
1
From: Thomas Huth <thuth@redhat.com>
1
2
3
When using the vvfat driver with a directory that contains too many files,
4
QEMU currently crashes. This can be triggered like this for example:
5
6
mkdir /tmp/vvfattest
7
cd /tmp/vvfattest
8
for ((x=0;x<=513;x++)); do mkdir $x; done
9
qemu-system-x86_64 -drive \
10
file.driver=vvfat,file.dir=.,read-only=on,media=cdrom
11
12
Seems like read_directory() is changing the mapping->path variable. Make
13
sure we use the right pointer instead.
14
15
Signed-off-by: Thomas Huth <thuth@redhat.com>
16
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
17
---
18
block/vvfat.c | 4 ++--
19
1 file changed, 2 insertions(+), 2 deletions(-)
20
21
diff --git a/block/vvfat.c b/block/vvfat.c
22
index XXXXXXX..XXXXXXX 100644
23
--- a/block/vvfat.c
24
+++ b/block/vvfat.c
25
@@ -XXX,XX +XXX,XX @@ static int init_directories(BDRVVVFATState* s,
26
mapping = array_get(&(s->mapping), i);
27
28
if (mapping->mode & MODE_DIRECTORY) {
29
+ char *path = mapping->path;
30
mapping->begin = cluster;
31
if(read_directory(s, i)) {
32
- error_setg(errp, "Could not read directory %s",
33
- mapping->path);
34
+ error_setg(errp, "Could not read directory %s", path);
35
return -1;
36
}
37
mapping = array_get(&(s->mapping), i);
38
--
39
2.19.1
40
41
diff view generated by jsdifflib
New patch
1
From: Alberto Garcia <berto@igalia.com>
1
2
3
Signed-off-by: Alberto Garcia <berto@igalia.com>
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
---
6
block.c | 6 +++---
7
1 file changed, 3 insertions(+), 3 deletions(-)
8
9
diff --git a/block.c b/block.c
10
index XXXXXXX..XXXXXXX 100644
11
--- a/block.c
12
+++ b/block.c
13
@@ -XXX,XX +XXX,XX @@ QemuOptsList bdrv_runtime_opts = {
14
.help = "try to optimize zero writes (off, on, unmap)",
15
},
16
{
17
- .name = "discard",
18
+ .name = BDRV_OPT_DISCARD,
19
.type = QEMU_OPT_STRING,
20
.help = "discard operation (ignore/off, unmap/on)",
21
},
22
@@ -XXX,XX +XXX,XX @@ static int bdrv_open_common(BlockDriverState *bs, BlockBackend *file,
23
}
24
}
25
26
- discard = qemu_opt_get(opts, "discard");
27
+ discard = qemu_opt_get(opts, BDRV_OPT_DISCARD);
28
if (discard != NULL) {
29
if (bdrv_parse_discard_flags(discard, &bs->open_flags) != 0) {
30
error_setg(errp, "Invalid discard option");
31
@@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
32
33
update_flags_from_options(&reopen_state->flags, opts);
34
35
- discard = qemu_opt_get_del(opts, "discard");
36
+ discard = qemu_opt_get_del(opts, BDRV_OPT_DISCARD);
37
if (discard != NULL) {
38
if (bdrv_parse_discard_flags(discard, &reopen_state->flags) != 0) {
39
error_setg(errp, "Invalid discard option");
40
--
41
2.19.1
42
43
diff view generated by jsdifflib
1
From: Fam Zheng <famz@redhat.com>
1
From: Stefan Weil <sw@weilnetz.de>
2
2
3
This brings the request handling logic inline with write and discard,
3
Use %zu instead of %zd for unsigned numbers.
4
fixing write_gen, resize_cb, dirty bitmaps and image size refreshing.
5
The last of these issues broke iotest case 222, which is now fixed.
6
4
7
Signed-off-by: Fam Zheng <famz@redhat.com>
5
This fixes two error messages from the LSTM static code analyzer:
6
7
This argument should be of type 'ssize_t' but is of type 'unsigned long'
8
9
Signed-off-by: Stefan Weil <sw@weilnetz.de>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9
---
12
---
10
block/io.c | 24 ++++++++++--------------
13
qemu-io-cmds.c | 4 ++--
11
1 file changed, 10 insertions(+), 14 deletions(-)
14
1 file changed, 2 insertions(+), 2 deletions(-)
12
15
13
diff --git a/block/io.c b/block/io.c
16
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
14
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
15
--- a/block/io.c
18
--- a/qemu-io-cmds.c
16
+++ b/block/io.c
19
+++ b/qemu-io-cmds.c
17
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_copy_range_internal(
20
@@ -XXX,XX +XXX,XX @@ static int readv_f(BlockBackend *blk, int argc, char **argv)
18
bdrv_inc_in_flight(dst->bs);
21
memset(cmp_buf, pattern, qiov.size);
19
tracked_request_begin(&req, dst->bs, dst_offset, bytes,
22
if (memcmp(buf, cmp_buf, qiov.size)) {
20
BDRV_TRACKED_WRITE);
23
printf("Pattern verification failed at offset %"
21
-
24
- PRId64 ", %zd bytes\n", offset, qiov.size);
22
- /* BDRV_REQ_NO_SERIALISING is only for read operation */
25
+ PRId64 ", %zu bytes\n", offset, qiov.size);
23
- assert(!(write_flags & BDRV_REQ_NO_SERIALISING));
26
ret = -EINVAL;
24
- if (write_flags & BDRV_REQ_SERIALISING) {
27
}
25
- mark_request_serialising(&req, bdrv_get_cluster_size(dst->bs));
28
g_free(cmp_buf);
26
- }
29
@@ -XXX,XX +XXX,XX @@ static void aio_read_done(void *opaque, int ret)
27
- wait_serialising_requests(&req);
30
memset(cmp_buf, ctx->pattern, ctx->qiov.size);
28
-
31
if (memcmp(ctx->buf, cmp_buf, ctx->qiov.size)) {
29
- ret = dst->bs->drv->bdrv_co_copy_range_to(dst->bs,
32
printf("Pattern verification failed at offset %"
30
- src, src_offset,
33
- PRId64 ", %zd bytes\n", ctx->offset, ctx->qiov.size);
31
- dst, dst_offset,
34
+ PRId64 ", %zu bytes\n", ctx->offset, ctx->qiov.size);
32
- bytes,
35
}
33
- read_flags, write_flags);
36
g_free(cmp_buf);
34
-
35
+ ret = bdrv_co_write_req_prepare(dst, dst_offset, bytes, &req,
36
+ write_flags);
37
+ if (!ret) {
38
+ ret = dst->bs->drv->bdrv_co_copy_range_to(dst->bs,
39
+ src, src_offset,
40
+ dst, dst_offset,
41
+ bytes,
42
+ read_flags, write_flags);
43
+ }
44
+ bdrv_co_write_req_finish(dst, dst_offset, bytes, &req, ret);
45
tracked_request_end(&req);
46
bdrv_dec_in_flight(dst->bs);
47
}
37
}
48
--
38
--
49
2.13.6
39
2.19.1
50
40
51
41
diff view generated by jsdifflib
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
From: Peter Maydell <peter.maydell@linaro.org>
2
2
3
Pass read flags and write flags separately. This is needed to handle
3
Taking the address of a field in a packed struct is a bad idea, because
4
coming BDRV_REQ_NO_SERIALISING clearly in following patches.
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
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
9
There are a few places where the in-place swap function is
7
Reviewed-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
This patch was produced with the following spatch script
14
(and hand-editing to fold a few resulting overlength lines):
15
16
@@
17
expression E;
18
@@
19
-be16_to_cpus(&E);
20
+E = be16_to_cpu(E);
21
@@
22
expression E;
23
@@
24
-be32_to_cpus(&E);
25
+E = be32_to_cpu(E);
26
@@
27
expression E;
28
@@
29
-be64_to_cpus(&E);
30
+E = be64_to_cpu(E);
31
@@
32
expression E;
33
@@
34
-cpu_to_be16s(&E);
35
+E = cpu_to_be16(E);
36
@@
37
expression E;
38
@@
39
-cpu_to_be32s(&E);
40
+E = cpu_to_be32(E);
41
@@
42
expression E;
43
@@
44
-cpu_to_be64s(&E);
45
+E = cpu_to_be64(E);
46
47
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
48
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
49
Tested-by: John Snow <jsnow@redhat.com>
50
Reviewed-by: John Snow <jsnow@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
51
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9
---
52
---
10
include/block/block.h | 3 ++-
53
block/qcow2.c | 64 +++++++++++++++++++++++++++------------------------
11
include/block/block_int.h | 14 +++++++++----
54
1 file changed, 34 insertions(+), 30 deletions(-)
12
include/sysemu/block-backend.h | 3 ++-
13
block/backup.c | 2 +-
14
block/block-backend.c | 5 +++--
15
block/file-posix.c | 21 +++++++++++--------
16
block/io.c | 46 +++++++++++++++++++++++-------------------
17
block/iscsi.c | 9 ++++++---
18
block/qcow2.c | 20 +++++++++---------
19
block/raw-format.c | 24 ++++++++++++++--------
20
qemu-img.c | 2 +-
21
11 files changed, 90 insertions(+), 59 deletions(-)
22
55
23
diff --git a/include/block/block.h b/include/block/block.h
24
index XXXXXXX..XXXXXXX 100644
25
--- a/include/block/block.h
26
+++ b/include/block/block.h
27
@@ -XXX,XX +XXX,XX @@ void bdrv_unregister_buf(BlockDriverState *bs, void *host);
28
**/
29
int coroutine_fn bdrv_co_copy_range(BdrvChild *src, uint64_t src_offset,
30
BdrvChild *dst, uint64_t dst_offset,
31
- uint64_t bytes, BdrvRequestFlags flags);
32
+ uint64_t bytes, BdrvRequestFlags read_flags,
33
+ BdrvRequestFlags write_flags);
34
#endif
35
diff --git a/include/block/block_int.h b/include/block/block_int.h
36
index XXXXXXX..XXXXXXX 100644
37
--- a/include/block/block_int.h
38
+++ b/include/block/block_int.h
39
@@ -XXX,XX +XXX,XX @@ struct BlockDriver {
40
BdrvChild *dst,
41
uint64_t dst_offset,
42
uint64_t bytes,
43
- BdrvRequestFlags flags);
44
+ BdrvRequestFlags read_flags,
45
+ BdrvRequestFlags write_flags);
46
47
/* Map [offset, offset + nbytes) range onto a child of bs to copy data to,
48
* and invoke bdrv_co_copy_range_to(child, src, ...), or perform the copy
49
@@ -XXX,XX +XXX,XX @@ struct BlockDriver {
50
BdrvChild *dst,
51
uint64_t dst_offset,
52
uint64_t bytes,
53
- BdrvRequestFlags flags);
54
+ BdrvRequestFlags read_flags,
55
+ BdrvRequestFlags write_flags);
56
57
/*
58
* Building block for bdrv_block_status[_above] and
59
@@ -XXX,XX +XXX,XX @@ void blockdev_close_all_bdrv_states(void);
60
61
int coroutine_fn bdrv_co_copy_range_from(BdrvChild *src, uint64_t src_offset,
62
BdrvChild *dst, uint64_t dst_offset,
63
- uint64_t bytes, BdrvRequestFlags flags);
64
+ uint64_t bytes,
65
+ BdrvRequestFlags read_flags,
66
+ BdrvRequestFlags write_flags);
67
int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, uint64_t src_offset,
68
BdrvChild *dst, uint64_t dst_offset,
69
- uint64_t bytes, BdrvRequestFlags flags);
70
+ uint64_t bytes,
71
+ BdrvRequestFlags read_flags,
72
+ BdrvRequestFlags write_flags);
73
74
int refresh_total_sectors(BlockDriverState *bs, int64_t hint);
75
76
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
77
index XXXXXXX..XXXXXXX 100644
78
--- a/include/sysemu/block-backend.h
79
+++ b/include/sysemu/block-backend.h
80
@@ -XXX,XX +XXX,XX @@ void blk_unregister_buf(BlockBackend *blk, void *host);
81
82
int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in,
83
BlockBackend *blk_out, int64_t off_out,
84
- int bytes, BdrvRequestFlags flags);
85
+ int bytes, BdrvRequestFlags read_flags,
86
+ BdrvRequestFlags write_flags);
87
88
#endif
89
diff --git a/block/backup.c b/block/backup.c
90
index XXXXXXX..XXXXXXX 100644
91
--- a/block/backup.c
92
+++ b/block/backup.c
93
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn backup_cow_with_offload(BackupBlockJob *job,
94
hbitmap_reset(job->copy_bitmap, start / job->cluster_size,
95
nr_clusters);
96
ret = blk_co_copy_range(blk, start, job->target, start, nbytes,
97
- is_write_notifier ? BDRV_REQ_NO_SERIALISING : 0);
98
+ is_write_notifier ? BDRV_REQ_NO_SERIALISING : 0, 0);
99
if (ret < 0) {
100
trace_backup_do_cow_copy_range_fail(job, start, ret);
101
hbitmap_set(job->copy_bitmap, start / job->cluster_size,
102
diff --git a/block/block-backend.c b/block/block-backend.c
103
index XXXXXXX..XXXXXXX 100644
104
--- a/block/block-backend.c
105
+++ b/block/block-backend.c
106
@@ -XXX,XX +XXX,XX @@ void blk_unregister_buf(BlockBackend *blk, void *host)
107
108
int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in,
109
BlockBackend *blk_out, int64_t off_out,
110
- int bytes, BdrvRequestFlags flags)
111
+ int bytes, BdrvRequestFlags read_flags,
112
+ BdrvRequestFlags write_flags)
113
{
114
int r;
115
r = blk_check_byte_request(blk_in, off_in, bytes);
116
@@ -XXX,XX +XXX,XX @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in,
117
}
118
return bdrv_co_copy_range(blk_in->root, off_in,
119
blk_out->root, off_out,
120
- bytes, flags);
121
+ bytes, read_flags, write_flags);
122
}
123
diff --git a/block/file-posix.c b/block/file-posix.c
124
index XXXXXXX..XXXXXXX 100644
125
--- a/block/file-posix.c
126
+++ b/block/file-posix.c
127
@@ -XXX,XX +XXX,XX @@ static void raw_abort_perm_update(BlockDriverState *bs)
128
raw_handle_perm_lock(bs, RAW_PL_ABORT, 0, 0, NULL);
129
}
130
131
-static int coroutine_fn raw_co_copy_range_from(BlockDriverState *bs,
132
- BdrvChild *src, uint64_t src_offset,
133
- BdrvChild *dst, uint64_t dst_offset,
134
- uint64_t bytes, BdrvRequestFlags flags)
135
+static int coroutine_fn raw_co_copy_range_from(
136
+ BlockDriverState *bs, BdrvChild *src, uint64_t src_offset,
137
+ BdrvChild *dst, uint64_t dst_offset, uint64_t bytes,
138
+ BdrvRequestFlags read_flags, BdrvRequestFlags write_flags)
139
{
140
- return bdrv_co_copy_range_to(src, src_offset, dst, dst_offset, bytes, flags);
141
+ return bdrv_co_copy_range_to(src, src_offset, dst, dst_offset, bytes,
142
+ read_flags, write_flags);
143
}
144
145
static int coroutine_fn raw_co_copy_range_to(BlockDriverState *bs,
146
- BdrvChild *src, uint64_t src_offset,
147
- BdrvChild *dst, uint64_t dst_offset,
148
- uint64_t bytes, BdrvRequestFlags flags)
149
+ BdrvChild *src,
150
+ uint64_t src_offset,
151
+ BdrvChild *dst,
152
+ uint64_t dst_offset,
153
+ uint64_t bytes,
154
+ BdrvRequestFlags read_flags,
155
+ BdrvRequestFlags write_flags)
156
{
157
BDRVRawState *s = bs->opaque;
158
BDRVRawState *src_s;
159
diff --git a/block/io.c b/block/io.c
160
index XXXXXXX..XXXXXXX 100644
161
--- a/block/io.c
162
+++ b/block/io.c
163
@@ -XXX,XX +XXX,XX @@ void bdrv_unregister_buf(BlockDriverState *bs, void *host)
164
}
165
}
166
167
-static int coroutine_fn bdrv_co_copy_range_internal(BdrvChild *src,
168
- uint64_t src_offset,
169
- BdrvChild *dst,
170
- uint64_t dst_offset,
171
- uint64_t bytes,
172
- BdrvRequestFlags flags,
173
- bool recurse_src)
174
+static int coroutine_fn bdrv_co_copy_range_internal(
175
+ BdrvChild *src, uint64_t src_offset, BdrvChild *dst,
176
+ uint64_t dst_offset, uint64_t bytes,
177
+ BdrvRequestFlags read_flags, BdrvRequestFlags write_flags,
178
+ bool recurse_src)
179
{
180
BdrvTrackedRequest req;
181
int ret;
182
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_copy_range_internal(BdrvChild *src,
183
if (ret) {
184
return ret;
185
}
186
- if (flags & BDRV_REQ_ZERO_WRITE) {
187
- return bdrv_co_pwrite_zeroes(dst, dst_offset, bytes, flags);
188
+ if (write_flags & BDRV_REQ_ZERO_WRITE) {
189
+ return bdrv_co_pwrite_zeroes(dst, dst_offset, bytes, write_flags);
190
}
191
192
if (!src || !src->bs) {
193
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_copy_range_internal(BdrvChild *src,
194
tracked_request_begin(&req, src->bs, src_offset, bytes,
195
BDRV_TRACKED_READ);
196
197
- if (!(flags & BDRV_REQ_NO_SERIALISING)) {
198
+ if (!(read_flags & BDRV_REQ_NO_SERIALISING)) {
199
wait_serialising_requests(&req);
200
}
201
202
ret = src->bs->drv->bdrv_co_copy_range_from(src->bs,
203
src, src_offset,
204
dst, dst_offset,
205
- bytes, flags);
206
+ bytes,
207
+ read_flags, write_flags);
208
209
tracked_request_end(&req);
210
bdrv_dec_in_flight(src->bs);
211
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_copy_range_internal(BdrvChild *src,
212
tracked_request_begin(&req, dst->bs, dst_offset, bytes,
213
BDRV_TRACKED_WRITE);
214
215
- /* BDRV_REQ_NO_SERIALISING is only for read operation,
216
- * so we ignore it in flags.
217
- */
218
+ /* BDRV_REQ_NO_SERIALISING is only for read operation */
219
+ assert(!(write_flags & BDRV_REQ_NO_SERIALISING));
220
wait_serialising_requests(&req);
221
222
ret = dst->bs->drv->bdrv_co_copy_range_to(dst->bs,
223
src, src_offset,
224
dst, dst_offset,
225
- bytes, flags);
226
+ bytes,
227
+ read_flags, write_flags);
228
229
tracked_request_end(&req);
230
bdrv_dec_in_flight(dst->bs);
231
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_copy_range_internal(BdrvChild *src,
232
* semantics. */
233
int coroutine_fn bdrv_co_copy_range_from(BdrvChild *src, uint64_t src_offset,
234
BdrvChild *dst, uint64_t dst_offset,
235
- uint64_t bytes, BdrvRequestFlags flags)
236
+ uint64_t bytes,
237
+ BdrvRequestFlags read_flags,
238
+ BdrvRequestFlags write_flags)
239
{
240
return bdrv_co_copy_range_internal(src, src_offset, dst, dst_offset,
241
- bytes, flags, true);
242
+ bytes, read_flags, write_flags, true);
243
}
244
245
/* Copy range from @src to @dst.
246
@@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_copy_range_from(BdrvChild *src, uint64_t src_offset,
247
* semantics. */
248
int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, uint64_t src_offset,
249
BdrvChild *dst, uint64_t dst_offset,
250
- uint64_t bytes, BdrvRequestFlags flags)
251
+ uint64_t bytes,
252
+ BdrvRequestFlags read_flags,
253
+ BdrvRequestFlags write_flags)
254
{
255
return bdrv_co_copy_range_internal(src, src_offset, dst, dst_offset,
256
- bytes, flags, false);
257
+ bytes, read_flags, write_flags, false);
258
}
259
260
int coroutine_fn bdrv_co_copy_range(BdrvChild *src, uint64_t src_offset,
261
BdrvChild *dst, uint64_t dst_offset,
262
- uint64_t bytes, BdrvRequestFlags flags)
263
+ uint64_t bytes, BdrvRequestFlags read_flags,
264
+ BdrvRequestFlags write_flags)
265
{
266
return bdrv_co_copy_range_from(src, src_offset,
267
dst, dst_offset,
268
- bytes, flags);
269
+ bytes, read_flags, write_flags);
270
}
271
272
static void bdrv_parent_cb_resize(BlockDriverState *bs)
273
diff --git a/block/iscsi.c b/block/iscsi.c
274
index XXXXXXX..XXXXXXX 100644
275
--- a/block/iscsi.c
276
+++ b/block/iscsi.c
277
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn iscsi_co_copy_range_from(BlockDriverState *bs,
278
BdrvChild *dst,
279
uint64_t dst_offset,
280
uint64_t bytes,
281
- BdrvRequestFlags flags)
282
+ BdrvRequestFlags read_flags,
283
+ BdrvRequestFlags write_flags)
284
{
285
- return bdrv_co_copy_range_to(src, src_offset, dst, dst_offset, bytes, flags);
286
+ return bdrv_co_copy_range_to(src, src_offset, dst, dst_offset, bytes,
287
+ read_flags, write_flags);
288
}
289
290
static struct scsi_task *iscsi_xcopy_task(int param_len)
291
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn iscsi_co_copy_range_to(BlockDriverState *bs,
292
BdrvChild *dst,
293
uint64_t dst_offset,
294
uint64_t bytes,
295
- BdrvRequestFlags flags)
296
+ BdrvRequestFlags read_flags,
297
+ BdrvRequestFlags write_flags)
298
{
299
IscsiLun *dst_lun = dst->bs->opaque;
300
IscsiLun *src_lun;
301
diff --git a/block/qcow2.c b/block/qcow2.c
56
diff --git a/block/qcow2.c b/block/qcow2.c
302
index XXXXXXX..XXXXXXX 100644
57
index XXXXXXX..XXXXXXX 100644
303
--- a/block/qcow2.c
58
--- a/block/qcow2.c
304
+++ b/block/qcow2.c
59
+++ b/block/qcow2.c
305
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn
60
@@ -XXX,XX +XXX,XX @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset,
306
qcow2_co_copy_range_from(BlockDriverState *bs,
61
"pread fail from offset %" PRIu64, offset);
307
BdrvChild *src, uint64_t src_offset,
62
return 1;
308
BdrvChild *dst, uint64_t dst_offset,
63
}
309
- uint64_t bytes, BdrvRequestFlags flags)
64
- be32_to_cpus(&ext.magic);
310
+ uint64_t bytes, BdrvRequestFlags read_flags,
65
- be32_to_cpus(&ext.len);
311
+ BdrvRequestFlags write_flags)
66
+ ext.magic = be32_to_cpu(ext.magic);
312
{
67
+ ext.len = be32_to_cpu(ext.len);
313
BDRVQcow2State *s = bs->opaque;
68
offset += sizeof(ext);
314
int ret;
69
#ifdef DEBUG_EXT
315
unsigned int cur_bytes; /* number of bytes in current iteration */
70
printf("ext.magic = 0x%x\n", ext.magic);
316
BdrvChild *child = NULL;
71
@@ -XXX,XX +XXX,XX @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset,
317
- BdrvRequestFlags cur_flags;
72
"Unable to read CRYPTO header extension");
318
+ BdrvRequestFlags cur_write_flags;
73
return ret;
319
320
assert(!bs->encrypted);
321
qemu_co_mutex_lock(&s->lock);
322
@@ -XXX,XX +XXX,XX @@ qcow2_co_copy_range_from(BlockDriverState *bs,
323
uint64_t copy_offset = 0;
324
/* prepare next request */
325
cur_bytes = MIN(bytes, INT_MAX);
326
- cur_flags = flags;
327
+ cur_write_flags = write_flags;
328
329
ret = qcow2_get_cluster_offset(bs, src_offset, &cur_bytes, &copy_offset);
330
if (ret < 0) {
331
@@ -XXX,XX +XXX,XX @@ qcow2_co_copy_range_from(BlockDriverState *bs,
332
if (bs->backing && bs->backing->bs) {
333
int64_t backing_length = bdrv_getlength(bs->backing->bs);
334
if (src_offset >= backing_length) {
335
- cur_flags |= BDRV_REQ_ZERO_WRITE;
336
+ cur_write_flags |= BDRV_REQ_ZERO_WRITE;
337
} else {
338
child = bs->backing;
339
cur_bytes = MIN(cur_bytes, backing_length - src_offset);
340
copy_offset = src_offset;
341
}
342
} else {
343
- cur_flags |= BDRV_REQ_ZERO_WRITE;
344
+ cur_write_flags |= BDRV_REQ_ZERO_WRITE;
345
}
74
}
346
break;
75
- be64_to_cpus(&s->crypto_header.offset);
347
76
- be64_to_cpus(&s->crypto_header.length);
348
case QCOW2_CLUSTER_ZERO_PLAIN:
77
+ s->crypto_header.offset = be64_to_cpu(s->crypto_header.offset);
349
case QCOW2_CLUSTER_ZERO_ALLOC:
78
+ s->crypto_header.length = be64_to_cpu(s->crypto_header.length);
350
- cur_flags |= BDRV_REQ_ZERO_WRITE;
79
351
+ cur_write_flags |= BDRV_REQ_ZERO_WRITE;
80
if ((s->crypto_header.offset % s->cluster_size) != 0) {
352
break;
81
error_setg(errp, "Encryption header offset '%" PRIu64 "' is "
353
82
@@ -XXX,XX +XXX,XX @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset,
354
case QCOW2_CLUSTER_COMPRESSED:
83
return -EINVAL;
355
@@ -XXX,XX +XXX,XX @@ qcow2_co_copy_range_from(BlockDriverState *bs,
84
}
356
ret = bdrv_co_copy_range_from(child,
85
357
copy_offset,
86
- be32_to_cpus(&bitmaps_ext.nb_bitmaps);
358
dst, dst_offset,
87
- be64_to_cpus(&bitmaps_ext.bitmap_directory_size);
359
- cur_bytes, cur_flags);
88
- be64_to_cpus(&bitmaps_ext.bitmap_directory_offset);
360
+ cur_bytes, read_flags, cur_write_flags);
89
+ bitmaps_ext.nb_bitmaps = be32_to_cpu(bitmaps_ext.nb_bitmaps);
361
qemu_co_mutex_lock(&s->lock);
90
+ bitmaps_ext.bitmap_directory_size =
362
if (ret < 0) {
91
+ be64_to_cpu(bitmaps_ext.bitmap_directory_size);
363
goto out;
92
+ bitmaps_ext.bitmap_directory_offset =
364
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn
93
+ be64_to_cpu(bitmaps_ext.bitmap_directory_offset);
365
qcow2_co_copy_range_to(BlockDriverState *bs,
94
366
BdrvChild *src, uint64_t src_offset,
95
if (bitmaps_ext.nb_bitmaps > QCOW2_MAX_BITMAPS) {
367
BdrvChild *dst, uint64_t dst_offset,
96
error_setg(errp,
368
- uint64_t bytes, BdrvRequestFlags flags)
97
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
369
+ uint64_t bytes, BdrvRequestFlags read_flags,
98
error_setg_errno(errp, -ret, "Could not read qcow2 header");
370
+ BdrvRequestFlags write_flags)
99
goto fail;
371
{
100
}
372
BDRVQcow2State *s = bs->opaque;
101
- be32_to_cpus(&header.magic);
373
int offset_in_cluster;
102
- be32_to_cpus(&header.version);
374
@@ -XXX,XX +XXX,XX @@ qcow2_co_copy_range_to(BlockDriverState *bs,
103
- be64_to_cpus(&header.backing_file_offset);
375
ret = bdrv_co_copy_range_to(src, src_offset,
104
- be32_to_cpus(&header.backing_file_size);
376
bs->file,
105
- be64_to_cpus(&header.size);
377
cluster_offset + offset_in_cluster,
106
- be32_to_cpus(&header.cluster_bits);
378
- cur_bytes, flags);
107
- be32_to_cpus(&header.crypt_method);
379
+ cur_bytes, read_flags, write_flags);
108
- be64_to_cpus(&header.l1_table_offset);
380
qemu_co_mutex_lock(&s->lock);
109
- be32_to_cpus(&header.l1_size);
110
- be64_to_cpus(&header.refcount_table_offset);
111
- be32_to_cpus(&header.refcount_table_clusters);
112
- be64_to_cpus(&header.snapshots_offset);
113
- be32_to_cpus(&header.nb_snapshots);
114
+ header.magic = be32_to_cpu(header.magic);
115
+ header.version = be32_to_cpu(header.version);
116
+ header.backing_file_offset = be64_to_cpu(header.backing_file_offset);
117
+ header.backing_file_size = be32_to_cpu(header.backing_file_size);
118
+ header.size = be64_to_cpu(header.size);
119
+ header.cluster_bits = be32_to_cpu(header.cluster_bits);
120
+ header.crypt_method = be32_to_cpu(header.crypt_method);
121
+ header.l1_table_offset = be64_to_cpu(header.l1_table_offset);
122
+ header.l1_size = be32_to_cpu(header.l1_size);
123
+ header.refcount_table_offset = be64_to_cpu(header.refcount_table_offset);
124
+ header.refcount_table_clusters =
125
+ be32_to_cpu(header.refcount_table_clusters);
126
+ header.snapshots_offset = be64_to_cpu(header.snapshots_offset);
127
+ header.nb_snapshots = be32_to_cpu(header.nb_snapshots);
128
129
if (header.magic != QCOW_MAGIC) {
130
error_setg(errp, "Image is not in qcow2 format");
131
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
132
header.refcount_order = 4;
133
header.header_length = 72;
134
} else {
135
- be64_to_cpus(&header.incompatible_features);
136
- be64_to_cpus(&header.compatible_features);
137
- be64_to_cpus(&header.autoclear_features);
138
- be32_to_cpus(&header.refcount_order);
139
- be32_to_cpus(&header.header_length);
140
+ header.incompatible_features =
141
+ be64_to_cpu(header.incompatible_features);
142
+ header.compatible_features = be64_to_cpu(header.compatible_features);
143
+ header.autoclear_features = be64_to_cpu(header.autoclear_features);
144
+ header.refcount_order = be32_to_cpu(header.refcount_order);
145
+ header.header_length = be32_to_cpu(header.header_length);
146
147
if (header.header_length < 104) {
148
error_setg(errp, "qcow2 header too short");
149
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
150
goto fail;
151
}
152
for(i = 0;i < s->l1_size; i++) {
153
- be64_to_cpus(&s->l1_table[i]);
154
+ s->l1_table[i] = be64_to_cpu(s->l1_table[i]);
155
}
156
}
157
158
@@ -XXX,XX +XXX,XX @@ int qcow2_update_header(BlockDriverState *bs)
159
160
/* Full disk encryption header pointer extension */
161
if (s->crypto_header.offset != 0) {
162
- cpu_to_be64s(&s->crypto_header.offset);
163
- cpu_to_be64s(&s->crypto_header.length);
164
+ s->crypto_header.offset = cpu_to_be64(s->crypto_header.offset);
165
+ s->crypto_header.length = cpu_to_be64(s->crypto_header.length);
166
ret = header_ext_add(buf, QCOW2_EXT_MAGIC_CRYPTO_HEADER,
167
&s->crypto_header, sizeof(s->crypto_header),
168
buflen);
169
- be64_to_cpus(&s->crypto_header.offset);
170
- be64_to_cpus(&s->crypto_header.length);
171
+ s->crypto_header.offset = be64_to_cpu(s->crypto_header.offset);
172
+ s->crypto_header.length = be64_to_cpu(s->crypto_header.length);
381
if (ret < 0) {
173
if (ret < 0) {
382
goto fail;
174
goto fail;
383
diff --git a/block/raw-format.c b/block/raw-format.c
384
index XXXXXXX..XXXXXXX 100644
385
--- a/block/raw-format.c
386
+++ b/block/raw-format.c
387
@@ -XXX,XX +XXX,XX @@ static int raw_probe_geometry(BlockDriverState *bs, HDGeometry *geo)
388
}
389
390
static int coroutine_fn raw_co_copy_range_from(BlockDriverState *bs,
391
- BdrvChild *src, uint64_t src_offset,
392
- BdrvChild *dst, uint64_t dst_offset,
393
- uint64_t bytes, BdrvRequestFlags flags)
394
+ BdrvChild *src,
395
+ uint64_t src_offset,
396
+ BdrvChild *dst,
397
+ uint64_t dst_offset,
398
+ uint64_t bytes,
399
+ BdrvRequestFlags read_flags,
400
+ BdrvRequestFlags write_flags)
401
{
402
int ret;
403
404
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn raw_co_copy_range_from(BlockDriverState *bs,
405
return ret;
406
}
407
return bdrv_co_copy_range_from(bs->file, src_offset, dst, dst_offset,
408
- bytes, flags);
409
+ bytes, read_flags, write_flags);
410
}
411
412
static int coroutine_fn raw_co_copy_range_to(BlockDriverState *bs,
413
- BdrvChild *src, uint64_t src_offset,
414
- BdrvChild *dst, uint64_t dst_offset,
415
- uint64_t bytes, BdrvRequestFlags flags)
416
+ BdrvChild *src,
417
+ uint64_t src_offset,
418
+ BdrvChild *dst,
419
+ uint64_t dst_offset,
420
+ uint64_t bytes,
421
+ BdrvRequestFlags read_flags,
422
+ BdrvRequestFlags write_flags)
423
{
424
int ret;
425
426
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn raw_co_copy_range_to(BlockDriverState *bs,
427
return ret;
428
}
429
return bdrv_co_copy_range_to(src, src_offset, bs->file, dst_offset, bytes,
430
- flags);
431
+ read_flags, write_flags);
432
}
433
434
BlockDriver bdrv_raw = {
435
diff --git a/qemu-img.c b/qemu-img.c
436
index XXXXXXX..XXXXXXX 100644
437
--- a/qemu-img.c
438
+++ b/qemu-img.c
439
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn convert_co_copy_range(ImgConvertState *s, int64_t sector
440
441
ret = blk_co_copy_range(blk, offset, s->target,
442
sector_num << BDRV_SECTOR_BITS,
443
- n << BDRV_SECTOR_BITS, 0);
444
+ n << BDRV_SECTOR_BITS, 0, 0);
445
if (ret < 0) {
446
return ret;
447
}
175
}
448
--
176
--
449
2.13.6
177
2.19.1
450
178
451
179
diff view generated by jsdifflib
1
From: Cornelia Huck <cohuck@redhat.com>
1
From: Peter Maydell <peter.maydell@linaro.org>
2
2
3
This reverts commit b0083267444a5e0f28391f6c2831a539f878d424.
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
Hold off removing this for one more QEMU release (current libvirt
9
There are a few places where the in-place swap function is
6
release still uses it.)
10
used on something other than a packed struct field; we convert
11
those anyway, for consistency.
7
12
8
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
13
This patch was produced with the following spatch script:
14
15
@@
16
expression E;
17
@@
18
-be16_to_cpus(&E);
19
+E = be16_to_cpu(E);
20
@@
21
expression E;
22
@@
23
-be32_to_cpus(&E);
24
+E = be32_to_cpu(E);
25
@@
26
expression E;
27
@@
28
-be64_to_cpus(&E);
29
+E = be64_to_cpu(E);
30
@@
31
expression E;
32
@@
33
-cpu_to_be16s(&E);
34
+E = cpu_to_be16(E);
35
@@
36
expression E;
37
@@
38
-cpu_to_be32s(&E);
39
+E = cpu_to_be32(E);
40
@@
41
expression E;
42
@@
43
-cpu_to_be64s(&E);
44
+E = cpu_to_be64(E);
45
46
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
47
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
48
Tested-by: John Snow <jsnow@redhat.com>
49
Reviewed-by: John Snow <jsnow@redhat.com>
9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
50
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10
---
51
---
11
include/hw/block/block.h | 1 +
52
block/qcow.c | 18 +++++++++---------
12
include/sysemu/blockdev.h | 1 +
53
1 file changed, 9 insertions(+), 9 deletions(-)
13
block/block-backend.c | 1 +
14
blockdev.c | 10 ++++++++++
15
hw/block/block.c | 13 +++++++++++++
16
hw/block/nvme.c | 1 +
17
hw/block/virtio-blk.c | 1 +
18
hw/ide/qdev.c | 1 +
19
hw/scsi/scsi-disk.c | 1 +
20
hw/usb/dev-storage.c | 1 +
21
tests/ahci-test.c | 6 +++---
22
tests/ide-test.c | 8 ++++----
23
qemu-doc.texi | 5 +++++
24
qemu-options.hx | 6 +++++-
25
14 files changed, 48 insertions(+), 8 deletions(-)
26
54
27
diff --git a/include/hw/block/block.h b/include/hw/block/block.h
55
diff --git a/block/qcow.c b/block/qcow.c
28
index XXXXXXX..XXXXXXX 100644
56
index XXXXXXX..XXXXXXX 100644
29
--- a/include/hw/block/block.h
57
--- a/block/qcow.c
30
+++ b/include/hw/block/block.h
58
+++ b/block/qcow.c
31
@@ -XXX,XX +XXX,XX @@ static inline unsigned int get_physical_block_exp(BlockConf *conf)
59
@@ -XXX,XX +XXX,XX @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
32
60
if (ret < 0) {
33
/* Configuration helpers */
34
35
+void blkconf_serial(BlockConf *conf, char **serial);
36
bool blkconf_geometry(BlockConf *conf, int *trans,
37
unsigned cyls_max, unsigned heads_max, unsigned secs_max,
38
Error **errp);
39
diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h
40
index XXXXXXX..XXXXXXX 100644
41
--- a/include/sysemu/blockdev.h
42
+++ b/include/sysemu/blockdev.h
43
@@ -XXX,XX +XXX,XX @@ struct DriveInfo {
44
bool is_default; /* Added by default_drive() ? */
45
int media_cd;
46
QemuOpts *opts;
47
+ char *serial;
48
QTAILQ_ENTRY(DriveInfo) next;
49
};
50
51
diff --git a/block/block-backend.c b/block/block-backend.c
52
index XXXXXXX..XXXXXXX 100644
53
--- a/block/block-backend.c
54
+++ b/block/block-backend.c
55
@@ -XXX,XX +XXX,XX @@ static void drive_info_del(DriveInfo *dinfo)
56
return;
57
}
58
qemu_opts_del(dinfo->opts);
59
+ g_free(dinfo->serial);
60
g_free(dinfo);
61
}
62
63
diff --git a/blockdev.c b/blockdev.c
64
index XXXXXXX..XXXXXXX 100644
65
--- a/blockdev.c
66
+++ b/blockdev.c
67
@@ -XXX,XX +XXX,XX @@ QemuOptsList qemu_legacy_drive_opts = {
68
.type = QEMU_OPT_STRING,
69
.help = "interface (ide, scsi, sd, mtd, floppy, pflash, virtio)",
70
},{
71
+ .name = "serial",
72
+ .type = QEMU_OPT_STRING,
73
+ .help = "disk serial number",
74
+ },{
75
.name = "file",
76
.type = QEMU_OPT_STRING,
77
.help = "file name",
78
@@ -XXX,XX +XXX,XX @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
79
const char *werror, *rerror;
80
bool read_only = false;
81
bool copy_on_read;
82
+ const char *serial;
83
const char *filename;
84
Error *local_err = NULL;
85
int i;
86
const char *deprecated[] = {
87
+ "serial"
88
};
89
90
/* Change legacy command line options into QMP ones */
91
@@ -XXX,XX +XXX,XX @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
92
goto fail;
61
goto fail;
93
}
62
}
94
63
- be32_to_cpus(&header.magic);
95
+ /* Serial number */
64
- be32_to_cpus(&header.version);
96
+ serial = qemu_opt_get(legacy_opts, "serial");
65
- be64_to_cpus(&header.backing_file_offset);
97
+
66
- be32_to_cpus(&header.backing_file_size);
98
/* no id supplied -> create one */
67
- be32_to_cpus(&header.mtime);
99
if (qemu_opts_id(all_opts) == NULL) {
68
- be64_to_cpus(&header.size);
100
char *new_id;
69
- be32_to_cpus(&header.crypt_method);
101
@@ -XXX,XX +XXX,XX @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
70
- be64_to_cpus(&header.l1_table_offset);
102
dinfo->type = type;
71
+ header.magic = be32_to_cpu(header.magic);
103
dinfo->bus = bus_id;
72
+ header.version = be32_to_cpu(header.version);
104
dinfo->unit = unit_id;
73
+ header.backing_file_offset = be64_to_cpu(header.backing_file_offset);
105
+ dinfo->serial = g_strdup(serial);
74
+ header.backing_file_size = be32_to_cpu(header.backing_file_size);
106
75
+ header.mtime = be32_to_cpu(header.mtime);
107
blk_set_legacy_dinfo(blk, dinfo);
76
+ header.size = be64_to_cpu(header.size);
108
77
+ header.crypt_method = be32_to_cpu(header.crypt_method);
109
diff --git a/hw/block/block.c b/hw/block/block.c
78
+ header.l1_table_offset = be64_to_cpu(header.l1_table_offset);
110
index XXXXXXX..XXXXXXX 100644
79
111
--- a/hw/block/block.c
80
if (header.magic != QCOW_MAGIC) {
112
+++ b/hw/block/block.c
81
error_setg(errp, "Image not in qcow format");
113
@@ -XXX,XX +XXX,XX @@
82
@@ -XXX,XX +XXX,XX @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
114
#include "qapi/qapi-types-block.h"
115
#include "qemu/error-report.h"
116
117
+void blkconf_serial(BlockConf *conf, char **serial)
118
+{
119
+ DriveInfo *dinfo;
120
+
121
+ if (!*serial) {
122
+ /* try to fall back to value set with legacy -drive serial=... */
123
+ dinfo = blk_legacy_dinfo(conf->blk);
124
+ if (dinfo) {
125
+ *serial = g_strdup(dinfo->serial);
126
+ }
127
+ }
128
+}
129
+
130
void blkconf_blocksizes(BlockConf *conf)
131
{
132
BlockBackend *blk = conf->blk;
133
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
134
index XXXXXXX..XXXXXXX 100644
135
--- a/hw/block/nvme.c
136
+++ b/hw/block/nvme.c
137
@@ -XXX,XX +XXX,XX @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp)
138
return;
139
}
83
}
140
84
141
+ blkconf_serial(&n->conf, &n->serial);
85
for(i = 0;i < s->l1_size; i++) {
142
if (!n->serial) {
86
- be64_to_cpus(&s->l1_table[i]);
143
error_setg(errp, "serial property not set");
87
+ s->l1_table[i] = be64_to_cpu(s->l1_table[i]);
144
return;
145
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
146
index XXXXXXX..XXXXXXX 100644
147
--- a/hw/block/virtio-blk.c
148
+++ b/hw/block/virtio-blk.c
149
@@ -XXX,XX +XXX,XX @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
150
return;
151
}
88
}
152
89
153
+ blkconf_serial(&conf->conf, &conf->serial);
90
/* alloc L2 cache (max. 64k * 16 * 8 = 8 MB) */
154
if (!blkconf_apply_backend_options(&conf->conf,
155
blk_is_read_only(conf->conf.blk), true,
156
errp)) {
157
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
158
index XXXXXXX..XXXXXXX 100644
159
--- a/hw/ide/qdev.c
160
+++ b/hw/ide/qdev.c
161
@@ -XXX,XX +XXX,XX @@ static void ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind, Error **errp)
162
return;
163
}
164
165
+ blkconf_serial(&dev->conf, &dev->serial);
166
if (kind != IDE_CD) {
167
if (!blkconf_geometry(&dev->conf, &dev->chs_trans, 65535, 16, 255,
168
errp)) {
169
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
170
index XXXXXXX..XXXXXXX 100644
171
--- a/hw/scsi/scsi-disk.c
172
+++ b/hw/scsi/scsi-disk.c
173
@@ -XXX,XX +XXX,XX @@ static void scsi_realize(SCSIDevice *dev, Error **errp)
174
return;
175
}
176
177
+ blkconf_serial(&s->qdev.conf, &s->serial);
178
blkconf_blocksizes(&s->qdev.conf);
179
180
if (s->qdev.conf.logical_block_size >
181
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
182
index XXXXXXX..XXXXXXX 100644
183
--- a/hw/usb/dev-storage.c
184
+++ b/hw/usb/dev-storage.c
185
@@ -XXX,XX +XXX,XX @@ static void usb_msd_storage_realize(USBDevice *dev, Error **errp)
186
return;
187
}
188
189
+ blkconf_serial(&s->conf, &dev->serial);
190
blkconf_blocksizes(&s->conf);
191
if (!blkconf_apply_backend_options(&s->conf, blk_is_read_only(blk), true,
192
errp)) {
193
diff --git a/tests/ahci-test.c b/tests/ahci-test.c
194
index XXXXXXX..XXXXXXX 100644
195
--- a/tests/ahci-test.c
196
+++ b/tests/ahci-test.c
197
@@ -XXX,XX +XXX,XX @@ static AHCIQState *ahci_boot(const char *cli, ...)
198
s = ahci_vboot(cli, ap);
199
va_end(ap);
200
} else {
201
- cli = "-drive if=none,id=drive0,file=%s,cache=writeback,format=%s"
202
+ cli = "-drive if=none,id=drive0,file=%s,cache=writeback,serial=%s"
203
+ ",format=%s"
204
" -M q35 "
205
"-device ide-hd,drive=drive0 "
206
- "-global ide-hd.serial=%s "
207
"-global ide-hd.ver=%s";
208
- s = ahci_boot(cli, tmp_path, imgfmt, "testdisk", "version");
209
+ s = ahci_boot(cli, tmp_path, "testdisk", imgfmt, "version");
210
}
211
212
return s;
213
diff --git a/tests/ide-test.c b/tests/ide-test.c
214
index XXXXXXX..XXXXXXX 100644
215
--- a/tests/ide-test.c
216
+++ b/tests/ide-test.c
217
@@ -XXX,XX +XXX,XX @@ static void test_bmdma_no_busmaster(void)
218
static void test_bmdma_setup(void)
219
{
220
ide_test_start(
221
- "-drive file=%s,if=ide,cache=writeback,format=raw "
222
- "-global ide-hd.serial=%s -global ide-hd.ver=%s",
223
+ "-drive file=%s,if=ide,serial=%s,cache=writeback,format=raw "
224
+ "-global ide-hd.ver=%s",
225
tmp_path, "testdisk", "version");
226
qtest_irq_intercept_in(global_qtest, "ioapic");
227
}
228
@@ -XXX,XX +XXX,XX @@ static void test_identify(void)
229
int ret;
230
231
ide_test_start(
232
- "-drive file=%s,if=ide,cache=writeback,format=raw "
233
- "-global ide-hd.serial=%s -global ide-hd.ver=%s",
234
+ "-drive file=%s,if=ide,serial=%s,cache=writeback,format=raw "
235
+ "-global ide-hd.ver=%s",
236
tmp_path, "testdisk", "version");
237
238
dev = get_pci_device(&bmdma_bar, &ide_bar);
239
diff --git a/qemu-doc.texi b/qemu-doc.texi
240
index XXXXXXX..XXXXXXX 100644
241
--- a/qemu-doc.texi
242
+++ b/qemu-doc.texi
243
@@ -XXX,XX +XXX,XX @@ with ``-device ...,netdev=x''), or ``-nic user,smb=/some/dir''
244
(for embedded NICs). The new syntax allows different settings to be
245
provided per NIC.
246
247
+@subsection -drive serial=... (since 2.10.0)
248
+
249
+The drive serial argument is replaced by the the serial argument
250
+that can be specified with the ``-device'' parameter.
251
+
252
@subsection -usbdevice (since 2.10.0)
253
254
The ``-usbdevice DEV'' argument is now a synonym for setting
255
diff --git a/qemu-options.hx b/qemu-options.hx
256
index XXXXXXX..XXXXXXX 100644
257
--- a/qemu-options.hx
258
+++ b/qemu-options.hx
259
@@ -XXX,XX +XXX,XX @@ ETEXI
260
DEF("drive", HAS_ARG, QEMU_OPTION_drive,
261
"-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i]\n"
262
" [,cache=writethrough|writeback|none|directsync|unsafe][,format=f]\n"
263
- " [,snapshot=on|off][,rerror=ignore|stop|report]\n"
264
+ " [,snapshot=on|off][,serial=s][,rerror=ignore|stop|report]\n"
265
" [,werror=ignore|stop|report|enospc][,id=name][,aio=threads|native]\n"
266
" [,readonly=on|off][,copy-on-read=on|off]\n"
267
" [,discard=ignore|unmap][,detect-zeroes=on|off|unmap]\n"
268
@@ -XXX,XX +XXX,XX @@ The default mode is @option{cache=writeback}.
269
Specify which disk @var{format} will be used rather than detecting
270
the format. Can be used to specify format=raw to avoid interpreting
271
an untrusted format header.
272
+@item serial=@var{serial}
273
+This option specifies the serial number to assign to the device. This
274
+parameter is deprecated, use the corresponding parameter of @code{-device}
275
+instead.
276
@item werror=@var{action},rerror=@var{action}
277
Specify which @var{action} to take on write and read errors. Valid actions are:
278
"ignore" (ignore the error and try to continue), "stop" (pause QEMU),
279
--
91
--
280
2.13.6
92
2.19.1
281
93
282
94
diff view generated by jsdifflib
1
From: Fam Zheng <famz@redhat.com>
1
From: Peter Maydell <peter.maydell@linaro.org>
2
2
3
Truncation is the last to convert from open coded req handling to
3
Taking the address of a field in a packed struct is a bad idea, because
4
reusing helpers. This time the permission check in prepare has to adapt
4
it might not be actually aligned enough for that pointer type (and
5
to the new caller: it checks a different permission bit, and doesn't
5
thus cause a crash on dereference on some host architectures). Newer
6
trigger the before write notifier.
6
versions of clang warn about this. Avoid the bug by not using the
7
"modify in place" byte swapping functions.
7
8
8
Also, truncation should always trigger a bs->total_sectors update and in
9
There are a few places where the in-place swap function is
9
turn call parent resize_cb. Update the condition in finish helper, too.
10
used on something other than a packed struct field; we convert
11
those anyway, for consistency.
10
12
11
It's intended to do a duplicated bs->read_only check before calling
13
This patch was produced with the following spatch script:
12
bdrv_co_write_req_prepare() so that we can be more informative with the
13
error message, as bdrv_co_write_req_prepare() doesn't have Error
14
parameter.
15
14
16
Signed-off-by: Fam Zheng <famz@redhat.com>
15
@@
16
expression E;
17
@@
18
-be16_to_cpus(&E);
19
+E = be16_to_cpu(E);
20
@@
21
expression E;
22
@@
23
-be32_to_cpus(&E);
24
+E = be32_to_cpu(E);
25
@@
26
expression E;
27
@@
28
-be64_to_cpus(&E);
29
+E = be64_to_cpu(E);
30
@@
31
expression E;
32
@@
33
-cpu_to_be16s(&E);
34
+E = cpu_to_be16(E);
35
@@
36
expression E;
37
@@
38
-cpu_to_be32s(&E);
39
+E = cpu_to_be32(E);
40
@@
41
expression E;
42
@@
43
-cpu_to_be64s(&E);
44
+E = cpu_to_be64(E);
45
46
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
47
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
48
Tested-by: John Snow <jsnow@redhat.com>
49
Reviewed-by: John Snow <jsnow@redhat.com>
17
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
50
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
18
---
51
---
19
block/io.c | 55 +++++++++++++++++++++++++++++++++++--------------------
52
block/qcow2-bitmap.c | 24 ++++++++++++------------
20
1 file changed, 35 insertions(+), 20 deletions(-)
53
1 file changed, 12 insertions(+), 12 deletions(-)
21
54
22
diff --git a/block/io.c b/block/io.c
55
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
23
index XXXXXXX..XXXXXXX 100644
56
index XXXXXXX..XXXXXXX 100644
24
--- a/block/io.c
57
--- a/block/qcow2-bitmap.c
25
+++ b/block/io.c
58
+++ b/block/qcow2-bitmap.c
26
@@ -XXX,XX +XXX,XX @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, uint64_t bytes,
59
@@ -XXX,XX +XXX,XX @@ static inline void bitmap_table_to_be(uint64_t *bitmap_table, size_t size)
27
is_request_serialising_and_aligned(req));
60
size_t i;
28
assert(req->overlap_offset <= offset);
61
29
assert(offset + bytes <= req->overlap_offset + req->overlap_bytes);
62
for (i = 0; i < size; ++i) {
30
+ assert(end_sector <= bs->total_sectors || child->perm & BLK_PERM_RESIZE);
63
- cpu_to_be64s(&bitmap_table[i]);
31
64
+ bitmap_table[i] = cpu_to_be64(bitmap_table[i]);
32
- if (flags & BDRV_REQ_WRITE_UNCHANGED) {
33
- assert(child->perm & (BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE));
34
- } else {
35
- assert(child->perm & BLK_PERM_WRITE);
36
+ switch (req->type) {
37
+ case BDRV_TRACKED_WRITE:
38
+ case BDRV_TRACKED_DISCARD:
39
+ if (flags & BDRV_REQ_WRITE_UNCHANGED) {
40
+ assert(child->perm & (BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE));
41
+ } else {
42
+ assert(child->perm & BLK_PERM_WRITE);
43
+ }
44
+ return notifier_with_return_list_notify(&bs->before_write_notifiers,
45
+ req);
46
+ case BDRV_TRACKED_TRUNCATE:
47
+ assert(child->perm & BLK_PERM_RESIZE);
48
+ return 0;
49
+ default:
50
+ abort();
51
}
65
}
52
- assert(end_sector <= bs->total_sectors || child->perm & BLK_PERM_RESIZE);
53
- return notifier_with_return_list_notify(&bs->before_write_notifiers, req);
54
}
66
}
55
67
56
static inline void coroutine_fn
68
@@ -XXX,XX +XXX,XX @@ static int bitmap_table_load(BlockDriverState *bs, Qcow2BitmapTable *tb,
57
@@ -XXX,XX +XXX,XX @@ bdrv_co_write_req_finish(BdrvChild *child, int64_t offset, uint64_t bytes,
58
* beyond EOF cannot expand the image anyway.
59
*/
60
if (ret == 0 &&
61
- end_sector > bs->total_sectors &&
62
- req->type != BDRV_TRACKED_DISCARD) {
63
+ (req->type == BDRV_TRACKED_TRUNCATE ||
64
+ end_sector > bs->total_sectors) &&
65
+ req->type != BDRV_TRACKED_DISCARD) {
66
bs->total_sectors = end_sector;
67
bdrv_parent_cb_resize(bs);
68
bdrv_dirty_bitmap_truncate(bs, end_sector << BDRV_SECTOR_BITS);
69
@@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset,
70
int64_t old_size, new_bytes;
71
int ret;
72
73
- assert(child->perm & BLK_PERM_RESIZE);
74
75
/* if bs->drv == NULL, bs is closed, so there's nothing to do here */
76
if (!drv) {
77
@@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset,
78
* concurrently or they might be overwritten by preallocation. */
79
if (new_bytes) {
80
mark_request_serialising(&req, 1);
81
- wait_serialising_requests(&req);
82
+ }
83
+ if (bs->read_only) {
84
+ error_setg(errp, "Image is read-only");
85
+ ret = -EACCES;
86
+ goto out;
87
+ }
88
+ ret = bdrv_co_write_req_prepare(child, offset - new_bytes, new_bytes, &req,
89
+ 0);
90
+ if (ret < 0) {
91
+ error_setg_errno(errp, -ret,
92
+ "Failed to prepare request for truncation");
93
+ goto out;
94
}
69
}
95
70
96
if (!drv->bdrv_co_truncate) {
71
for (i = 0; i < tb->size; ++i) {
97
@@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset,
72
- be64_to_cpus(&table[i]);
98
ret = -ENOTSUP;
73
+ table[i] = be64_to_cpu(table[i]);
99
goto out;
74
ret = check_table_entry(table[i], s->cluster_size);
100
}
75
if (ret < 0) {
101
- if (bs->read_only) {
76
goto fail;
102
- error_setg(errp, "Image is read-only");
77
@@ -XXX,XX +XXX,XX @@ fail:
103
- ret = -EACCES;
78
104
- goto out;
79
static inline void bitmap_dir_entry_to_cpu(Qcow2BitmapDirEntry *entry)
105
- }
80
{
106
-
81
- be64_to_cpus(&entry->bitmap_table_offset);
107
- assert(!(bs->open_flags & BDRV_O_INACTIVE));
82
- be32_to_cpus(&entry->bitmap_table_size);
108
83
- be32_to_cpus(&entry->flags);
109
ret = drv->bdrv_co_truncate(bs, offset, prealloc, errp);
84
- be16_to_cpus(&entry->name_size);
110
if (ret < 0) {
85
- be32_to_cpus(&entry->extra_data_size);
111
@@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset,
86
+ entry->bitmap_table_offset = be64_to_cpu(entry->bitmap_table_offset);
112
} else {
87
+ entry->bitmap_table_size = be32_to_cpu(entry->bitmap_table_size);
113
offset = bs->total_sectors * BDRV_SECTOR_SIZE;
88
+ entry->flags = be32_to_cpu(entry->flags);
114
}
89
+ entry->name_size = be16_to_cpu(entry->name_size);
115
- bdrv_dirty_bitmap_truncate(bs, offset);
90
+ entry->extra_data_size = be32_to_cpu(entry->extra_data_size);
116
- bdrv_parent_cb_resize(bs);
91
}
117
- atomic_inc(&bs->write_gen);
92
118
+ /* It's possible that truncation succeeded but refresh_total_sectors
93
static inline void bitmap_dir_entry_to_be(Qcow2BitmapDirEntry *entry)
119
+ * failed, but the latter doesn't affect how we should finish the request.
94
{
120
+ * Pass 0 as the last parameter so that dirty bitmaps etc. are handled. */
95
- cpu_to_be64s(&entry->bitmap_table_offset);
121
+ bdrv_co_write_req_finish(child, offset - new_bytes, new_bytes, &req, 0);
96
- cpu_to_be32s(&entry->bitmap_table_size);
122
97
- cpu_to_be32s(&entry->flags);
123
out:
98
- cpu_to_be16s(&entry->name_size);
124
tracked_request_end(&req);
99
- cpu_to_be32s(&entry->extra_data_size);
100
+ entry->bitmap_table_offset = cpu_to_be64(entry->bitmap_table_offset);
101
+ entry->bitmap_table_size = cpu_to_be32(entry->bitmap_table_size);
102
+ entry->flags = cpu_to_be32(entry->flags);
103
+ entry->name_size = cpu_to_be16(entry->name_size);
104
+ entry->extra_data_size = cpu_to_be32(entry->extra_data_size);
105
}
106
107
static inline int calc_dir_entry_size(size_t name_size, size_t extra_data_size)
125
--
108
--
126
2.13.6
109
2.19.1
127
110
128
111
diff view generated by jsdifflib
1
From: Fam Zheng <famz@redhat.com>
1
From: Daniel P. Berrangé <berrange@redhat.com>
2
2
3
Luks needs special parameters to operate the image. Since this test is
3
The qcow2 block driver expects to see a valid sector size even when it
4
focusing on image fleecing, skip skip that format.
4
has opened the crypto layer with QCRYPTO_BLOCK_OPEN_NO_IO.
5
5
6
Signed-off-by: Fam Zheng <famz@redhat.com>
6
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7
Reviewed-by: Alberto Garcia <berto@igalia.com>
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
---
9
---
9
tests/qemu-iotests/222 | 2 ++
10
crypto/block-qcow.c | 2 ++
10
1 file changed, 2 insertions(+)
11
1 file changed, 2 insertions(+)
11
12
12
diff --git a/tests/qemu-iotests/222 b/tests/qemu-iotests/222
13
diff --git a/crypto/block-qcow.c b/crypto/block-qcow.c
13
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
14
--- a/tests/qemu-iotests/222
15
--- a/crypto/block-qcow.c
15
+++ b/tests/qemu-iotests/222
16
+++ b/crypto/block-qcow.c
16
@@ -XXX,XX +XXX,XX @@ import iotests
17
@@ -XXX,XX +XXX,XX @@ qcrypto_block_qcow_open(QCryptoBlock *block,
17
from iotests import log, qemu_img, qemu_io, qemu_io_silent
18
Error **errp)
18
19
{
19
iotests.verify_platform(['linux'])
20
if (flags & QCRYPTO_BLOCK_OPEN_NO_IO) {
20
+iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk',
21
+ block->sector_size = QCRYPTO_BLOCK_QCOW_SECTOR_SIZE;
21
+ 'vhdx', 'raw'])
22
+ block->payload_offset = 0;
22
23
return 0;
23
patterns = [("0x5d", "0", "64k"),
24
} else {
24
("0xd5", "1M", "64k"),
25
if (!options->u.qcow.key_secret) {
25
--
26
--
26
2.13.6
27
2.19.1
27
28
28
29
diff view generated by jsdifflib
New patch
1
From: Alberto Garcia <berto@igalia.com>
1
2
3
This doesn't have any practical effect at the moment because the
4
values of BDRV_SECTOR_SIZE, QCRYPTO_BLOCK_LUKS_SECTOR_SIZE and
5
QCRYPTO_BLOCK_QCOW_SECTOR_SIZE are all the same (512 bytes), but
6
future encryption methods could have different requirements.
7
8
Signed-off-by: Alberto Garcia <berto@igalia.com>
9
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11
---
12
block/qcow2.c | 2 +-
13
1 file changed, 1 insertion(+), 1 deletion(-)
14
15
diff --git a/block/qcow2.c b/block/qcow2.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/block/qcow2.c
18
+++ b/block/qcow2.c
19
@@ -XXX,XX +XXX,XX @@ static void qcow2_refresh_limits(BlockDriverState *bs, Error **errp)
20
21
if (bs->encrypted) {
22
/* Encryption works on a sector granularity */
23
- bs->bl.request_alignment = BDRV_SECTOR_SIZE;
24
+ bs->bl.request_alignment = qcrypto_block_get_sector_size(s->crypto);
25
}
26
bs->bl.pwrite_zeroes_alignment = s->cluster_size;
27
bs->bl.pdiscard_alignment = s->cluster_size;
28
--
29
2.19.1
30
31
diff view generated by jsdifflib
1
From: Fam Zheng <famz@redhat.com>
1
From: Li Qiang <liq3ea@163.com>
2
2
3
Other I/O functions are already using a BdrvChild pointer in the API, so
3
Signed-off-by: Li Qiang <liq3ea@163.com>
4
make discard do the same. It makes it possible to initiate the same
4
Reviewed-by: Alberto Garcia <berto@igalia.com>
5
permission checks before doing I/O, and much easier to share the
6
helper functions for this, which will be added and used by write,
7
truncate and copy range paths.
8
9
Signed-off-by: Fam Zheng <famz@redhat.com>
10
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11
---
6
---
12
include/block/block.h | 4 ++--
7
include/sysemu/block-backend.h | 6 +++---
13
block/blkdebug.c | 2 +-
8
block/block-backend.c | 8 ++++----
14
block/blklogwrites.c | 2 +-
9
2 files changed, 7 insertions(+), 7 deletions(-)
15
block/blkreplay.c | 2 +-
16
block/block-backend.c | 2 +-
17
block/copy-on-read.c | 2 +-
18
block/io.c | 18 +++++++++---------
19
block/mirror.c | 2 +-
20
block/qcow2-refcount.c | 2 +-
21
block/raw-format.c | 2 +-
22
block/throttle.c | 2 +-
23
11 files changed, 20 insertions(+), 20 deletions(-)
24
10
25
diff --git a/include/block/block.h b/include/block/block.h
11
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
26
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
27
--- a/include/block/block.h
13
--- a/include/sysemu/block-backend.h
28
+++ b/include/block/block.h
14
+++ b/include/sysemu/block-backend.h
29
@@ -XXX,XX +XXX,XX @@ AioWait *bdrv_get_aio_wait(BlockDriverState *bs);
15
@@ -XXX,XX +XXX,XX @@ BlockErrorAction blk_get_error_action(BlockBackend *blk, bool is_read,
30
bdrv_get_aio_context(bs_), \
16
int error);
31
cond); })
17
void blk_error_action(BlockBackend *blk, BlockErrorAction action,
32
18
bool is_read, int error);
33
-int bdrv_pdiscard(BlockDriverState *bs, int64_t offset, int bytes);
19
-int blk_is_read_only(BlockBackend *blk);
34
-int bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes);
20
-int blk_is_sg(BlockBackend *blk);
35
+int bdrv_pdiscard(BdrvChild *child, int64_t offset, int bytes);
21
-int blk_enable_write_cache(BlockBackend *blk);
36
+int bdrv_co_pdiscard(BdrvChild *child, int64_t offset, int bytes);
22
+bool blk_is_read_only(BlockBackend *blk);
37
int bdrv_has_zero_init_1(BlockDriverState *bs);
23
+bool blk_is_sg(BlockBackend *blk);
38
int bdrv_has_zero_init(BlockDriverState *bs);
24
+bool blk_enable_write_cache(BlockBackend *blk);
39
bool bdrv_unallocated_blocks_are_zero(BlockDriverState *bs);
25
void blk_set_enable_write_cache(BlockBackend *blk, bool wce);
40
diff --git a/block/blkdebug.c b/block/blkdebug.c
26
void blk_invalidate_cache(BlockBackend *blk, Error **errp);
41
index XXXXXXX..XXXXXXX 100644
27
bool blk_is_inserted(BlockBackend *blk);
42
--- a/block/blkdebug.c
43
+++ b/block/blkdebug.c
44
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn blkdebug_co_pdiscard(BlockDriverState *bs,
45
return err;
46
}
47
48
- return bdrv_co_pdiscard(bs->file->bs, offset, bytes);
49
+ return bdrv_co_pdiscard(bs->file, offset, bytes);
50
}
51
52
static int coroutine_fn blkdebug_co_block_status(BlockDriverState *bs,
53
diff --git a/block/blklogwrites.c b/block/blklogwrites.c
54
index XXXXXXX..XXXXXXX 100644
55
--- a/block/blklogwrites.c
56
+++ b/block/blklogwrites.c
57
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn blk_log_writes_co_do_file_flush(BlkLogWritesFileReq *fr)
58
static int coroutine_fn
59
blk_log_writes_co_do_file_pdiscard(BlkLogWritesFileReq *fr)
60
{
61
- return bdrv_co_pdiscard(fr->bs->file->bs, fr->offset, fr->bytes);
62
+ return bdrv_co_pdiscard(fr->bs->file, fr->offset, fr->bytes);
63
}
64
65
static int coroutine_fn
66
diff --git a/block/blkreplay.c b/block/blkreplay.c
67
index XXXXXXX..XXXXXXX 100755
68
--- a/block/blkreplay.c
69
+++ b/block/blkreplay.c
70
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn blkreplay_co_pdiscard(BlockDriverState *bs,
71
int64_t offset, int bytes)
72
{
73
uint64_t reqid = blkreplay_next_id();
74
- int ret = bdrv_co_pdiscard(bs->file->bs, offset, bytes);
75
+ int ret = bdrv_co_pdiscard(bs->file, offset, bytes);
76
block_request_create(reqid, bs, qemu_coroutine_self());
77
qemu_coroutine_yield();
78
79
diff --git a/block/block-backend.c b/block/block-backend.c
28
diff --git a/block/block-backend.c b/block/block-backend.c
80
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
81
--- a/block/block-backend.c
30
--- a/block/block-backend.c
82
+++ b/block/block-backend.c
31
+++ b/block/block-backend.c
83
@@ -XXX,XX +XXX,XX @@ int blk_co_pdiscard(BlockBackend *blk, int64_t offset, int bytes)
32
@@ -XXX,XX +XXX,XX @@ void blk_error_action(BlockBackend *blk, BlockErrorAction action,
84
return ret;
85
}
33
}
86
87
- return bdrv_co_pdiscard(blk_bs(blk), offset, bytes);
88
+ return bdrv_co_pdiscard(blk->root, offset, bytes);
89
}
34
}
90
35
91
int blk_co_flush(BlockBackend *blk)
36
-int blk_is_read_only(BlockBackend *blk)
92
diff --git a/block/copy-on-read.c b/block/copy-on-read.c
37
+bool blk_is_read_only(BlockBackend *blk)
93
index XXXXXXX..XXXXXXX 100644
94
--- a/block/copy-on-read.c
95
+++ b/block/copy-on-read.c
96
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn cor_co_pwrite_zeroes(BlockDriverState *bs,
97
static int coroutine_fn cor_co_pdiscard(BlockDriverState *bs,
98
int64_t offset, int bytes)
99
{
38
{
100
- return bdrv_co_pdiscard(bs->file->bs, offset, bytes);
39
BlockDriverState *bs = blk_bs(blk);
101
+ return bdrv_co_pdiscard(bs->file, offset, bytes);
40
41
@@ -XXX,XX +XXX,XX @@ int blk_is_read_only(BlockBackend *blk)
42
}
102
}
43
}
103
44
104
45
-int blk_is_sg(BlockBackend *blk)
105
diff --git a/block/io.c b/block/io.c
46
+bool blk_is_sg(BlockBackend *blk)
106
index XXXXXXX..XXXXXXX 100644
47
{
107
--- a/block/io.c
48
BlockDriverState *bs = blk_bs(blk);
108
+++ b/block/io.c
49
109
@@ -XXX,XX +XXX,XX @@ int bdrv_flush(BlockDriverState *bs)
50
if (!bs) {
51
- return 0;
52
+ return false;
53
}
54
55
return bdrv_is_sg(bs);
110
}
56
}
111
57
112
typedef struct DiscardCo {
58
-int blk_enable_write_cache(BlockBackend *blk)
113
- BlockDriverState *bs;
59
+bool blk_enable_write_cache(BlockBackend *blk)
114
+ BdrvChild *child;
115
int64_t offset;
116
int bytes;
117
int ret;
118
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn bdrv_pdiscard_co_entry(void *opaque)
119
{
60
{
120
DiscardCo *rwco = opaque;
61
return blk->enable_write_cache;
121
122
- rwco->ret = bdrv_co_pdiscard(rwco->bs, rwco->offset, rwco->bytes);
123
+ rwco->ret = bdrv_co_pdiscard(rwco->child, rwco->offset, rwco->bytes);
124
}
62
}
125
126
-int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset,
127
- int bytes)
128
+int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, int64_t offset, int bytes)
129
{
130
BdrvTrackedRequest req;
131
int max_pdiscard, ret;
132
int head, tail, align;
133
+ BlockDriverState *bs = child->bs;
134
135
- if (!bs->drv) {
136
+ if (!bs || !bs->drv) {
137
return -ENOMEDIUM;
138
}
139
140
@@ -XXX,XX +XXX,XX @@ out:
141
return ret;
142
}
143
144
-int bdrv_pdiscard(BlockDriverState *bs, int64_t offset, int bytes)
145
+int bdrv_pdiscard(BdrvChild *child, int64_t offset, int bytes)
146
{
147
Coroutine *co;
148
DiscardCo rwco = {
149
- .bs = bs,
150
+ .child = child,
151
.offset = offset,
152
.bytes = bytes,
153
.ret = NOT_DONE,
154
@@ -XXX,XX +XXX,XX @@ int bdrv_pdiscard(BlockDriverState *bs, int64_t offset, int bytes)
155
bdrv_pdiscard_co_entry(&rwco);
156
} else {
157
co = qemu_coroutine_create(bdrv_pdiscard_co_entry, &rwco);
158
- bdrv_coroutine_enter(bs, co);
159
- BDRV_POLL_WHILE(bs, rwco.ret == NOT_DONE);
160
+ bdrv_coroutine_enter(child->bs, co);
161
+ BDRV_POLL_WHILE(child->bs, rwco.ret == NOT_DONE);
162
}
163
164
return rwco.ret;
165
diff --git a/block/mirror.c b/block/mirror.c
166
index XXXXXXX..XXXXXXX 100644
167
--- a/block/mirror.c
168
+++ b/block/mirror.c
169
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_mirror_top_do_write(BlockDriverState *bs,
170
break;
171
172
case MIRROR_METHOD_DISCARD:
173
- ret = bdrv_co_pdiscard(bs->backing->bs, offset, bytes);
174
+ ret = bdrv_co_pdiscard(bs->backing, offset, bytes);
175
break;
176
177
default:
178
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
179
index XXXXXXX..XXXXXXX 100644
180
--- a/block/qcow2-refcount.c
181
+++ b/block/qcow2-refcount.c
182
@@ -XXX,XX +XXX,XX @@ void qcow2_process_discards(BlockDriverState *bs, int ret)
183
184
/* Discard is optional, ignore the return value */
185
if (ret >= 0) {
186
- bdrv_pdiscard(bs->file->bs, d->offset, d->bytes);
187
+ bdrv_pdiscard(bs->file, d->offset, d->bytes);
188
}
189
190
g_free(d);
191
diff --git a/block/raw-format.c b/block/raw-format.c
192
index XXXXXXX..XXXXXXX 100644
193
--- a/block/raw-format.c
194
+++ b/block/raw-format.c
195
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn raw_co_pdiscard(BlockDriverState *bs,
196
if (ret) {
197
return ret;
198
}
199
- return bdrv_co_pdiscard(bs->file->bs, offset, bytes);
200
+ return bdrv_co_pdiscard(bs->file, offset, bytes);
201
}
202
203
static int64_t raw_getlength(BlockDriverState *bs)
204
diff --git a/block/throttle.c b/block/throttle.c
205
index XXXXXXX..XXXXXXX 100644
206
--- a/block/throttle.c
207
+++ b/block/throttle.c
208
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn throttle_co_pdiscard(BlockDriverState *bs,
209
ThrottleGroupMember *tgm = bs->opaque;
210
throttle_group_co_io_limits_intercept(tgm, bytes, true);
211
212
- return bdrv_co_pdiscard(bs->file->bs, offset, bytes);
213
+ return bdrv_co_pdiscard(bs->file, offset, bytes);
214
}
215
216
static int throttle_co_flush(BlockDriverState *bs)
217
--
63
--
218
2.13.6
64
2.19.1
219
65
220
66
diff view generated by jsdifflib
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
From: Cleber Rosa <crosa@redhat.com>
2
2
3
Here two things are fixed:
3
While testing the Python 3 changes which touch the 083 test, I noticed
4
that it would fail with qcow2. Expanding the testing, I noticed it
5
had nothing to do with the Python 3 changes, and in fact, it would not
6
pass on anything but raw:
4
7
5
1. Architecture
8
raw: pass
9
bochs: not generic
10
cloop: not generic
11
parallels: fail
12
qcow: fail
13
qcow2: fail
14
qed: fail
15
vdi: fail
16
vhdx: fail
17
vmdk: fail
18
vpc: fail
19
luks: fail
6
20
7
On each recursion step, we go to the child of src or dst, only for one
21
The errors are a mixture I/O and "image not in xxx format", such as:
8
of them. So, it's wrong to create tracked requests for both on each
9
step. It leads to tracked requests duplication.
10
22
11
2. Wait for serializing requests on write path independently of
23
=== Check disconnect before data ===
12
BDRV_REQ_NO_SERIALISING
13
24
14
Before commit 9ded4a01149 "backup: Use copy offloading",
25
Unexpected end-of-file before all bytes were read
15
BDRV_REQ_NO_SERIALISING was used for only one case: read in
26
-read failed: Input/output error
16
copy-on-write operation during backup. Also, the flag was handled only
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
17
on read path (in bdrv_co_preadv and bdrv_aligned_preadv).
18
28
19
After 9ded4a01149, flag is used for not waiting serializing operations
29
=== Check disconnect after data ===
20
on backup target (in same case of copy-on-write operation). This
21
behavior change is unsubstantiated and potentially dangerous, let's
22
drop it and add additional asserts and documentation.
23
30
24
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
31
-read 512/512 bytes at offset 0
25
Reviewed-by: Fam Zheng <famz@redhat.com>
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>
26
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
40
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
27
---
41
---
28
include/block/block.h | 12 ++++++++++++
42
tests/qemu-iotests/083 | 2 +-
29
block/io.c | 42 +++++++++++++++++++++++++++---------------
43
1 file changed, 1 insertion(+), 1 deletion(-)
30
2 files changed, 39 insertions(+), 15 deletions(-)
31
44
32
diff --git a/include/block/block.h b/include/block/block.h
45
diff --git a/tests/qemu-iotests/083 b/tests/qemu-iotests/083
33
index XXXXXXX..XXXXXXX 100644
46
index XXXXXXX..XXXXXXX 100755
34
--- a/include/block/block.h
47
--- a/tests/qemu-iotests/083
35
+++ b/include/block/block.h
48
+++ b/tests/qemu-iotests/083
36
@@ -XXX,XX +XXX,XX @@ typedef enum {
49
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
37
* opened with BDRV_O_UNMAP.
50
. ./common.rc
38
*/
51
. ./common.filter
39
BDRV_REQ_MAY_UNMAP = 0x4,
52
40
+
53
-_supported_fmt generic
41
+ /*
54
+_supported_fmt raw
42
+ * The BDRV_REQ_NO_SERIALISING flag is only valid for reads and means that
55
_supported_proto nbd
43
+ * we don't want wait_serialising_requests() during the read operation.
56
_supported_os Linux
44
+ *
45
+ * This flag is used for backup copy-on-write operations, when we need to
46
+ * read old data before write (write notifier triggered). It is okay since
47
+ * we already waited for other serializing requests in the initiating write
48
+ * (see bdrv_aligned_pwritev), and it is necessary if the initiating write
49
+ * is already serializing (without the flag, the read would deadlock
50
+ * waiting for the serialising write to complete).
51
+ */
52
BDRV_REQ_NO_SERIALISING = 0x8,
53
BDRV_REQ_FUA = 0x10,
54
BDRV_REQ_WRITE_COMPRESSED = 0x20,
55
diff --git a/block/io.c b/block/io.c
56
index XXXXXXX..XXXXXXX 100644
57
--- a/block/io.c
58
+++ b/block/io.c
59
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
60
max_transfer = QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_transfer, INT_MAX),
61
align);
62
63
+ /* BDRV_REQ_NO_SERIALISING is only for read operation */
64
+ assert(!(flags & BDRV_REQ_NO_SERIALISING));
65
waited = wait_serialising_requests(req);
66
assert(!waited || !req->serialising);
67
assert(req->overlap_offset <= offset);
68
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_copy_range_internal(BdrvChild *src,
69
BdrvRequestFlags flags,
70
bool recurse_src)
71
{
72
- BdrvTrackedRequest src_req, dst_req;
73
+ BdrvTrackedRequest req;
74
int ret;
75
76
if (!dst || !dst->bs) {
77
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_copy_range_internal(BdrvChild *src,
78
|| src->bs->encrypted || dst->bs->encrypted) {
79
return -ENOTSUP;
80
}
81
- bdrv_inc_in_flight(src->bs);
82
- bdrv_inc_in_flight(dst->bs);
83
- tracked_request_begin(&src_req, src->bs, src_offset,
84
- bytes, BDRV_TRACKED_READ);
85
- tracked_request_begin(&dst_req, dst->bs, dst_offset,
86
- bytes, BDRV_TRACKED_WRITE);
87
88
- if (!(flags & BDRV_REQ_NO_SERIALISING)) {
89
- wait_serialising_requests(&src_req);
90
- wait_serialising_requests(&dst_req);
91
- }
92
if (recurse_src) {
93
+ bdrv_inc_in_flight(src->bs);
94
+ tracked_request_begin(&req, src->bs, src_offset, bytes,
95
+ BDRV_TRACKED_READ);
96
+
97
+ if (!(flags & BDRV_REQ_NO_SERIALISING)) {
98
+ wait_serialising_requests(&req);
99
+ }
100
+
101
ret = src->bs->drv->bdrv_co_copy_range_from(src->bs,
102
src, src_offset,
103
dst, dst_offset,
104
bytes, flags);
105
+
106
+ tracked_request_end(&req);
107
+ bdrv_dec_in_flight(src->bs);
108
} else {
109
+ bdrv_inc_in_flight(dst->bs);
110
+ tracked_request_begin(&req, dst->bs, dst_offset, bytes,
111
+ BDRV_TRACKED_WRITE);
112
+
113
+ /* BDRV_REQ_NO_SERIALISING is only for read operation,
114
+ * so we ignore it in flags.
115
+ */
116
+ wait_serialising_requests(&req);
117
+
118
ret = dst->bs->drv->bdrv_co_copy_range_to(dst->bs,
119
src, src_offset,
120
dst, dst_offset,
121
bytes, flags);
122
+
123
+ tracked_request_end(&req);
124
+ bdrv_dec_in_flight(dst->bs);
125
}
126
- tracked_request_end(&src_req);
127
- tracked_request_end(&dst_req);
128
- bdrv_dec_in_flight(src->bs);
129
- bdrv_dec_in_flight(dst->bs);
130
+
131
return ret;
132
}
133
57
134
--
58
--
135
2.13.6
59
2.19.1
136
60
137
61
diff view generated by jsdifflib
New patch
1
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2
Reviewed-by: Alberto Garcia <berto@igalia.com>
3
---
4
block/vpc.c | 2 ++
5
1 file changed, 2 insertions(+)
1
6
7
diff --git a/block/vpc.c b/block/vpc.c
8
index XXXXXXX..XXXXXXX 100644
9
--- a/block/vpc.c
10
+++ b/block/vpc.c
11
@@ -XXX,XX +XXX,XX @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,
12
}
13
14
qemu_co_mutex_init(&s->lock);
15
+ qemu_opts_del(opts);
16
17
return 0;
18
19
fail:
20
+ qemu_opts_del(opts);
21
qemu_vfree(s->pagetable);
22
#ifdef CACHE
23
g_free(s->pageentry_u8);
24
--
25
2.19.1
26
27
diff view generated by jsdifflib
New patch
1
1
From: Peter Maydell <peter.maydell@linaro.org>
2
3
Taking the address of a field in a packed struct is a bad idea, because
4
it might not be actually aligned enough for that pointer type (and
5
thus cause a crash on dereference on some host architectures). Newer
6
versions of clang warn about this. Avoid the bug by not using the
7
"modify in place" byte swapping functions.
8
9
There are a few places where the in-place swap function is
10
used on something other than a packed struct field; we convert
11
those anyway, for consistency.
12
13
Patch produced with scripts/coccinelle/inplace-byteswaps.cocci.
14
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
17
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
18
---
19
block/vhdx.h | 12 ++---
20
block/vhdx-endian.c | 118 ++++++++++++++++++++++----------------------
21
block/vhdx-log.c | 4 +-
22
block/vhdx.c | 18 +++----
23
4 files changed, 76 insertions(+), 76 deletions(-)
24
25
diff --git a/block/vhdx.h b/block/vhdx.h
26
index XXXXXXX..XXXXXXX 100644
27
--- a/block/vhdx.h
28
+++ b/block/vhdx.h
29
@@ -XXX,XX +XXX,XX @@ int vhdx_log_write_and_flush(BlockDriverState *bs, BDRVVHDXState *s,
30
31
static inline void leguid_to_cpus(MSGUID *guid)
32
{
33
- le32_to_cpus(&guid->data1);
34
- le16_to_cpus(&guid->data2);
35
- le16_to_cpus(&guid->data3);
36
+ guid->data1 = le32_to_cpu(guid->data1);
37
+ guid->data2 = le16_to_cpu(guid->data2);
38
+ guid->data3 = le16_to_cpu(guid->data3);
39
}
40
41
static inline void cpu_to_leguids(MSGUID *guid)
42
{
43
- cpu_to_le32s(&guid->data1);
44
- cpu_to_le16s(&guid->data2);
45
- cpu_to_le16s(&guid->data3);
46
+ guid->data1 = cpu_to_le32(guid->data1);
47
+ guid->data2 = cpu_to_le16(guid->data2);
48
+ guid->data3 = cpu_to_le16(guid->data3);
49
}
50
51
void vhdx_header_le_import(VHDXHeader *h);
52
diff --git a/block/vhdx-endian.c b/block/vhdx-endian.c
53
index XXXXXXX..XXXXXXX 100644
54
--- a/block/vhdx-endian.c
55
+++ b/block/vhdx-endian.c
56
@@ -XXX,XX +XXX,XX @@ void vhdx_header_le_import(VHDXHeader *h)
57
{
58
assert(h != NULL);
59
60
- le32_to_cpus(&h->signature);
61
- le32_to_cpus(&h->checksum);
62
- le64_to_cpus(&h->sequence_number);
63
+ h->signature = le32_to_cpu(h->signature);
64
+ h->checksum = le32_to_cpu(h->checksum);
65
+ h->sequence_number = le64_to_cpu(h->sequence_number);
66
67
leguid_to_cpus(&h->file_write_guid);
68
leguid_to_cpus(&h->data_write_guid);
69
leguid_to_cpus(&h->log_guid);
70
71
- le16_to_cpus(&h->log_version);
72
- le16_to_cpus(&h->version);
73
- le32_to_cpus(&h->log_length);
74
- le64_to_cpus(&h->log_offset);
75
+ h->log_version = le16_to_cpu(h->log_version);
76
+ h->version = le16_to_cpu(h->version);
77
+ h->log_length = le32_to_cpu(h->log_length);
78
+ h->log_offset = le64_to_cpu(h->log_offset);
79
}
80
81
void vhdx_header_le_export(VHDXHeader *orig_h, VHDXHeader *new_h)
82
@@ -XXX,XX +XXX,XX @@ void vhdx_log_desc_le_import(VHDXLogDescriptor *d)
83
{
84
assert(d != NULL);
85
86
- le32_to_cpus(&d->signature);
87
- le64_to_cpus(&d->file_offset);
88
- le64_to_cpus(&d->sequence_number);
89
+ d->signature = le32_to_cpu(d->signature);
90
+ d->file_offset = le64_to_cpu(d->file_offset);
91
+ d->sequence_number = le64_to_cpu(d->sequence_number);
92
}
93
94
void vhdx_log_desc_le_export(VHDXLogDescriptor *d)
95
{
96
assert(d != NULL);
97
98
- cpu_to_le32s(&d->signature);
99
- cpu_to_le32s(&d->trailing_bytes);
100
- cpu_to_le64s(&d->leading_bytes);
101
- cpu_to_le64s(&d->file_offset);
102
- cpu_to_le64s(&d->sequence_number);
103
+ d->signature = cpu_to_le32(d->signature);
104
+ d->trailing_bytes = cpu_to_le32(d->trailing_bytes);
105
+ d->leading_bytes = cpu_to_le64(d->leading_bytes);
106
+ d->file_offset = cpu_to_le64(d->file_offset);
107
+ d->sequence_number = cpu_to_le64(d->sequence_number);
108
}
109
110
void vhdx_log_data_le_import(VHDXLogDataSector *d)
111
{
112
assert(d != NULL);
113
114
- le32_to_cpus(&d->data_signature);
115
- le32_to_cpus(&d->sequence_high);
116
- le32_to_cpus(&d->sequence_low);
117
+ d->data_signature = le32_to_cpu(d->data_signature);
118
+ d->sequence_high = le32_to_cpu(d->sequence_high);
119
+ d->sequence_low = le32_to_cpu(d->sequence_low);
120
}
121
122
void vhdx_log_data_le_export(VHDXLogDataSector *d)
123
{
124
assert(d != NULL);
125
126
- cpu_to_le32s(&d->data_signature);
127
- cpu_to_le32s(&d->sequence_high);
128
- cpu_to_le32s(&d->sequence_low);
129
+ d->data_signature = cpu_to_le32(d->data_signature);
130
+ d->sequence_high = cpu_to_le32(d->sequence_high);
131
+ d->sequence_low = cpu_to_le32(d->sequence_low);
132
}
133
134
void vhdx_log_entry_hdr_le_import(VHDXLogEntryHeader *hdr)
135
{
136
assert(hdr != NULL);
137
138
- le32_to_cpus(&hdr->signature);
139
- le32_to_cpus(&hdr->checksum);
140
- le32_to_cpus(&hdr->entry_length);
141
- le32_to_cpus(&hdr->tail);
142
- le64_to_cpus(&hdr->sequence_number);
143
- le32_to_cpus(&hdr->descriptor_count);
144
+ hdr->signature = le32_to_cpu(hdr->signature);
145
+ hdr->checksum = le32_to_cpu(hdr->checksum);
146
+ hdr->entry_length = le32_to_cpu(hdr->entry_length);
147
+ hdr->tail = le32_to_cpu(hdr->tail);
148
+ hdr->sequence_number = le64_to_cpu(hdr->sequence_number);
149
+ hdr->descriptor_count = le32_to_cpu(hdr->descriptor_count);
150
leguid_to_cpus(&hdr->log_guid);
151
- le64_to_cpus(&hdr->flushed_file_offset);
152
- le64_to_cpus(&hdr->last_file_offset);
153
+ hdr->flushed_file_offset = le64_to_cpu(hdr->flushed_file_offset);
154
+ hdr->last_file_offset = le64_to_cpu(hdr->last_file_offset);
155
}
156
157
void vhdx_log_entry_hdr_le_export(VHDXLogEntryHeader *hdr)
158
{
159
assert(hdr != NULL);
160
161
- cpu_to_le32s(&hdr->signature);
162
- cpu_to_le32s(&hdr->checksum);
163
- cpu_to_le32s(&hdr->entry_length);
164
- cpu_to_le32s(&hdr->tail);
165
- cpu_to_le64s(&hdr->sequence_number);
166
- cpu_to_le32s(&hdr->descriptor_count);
167
+ hdr->signature = cpu_to_le32(hdr->signature);
168
+ hdr->checksum = cpu_to_le32(hdr->checksum);
169
+ hdr->entry_length = cpu_to_le32(hdr->entry_length);
170
+ hdr->tail = cpu_to_le32(hdr->tail);
171
+ hdr->sequence_number = cpu_to_le64(hdr->sequence_number);
172
+ hdr->descriptor_count = cpu_to_le32(hdr->descriptor_count);
173
cpu_to_leguids(&hdr->log_guid);
174
- cpu_to_le64s(&hdr->flushed_file_offset);
175
- cpu_to_le64s(&hdr->last_file_offset);
176
+ hdr->flushed_file_offset = cpu_to_le64(hdr->flushed_file_offset);
177
+ hdr->last_file_offset = cpu_to_le64(hdr->last_file_offset);
178
}
179
180
181
@@ -XXX,XX +XXX,XX @@ void vhdx_region_header_le_import(VHDXRegionTableHeader *hdr)
182
{
183
assert(hdr != NULL);
184
185
- le32_to_cpus(&hdr->signature);
186
- le32_to_cpus(&hdr->checksum);
187
- le32_to_cpus(&hdr->entry_count);
188
+ hdr->signature = le32_to_cpu(hdr->signature);
189
+ hdr->checksum = le32_to_cpu(hdr->checksum);
190
+ hdr->entry_count = le32_to_cpu(hdr->entry_count);
191
}
192
193
void vhdx_region_header_le_export(VHDXRegionTableHeader *hdr)
194
{
195
assert(hdr != NULL);
196
197
- cpu_to_le32s(&hdr->signature);
198
- cpu_to_le32s(&hdr->checksum);
199
- cpu_to_le32s(&hdr->entry_count);
200
+ hdr->signature = cpu_to_le32(hdr->signature);
201
+ hdr->checksum = cpu_to_le32(hdr->checksum);
202
+ hdr->entry_count = cpu_to_le32(hdr->entry_count);
203
}
204
205
void vhdx_region_entry_le_import(VHDXRegionTableEntry *e)
206
@@ -XXX,XX +XXX,XX @@ void vhdx_region_entry_le_import(VHDXRegionTableEntry *e)
207
assert(e != NULL);
208
209
leguid_to_cpus(&e->guid);
210
- le64_to_cpus(&e->file_offset);
211
- le32_to_cpus(&e->length);
212
- le32_to_cpus(&e->data_bits);
213
+ e->file_offset = le64_to_cpu(e->file_offset);
214
+ e->length = le32_to_cpu(e->length);
215
+ e->data_bits = le32_to_cpu(e->data_bits);
216
}
217
218
void vhdx_region_entry_le_export(VHDXRegionTableEntry *e)
219
@@ -XXX,XX +XXX,XX @@ void vhdx_region_entry_le_export(VHDXRegionTableEntry *e)
220
assert(e != NULL);
221
222
cpu_to_leguids(&e->guid);
223
- cpu_to_le64s(&e->file_offset);
224
- cpu_to_le32s(&e->length);
225
- cpu_to_le32s(&e->data_bits);
226
+ e->file_offset = cpu_to_le64(e->file_offset);
227
+ e->length = cpu_to_le32(e->length);
228
+ e->data_bits = cpu_to_le32(e->data_bits);
229
}
230
231
232
@@ -XXX,XX +XXX,XX @@ void vhdx_metadata_header_le_import(VHDXMetadataTableHeader *hdr)
233
{
234
assert(hdr != NULL);
235
236
- le64_to_cpus(&hdr->signature);
237
- le16_to_cpus(&hdr->entry_count);
238
+ hdr->signature = le64_to_cpu(hdr->signature);
239
+ hdr->entry_count = le16_to_cpu(hdr->entry_count);
240
}
241
242
void vhdx_metadata_header_le_export(VHDXMetadataTableHeader *hdr)
243
{
244
assert(hdr != NULL);
245
246
- cpu_to_le64s(&hdr->signature);
247
- cpu_to_le16s(&hdr->entry_count);
248
+ hdr->signature = cpu_to_le64(hdr->signature);
249
+ hdr->entry_count = cpu_to_le16(hdr->entry_count);
250
}
251
252
void vhdx_metadata_entry_le_import(VHDXMetadataTableEntry *e)
253
@@ -XXX,XX +XXX,XX @@ void vhdx_metadata_entry_le_import(VHDXMetadataTableEntry *e)
254
assert(e != NULL);
255
256
leguid_to_cpus(&e->item_id);
257
- le32_to_cpus(&e->offset);
258
- le32_to_cpus(&e->length);
259
- le32_to_cpus(&e->data_bits);
260
+ e->offset = le32_to_cpu(e->offset);
261
+ e->length = le32_to_cpu(e->length);
262
+ e->data_bits = le32_to_cpu(e->data_bits);
263
}
264
void vhdx_metadata_entry_le_export(VHDXMetadataTableEntry *e)
265
{
266
assert(e != NULL);
267
268
cpu_to_leguids(&e->item_id);
269
- cpu_to_le32s(&e->offset);
270
- cpu_to_le32s(&e->length);
271
- cpu_to_le32s(&e->data_bits);
272
+ e->offset = cpu_to_le32(e->offset);
273
+ e->length = cpu_to_le32(e->length);
274
+ e->data_bits = cpu_to_le32(e->data_bits);
275
}
276
diff --git a/block/vhdx-log.c b/block/vhdx-log.c
277
index XXXXXXX..XXXXXXX 100644
278
--- a/block/vhdx-log.c
279
+++ b/block/vhdx-log.c
280
@@ -XXX,XX +XXX,XX @@ static void vhdx_log_raw_to_le_sector(VHDXLogDescriptor *desc,
281
/* 8 + 4084 + 4 = 4096, 1 log sector */
282
memcpy(&desc->leading_bytes, data, 8);
283
data += 8;
284
- cpu_to_le64s(&desc->leading_bytes);
285
+ desc->leading_bytes = cpu_to_le64(desc->leading_bytes);
286
memcpy(sector->data, data, 4084);
287
data += 4084;
288
memcpy(&desc->trailing_bytes, data, 4);
289
- cpu_to_le32s(&desc->trailing_bytes);
290
+ desc->trailing_bytes = cpu_to_le32(desc->trailing_bytes);
291
data += 4;
292
293
sector->sequence_high = (uint32_t) (seq >> 32);
294
diff --git a/block/vhdx.c b/block/vhdx.c
295
index XXXXXXX..XXXXXXX 100644
296
--- a/block/vhdx.c
297
+++ b/block/vhdx.c
298
@@ -XXX,XX +XXX,XX @@ uint32_t vhdx_update_checksum(uint8_t *buf, size_t size, int crc_offset)
299
300
memset(buf + crc_offset, 0, sizeof(crc));
301
crc = crc32c(0xffffffff, buf, size);
302
- cpu_to_le32s(&crc);
303
+ crc = cpu_to_le32(crc);
304
memcpy(buf + crc_offset, &crc, sizeof(crc));
305
306
return crc;
307
@@ -XXX,XX +XXX,XX @@ static int vhdx_parse_metadata(BlockDriverState *bs, BDRVVHDXState *s)
308
goto exit;
309
}
310
311
- le32_to_cpus(&s->params.block_size);
312
- le32_to_cpus(&s->params.data_bits);
313
+ s->params.block_size = le32_to_cpu(s->params.block_size);
314
+ s->params.data_bits = le32_to_cpu(s->params.data_bits);
315
316
317
/* We now have the file parameters, so we can tell if this is a
318
@@ -XXX,XX +XXX,XX @@ static int vhdx_parse_metadata(BlockDriverState *bs, BDRVVHDXState *s)
319
goto exit;
320
}
321
322
- le64_to_cpus(&s->virtual_disk_size);
323
- le32_to_cpus(&s->logical_sector_size);
324
- le32_to_cpus(&s->physical_sector_size);
325
+ s->virtual_disk_size = le64_to_cpu(s->virtual_disk_size);
326
+ s->logical_sector_size = le32_to_cpu(s->logical_sector_size);
327
+ s->physical_sector_size = le32_to_cpu(s->physical_sector_size);
328
329
if (s->params.block_size < VHDX_BLOCK_SIZE_MIN ||
330
s->params.block_size > VHDX_BLOCK_SIZE_MAX) {
331
@@ -XXX,XX +XXX,XX @@ static int vhdx_open(BlockDriverState *bs, QDict *options, int flags,
332
/* endian convert, and verify populated BAT field file offsets against
333
* region table and log entries */
334
for (i = 0; i < s->bat_entries; i++) {
335
- le64_to_cpus(&s->bat[i]);
336
+ s->bat[i] = le64_to_cpu(s->bat[i]);
337
if (payblocks--) {
338
/* payload bat entries */
339
if ((s->bat[i] & VHDX_BAT_STATE_BIT_MASK) ==
340
@@ -XXX,XX +XXX,XX @@ static int vhdx_create_new_metadata(BlockBackend *blk,
341
mt_file_params->block_size = cpu_to_le32(block_size);
342
if (type == VHDX_TYPE_FIXED) {
343
mt_file_params->data_bits |= VHDX_PARAMS_LEAVE_BLOCKS_ALLOCED;
344
- cpu_to_le32s(&mt_file_params->data_bits);
345
+ mt_file_params->data_bits = cpu_to_le32(mt_file_params->data_bits);
346
}
347
348
vhdx_guid_generate(&mt_page83->page_83_data);
349
@@ -XXX,XX +XXX,XX @@ static int vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s,
350
sinfo.file_offset = ROUND_UP(sinfo.file_offset, MiB);
351
vhdx_update_bat_table_entry(blk_bs(blk), s, &sinfo, &unused, &unused,
352
block_state);
353
- cpu_to_le64s(&s->bat[sinfo.bat_idx]);
354
+ s->bat[sinfo.bat_idx] = cpu_to_le64(s->bat[sinfo.bat_idx]);
355
sector_num += s->sectors_per_block;
356
}
357
ret = blk_pwrite(blk, file_offset, s->bat, length, 0);
358
--
359
2.19.1
360
361
diff view generated by jsdifflib
New patch
1
From: Peter Maydell <peter.maydell@linaro.org>
1
2
3
Taking the address of a field in a packed struct is a bad idea, because
4
it might not be actually aligned enough for that pointer type (and
5
thus cause a crash on dereference on some host architectures). Newer
6
versions of clang warn about this. Avoid the bug by not using the
7
"modify in place" byte swapping functions.
8
9
There are a few places where the in-place swap function is
10
used on something other than a packed struct field; we convert
11
those anyway, for consistency.
12
13
Patch produced with scripts/coccinelle/inplace-byteswaps.cocci.
14
15
There are other places where we take the address of a packed member
16
in this file for other purposes than passing it to a byteswap
17
function (all the calls to qemu_uuid_*()); we leave those for now.
18
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
21
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
22
---
23
block/vdi.c | 64 ++++++++++++++++++++++++++---------------------------
24
1 file changed, 32 insertions(+), 32 deletions(-)
25
26
diff --git a/block/vdi.c b/block/vdi.c
27
index XXXXXXX..XXXXXXX 100644
28
--- a/block/vdi.c
29
+++ b/block/vdi.c
30
@@ -XXX,XX +XXX,XX @@ typedef struct {
31
32
static void vdi_header_to_cpu(VdiHeader *header)
33
{
34
- le32_to_cpus(&header->signature);
35
- le32_to_cpus(&header->version);
36
- le32_to_cpus(&header->header_size);
37
- le32_to_cpus(&header->image_type);
38
- le32_to_cpus(&header->image_flags);
39
- le32_to_cpus(&header->offset_bmap);
40
- le32_to_cpus(&header->offset_data);
41
- le32_to_cpus(&header->cylinders);
42
- le32_to_cpus(&header->heads);
43
- le32_to_cpus(&header->sectors);
44
- le32_to_cpus(&header->sector_size);
45
- le64_to_cpus(&header->disk_size);
46
- le32_to_cpus(&header->block_size);
47
- le32_to_cpus(&header->block_extra);
48
- le32_to_cpus(&header->blocks_in_image);
49
- le32_to_cpus(&header->blocks_allocated);
50
+ header->signature = le32_to_cpu(header->signature);
51
+ header->version = le32_to_cpu(header->version);
52
+ header->header_size = le32_to_cpu(header->header_size);
53
+ header->image_type = le32_to_cpu(header->image_type);
54
+ header->image_flags = le32_to_cpu(header->image_flags);
55
+ header->offset_bmap = le32_to_cpu(header->offset_bmap);
56
+ header->offset_data = le32_to_cpu(header->offset_data);
57
+ header->cylinders = le32_to_cpu(header->cylinders);
58
+ header->heads = le32_to_cpu(header->heads);
59
+ header->sectors = le32_to_cpu(header->sectors);
60
+ header->sector_size = le32_to_cpu(header->sector_size);
61
+ header->disk_size = le64_to_cpu(header->disk_size);
62
+ header->block_size = le32_to_cpu(header->block_size);
63
+ header->block_extra = le32_to_cpu(header->block_extra);
64
+ header->blocks_in_image = le32_to_cpu(header->blocks_in_image);
65
+ header->blocks_allocated = le32_to_cpu(header->blocks_allocated);
66
qemu_uuid_bswap(&header->uuid_image);
67
qemu_uuid_bswap(&header->uuid_last_snap);
68
qemu_uuid_bswap(&header->uuid_link);
69
@@ -XXX,XX +XXX,XX @@ static void vdi_header_to_cpu(VdiHeader *header)
70
71
static void vdi_header_to_le(VdiHeader *header)
72
{
73
- cpu_to_le32s(&header->signature);
74
- cpu_to_le32s(&header->version);
75
- cpu_to_le32s(&header->header_size);
76
- cpu_to_le32s(&header->image_type);
77
- cpu_to_le32s(&header->image_flags);
78
- cpu_to_le32s(&header->offset_bmap);
79
- cpu_to_le32s(&header->offset_data);
80
- cpu_to_le32s(&header->cylinders);
81
- cpu_to_le32s(&header->heads);
82
- cpu_to_le32s(&header->sectors);
83
- cpu_to_le32s(&header->sector_size);
84
- cpu_to_le64s(&header->disk_size);
85
- cpu_to_le32s(&header->block_size);
86
- cpu_to_le32s(&header->block_extra);
87
- cpu_to_le32s(&header->blocks_in_image);
88
- cpu_to_le32s(&header->blocks_allocated);
89
+ header->signature = cpu_to_le32(header->signature);
90
+ header->version = cpu_to_le32(header->version);
91
+ header->header_size = cpu_to_le32(header->header_size);
92
+ header->image_type = cpu_to_le32(header->image_type);
93
+ header->image_flags = cpu_to_le32(header->image_flags);
94
+ header->offset_bmap = cpu_to_le32(header->offset_bmap);
95
+ header->offset_data = cpu_to_le32(header->offset_data);
96
+ header->cylinders = cpu_to_le32(header->cylinders);
97
+ header->heads = cpu_to_le32(header->heads);
98
+ header->sectors = cpu_to_le32(header->sectors);
99
+ header->sector_size = cpu_to_le32(header->sector_size);
100
+ header->disk_size = cpu_to_le64(header->disk_size);
101
+ header->block_size = cpu_to_le32(header->block_size);
102
+ header->block_extra = cpu_to_le32(header->block_extra);
103
+ header->blocks_in_image = cpu_to_le32(header->blocks_in_image);
104
+ header->blocks_allocated = cpu_to_le32(header->blocks_allocated);
105
qemu_uuid_bswap(&header->uuid_image);
106
qemu_uuid_bswap(&header->uuid_last_snap);
107
qemu_uuid_bswap(&header->uuid_link);
108
--
109
2.19.1
110
111
diff view generated by jsdifflib
1
From: Fam Zheng <famz@redhat.com>
1
From: Alberto Garcia <berto@igalia.com>
2
2
3
As a mechanical refactoring patch, this is the first step towards
3
This is a static function with only one caller, so there's no need to
4
unified and more correct write code paths. This is helpful because
4
keep it. Inlining the code in quorum_compare() makes it much simpler.
5
multiple BlockDriverState fields need to be updated after modifying
6
image data, and it's hard to maintain in multiple places such as copy
7
offload, discard and truncate.
8
5
9
Suggested-by: Kevin Wolf <kwolf@redhat.com>
6
Signed-off-by: Alberto Garcia <berto@igalia.com>
10
Signed-off-by: Fam Zheng <famz@redhat.com>
7
Reported-by: Markus Armbruster <armbru@redhat.com>
11
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12
---
9
---
13
block/io.c | 91 +++++++++++++++++++++++++++++++++++++++-----------------------
10
block/quorum.c | 24 +++++-------------------
14
1 file changed, 57 insertions(+), 34 deletions(-)
11
1 file changed, 5 insertions(+), 19 deletions(-)
15
12
16
diff --git a/block/io.c b/block/io.c
13
diff --git a/block/quorum.c b/block/quorum.c
17
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
18
--- a/block/io.c
15
--- a/block/quorum.c
19
+++ b/block/io.c
16
+++ b/block/quorum.c
20
@@ -XXX,XX +XXX,XX @@ fail:
17
@@ -XXX,XX +XXX,XX @@ static bool quorum_iovec_compare(QEMUIOVector *a, QEMUIOVector *b)
21
return ret;
18
return true;
22
}
19
}
23
20
24
+static inline int coroutine_fn
21
-static void GCC_FMT_ATTR(2, 3) quorum_err(QuorumAIOCB *acb,
25
+bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, uint64_t bytes,
22
- const char *fmt, ...)
26
+ BdrvTrackedRequest *req, int flags)
23
-{
27
+{
24
- va_list ap;
28
+ BlockDriverState *bs = child->bs;
25
-
29
+ bool waited;
26
- va_start(ap, fmt);
30
+ int64_t end_sector = DIV_ROUND_UP(offset + bytes, BDRV_SECTOR_SIZE);
27
- fprintf(stderr, "quorum: offset=%" PRIu64 " bytes=%" PRIu64 " ",
31
+
28
- acb->offset, acb->bytes);
32
+ if (bs->read_only) {
29
- vfprintf(stderr, fmt, ap);
33
+ return -EPERM;
30
- fprintf(stderr, "\n");
34
+ }
31
- va_end(ap);
35
+
32
- exit(1);
36
+ /* BDRV_REQ_NO_SERIALISING is only for read operation */
33
-}
37
+ assert(!(flags & BDRV_REQ_NO_SERIALISING));
34
-
38
+ assert(!(bs->open_flags & BDRV_O_INACTIVE));
35
-static bool quorum_compare(QuorumAIOCB *acb,
39
+ assert((bs->open_flags & BDRV_O_NO_IO) == 0);
36
- QEMUIOVector *a,
40
+ assert(!(flags & ~BDRV_REQ_MASK));
37
- QEMUIOVector *b)
41
+
38
+static bool quorum_compare(QuorumAIOCB *acb, QEMUIOVector *a, QEMUIOVector *b)
42
+ if (flags & BDRV_REQ_SERIALISING) {
43
+ mark_request_serialising(req, bdrv_get_cluster_size(bs));
44
+ }
45
+
46
+ waited = wait_serialising_requests(req);
47
+
48
+ assert(!waited || !req->serialising ||
49
+ is_request_serialising_and_aligned(req));
50
+ assert(req->overlap_offset <= offset);
51
+ assert(offset + bytes <= req->overlap_offset + req->overlap_bytes);
52
+
53
+ if (flags & BDRV_REQ_WRITE_UNCHANGED) {
54
+ assert(child->perm & (BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE));
55
+ } else {
56
+ assert(child->perm & BLK_PERM_WRITE);
57
+ }
58
+ assert(end_sector <= bs->total_sectors || child->perm & BLK_PERM_RESIZE);
59
+ return notifier_with_return_list_notify(&bs->before_write_notifiers, req);
60
+}
61
+
62
+static inline void coroutine_fn
63
+bdrv_co_write_req_finish(BdrvChild *child, int64_t offset, uint64_t bytes,
64
+ BdrvTrackedRequest *req, int ret)
65
+{
66
+ int64_t end_sector = DIV_ROUND_UP(offset + bytes, BDRV_SECTOR_SIZE);
67
+ BlockDriverState *bs = child->bs;
68
+
69
+ atomic_inc(&bs->write_gen);
70
+ bdrv_set_dirty(bs, offset, bytes);
71
+
72
+ stat64_max(&bs->wr_highest_offset, offset + bytes);
73
+
74
+ if (ret == 0) {
75
+ bs->total_sectors = MAX(bs->total_sectors, end_sector);
76
+ }
77
+}
78
+
79
/*
80
* Forwards an already correctly aligned write request to the BlockDriver,
81
* after possibly fragmenting it.
82
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
83
{
39
{
84
BlockDriverState *bs = child->bs;
40
BDRVQuorumState *s = acb->bs->opaque;
85
BlockDriver *drv = bs->drv;
41
ssize_t offset;
86
- bool waited;
42
@@ -XXX,XX +XXX,XX @@ static bool quorum_compare(QuorumAIOCB *acb,
87
int ret;
43
if (s->is_blkverify) {
88
44
offset = qemu_iovec_compare(a, b);
89
- int64_t end_sector = DIV_ROUND_UP(offset + bytes, BDRV_SECTOR_SIZE);
45
if (offset != -1) {
90
uint64_t bytes_remaining = bytes;
46
- quorum_err(acb, "contents mismatch at offset %" PRIu64,
91
int max_transfer;
47
- acb->offset + offset);
92
48
+ fprintf(stderr, "quorum: offset=%" PRIu64 " bytes=%" PRIu64
93
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
49
+ " contents mismatch at offset %" PRIu64 "\n",
94
assert((offset & (align - 1)) == 0);
50
+ acb->offset, acb->bytes, acb->offset + offset);
95
assert((bytes & (align - 1)) == 0);
51
+ exit(1);
96
assert(!qiov || bytes == qiov->size);
52
}
97
- assert((bs->open_flags & BDRV_O_NO_IO) == 0);
53
return true;
98
- assert(!(flags & ~BDRV_REQ_MASK));
99
max_transfer = QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_transfer, INT_MAX),
100
align);
101
102
- /* BDRV_REQ_NO_SERIALISING is only for read operation */
103
- assert(!(flags & BDRV_REQ_NO_SERIALISING));
104
-
105
- if (flags & BDRV_REQ_SERIALISING) {
106
- mark_request_serialising(req, bdrv_get_cluster_size(bs));
107
- }
108
-
109
- waited = wait_serialising_requests(req);
110
- assert(!waited || !req->serialising ||
111
- is_request_serialising_and_aligned(req));
112
- assert(req->overlap_offset <= offset);
113
- assert(offset + bytes <= req->overlap_offset + req->overlap_bytes);
114
- if (flags & BDRV_REQ_WRITE_UNCHANGED) {
115
- assert(child->perm & (BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE));
116
- } else {
117
- assert(child->perm & BLK_PERM_WRITE);
118
- }
119
- assert(end_sector <= bs->total_sectors || child->perm & BLK_PERM_RESIZE);
120
-
121
- ret = notifier_with_return_list_notify(&bs->before_write_notifiers, req);
122
+ ret = bdrv_co_write_req_prepare(child, offset, bytes, req, flags);
123
124
if (!ret && bs->detect_zeroes != BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF &&
125
!(flags & BDRV_REQ_ZERO_WRITE) && drv->bdrv_co_pwrite_zeroes &&
126
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
127
}
54
}
128
bdrv_debug_event(bs, BLKDBG_PWRITEV_DONE);
129
130
- atomic_inc(&bs->write_gen);
131
- bdrv_set_dirty(bs, offset, bytes);
132
-
133
- stat64_max(&bs->wr_highest_offset, offset + bytes);
134
-
135
if (ret >= 0) {
136
- bs->total_sectors = MAX(bs->total_sectors, end_sector);
137
ret = 0;
138
}
139
+ bdrv_co_write_req_finish(child, offset, bytes, req, ret);
140
141
return ret;
142
}
143
@@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_pwritev(BdrvChild *child,
144
if (!bs->drv) {
145
return -ENOMEDIUM;
146
}
147
- if (bs->read_only) {
148
- return -EPERM;
149
- }
150
- assert(!(bs->open_flags & BDRV_O_INACTIVE));
151
152
ret = bdrv_check_byte_request(bs, offset, bytes);
153
if (ret < 0) {
154
--
55
--
155
2.13.6
56
2.19.1
156
57
157
58
diff view generated by jsdifflib
New patch
1
From: Alberto Garcia <berto@igalia.com>
1
2
3
The blkverify mode of Quorum can only be enabled if the number of
4
children is exactly two and the value of vote-threshold is also two.
5
6
If the user tries to enable it but the other settings are incorrect
7
then QEMU simply prints an error message to stderr and carries on
8
disabling the blkverify setting.
9
10
This patch makes quorum_open() fail and return an error in this case.
11
12
Signed-off-by: Alberto Garcia <berto@igalia.com>
13
Reported-by: Markus Armbruster <armbru@redhat.com>
14
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
15
---
16
block/quorum.c | 13 ++++++-------
17
1 file changed, 6 insertions(+), 7 deletions(-)
18
19
diff --git a/block/quorum.c b/block/quorum.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/block/quorum.c
22
+++ b/block/quorum.c
23
@@ -XXX,XX +XXX,XX @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
24
s->read_pattern = ret;
25
26
if (s->read_pattern == QUORUM_READ_PATTERN_QUORUM) {
27
- /* is the driver in blkverify mode */
28
- if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false) &&
29
- s->num_children == 2 && s->threshold == 2) {
30
- s->is_blkverify = true;
31
- } else if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false)) {
32
- fprintf(stderr, "blkverify mode is set by setting blkverify=on "
33
- "and using two files with vote_threshold=2\n");
34
+ s->is_blkverify = qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false);
35
+ if (s->is_blkverify && (s->num_children != 2 || s->threshold != 2)) {
36
+ error_setg(&local_err, "blkverify=on can only be set if there are "
37
+ "exactly two files and vote-threshold is 2");
38
+ ret = -EINVAL;
39
+ goto exit;
40
}
41
42
s->rewrite_corrupted = qemu_opt_get_bool(opts, QUORUM_OPT_REWRITE,
43
--
44
2.19.1
45
46
diff view generated by jsdifflib
1
If the virtual disk size isn't aligned to full clusters,
1
From: Alberto Garcia <berto@igalia.com>
2
bdrv_co_do_copy_on_readv() may get pnum == 0 before having the full
3
cluster completed, which will let it run into an assertion failure:
4
2
5
qemu-io: block/io.c:1203: bdrv_co_do_copy_on_readv: Assertion `skip_bytes < pnum' failed.
3
Signed-off-by: Alberto Garcia <berto@igalia.com>
6
7
Check for EOF, assert that we read at least as much as the read request
8
originally wanted to have (which is true at EOF because otherwise
9
bdrv_check_byte_request() would already have returned an error) and
10
return success early even though we couldn't copy the full cluster.
11
12
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13
---
5
---
14
block/io.c | 6 ++++++
6
tests/qemu-iotests/081 | 30 ++++++++++++++++++++++++++++++
15
tests/qemu-iotests/197 | 9 +++++++++
7
tests/qemu-iotests/081.out | 16 ++++++++++++++++
16
tests/qemu-iotests/197.out | 8 ++++++++
8
2 files changed, 46 insertions(+)
17
3 files changed, 23 insertions(+)
18
9
19
diff --git a/block/io.c b/block/io.c
10
diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081
20
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100755
21
--- a/block/io.c
12
--- a/tests/qemu-iotests/081
22
+++ b/block/io.c
13
+++ b/tests/qemu-iotests/081
23
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child,
14
@@ -XXX,XX +XXX,XX @@ echo "== checking that quorum is broken =="
24
pnum = MIN(cluster_bytes, max_transfer);
15
25
}
16
$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io
26
17
27
+ /* Stop at EOF if the image ends in the middle of the cluster */
18
+echo
28
+ if (ret == 0 && pnum == 0) {
19
+echo "== checking the blkverify mode with broken content =="
29
+ assert(progress >= bytes);
30
+ break;
31
+ }
32
+
20
+
33
assert(skip_bytes < pnum);
21
+quorum="driver=raw,file.driver=quorum,file.vote-threshold=2,file.blkverify=on"
34
22
+quorum="$quorum,file.children.0.file.filename=$TEST_DIR/1.raw"
35
if (ret <= 0) {
23
+quorum="$quorum,file.children.1.file.filename=$TEST_DIR/2.raw"
36
diff --git a/tests/qemu-iotests/197 b/tests/qemu-iotests/197
24
+quorum="$quorum,file.children.0.driver=raw"
37
index XXXXXXX..XXXXXXX 100755
25
+quorum="$quorum,file.children.1.driver=raw"
38
--- a/tests/qemu-iotests/197
26
+
39
+++ b/tests/qemu-iotests/197
27
+$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io
40
@@ -XXX,XX +XXX,XX @@ $QEMU_IO -f qcow2 -c map "$TEST_WRAP"
28
+
41
_check_test_img
42
$QEMU_IMG compare -f $IMGFMT -F qcow2 "$TEST_IMG" "$TEST_WRAP"
43
44
+echo
29
+echo
45
+echo '=== Partial final cluster ==='
30
+echo "== writing the same data to both files =="
31
+
32
+$QEMU_IO -c "write -P 0x32 0 $size" "$TEST_DIR/1.raw" | _filter_qemu_io
33
+$QEMU_IO -c "write -P 0x32 0 $size" "$TEST_DIR/2.raw" | _filter_qemu_io
34
+
46
+echo
35
+echo
36
+echo "== checking the blkverify mode with valid content =="
47
+
37
+
48
+_make_test_img 1024
38
+$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io
49
+$QEMU_IO -f $IMGFMT -C -c 'read 0 1024' "$TEST_IMG" | _filter_qemu_io
39
+
50
+$QEMU_IO -f $IMGFMT -c map "$TEST_IMG"
40
+echo
51
+_check_test_img
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
52
+
47
+
53
# success, all done
48
# success, all done
54
echo '*** done'
49
echo "*** done"
55
status=0
50
rm -f $seq.full
56
diff --git a/tests/qemu-iotests/197.out b/tests/qemu-iotests/197.out
51
diff --git a/tests/qemu-iotests/081.out b/tests/qemu-iotests/081.out
57
index XXXXXXX..XXXXXXX 100644
52
index XXXXXXX..XXXXXXX 100644
58
--- a/tests/qemu-iotests/197.out
53
--- a/tests/qemu-iotests/081.out
59
+++ b/tests/qemu-iotests/197.out
54
+++ b/tests/qemu-iotests/081.out
60
@@ -XXX,XX +XXX,XX @@ can't open device TEST_DIR/t.wrap.qcow2: Can't use copy-on-read on read-only dev
55
@@ -XXX,XX +XXX,XX @@ wrote 10485760/10485760 bytes at offset 0
61
1023.938 MiB (0x3fff0000) bytes not allocated at offset 3 GiB (0xc0010000)
56
62
No errors were found on the image.
57
== checking that quorum is broken ==
63
Images are identical.
58
read failed: Input/output error
64
+
59
+
65
+=== Partial final cluster ===
60
+== checking the blkverify mode with broken content ==
61
+quorum: offset=0 bytes=10485760 contents mismatch at offset 0
66
+
62
+
67
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1024
63
+== writing the same data to both files ==
68
+read 1024/1024 bytes at offset 0
64
+wrote 10485760/10485760 bytes at offset 0
69
+1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
65
+10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
70
+1 KiB (0x400) bytes allocated at offset 0 bytes (0x0)
66
+wrote 10485760/10485760 bytes at offset 0
71
+No errors were found on the image.
67
+10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
68
+
69
+== checking the blkverify mode with valid content ==
70
+read 10485760/10485760 bytes at offset 0
71
+10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
72
+
73
+== checking the blkverify mode with invalid settings ==
74
+can't open: blkverify=on can only be set if there are exactly two files and vote-threshold is 2
72
*** done
75
*** done
73
--
76
--
74
2.13.6
77
2.19.1
75
78
76
79
diff view generated by jsdifflib
1
From: Cornelia Huck <cohuck@redhat.com>
1
From: Alberto Garcia <berto@igalia.com>
2
2
3
This reverts commit eae3bd1eb7c6b105d30ec06008b3bc3dfc5f45bb.
3
The blkverify mode of Quorum only works when the number of children is
4
exactly two, so any attempt to add a new one must return an error.
4
5
5
Reverted to avoid conflicts for geometry options revert.
6
quorum_del_child() on the other hand doesn't need any additional check
7
because decreasing the number of children would make it go under the
8
vote threshold.
6
9
7
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
10
Signed-off-by: Alberto Garcia <berto@igalia.com>
11
Reported-by: Kevin Wolf <kwolf@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9
---
13
---
10
include/sysemu/blockdev.h | 1 +
14
block/quorum.c | 8 ++++++++
11
blockdev.c | 17 ++++++++++++++++-
15
1 file changed, 8 insertions(+)
12
device-hotplug.c | 4 ++++
13
qemu-doc.texi | 5 +++++
14
qemu-options.hx | 5 ++++-
15
5 files changed, 30 insertions(+), 2 deletions(-)
16
16
17
diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h
17
diff --git a/block/quorum.c b/block/quorum.c
18
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
19
--- a/include/sysemu/blockdev.h
19
--- a/block/quorum.c
20
+++ b/include/sysemu/blockdev.h
20
+++ b/block/quorum.c
21
@@ -XXX,XX +XXX,XX @@ typedef enum {
21
@@ -XXX,XX +XXX,XX @@ static void quorum_add_child(BlockDriverState *bs, BlockDriverState *child_bs,
22
} BlockInterfaceType;
22
char indexstr[32];
23
23
int ret;
24
struct DriveInfo {
24
25
+ const char *devaddr;
25
+ if (s->is_blkverify) {
26
BlockInterfaceType type;
26
+ error_setg(errp, "Cannot add a child to a quorum in blkverify mode");
27
int bus;
27
+ return;
28
int unit;
29
diff --git a/blockdev.c b/blockdev.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/blockdev.c
32
+++ b/blockdev.c
33
@@ -XXX,XX +XXX,XX @@ QemuOptsList qemu_legacy_drive_opts = {
34
.type = QEMU_OPT_STRING,
35
.help = "interface (ide, scsi, sd, mtd, floppy, pflash, virtio)",
36
},{
37
+ .name = "addr",
38
+ .type = QEMU_OPT_STRING,
39
+ .help = "pci address (virtio only)",
40
+ },{
41
.name = "serial",
42
.type = QEMU_OPT_STRING,
43
.help = "disk serial number",
44
@@ -XXX,XX +XXX,XX @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
45
DriveMediaType media = MEDIA_DISK;
46
BlockInterfaceType type;
47
int max_devs, bus_id, unit_id, index;
48
+ const char *devaddr;
49
const char *werror, *rerror;
50
bool read_only = false;
51
bool copy_on_read;
52
@@ -XXX,XX +XXX,XX @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
53
Error *local_err = NULL;
54
int i;
55
const char *deprecated[] = {
56
- "serial"
57
+ "serial", "addr"
58
};
59
60
/* Change legacy command line options into QMP ones */
61
@@ -XXX,XX +XXX,XX @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
62
}
63
64
/* Add virtio block device */
65
+ devaddr = qemu_opt_get(legacy_opts, "addr");
66
+ if (devaddr && type != IF_VIRTIO) {
67
+ error_report("addr is not supported by this bus type");
68
+ goto fail;
69
+ }
28
+ }
70
+
29
+
71
if (type == IF_VIRTIO) {
30
assert(s->num_children <= INT_MAX / sizeof(BdrvChild *));
72
QemuOpts *devopts;
31
if (s->num_children == INT_MAX / sizeof(BdrvChild *) ||
73
devopts = qemu_opts_create(qemu_find_opts("device"), NULL, 0,
32
s->next_child_index == UINT_MAX) {
74
@@ -XXX,XX +XXX,XX @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
33
@@ -XXX,XX +XXX,XX @@ static void quorum_del_child(BlockDriverState *bs, BdrvChild *child,
75
}
34
return;
76
qemu_opt_set(devopts, "drive", qdict_get_str(bs_opts, "id"),
77
&error_abort);
78
+ if (devaddr) {
79
+ qemu_opt_set(devopts, "addr", devaddr, &error_abort);
80
+ }
81
}
35
}
82
36
83
filename = qemu_opt_get(legacy_opts, "file");
37
+ /* We know now that num_children > threshold, so blkverify must be false */
84
@@ -XXX,XX +XXX,XX @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
38
+ assert(!s->is_blkverify);
85
dinfo->type = type;
86
dinfo->bus = bus_id;
87
dinfo->unit = unit_id;
88
+ dinfo->devaddr = devaddr;
89
dinfo->serial = g_strdup(serial);
90
91
blk_set_legacy_dinfo(blk, dinfo);
92
diff --git a/device-hotplug.c b/device-hotplug.c
93
index XXXXXXX..XXXXXXX 100644
94
--- a/device-hotplug.c
95
+++ b/device-hotplug.c
96
@@ -XXX,XX +XXX,XX @@ void hmp_drive_add(Monitor *mon, const QDict *qdict)
97
if (!dinfo) {
98
goto err;
99
}
100
+ if (dinfo->devaddr) {
101
+ monitor_printf(mon, "Parameter addr not supported\n");
102
+ goto err;
103
+ }
104
105
switch (dinfo->type) {
106
case IF_NONE:
107
diff --git a/qemu-doc.texi b/qemu-doc.texi
108
index XXXXXXX..XXXXXXX 100644
109
--- a/qemu-doc.texi
110
+++ b/qemu-doc.texi
111
@@ -XXX,XX +XXX,XX @@ provided per NIC.
112
The drive serial argument is replaced by the the serial argument
113
that can be specified with the ``-device'' parameter.
114
115
+@subsection -drive addr=... (since 2.10.0)
116
+
39
+
117
+The drive addr argument is replaced by the the addr argument
40
bdrv_drained_begin(bs);
118
+that can be specified with the ``-device'' parameter.
41
119
+
42
/* We can safely remove this child now */
120
@subsection -usbdevice (since 2.10.0)
121
122
The ``-usbdevice DEV'' argument is now a synonym for setting
123
diff --git a/qemu-options.hx b/qemu-options.hx
124
index XXXXXXX..XXXXXXX 100644
125
--- a/qemu-options.hx
126
+++ b/qemu-options.hx
127
@@ -XXX,XX +XXX,XX @@ ETEXI
128
DEF("drive", HAS_ARG, QEMU_OPTION_drive,
129
"-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i]\n"
130
" [,cache=writethrough|writeback|none|directsync|unsafe][,format=f]\n"
131
- " [,snapshot=on|off][,serial=s][,rerror=ignore|stop|report]\n"
132
+ " [,snapshot=on|off][,serial=s][,addr=A][,rerror=ignore|stop|report]\n"
133
" [,werror=ignore|stop|report|enospc][,id=name][,aio=threads|native]\n"
134
" [,readonly=on|off][,copy-on-read=on|off]\n"
135
" [,discard=ignore|unmap][,detect-zeroes=on|off|unmap]\n"
136
@@ -XXX,XX +XXX,XX @@ an untrusted format header.
137
This option specifies the serial number to assign to the device. This
138
parameter is deprecated, use the corresponding parameter of @code{-device}
139
instead.
140
+@item addr=@var{addr}
141
+Specify the controller's PCI address (if=virtio only). This parameter is
142
+deprecated, use the corresponding parameter of @code{-device} instead.
143
@item werror=@var{action},rerror=@var{action}
144
Specify which @var{action} to take on write and read errors. Valid actions are:
145
"ignore" (ignore the error and try to continue), "stop" (pause QEMU),
146
--
43
--
147
2.13.6
44
2.19.1
148
45
149
46
diff view generated by jsdifflib
1
From: Cornelia Huck <cohuck@redhat.com>
1
From: Alberto Garcia <berto@igalia.com>
2
2
3
This reverts commit a7aff6dd10b16b67e8b142d0c94c5d92c3fe88f6.
3
This patch tests that you can add and remove drives from a Quorum
4
using the x-blockdev-change command.
4
5
5
Hold off removing this for one more QEMU release (current libvirt
6
Signed-off-by: Alberto Garcia <berto@igalia.com>
6
release still uses it.)
7
8
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10
---
8
---
11
include/sysemu/blockdev.h | 1 +
9
tests/qemu-iotests/081 | 86 ++++++++++++++++++++++++++++++++++++++
12
blockdev.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++-
10
tests/qemu-iotests/081.out | 54 ++++++++++++++++++++++++
13
hw/block/block.c | 14 +++++++++
11
2 files changed, 140 insertions(+)
14
tests/hd-geo-test.c | 37 ++++++++++++++++++-----
15
hmp-commands.hx | 1 +
16
qemu-doc.texi | 5 ++++
17
qemu-options.hx | 7 ++++-
18
7 files changed, 131 insertions(+), 9 deletions(-)
19
12
20
diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h
13
diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081
21
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100755
22
--- a/include/sysemu/blockdev.h
15
--- a/tests/qemu-iotests/081
23
+++ b/include/sysemu/blockdev.h
16
+++ b/tests/qemu-iotests/081
24
@@ -XXX,XX +XXX,XX @@ struct DriveInfo {
17
@@ -XXX,XX +XXX,XX @@ quorum="$quorum,file.children.2.driver=raw"
25
int auto_del; /* see blockdev_mark_auto_del() */
18
26
bool is_default; /* Added by default_drive() ? */
19
$QEMU_IO -c "open -o $quorum" | _filter_qemu_io
27
int media_cd;
20
28
+ int cyls, heads, secs, trans;
21
+echo
29
QemuOpts *opts;
22
+echo "== dynamically adding a child to a quorum =="
30
char *serial;
31
QTAILQ_ENTRY(DriveInfo) next;
32
diff --git a/blockdev.c b/blockdev.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/blockdev.c
35
+++ b/blockdev.c
36
@@ -XXX,XX +XXX,XX @@ QemuOptsList qemu_legacy_drive_opts = {
37
.type = QEMU_OPT_STRING,
38
.help = "interface (ide, scsi, sd, mtd, floppy, pflash, virtio)",
39
},{
40
+ .name = "cyls",
41
+ .type = QEMU_OPT_NUMBER,
42
+ .help = "number of cylinders (ide disk geometry)",
43
+ },{
44
+ .name = "heads",
45
+ .type = QEMU_OPT_NUMBER,
46
+ .help = "number of heads (ide disk geometry)",
47
+ },{
48
+ .name = "secs",
49
+ .type = QEMU_OPT_NUMBER,
50
+ .help = "number of sectors (ide disk geometry)",
51
+ },{
52
+ .name = "trans",
53
+ .type = QEMU_OPT_STRING,
54
+ .help = "chs translation (auto, lba, none)",
55
+ },{
56
.name = "addr",
57
.type = QEMU_OPT_STRING,
58
.help = "pci address (virtio only)",
59
@@ -XXX,XX +XXX,XX @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
60
QemuOpts *legacy_opts;
61
DriveMediaType media = MEDIA_DISK;
62
BlockInterfaceType type;
63
+ int cyls, heads, secs, translation;
64
int max_devs, bus_id, unit_id, index;
65
const char *devaddr;
66
const char *werror, *rerror;
67
@@ -XXX,XX +XXX,XX @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
68
Error *local_err = NULL;
69
int i;
70
const char *deprecated[] = {
71
- "serial", "addr"
72
+ "serial", "trans", "secs", "heads", "cyls", "addr"
73
};
74
75
/* Change legacy command line options into QMP ones */
76
@@ -XXX,XX +XXX,XX @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
77
type = block_default_type;
78
}
79
80
+ /* Geometry */
81
+ cyls = qemu_opt_get_number(legacy_opts, "cyls", 0);
82
+ heads = qemu_opt_get_number(legacy_opts, "heads", 0);
83
+ secs = qemu_opt_get_number(legacy_opts, "secs", 0);
84
+
23
+
85
+ if (cyls || heads || secs) {
24
+for verify in false true; do
86
+ if (cyls < 1) {
25
+ run_qemu <<EOF
87
+ error_report("invalid physical cyls number");
26
+ { "execute": "qmp_capabilities" }
88
+ goto fail;
27
+ { "execute": "blockdev-add",
89
+ }
28
+ "arguments": {
90
+ if (heads < 1) {
29
+ "driver": "quorum",
91
+ error_report("invalid physical heads number");
30
+ "node-name": "drive0-quorum",
92
+ goto fail;
31
+ "vote-threshold": 2,
93
+ }
32
+ "blkverify": ${verify},
94
+ if (secs < 1) {
33
+ "children": [
95
+ error_report("invalid physical secs number");
34
+ {
96
+ goto fail;
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
+ ]
97
+ }
49
+ }
98
+ }
50
+ }
99
+
51
+ { "execute": "blockdev-add",
100
+ translation = BIOS_ATA_TRANSLATION_AUTO;
52
+ "arguments": {
101
+ value = qemu_opt_get(legacy_opts, "trans");
53
+ "node-name": "drive3",
102
+ if (value != NULL) {
54
+ "driver": "$IMGFMT",
103
+ if (!cyls) {
55
+ "file": {
104
+ error_report("'%s' trans must be used with cyls, heads and secs",
56
+ "driver": "file",
105
+ value);
57
+ "filename": "$TEST_DIR/2.raw"
106
+ goto fail;
107
+ }
108
+ if (!strcmp(value, "none")) {
109
+ translation = BIOS_ATA_TRANSLATION_NONE;
110
+ } else if (!strcmp(value, "lba")) {
111
+ translation = BIOS_ATA_TRANSLATION_LBA;
112
+ } else if (!strcmp(value, "large")) {
113
+ translation = BIOS_ATA_TRANSLATION_LARGE;
114
+ } else if (!strcmp(value, "rechs")) {
115
+ translation = BIOS_ATA_TRANSLATION_RECHS;
116
+ } else if (!strcmp(value, "auto")) {
117
+ translation = BIOS_ATA_TRANSLATION_AUTO;
118
+ } else {
119
+ error_report("'%s' invalid translation type", value);
120
+ goto fail;
121
+ }
122
+ }
123
+
124
+ if (media == MEDIA_CDROM) {
125
+ if (cyls || secs || heads) {
126
+ error_report("CHS can't be set with media=cdrom");
127
+ goto fail;
128
+ }
129
+ }
130
+
131
/* Device address specified by bus/unit or index.
132
* If none was specified, try to find the first free one. */
133
bus_id = qemu_opt_get_number(legacy_opts, "bus", 0);
134
@@ -XXX,XX +XXX,XX @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
135
dinfo = g_malloc0(sizeof(*dinfo));
136
dinfo->opts = all_opts;
137
138
+ dinfo->cyls = cyls;
139
+ dinfo->heads = heads;
140
+ dinfo->secs = secs;
141
+ dinfo->trans = translation;
142
+
143
dinfo->type = type;
144
dinfo->bus = bus_id;
145
dinfo->unit = unit_id;
146
diff --git a/hw/block/block.c b/hw/block/block.c
147
index XXXXXXX..XXXXXXX 100644
148
--- a/hw/block/block.c
149
+++ b/hw/block/block.c
150
@@ -XXX,XX +XXX,XX @@ bool blkconf_geometry(BlockConf *conf, int *ptrans,
151
unsigned cyls_max, unsigned heads_max, unsigned secs_max,
152
Error **errp)
153
{
154
+ DriveInfo *dinfo;
155
+
156
+ if (!conf->cyls && !conf->heads && !conf->secs) {
157
+ /* try to fall back to value set with legacy -drive cyls=... */
158
+ dinfo = blk_legacy_dinfo(conf->blk);
159
+ if (dinfo) {
160
+ conf->cyls = dinfo->cyls;
161
+ conf->heads = dinfo->heads;
162
+ conf->secs = dinfo->secs;
163
+ if (ptrans) {
164
+ *ptrans = dinfo->trans;
165
+ }
58
+ }
166
+ }
59
+ }
167
+ }
60
+ }
168
if (!conf->cyls && !conf->heads && !conf->secs) {
61
+ { "execute": "x-blockdev-change",
169
hd_geometry_guess(conf->blk,
62
+ "arguments": { "parent": "drive0-quorum",
170
&conf->cyls, &conf->heads, &conf->secs,
63
+ "node": "drive3" } }
171
diff --git a/tests/hd-geo-test.c b/tests/hd-geo-test.c
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
172
index XXXXXXX..XXXXXXX 100644
111
index XXXXXXX..XXXXXXX 100644
173
--- a/tests/hd-geo-test.c
112
--- a/tests/qemu-iotests/081.out
174
+++ b/tests/hd-geo-test.c
113
+++ b/tests/qemu-iotests/081.out
175
@@ -XXX,XX +XXX,XX @@ static void setup_mbr(int img_idx, MBRcontents mbr)
114
@@ -XXX,XX +XXX,XX @@ read 10485760/10485760 bytes at offset 0
176
115
177
static int setup_ide(int argc, char *argv[], int argv_sz,
116
== checking the blkverify mode with invalid settings ==
178
int ide_idx, const char *dev, int img_idx,
117
can't open: blkverify=on can only be set if there are exactly two files and vote-threshold is 2
179
- MBRcontents mbr)
180
+ MBRcontents mbr, const char *opts)
181
{
182
char *s1, *s2, *s3;
183
184
@@ -XXX,XX +XXX,XX @@ static int setup_ide(int argc, char *argv[], int argv_sz,
185
s3 = g_strdup(",media=cdrom");
186
}
187
argc = append_arg(argc, argv, argv_sz,
188
- g_strdup_printf("%s%s%s", s1, s2, s3));
189
+ g_strdup_printf("%s%s%s%s", s1, s2, s3, opts));
190
g_free(s1);
191
g_free(s2);
192
g_free(s3);
193
@@ -XXX,XX +XXX,XX @@ static void test_ide_mbr(bool use_device, MBRcontents mbr)
194
for (i = 0; i < backend_last; i++) {
195
cur_ide[i] = &hd_chst[i][mbr];
196
dev = use_device ? (is_hd(cur_ide[i]) ? "ide-hd" : "ide-cd") : NULL;
197
- argc = setup_ide(argc, argv, ARGV_SIZE, i, dev, i, mbr);
198
+ argc = setup_ide(argc, argv, ARGV_SIZE, i, dev, i, mbr, "");
199
}
200
args = g_strjoinv(" ", argv);
201
qtest_start(args);
202
@@ -XXX,XX +XXX,XX @@ static void test_ide_drive_user(const char *dev, bool trans)
203
const CHST expected_chst = { secs / (4 * 32) , 4, 32, trans };
204
205
argc = setup_common(argv, ARGV_SIZE);
206
- opts = g_strdup_printf("%s,%scyls=%d,heads=%d,secs=%d",
207
- dev, trans ? "bios-chs-trans=lba," : "",
208
+ opts = g_strdup_printf("%s,%s%scyls=%d,heads=%d,secs=%d",
209
+ dev ?: "",
210
+ trans && dev ? "bios-chs-" : "",
211
+ trans ? "trans=lba," : "",
212
expected_chst.cyls, expected_chst.heads,
213
expected_chst.secs);
214
cur_ide[0] = &expected_chst;
215
- argc = setup_ide(argc, argv, ARGV_SIZE, 0, opts, backend_small, mbr_chs);
216
+ argc = setup_ide(argc, argv, ARGV_SIZE,
217
+ 0, dev ? opts : NULL, backend_small, mbr_chs,
218
+ dev ? "" : opts);
219
g_free(opts);
220
args = g_strjoinv(" ", argv);
221
qtest_start(args);
222
@@ -XXX,XX +XXX,XX @@ static void test_ide_drive_user(const char *dev, bool trans)
223
}
224
225
/*
226
+ * Test case: IDE device (if=ide) with explicit CHS
227
+ */
228
+static void test_ide_drive_user_chs(void)
229
+{
230
+ test_ide_drive_user(NULL, false);
231
+}
232
+
118
+
233
+/*
119
+== dynamically adding a child to a quorum ==
234
+ * Test case: IDE device (if=ide) with explicit CHS and translation
120
+Testing:
235
+ */
121
+QMP_VERSION
236
+static void test_ide_drive_user_chst(void)
122
+{"return": {}}
237
+{
123
+{"return": {}}
238
+ test_ide_drive_user(NULL, true);
124
+{"return": {}}
239
+}
125
+{"return": {}}
126
+{"return": {}}
127
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
240
+
128
+
241
+/*
129
+Testing:
242
* Test case: IDE device (if=none) with explicit CHS
130
+QMP_VERSION
243
*/
131
+{"return": {}}
244
static void test_ide_device_user_chs(void)
132
+{"return": {}}
245
@@ -XXX,XX +XXX,XX @@ static void test_ide_drive_cd_0(void)
133
+{"return": {}}
246
for (i = 0; i <= backend_empty; i++) {
134
+{"error": {"class": "GenericError", "desc": "Cannot add a child to a quorum in blkverify mode"}}
247
ide_idx = backend_empty - i;
135
+{"return": {}}
248
cur_ide[ide_idx] = &hd_chst[i][mbr_blank];
136
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
249
- argc = setup_ide(argc, argv, ARGV_SIZE, ide_idx, NULL, i, mbr_blank);
250
+ argc = setup_ide(argc, argv, ARGV_SIZE,
251
+ ide_idx, NULL, i, mbr_blank, "");
252
}
253
args = g_strjoinv(" ", argv);
254
qtest_start(args);
255
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv)
256
qtest_add_func("hd-geo/ide/drive/mbr/blank", test_ide_drive_mbr_blank);
257
qtest_add_func("hd-geo/ide/drive/mbr/lba", test_ide_drive_mbr_lba);
258
qtest_add_func("hd-geo/ide/drive/mbr/chs", test_ide_drive_mbr_chs);
259
+ qtest_add_func("hd-geo/ide/drive/user/chs", test_ide_drive_user_chs);
260
+ qtest_add_func("hd-geo/ide/drive/user/chst", test_ide_drive_user_chst);
261
qtest_add_func("hd-geo/ide/drive/cd_0", test_ide_drive_cd_0);
262
qtest_add_func("hd-geo/ide/device/mbr/blank", test_ide_device_mbr_blank);
263
qtest_add_func("hd-geo/ide/device/mbr/lba", test_ide_device_mbr_lba);
264
diff --git a/hmp-commands.hx b/hmp-commands.hx
265
index XXXXXXX..XXXXXXX 100644
266
--- a/hmp-commands.hx
267
+++ b/hmp-commands.hx
268
@@ -XXX,XX +XXX,XX @@ ETEXI
269
.params = "[-n] [[<domain>:]<bus>:]<slot>\n"
270
"[file=file][,if=type][,bus=n]\n"
271
"[,unit=m][,media=d][,index=i]\n"
272
+ "[,cyls=c,heads=h,secs=s[,trans=t]]\n"
273
"[,snapshot=on|off][,cache=on|off]\n"
274
"[,readonly=on|off][,copy-on-read=on|off]",
275
.help = "add drive to PCI storage controller",
276
diff --git a/qemu-doc.texi b/qemu-doc.texi
277
index XXXXXXX..XXXXXXX 100644
278
--- a/qemu-doc.texi
279
+++ b/qemu-doc.texi
280
@@ -XXX,XX +XXX,XX @@ with ``-device ...,netdev=x''), or ``-nic user,smb=/some/dir''
281
(for embedded NICs). The new syntax allows different settings to be
282
provided per NIC.
283
284
+@subsection -drive cyls=...,heads=...,secs=...,trans=... (since 2.10.0)
285
+
137
+
286
+The drive geometry arguments are replaced by the the geometry arguments
287
+that can be specified with the ``-device'' parameter.
288
+
138
+
289
@subsection -drive serial=... (since 2.10.0)
139
+== dynamically removing a child from a quorum ==
290
140
+Testing:
291
The drive serial argument is replaced by the the serial argument
141
+QMP_VERSION
292
diff --git a/qemu-options.hx b/qemu-options.hx
142
+{"return": {}}
293
index XXXXXXX..XXXXXXX 100644
143
+{"return": {}}
294
--- a/qemu-options.hx
144
+{"return": {}}
295
+++ b/qemu-options.hx
145
+{"return": {}}
296
@@ -XXX,XX +XXX,XX @@ ETEXI
146
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
297
147
+
298
DEF("drive", HAS_ARG, QEMU_OPTION_drive,
148
+Testing:
299
"-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i]\n"
149
+QMP_VERSION
300
+ " [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off]\n"
150
+{"return": {}}
301
" [,cache=writethrough|writeback|none|directsync|unsafe][,format=f]\n"
151
+{"return": {}}
302
- " [,snapshot=on|off][,serial=s][,addr=A][,rerror=ignore|stop|report]\n"
152
+{"error": {"class": "GenericError", "desc": "The number of children cannot be lower than the vote threshold 2"}}
303
+ " [,serial=s][,addr=A][,rerror=ignore|stop|report]\n"
153
+{"return": {}}
304
" [,werror=ignore|stop|report|enospc][,id=name][,aio=threads|native]\n"
154
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
305
" [,readonly=on|off][,copy-on-read=on|off]\n"
155
+
306
" [,discard=ignore|unmap][,detect-zeroes=on|off|unmap]\n"
156
+Testing:
307
@@ -XXX,XX +XXX,XX @@ This option defines where is connected the drive by using an index in the list
157
+QMP_VERSION
308
of available connectors of a given interface type.
158
+{"return": {}}
309
@item media=@var{media}
159
+{"error": {"class": "GenericError", "desc": "blkverify=on can only be set if there are exactly two files and vote-threshold is 2"}}
310
This option defines the type of the media: disk or cdrom.
160
+{"error": {"class": "GenericError", "desc": "Cannot find device=drive0-quorum nor node_name=drive0-quorum"}}
311
+@item cyls=@var{c},heads=@var{h},secs=@var{s}[,trans=@var{t}]
161
+{"return": {}}
312
+Force disk physical geometry and the optional BIOS translation (trans=none or
162
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
313
+lba). These parameters are deprecated, use the corresponding parameters
163
+
314
+of @code{-device} instead.
164
+Testing:
315
@item snapshot=@var{snapshot}
165
+QMP_VERSION
316
@var{snapshot} is "on" or "off" and controls snapshot mode for the given drive
166
+{"return": {}}
317
(see @option{-snapshot}).
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
318
--
173
--
319
2.13.6
174
2.19.1
320
175
321
176
diff view generated by jsdifflib
1
Commit dcf94a23b1 ('block: Don't poll in parent drain callbacks')
1
To fully change the read-only state of a node, we must not only change
2
removed polling in bdrv_child_cb_drained_begin() on the grounds that the
2
bs->read_only, but also update bs->open_flags.
3
original bdrv_drain() already will poll and BdrvChildRole.drained_begin
4
calls must not cause graph changes (and therefore must not call
5
aio_poll() or the recursion through the graph will break.
6
3
7
This reasoning is correct for calls through bdrv_do_drained_begin().
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
However, BdrvChildRole.drained_begin is also called when a node that is
5
Reviewed-by: Eric Blake <eblake@redhat.com>
9
already in a drained section (i.e. bdrv_do_drained_begin() has already
6
Reviewed-by: Alberto Garcia <berto@igalia.com>
10
returned and therefore can't poll any more) is attached to a new parent.
7
---
11
In this case, we must explicitly poll to have all requests completed
8
block.c | 7 +++++++
12
before the drained new child can be attached to the parent.
9
1 file changed, 7 insertions(+)
13
10
14
In bdrv_replace_child_noperm(), we know that we're not inside the
15
recursion of bdrv_do_drained_begin() because graph changes are not
16
allowed there, and bdrv_replace_child_noperm() is a graph change. The
17
call of BdrvChildRole.drained_begin() must therefore be followed by a
18
BDRV_POLL_WHILE() that waits for the completion of requests.
19
20
Reported-by: Max Reitz <mreitz@redhat.com>
21
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
22
---
23
include/block/block.h | 8 ++++++++
24
include/block/block_int.h | 3 +++
25
block.c | 2 +-
26
block/io.c | 26 ++++++++++++++++++++------
27
4 files changed, 32 insertions(+), 7 deletions(-)
28
29
diff --git a/include/block/block.h b/include/block/block.h
30
index XXXXXXX..XXXXXXX 100644
31
--- a/include/block/block.h
32
+++ b/include/block/block.h
33
@@ -XXX,XX +XXX,XX @@ void bdrv_parent_drained_begin(BlockDriverState *bs, BdrvChild *ignore,
34
bool ignore_bds_parents);
35
36
/**
37
+ * bdrv_parent_drained_begin_single:
38
+ *
39
+ * Begin a quiesced section for the parent of @c. If @poll is true, wait for
40
+ * any pending activity to cease.
41
+ */
42
+void bdrv_parent_drained_begin_single(BdrvChild *c, bool poll);
43
+
44
+/**
45
* bdrv_parent_drained_end:
46
*
47
* End a quiesced section of all users of @bs. This is part of
48
diff --git a/include/block/block_int.h b/include/block/block_int.h
49
index XXXXXXX..XXXXXXX 100644
50
--- a/include/block/block_int.h
51
+++ b/include/block/block_int.h
52
@@ -XXX,XX +XXX,XX @@ struct BdrvChildRole {
53
* requests after returning from .drained_begin() until .drained_end() is
54
* called.
55
*
56
+ * These functions must not change the graph (and therefore also must not
57
+ * call aio_poll(), which could change the graph indirectly).
58
+ *
59
* Note that this can be nested. If drained_begin() was called twice, new
60
* I/O is allowed only after drained_end() was called twice, too.
61
*/
62
diff --git a/block.c b/block.c
11
diff --git a/block.c b/block.c
63
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
64
--- a/block.c
13
--- a/block.c
65
+++ b/block.c
14
+++ b/block.c
66
@@ -XXX,XX +XXX,XX @@ static void bdrv_replace_child_noperm(BdrvChild *child,
15
@@ -XXX,XX +XXX,XX @@ int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
67
}
68
assert(num >= 0);
69
for (i = 0; i < num; i++) {
70
- child->role->drained_begin(child);
71
+ bdrv_parent_drained_begin_single(child, true);
72
}
73
}
74
75
diff --git a/block/io.c b/block/io.c
76
index XXXXXXX..XXXXXXX 100644
77
--- a/block/io.c
78
+++ b/block/io.c
79
@@ -XXX,XX +XXX,XX @@ void bdrv_parent_drained_begin(BlockDriverState *bs, BdrvChild *ignore,
80
if (c == ignore || (ignore_bds_parents && c->role->parent_is_bds)) {
81
continue;
82
}
83
- if (c->role->drained_begin) {
84
- c->role->drained_begin(c);
85
- }
86
+ bdrv_parent_drained_begin_single(c, false);
87
}
16
}
17
18
bs->read_only = read_only;
19
+
20
+ if (read_only) {
21
+ bs->open_flags &= ~BDRV_O_RDWR;
22
+ } else {
23
+ bs->open_flags |= BDRV_O_RDWR;
24
+ }
25
+
26
return 0;
88
}
27
}
89
28
90
@@ -XXX,XX +XXX,XX @@ void bdrv_parent_drained_end(BlockDriverState *bs, BdrvChild *ignore,
91
}
92
}
93
94
+static bool bdrv_parent_drained_poll_single(BdrvChild *c)
95
+{
96
+ if (c->role->drained_poll) {
97
+ return c->role->drained_poll(c);
98
+ }
99
+ return false;
100
+}
101
+
102
static bool bdrv_parent_drained_poll(BlockDriverState *bs, BdrvChild *ignore,
103
bool ignore_bds_parents)
104
{
105
@@ -XXX,XX +XXX,XX @@ static bool bdrv_parent_drained_poll(BlockDriverState *bs, BdrvChild *ignore,
106
if (c == ignore || (ignore_bds_parents && c->role->parent_is_bds)) {
107
continue;
108
}
109
- if (c->role->drained_poll) {
110
- busy |= c->role->drained_poll(c);
111
- }
112
+ busy |= bdrv_parent_drained_poll_single(c);
113
}
114
115
return busy;
116
}
117
118
+void bdrv_parent_drained_begin_single(BdrvChild *c, bool poll)
119
+{
120
+ if (c->role->drained_begin) {
121
+ c->role->drained_begin(c);
122
+ }
123
+ if (poll) {
124
+ BDRV_POLL_WHILE(c->bs, bdrv_parent_drained_poll_single(c));
125
+ }
126
+}
127
+
128
static void bdrv_merge_limits(BlockLimits *dst, const BlockLimits *src)
129
{
130
dst->opt_transfer = MAX(dst->opt_transfer, src->opt_transfer);
131
--
29
--
132
2.13.6
30
2.19.1
133
31
134
32
diff view generated by jsdifflib
1
From: Ari Sundholm <ari@tuxera.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
This was accidentally omitted. Thanks to Eric Blake for spotting this.
5
Backing files should work on read-only storage, but at the same time, a
6
block job like commit should be able to reopen them read-write if they
7
are on read-write storage. However, without option inheritance, reopen
8
only changes the read-only option for the root node (typically the
9
format layer), but not the protocol layer, so reopening fails (the
10
format layer wants to get write permissions, but the protocol layer is
11
still read-only).
4
12
5
Signed-off-by: Ari Sundholm <ari@tuxera.com>
13
A simple workaround for the problem in the management tool would be to
14
open the protocol layer always read-write and to make only the format
15
layer read-only for backing files. However, sometimes the file is
16
actually stored on read-only storage and we don't know whether the image
17
can be opened read-write (for example, for NBD it depends on the server
18
we're trying to connect to). This adds an option that makes QEMU try to
19
open the image read-write, but allows it to degrade to a read-only mode
20
without returning an error.
21
22
The documentation for this option is consciously phrased in a way that
23
allows QEMU to switch to a better model eventually: Instead of trying
24
when the image is first opened, making the read-only flag dynamic and
25
changing it automatically whenever the first BLK_PERM_WRITE user is
26
attached or the last one is detached would be much more useful
27
behaviour.
28
29
Unfortunately, this more useful behaviour is also a lot harder to
30
implement, and libvirt needs a solution now before it can switch to
31
-blockdev, so let's start with this easier approach for now.
32
33
Instead of adding a new auto-read-only option, turning the existing
34
read-only into an enum (with a bool alternate for compatibility) was
35
considered, but it complicated the implementation to the point that it
36
didn't seem to be worth it.
37
38
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
6
Reviewed-by: Eric Blake <eblake@redhat.com>
39
Reviewed-by: Eric Blake <eblake@redhat.com>
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
---
40
---
9
qapi/block-core.json | 2 ++
41
qapi/block-core.json | 7 +++++++
10
1 file changed, 2 insertions(+)
42
include/block/block.h | 2 ++
43
block.c | 17 +++++++++++++++++
44
block/vvfat.c | 1 +
45
blockdev.c | 2 +-
46
5 files changed, 28 insertions(+), 1 deletion(-)
11
47
12
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
13
index XXXXXXX..XXXXXXX 100644
49
index XXXXXXX..XXXXXXX 100644
14
--- a/qapi/block-core.json
50
--- a/qapi/block-core.json
15
+++ b/qapi/block-core.json
51
+++ b/qapi/block-core.json
16
@@ -XXX,XX +XXX,XX @@
52
@@ -XXX,XX +XXX,XX @@
17
# @log-sector-size: sector size used in logging writes to @file, determines
53
# either generally or in certain configurations. In this case,
18
# granularity of offsets and sizes of writes (default: 512)
54
# the default value does not work and the option must be
19
#
55
# specified explicitly.
20
+# @log-append: append to an existing log (default: false)
56
+# @auto-read-only: if true and @read-only is false, QEMU may automatically
21
+#
57
+# decide not to open the image read-write as requested, but
22
# @log-super-update-interval: interval of write requests after which the log
58
+# fall back to read-only instead (and switch between the modes
23
# super block is updated to disk (default: 4096)
59
+# later), e.g. depending on whether the image file is writable
24
#
60
+# or whether a writing user is attached to the node
61
+# (default: false, since 3.1)
62
# @detect-zeroes: detect and optimize zero writes (Since 2.1)
63
# (default: off)
64
# @force-share: force share all permission on added nodes.
65
@@ -XXX,XX +XXX,XX @@
66
'*discard': 'BlockdevDiscardOptions',
67
'*cache': 'BlockdevCacheOptions',
68
'*read-only': 'bool',
69
+ '*auto-read-only': 'bool',
70
'*force-share': 'bool',
71
'*detect-zeroes': 'BlockdevDetectZeroesOptions' },
72
'discriminator': 'driver',
73
diff --git a/include/block/block.h b/include/block/block.h
74
index XXXXXXX..XXXXXXX 100644
75
--- a/include/block/block.h
76
+++ b/include/block/block.h
77
@@ -XXX,XX +XXX,XX @@ typedef struct HDGeometry {
78
select an appropriate protocol driver,
79
ignoring the format layer */
80
#define BDRV_O_NO_IO 0x10000 /* don't initialize for I/O */
81
+#define BDRV_O_AUTO_RDONLY 0x20000 /* degrade to read-only if opening read-write fails */
82
83
#define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_NO_FLUSH)
84
85
@@ -XXX,XX +XXX,XX @@ typedef struct HDGeometry {
86
#define BDRV_OPT_CACHE_DIRECT "cache.direct"
87
#define BDRV_OPT_CACHE_NO_FLUSH "cache.no-flush"
88
#define BDRV_OPT_READ_ONLY "read-only"
89
+#define BDRV_OPT_AUTO_READ_ONLY "auto-read-only"
90
#define BDRV_OPT_DISCARD "discard"
91
#define BDRV_OPT_FORCE_SHARE "force-share"
92
93
diff --git a/block.c b/block.c
94
index XXXXXXX..XXXXXXX 100644
95
--- a/block.c
96
+++ b/block.c
97
@@ -XXX,XX +XXX,XX @@ static void bdrv_inherited_options(int *child_flags, QDict *child_options,
98
99
/* Inherit the read-only option from the parent if it's not set */
100
qdict_copy_default(child_options, parent_options, BDRV_OPT_READ_ONLY);
101
+ qdict_copy_default(child_options, parent_options, BDRV_OPT_AUTO_READ_ONLY);
102
103
/* Our block drivers take care to send flushes and respect unmap policy,
104
* so we can default to enable both on lower layers regardless of the
105
@@ -XXX,XX +XXX,XX @@ static void bdrv_backing_options(int *child_flags, QDict *child_options,
106
107
/* backing files always opened read-only */
108
qdict_set_default_str(child_options, BDRV_OPT_READ_ONLY, "on");
109
+ qdict_set_default_str(child_options, BDRV_OPT_AUTO_READ_ONLY, "off");
110
flags &= ~BDRV_O_COPY_ON_READ;
111
112
/* snapshot=on is handled on the top layer */
113
@@ -XXX,XX +XXX,XX @@ static void update_flags_from_options(int *flags, QemuOpts *opts)
114
*flags |= BDRV_O_RDWR;
115
}
116
117
+ assert(qemu_opt_find(opts, BDRV_OPT_AUTO_READ_ONLY));
118
+ if (qemu_opt_get_bool_del(opts, BDRV_OPT_AUTO_READ_ONLY, false)) {
119
+ *flags |= BDRV_O_AUTO_RDONLY;
120
+ }
121
}
122
123
static void update_options_from_flags(QDict *options, int flags)
124
@@ -XXX,XX +XXX,XX @@ static void update_options_from_flags(QDict *options, int flags)
125
if (!qdict_haskey(options, BDRV_OPT_READ_ONLY)) {
126
qdict_put_bool(options, BDRV_OPT_READ_ONLY, !(flags & BDRV_O_RDWR));
127
}
128
+ if (!qdict_haskey(options, BDRV_OPT_AUTO_READ_ONLY)) {
129
+ qdict_put_bool(options, BDRV_OPT_AUTO_READ_ONLY,
130
+ flags & BDRV_O_AUTO_RDONLY);
131
+ }
132
}
133
134
static void bdrv_assign_node_name(BlockDriverState *bs,
135
@@ -XXX,XX +XXX,XX @@ QemuOptsList bdrv_runtime_opts = {
136
.type = QEMU_OPT_BOOL,
137
.help = "Node is opened in read-only mode",
138
},
139
+ {
140
+ .name = BDRV_OPT_AUTO_READ_ONLY,
141
+ .type = QEMU_OPT_BOOL,
142
+ .help = "Node can become read-only if opening read-write fails",
143
+ },
144
{
145
.name = "detect-zeroes",
146
.type = QEMU_OPT_STRING,
147
@@ -XXX,XX +XXX,XX @@ BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp)
148
qdict_set_default_str(qdict, BDRV_OPT_CACHE_DIRECT, "off");
149
qdict_set_default_str(qdict, BDRV_OPT_CACHE_NO_FLUSH, "off");
150
qdict_set_default_str(qdict, BDRV_OPT_READ_ONLY, "off");
151
+ qdict_set_default_str(qdict, BDRV_OPT_AUTO_READ_ONLY, "off");
152
+
153
}
154
155
bs = bdrv_open_inherit(NULL, reference, qdict, 0, NULL, NULL, errp);
156
diff --git a/block/vvfat.c b/block/vvfat.c
157
index XXXXXXX..XXXXXXX 100644
158
--- a/block/vvfat.c
159
+++ b/block/vvfat.c
160
@@ -XXX,XX +XXX,XX @@ static void vvfat_qcow_options(int *child_flags, QDict *child_options,
161
int parent_flags, QDict *parent_options)
162
{
163
qdict_set_default_str(child_options, BDRV_OPT_READ_ONLY, "off");
164
+ qdict_set_default_str(child_options, BDRV_OPT_AUTO_READ_ONLY, "off");
165
qdict_set_default_str(child_options, BDRV_OPT_CACHE_NO_FLUSH, "on");
166
}
167
168
diff --git a/blockdev.c b/blockdev.c
169
index XXXXXXX..XXXXXXX 100644
170
--- a/blockdev.c
171
+++ b/blockdev.c
172
@@ -XXX,XX +XXX,XX @@ void qmp_blockdev_change_medium(bool has_device, const char *device,
173
174
bdrv_flags = blk_get_open_flags_from_root_state(blk);
175
bdrv_flags &= ~(BDRV_O_TEMPORARY | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING |
176
- BDRV_O_PROTOCOL);
177
+ BDRV_O_PROTOCOL | BDRV_O_AUTO_RDONLY);
178
179
if (!has_read_only) {
180
read_only = BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN;
25
--
181
--
26
2.13.6
182
2.19.1
27
183
28
184
diff view generated by jsdifflib
New patch
1
Commit e2b8247a322 introduced an error path in qemu_rbd_open() after
2
calling rbd_open(), but neglected to close the image again in this error
3
path. The error path should contain everything that the regular close
4
function qemu_rbd_close() contains.
1
5
6
This adds the missing rbd_close() call.
7
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9
Reviewed-by: Eric Blake <eblake@redhat.com>
10
---
11
block/rbd.c | 1 +
12
1 file changed, 1 insertion(+)
13
14
diff --git a/block/rbd.c b/block/rbd.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/block/rbd.c
17
+++ b/block/rbd.c
18
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
19
"automatically marking the image read-only.");
20
r = bdrv_set_read_only(bs, true, &local_err);
21
if (r < 0) {
22
+ rbd_close(s->image);
23
error_propagate(errp, local_err);
24
goto failed_open;
25
}
26
--
27
2.19.1
28
29
diff view generated by jsdifflib
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.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
Serialized writes should be used in copy-on-write of backup(sync=none)
3
since 2.11, expecting users to provide an explicit read-only=on option.
4
for image fleecing scheme.
4
5
5
Now that we have auto-read-only=on, enable these drivers to make use of
6
We need to change an assert in bdrv_aligned_pwritev, added in
6
the option.
7
28de2dcd88de. The assert may fail now, because call to
7
8
wait_serialising_requests here may become first call to it for this
8
This is the only use of bdrv_set_read_only(), so we can make it a bit
9
request with serializing flag set. It occurs if the request is aligned
9
more specific and turn it into a bdrv_apply_auto_read_only() that is
10
(otherwise, we should already set serializing flag before calling
10
more convenient for drivers to use.
11
bdrv_aligned_pwritev and correspondingly waited for all intersecting
11
12
requests). However, for aligned requests, we should not care about
13
outdating of previously read data, as there no such data. Therefore,
14
let's just update an assert to not care about aligned requests.
15
16
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
17
Reviewed-by: Fam Zheng <famz@redhat.com>
18
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13
Reviewed-by: Eric Blake <eblake@redhat.com>
19
---
14
---
20
include/block/block.h | 14 +++++++++++++-
15
include/block/block.h | 3 ++-
21
block/io.c | 28 +++++++++++++++++++++++++++-
16
block.c | 42 +++++++++++++++++++++++++++---------------
22
2 files changed, 40 insertions(+), 2 deletions(-)
17
block/bochs.c | 17 ++++++-----------
18
block/cloop.c | 16 +++++-----------
19
block/dmg.c | 16 +++++-----------
20
block/rbd.c | 15 ++++-----------
21
block/vvfat.c | 10 ++--------
22
7 files changed, 51 insertions(+), 68 deletions(-)
23
23
24
diff --git a/include/block/block.h b/include/block/block.h
24
diff --git a/include/block/block.h b/include/block/block.h
25
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
26
--- a/include/block/block.h
26
--- a/include/block/block.h
27
+++ b/include/block/block.h
27
+++ b/include/block/block.h
28
@@ -XXX,XX +XXX,XX @@ typedef enum {
28
@@ -XXX,XX +XXX,XX @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
29
* content. */
29
bool bdrv_is_read_only(BlockDriverState *bs);
30
BDRV_REQ_WRITE_UNCHANGED = 0x40,
30
int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only,
31
31
bool ignore_allow_rdw, Error **errp);
32
+ /*
32
-int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp);
33
+ * BDRV_REQ_SERIALISING forces request serialisation for writes.
33
+int bdrv_apply_auto_read_only(BlockDriverState *bs, const char *errmsg,
34
+ * It is used to ensure that writes to the backing file of a backup process
34
+ Error **errp);
35
+ * target cannot race with a read of the backup target that defers to the
35
bool bdrv_is_writable(BlockDriverState *bs);
36
+ * backing file.
36
bool bdrv_is_sg(BlockDriverState *bs);
37
+ *
37
bool bdrv_is_inserted(BlockDriverState *bs);
38
+ * Note, that BDRV_REQ_SERIALISING is _not_ opposite in meaning to
38
diff --git a/block.c b/block.c
39
+ * BDRV_REQ_NO_SERIALISING. A more descriptive name for the latter might be
39
index XXXXXXX..XXXXXXX 100644
40
+ * _DO_NOT_WAIT_FOR_SERIALISING, except that is too long.
40
--- a/block.c
41
+ */
41
+++ b/block.c
42
+ BDRV_REQ_SERIALISING = 0x80,
42
@@ -XXX,XX +XXX,XX @@ int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only,
43
+
43
return 0;
44
/* Mask of valid flags */
45
- BDRV_REQ_MASK = 0x7f,
46
+ BDRV_REQ_MASK = 0xff,
47
} BdrvRequestFlags;
48
49
typedef struct BlockSizes {
50
diff --git a/block/io.c b/block/io.c
51
index XXXXXXX..XXXXXXX 100644
52
--- a/block/io.c
53
+++ b/block/io.c
54
@@ -XXX,XX +XXX,XX @@ static void mark_request_serialising(BdrvTrackedRequest *req, uint64_t align)
55
req->overlap_bytes = MAX(req->overlap_bytes, overlap_bytes);
56
}
44
}
57
45
58
+static bool is_request_serialising_and_aligned(BdrvTrackedRequest *req)
46
-/* TODO Remove (deprecated since 2.11)
59
+{
47
- * Block drivers are not supposed to automatically change bs->read_only.
60
+ /*
48
- * Instead, they should just check whether they can provide what the user
61
+ * If the request is serialising, overlap_offset and overlap_bytes are set,
49
- * explicitly requested and error out if read-write is requested, but they can
62
+ * so we can check if the request is aligned. Otherwise, don't care and
50
- * only provide read-only access. */
63
+ * return false.
51
-int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
64
+ */
52
+/*
65
+
53
+ * Called by a driver that can only provide a read-only image.
66
+ return req->serialising && (req->offset == req->overlap_offset) &&
54
+ *
67
+ (req->bytes == req->overlap_bytes);
55
+ * Returns 0 if the node is already read-only or it could switch the node to
68
+}
56
+ * read-only because BDRV_O_AUTO_RDONLY is set.
69
+
57
+ *
70
/**
58
+ * Returns -EACCES if the node is read-write and BDRV_O_AUTO_RDONLY is not set
71
* Round a region to cluster boundaries
59
+ * or bdrv_can_set_read_only() forbids making the node read-only. If @errmsg
72
*/
60
+ * is not NULL, it is used as the error message for the Error object.
73
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child,
61
+ */
74
mark_request_serialising(req, bdrv_get_cluster_size(bs));
62
+int bdrv_apply_auto_read_only(BlockDriverState *bs, const char *errmsg,
75
}
63
+ Error **errp)
76
64
{
77
+ /* BDRV_REQ_SERIALISING is only for write operation */
65
int ret = 0;
78
+ assert(!(flags & BDRV_REQ_SERIALISING));
66
79
+
67
- ret = bdrv_can_set_read_only(bs, read_only, false, errp);
80
if (!(flags & BDRV_REQ_NO_SERIALISING)) {
68
- if (ret < 0) {
81
wait_serialising_requests(req);
69
- return ret;
82
}
70
+ if (!(bs->open_flags & BDRV_O_RDWR)) {
83
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
71
+ return 0;
84
72
+ }
85
/* BDRV_REQ_NO_SERIALISING is only for read operation */
73
+ if (!(bs->open_flags & BDRV_O_AUTO_RDONLY)) {
86
assert(!(flags & BDRV_REQ_NO_SERIALISING));
74
+ goto fail;
87
+
75
}
88
+ if (flags & BDRV_REQ_SERIALISING) {
76
89
+ mark_request_serialising(req, bdrv_get_cluster_size(bs));
77
- bs->read_only = read_only;
90
+ }
78
-
91
+
79
- if (read_only) {
92
waited = wait_serialising_requests(req);
80
- bs->open_flags &= ~BDRV_O_RDWR;
93
- assert(!waited || !req->serialising);
81
- } else {
94
+ assert(!waited || !req->serialising ||
82
- bs->open_flags |= BDRV_O_RDWR;
95
+ is_request_serialising_and_aligned(req));
83
+ ret = bdrv_can_set_read_only(bs, true, false, NULL);
96
assert(req->overlap_offset <= offset);
84
+ if (ret < 0) {
97
assert(offset + bytes <= req->overlap_offset + req->overlap_bytes);
85
+ goto fail;
98
if (flags & BDRV_REQ_WRITE_UNCHANGED) {
86
}
99
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_copy_range_internal(
87
100
tracked_request_begin(&req, src->bs, src_offset, bytes,
88
+ bs->read_only = true;
101
BDRV_TRACKED_READ);
89
+ bs->open_flags &= ~BDRV_O_RDWR;
102
90
+
103
+ /* BDRV_REQ_SERIALISING is only for write operation */
91
return 0;
104
+ assert(!(read_flags & BDRV_REQ_SERIALISING));
92
+
105
if (!(read_flags & BDRV_REQ_NO_SERIALISING)) {
93
+fail:
106
wait_serialising_requests(&req);
94
+ error_setg(errp, "%s", errmsg ?: "Image is read-only");
95
+ return -EACCES;
96
}
97
98
void bdrv_get_full_backing_filename_from_filename(const char *backed,
99
diff --git a/block/bochs.c b/block/bochs.c
100
index XXXXXXX..XXXXXXX 100644
101
--- a/block/bochs.c
102
+++ b/block/bochs.c
103
@@ -XXX,XX +XXX,XX @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
104
struct bochs_header bochs;
105
int ret;
106
107
+ /* No write support yet */
108
+ ret = bdrv_apply_auto_read_only(bs, NULL, errp);
109
+ if (ret < 0) {
110
+ return ret;
111
+ }
112
+
113
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
114
false, errp);
115
if (!bs->file) {
116
return -EINVAL;
117
}
118
119
- if (!bdrv_is_read_only(bs)) {
120
- error_report("Opening bochs images without an explicit read-only=on "
121
- "option is deprecated. Future versions will refuse to "
122
- "open the image instead of automatically marking the "
123
- "image read-only.");
124
- ret = bdrv_set_read_only(bs, true, errp); /* no write support yet */
125
- if (ret < 0) {
126
- return ret;
127
- }
128
- }
129
-
130
ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs));
131
if (ret < 0) {
132
return ret;
133
diff --git a/block/cloop.c b/block/cloop.c
134
index XXXXXXX..XXXXXXX 100644
135
--- a/block/cloop.c
136
+++ b/block/cloop.c
137
@@ -XXX,XX +XXX,XX @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags,
138
uint32_t offsets_size, max_compressed_block_size = 1, i;
139
int ret;
140
141
+ ret = bdrv_apply_auto_read_only(bs, NULL, errp);
142
+ if (ret < 0) {
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;
107
}
222
}
108
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_copy_range_internal(
223
}
109
224
110
/* BDRV_REQ_NO_SERIALISING is only for read operation */
225
diff --git a/block/vvfat.c b/block/vvfat.c
111
assert(!(write_flags & BDRV_REQ_NO_SERIALISING));
226
index XXXXXXX..XXXXXXX 100644
112
+ if (write_flags & BDRV_REQ_SERIALISING) {
227
--- a/block/vvfat.c
113
+ mark_request_serialising(&req, bdrv_get_cluster_size(dst->bs));
228
+++ b/block/vvfat.c
114
+ }
229
@@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
115
wait_serialising_requests(&req);
230
"Unable to set VVFAT to 'rw' when drive is read-only");
116
231
goto fail;
117
ret = dst->bs->drv->bdrv_co_copy_range_to(dst->bs,
232
}
233
- } else if (!bdrv_is_read_only(bs)) {
234
- error_report("Opening non-rw vvfat images without an explicit "
235
- "read-only=on option is deprecated. Future versions "
236
- "will refuse to open the image instead of "
237
- "automatically marking the image read-only.");
238
- /* read only is the default for safety */
239
- ret = bdrv_set_read_only(bs, true, &local_err);
240
+ } else {
241
+ ret = bdrv_apply_auto_read_only(bs, NULL, errp);
242
if (ret < 0) {
243
- error_propagate(errp, local_err);
244
goto fail;
245
}
246
}
118
--
247
--
119
2.13.6
248
2.19.1
120
249
121
250
diff view generated by jsdifflib
New patch
1
If read-only=off, but auto-read-only=on is given, open a read-write NBD
2
connection if the server provides a read-write export, but instead of
3
erroring out for read-only exports, just degrade to read-only.
1
4
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
6
Reviewed-by: Eric Blake <eblake@redhat.com>
7
---
8
block/nbd-client.c | 10 +++++-----
9
1 file changed, 5 insertions(+), 5 deletions(-)
10
11
diff --git a/block/nbd-client.c b/block/nbd-client.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/block/nbd-client.c
14
+++ b/block/nbd-client.c
15
@@ -XXX,XX +XXX,XX @@ int nbd_client_init(BlockDriverState *bs,
16
logout("Failed to negotiate with the NBD server\n");
17
return ret;
18
}
19
- if (client->info.flags & NBD_FLAG_READ_ONLY &&
20
- !bdrv_is_read_only(bs)) {
21
- error_setg(errp,
22
- "request for write access conflicts with read-only export");
23
- return -EACCES;
24
+ if (client->info.flags & NBD_FLAG_READ_ONLY) {
25
+ ret = bdrv_apply_auto_read_only(bs, "NBD export is read-only", errp);
26
+ if (ret < 0) {
27
+ return ret;
28
+ }
29
}
30
if (client->info.flags & NBD_FLAG_SEND_FUA) {
31
bs->supported_write_flags = BDRV_REQ_FUA;
32
--
33
2.19.1
34
35
diff view generated by jsdifflib
1
From: Fam Zheng <famz@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
With in one module, trace points usually have a common prefix named
4
after the module name. paio_submit and paio_submit_co are the only two
5
trace points so far in the two file protocol drivers. As we are adding
6
more, having a common prefix here is better so that trace points can be
7
enabled with a glob. Rename them.
8
9
Suggested-by: Kevin Wolf <kwolf@redhat.com>
10
Signed-off-by: Fam Zheng <famz@redhat.com>
11
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
6
Reviewed-by: Eric Blake <eblake@redhat.com>
12
---
7
---
13
block/file-posix.c | 2 +-
8
block/file-posix.c | 19 ++++++++++++++++---
14
block/file-win32.c | 2 +-
9
1 file changed, 16 insertions(+), 3 deletions(-)
15
block/trace-events | 4 ++--
16
3 files changed, 4 insertions(+), 4 deletions(-)
17
10
18
diff --git a/block/file-posix.c b/block/file-posix.c
11
diff --git a/block/file-posix.c b/block/file-posix.c
19
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
20
--- a/block/file-posix.c
13
--- a/block/file-posix.c
21
+++ b/block/file-posix.c
14
+++ b/block/file-posix.c
22
@@ -XXX,XX +XXX,XX @@ static int paio_submit_co_full(BlockDriverState *bs, int fd,
15
@@ -XXX,XX +XXX,XX @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
23
assert(qiov->size == bytes);
16
24
}
17
s->fd = -1;
25
18
fd = qemu_open(filename, s->open_flags, 0644);
26
- trace_paio_submit_co(offset, bytes, type);
19
- if (fd < 0) {
27
+ trace_file_paio_submit_co(offset, bytes, type);
20
- ret = -errno;
28
pool = aio_get_thread_pool(bdrv_get_aio_context(bs));
21
- error_setg_errno(errp, errno, "Could not open '%s'", filename);
29
return thread_pool_submit_co(pool, aio_worker, acb);
22
+ ret = fd < 0 ? -errno : 0;
30
}
23
+
31
diff --git a/block/file-win32.c b/block/file-win32.c
24
+ if (ret == -EACCES || ret == -EROFS) {
32
index XXXXXXX..XXXXXXX 100644
25
+ /* Try to degrade to read-only, but if it doesn't work, still use the
33
--- a/block/file-win32.c
26
+ * normal error message. */
34
+++ b/block/file-win32.c
27
+ if (bdrv_apply_auto_read_only(bs, NULL, NULL) == 0) {
35
@@ -XXX,XX +XXX,XX @@ static BlockAIOCB *paio_submit(BlockDriverState *bs, HANDLE hfile,
28
+ bdrv_flags &= ~BDRV_O_RDWR;
36
acb->aio_nbytes = count;
29
+ raw_parse_flags(bdrv_flags, &s->open_flags);
37
acb->aio_offset = offset;
30
+ assert(!(s->open_flags & O_CREAT));
38
31
+ fd = qemu_open(filename, s->open_flags);
39
- trace_paio_submit(acb, opaque, offset, count, type);
32
+ ret = fd < 0 ? -errno : 0;
40
+ trace_file_paio_submit(acb, opaque, offset, count, type);
33
+ }
41
pool = aio_get_thread_pool(bdrv_get_aio_context(bs));
34
+ }
42
return thread_pool_submit_aio(pool, aio_worker, acb, cb, opaque);
35
+
43
}
36
+ if (ret < 0) {
44
diff --git a/block/trace-events b/block/trace-events
37
+ error_setg_errno(errp, -ret, "Could not open '%s'", filename);
45
index XXXXXXX..XXXXXXX 100644
38
if (ret == -EROFS) {
46
--- a/block/trace-events
39
ret = -EACCES;
47
+++ b/block/trace-events
40
}
48
@@ -XXX,XX +XXX,XX @@ qmp_block_stream(void *bs, void *job) "bs %p job %p"
49
50
# block/file-win32.c
51
# block/file-posix.c
52
-paio_submit_co(int64_t offset, int count, int type) "offset %"PRId64" count %d type %d"
53
-paio_submit(void *acb, void *opaque, int64_t offset, int count, int type) "acb %p opaque %p offset %"PRId64" count %d type %d"
54
+file_paio_submit_co(int64_t offset, int count, int type) "offset %"PRId64" count %d type %d"
55
+file_paio_submit(void *acb, void *opaque, int64_t offset, int count, int type) "acb %p opaque %p offset %"PRId64" count %d type %d"
56
57
# block/qcow2.c
58
qcow2_writev_start_req(void *co, int64_t offset, int bytes) "co %p offset 0x%" PRIx64 " bytes %d"
59
--
41
--
60
2.13.6
42
2.19.1
61
43
62
44
diff view generated by jsdifflib
New patch
1
If read-only=off, but auto-read-only=on is given, just degrade to
2
read-only.
1
3
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
Reviewed-by: Eric Blake <eblake@redhat.com>
6
---
7
block/curl.c | 8 ++++----
8
1 file changed, 4 insertions(+), 4 deletions(-)
9
10
diff --git a/block/curl.c b/block/curl.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/block/curl.c
13
+++ b/block/curl.c
14
@@ -XXX,XX +XXX,XX @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
15
const char *protocol_delimiter;
16
int ret;
17
18
-
19
- if (flags & BDRV_O_RDWR) {
20
- error_setg(errp, "curl block device does not support writes");
21
- return -EROFS;
22
+ ret = bdrv_apply_auto_read_only(bs, "curl driver does not support writes",
23
+ errp);
24
+ if (ret < 0) {
25
+ return ret;
26
}
27
28
if (!libcurl_initialized) {
29
--
30
2.19.1
31
32
diff view generated by jsdifflib
New patch
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.
1
4
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
6
Reviewed-by: Niels de Vos <ndevos@redhat.com>
7
---
8
block/gluster.c | 12 ++++++++++--
9
1 file changed, 10 insertions(+), 2 deletions(-)
10
11
diff --git a/block/gluster.c b/block/gluster.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/block/gluster.c
14
+++ b/block/gluster.c
15
@@ -XXX,XX +XXX,XX @@ static int qemu_gluster_open(BlockDriverState *bs, QDict *options,
16
qemu_gluster_parse_flags(bdrv_flags, &open_flags);
17
18
s->fd = glfs_open(s->glfs, gconf->path, open_flags);
19
- if (!s->fd) {
20
- ret = -errno;
21
+ ret = s->fd ? 0 : -errno;
22
+
23
+ if (ret == -EACCES || ret == -EROFS) {
24
+ /* Try to degrade to read-only, but if it doesn't work, still use the
25
+ * normal error message. */
26
+ if (bdrv_apply_auto_read_only(bs, NULL, NULL) == 0) {
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
+ }
31
}
32
33
s->supports_seek_data = qemu_gluster_test_seek(s->fd);
34
--
35
2.19.1
36
37
diff view generated by jsdifflib
1
From: Fam Zheng <famz@redhat.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
A few trace points that can help reveal what is happening in a copy
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4
offloading I/O path.
6
Reviewed-by: Eric Blake <eblake@redhat.com>
7
---
8
block/iscsi.c | 8 +++++---
9
1 file changed, 5 insertions(+), 3 deletions(-)
5
10
6
Signed-off-by: Fam Zheng <famz@redhat.com>
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
---
9
block/file-posix.c | 2 ++
10
block/io.c | 4 ++++
11
block/iscsi.c | 3 +++
12
block/trace-events | 6 ++++++
13
4 files changed, 15 insertions(+)
14
15
diff --git a/block/file-posix.c b/block/file-posix.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/block/file-posix.c
18
+++ b/block/file-posix.c
19
@@ -XXX,XX +XXX,XX @@ static ssize_t handle_aiocb_copy_range(RawPosixAIOData *aiocb)
20
ssize_t ret = copy_file_range(aiocb->aio_fildes, &in_off,
21
aiocb->aio_fd2, &out_off,
22
bytes, 0);
23
+ trace_file_copy_file_range(aiocb->bs, aiocb->aio_fildes, in_off,
24
+ aiocb->aio_fd2, out_off, bytes, 0, ret);
25
if (ret == 0) {
26
/* No progress (e.g. when beyond EOF), let the caller fall back to
27
* buffer I/O. */
28
diff --git a/block/io.c b/block/io.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/block/io.c
31
+++ b/block/io.c
32
@@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_copy_range_from(BdrvChild *src, uint64_t src_offset,
33
BdrvRequestFlags read_flags,
34
BdrvRequestFlags write_flags)
35
{
36
+ trace_bdrv_co_copy_range_from(src, src_offset, dst, dst_offset, bytes,
37
+ read_flags, write_flags);
38
return bdrv_co_copy_range_internal(src, src_offset, dst, dst_offset,
39
bytes, read_flags, write_flags, true);
40
}
41
@@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, uint64_t src_offset,
42
BdrvRequestFlags read_flags,
43
BdrvRequestFlags write_flags)
44
{
45
+ trace_bdrv_co_copy_range_to(src, src_offset, dst, dst_offset, bytes,
46
+ read_flags, write_flags);
47
return bdrv_co_copy_range_internal(src, src_offset, dst, dst_offset,
48
bytes, read_flags, write_flags, false);
49
}
50
diff --git a/block/iscsi.c b/block/iscsi.c
11
diff --git a/block/iscsi.c b/block/iscsi.c
51
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
52
--- a/block/iscsi.c
13
--- a/block/iscsi.c
53
+++ b/block/iscsi.c
14
+++ b/block/iscsi.c
54
@@ -XXX,XX +XXX,XX @@
15
@@ -XXX,XX +XXX,XX @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
55
#include "qapi/qmp/qstring.h"
16
/* Check the write protect flag of the LUN if we want to write */
56
#include "crypto/secret.h"
17
if (iscsilun->type == TYPE_DISK && (flags & BDRV_O_RDWR) &&
57
#include "scsi/utils.h"
18
iscsilun->write_protected) {
58
+#include "trace.h"
19
- error_setg(errp, "Cannot open a write protected LUN as read-write");
59
20
- ret = -EACCES;
60
/* Conflict between scsi/utils.h and libiscsi! :( */
21
- goto out;
61
#define SCSI_XFER_NONE ISCSI_XFER_NONE
22
+ ret = bdrv_apply_auto_read_only(bs, "LUN is write protected", errp);
62
@@ -XXX,XX +XXX,XX @@ retry:
23
+ if (ret < 0) {
24
+ goto out;
25
+ }
26
+ flags &= ~BDRV_O_RDWR;
63
}
27
}
64
28
65
out_unlock:
29
iscsi_readcapacity_sync(iscsilun, &local_err);
66
+
67
+ trace_iscsi_xcopy(src_lun, src_offset, dst_lun, dst_offset, bytes, r);
68
g_free(iscsi_task.task);
69
qemu_mutex_unlock(&dst_lun->mutex);
70
g_free(iscsi_task.err_str);
71
diff --git a/block/trace-events b/block/trace-events
72
index XXXXXXX..XXXXXXX 100644
73
--- a/block/trace-events
74
+++ b/block/trace-events
75
@@ -XXX,XX +XXX,XX @@ bdrv_co_preadv(void *bs, int64_t offset, int64_t nbytes, unsigned int flags) "bs
76
bdrv_co_pwritev(void *bs, int64_t offset, int64_t nbytes, unsigned int flags) "bs %p offset %"PRId64" nbytes %"PRId64" flags 0x%x"
77
bdrv_co_pwrite_zeroes(void *bs, int64_t offset, int count, int flags) "bs %p offset %"PRId64" count %d flags 0x%x"
78
bdrv_co_do_copy_on_readv(void *bs, int64_t offset, unsigned int bytes, int64_t cluster_offset, int64_t cluster_bytes) "bs %p offset %"PRId64" bytes %u cluster_offset %"PRId64" cluster_bytes %"PRId64
79
+bdrv_co_copy_range_from(void *src, uint64_t src_offset, void *dst, uint64_t dst_offset, uint64_t bytes, int read_flags, int write_flags) "src %p offset %"PRIu64" dst %p offset %"PRIu64" bytes %"PRIu64" rw flags 0x%x 0x%x"
80
+bdrv_co_copy_range_to(void *src, uint64_t src_offset, void *dst, uint64_t dst_offset, uint64_t bytes, int read_flags, int write_flags) "src %p offset %"PRIu64" dst %p offset %"PRIu64" bytes %"PRIu64" rw flags 0x%x 0x%x"
81
82
# block/stream.c
83
stream_one_iteration(void *s, int64_t offset, uint64_t bytes, int is_allocated) "s %p offset %" PRId64 " bytes %" PRIu64 " is_allocated %d"
84
@@ -XXX,XX +XXX,XX @@ qmp_block_stream(void *bs, void *job) "bs %p job %p"
85
# block/file-posix.c
86
file_paio_submit_co(int64_t offset, int count, int type) "offset %"PRId64" count %d type %d"
87
file_paio_submit(void *acb, void *opaque, int64_t offset, int count, int type) "acb %p opaque %p offset %"PRId64" count %d type %d"
88
+file_copy_file_range(void *bs, int src, int64_t src_off, int dst, int64_t dst_off, int64_t bytes, int flags, int64_t ret) "bs %p src_fd %d offset %"PRIu64" dst_fd %d offset %"PRIu64" bytes %"PRIu64" flags %d ret %"PRId64
89
90
# block/qcow2.c
91
qcow2_writev_start_req(void *co, int64_t offset, int bytes) "co %p offset 0x%" PRIx64 " bytes %d"
92
@@ -XXX,XX +XXX,XX @@ nvme_free_req_queue_wait(void *q) "q %p"
93
nvme_cmd_map_qiov(void *s, void *cmd, void *req, void *qiov, int entries) "s %p cmd %p req %p qiov %p entries %d"
94
nvme_cmd_map_qiov_pages(void *s, int i, uint64_t page) "s %p page[%d] 0x%"PRIx64
95
nvme_cmd_map_qiov_iov(void *s, int i, void *page, int pages) "s %p iov[%d] %p pages %d"
96
+
97
+# block/iscsi.c
98
+iscsi_xcopy(void *src_lun, uint64_t src_off, void *dst_lun, uint64_t dst_off, uint64_t bytes, int ret) "src_lun %p offset %"PRIu64" dst_lun %p offset %"PRIu64" bytes %"PRIu64" ret %d"
99
--
30
--
100
2.13.6
31
2.19.1
101
32
102
33
diff view generated by jsdifflib
1
From: Cornelia Huck <cohuck@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
This reverts commit 6266e900b8083945cb766b45c124fb3c42932cb3.
4
5
Some deprecated -drive options were still in use by libvirt, only
6
fixed with libvirt commit b340c6c614 ("qemu: format serial and geometry
7
on frontend disk device"), which is not yet in any released version
8
of libvirt.
9
10
So let's hold off removing the deprecated options for one more QEMU
11
release.
12
13
Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
14
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
15
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>
16
---
11
---
17
blockdev.c | 12 ++++++++++++
12
blockdev.c | 1 +
18
1 file changed, 12 insertions(+)
13
1 file changed, 1 insertion(+)
19
14
20
diff --git a/blockdev.c b/blockdev.c
15
diff --git a/blockdev.c b/blockdev.c
21
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
22
--- a/blockdev.c
17
--- a/blockdev.c
23
+++ b/blockdev.c
18
+++ b/blockdev.c
24
@@ -XXX,XX +XXX,XX @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
19
@@ -XXX,XX +XXX,XX @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
25
const char *filename;
20
qdict_set_default_str(bs_opts, BDRV_OPT_CACHE_NO_FLUSH, "off");
26
Error *local_err = NULL;
21
qdict_set_default_str(bs_opts, BDRV_OPT_READ_ONLY,
27
int i;
22
read_only ? "on" : "off");
28
+ const char *deprecated[] = {
23
+ qdict_set_default_str(bs_opts, BDRV_OPT_AUTO_READ_ONLY, "on");
29
+ };
24
assert((bdrv_flags & BDRV_O_CACHE_MASK) == 0);
30
25
31
/* Change legacy command line options into QMP ones */
26
if (runstate_check(RUN_STATE_INMIGRATE)) {
32
static const struct {
33
@@ -XXX,XX +XXX,XX @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
34
goto fail;
35
}
36
37
+ /* Other deprecated options */
38
+ if (!qtest_enabled()) {
39
+ for (i = 0; i < ARRAY_SIZE(deprecated); i++) {
40
+ if (qemu_opt_get(legacy_opts, deprecated[i]) != NULL) {
41
+ error_report("'%s' is deprecated, please use the corresponding "
42
+ "option of '-device' instead", deprecated[i]);
43
+ }
44
+ }
45
+ }
46
+
47
/* Media type */
48
value = qemu_opt_get(legacy_opts, "media");
49
if (value) {
50
--
27
--
51
2.13.6
28
2.19.1
52
29
53
30
diff view generated by jsdifflib
New patch
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
1
10
11
diff --git a/tests/qemu-iotests/232 b/tests/qemu-iotests/232
12
new file mode 100755
13
index XXXXXXX..XXXXXXX
14
--- /dev/null
15
+++ b/tests/qemu-iotests/232
16
@@ -XXX,XX +XXX,XX @@
17
+#!/bin/bash
18
+#
19
+# Test for auto-read-only
20
+#
21
+# Copyright (C) 2018 Red Hat, Inc.
22
+#
23
+# This program is free software; you can redistribute it and/or modify
24
+# it under the terms of the GNU General Public License as published by
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
230
index XXXXXXX..XXXXXXX 100644
231
--- a/tests/qemu-iotests/group
232
+++ b/tests/qemu-iotests/group
233
@@ -XXX,XX +XXX,XX @@
234
227 auto quick
235
229 auto quick
236
231 auto quick
237
+232 auto quick
238
--
239
2.19.1
240
241
diff view generated by jsdifflib
1
From: Fam Zheng <famz@redhat.com>
1
From: Max Reitz <mreitz@redhat.com>
2
2
3
Reuse the new bdrv_co_write_req_prepare/finish helpers. The variation
3
This adds some whitespace into the option help (including indentation)
4
here is that discard requests don't affect bs->wr_highest_offset, and it
4
and puts angle brackets around the type names. Furthermore, the list
5
cannot extend the image.
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.
6
7
7
Signed-off-by: Fam Zheng <famz@redhat.com>
8
This patch also restores the description alignment we had before commit
9
9cbef9d68ee1d8d0, just at 24 instead of 16 characters like we used to.
10
This increase is because now we have the type and two spaces of
11
indentation before the description, and with a usual type name length of
12
three chracters, this sums up to eight additional characters -- which
13
means that we now need 24 characters to get the same amount of padding
14
for most options. Also, 24 is a third of 80, which makes it kind of a
15
round number in terminal terms.
16
17
Finally, this patch amends the reference output of iotest 082 to match
18
the changes (and thus makes it pass again).
19
20
Signed-off-by: Max Reitz <mreitz@redhat.com>
21
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
22
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9
---
23
---
10
block/io.c | 33 +++++++++++++++++++++++----------
24
include/qemu/option.h | 2 +-
11
1 file changed, 23 insertions(+), 10 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(-)
12
29
13
diff --git a/block/io.c b/block/io.c
30
diff --git a/include/qemu/option.h b/include/qemu/option.h
14
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
15
--- a/block/io.c
32
--- a/include/qemu/option.h
16
+++ b/block/io.c
33
+++ b/include/qemu/option.h
17
@@ -XXX,XX +XXX,XX @@ bdrv_co_write_req_finish(BdrvChild *child, int64_t offset, uint64_t bytes,
34
@@ -XXX,XX +XXX,XX @@ typedef int (*qemu_opts_loopfunc)(void *opaque, QemuOpts *opts, Error **errp);
18
35
int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func,
19
atomic_inc(&bs->write_gen);
36
void *opaque, Error **errp);
20
37
void qemu_opts_print(QemuOpts *opts, const char *sep);
21
- stat64_max(&bs->wr_highest_offset, offset + bytes);
38
-void qemu_opts_print_help(QemuOptsList *list);
22
-
39
+void qemu_opts_print_help(QemuOptsList *list, bool print_caption);
23
+ /*
40
void qemu_opts_free(QemuOptsList *list);
24
+ * Discard cannot extend the image, but in error handling cases, such as
41
QemuOptsList *qemu_opts_append(QemuOptsList *dst, QemuOptsList *list);
25
+ * when reverting a qcow2 cluster allocation, the discarded range can pass
42
26
+ * the end of image file, so we cannot assert about BDRV_TRACKED_DISCARD
43
diff --git a/qemu-img.c b/qemu-img.c
27
+ * here. Instead, just skip it, since semantically a discard request
44
index XXXXXXX..XXXXXXX 100644
28
+ * beyond EOF cannot expand the image anyway.
45
--- a/qemu-img.c
29
+ */
46
+++ b/qemu-img.c
30
if (ret == 0 &&
47
@@ -XXX,XX +XXX,XX @@ static int print_block_option_help(const char *filename, const char *fmt)
31
- end_sector > bs->total_sectors) {
32
+ end_sector > bs->total_sectors &&
33
+ req->type != BDRV_TRACKED_DISCARD) {
34
bs->total_sectors = end_sector;
35
bdrv_parent_cb_resize(bs);
36
bdrv_dirty_bitmap_truncate(bs, end_sector << BDRV_SECTOR_BITS);
37
}
48
}
38
- bdrv_set_dirty(bs, offset, bytes);
49
39
+ if (req->bytes) {
50
printf("Supported options:\n");
40
+ switch (req->type) {
51
- qemu_opts_print_help(create_opts);
41
+ case BDRV_TRACKED_WRITE:
52
+ qemu_opts_print_help(create_opts, false);
42
+ stat64_max(&bs->wr_highest_offset, offset + bytes);
53
qemu_opts_free(create_opts);
43
+ /* fall through, to set dirty bits */
54
return 0;
44
+ case BDRV_TRACKED_DISCARD:
55
}
45
+ bdrv_set_dirty(bs, offset, bytes);
56
@@ -XXX,XX +XXX,XX @@ static int print_amend_option_help(const char *format)
46
+ break;
57
assert(drv->create_opts);
47
+ default:
58
48
+ break;
59
printf("Creation options for '%s':\n", format);
60
- qemu_opts_print_help(drv->create_opts);
61
+ qemu_opts_print_help(drv->create_opts, false);
62
printf("\nNote that not all of these options may be amendable.\n");
63
return 0;
64
}
65
diff --git a/util/qemu-option.c b/util/qemu-option.c
66
index XXXXXXX..XXXXXXX 100644
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)
103
}
104
105
g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0);
106
+ if (print_caption && array->len > 0) {
107
+ if (list->name) {
108
+ printf("%s options:\n", list->name);
109
+ } else {
110
+ printf("Options:\n");
111
+ }
112
+ } else if (array->len == 0) {
113
+ if (list->name) {
114
+ printf("There are no options for %s.\n", list->name);
115
+ } else {
116
+ printf("No options available.\n");
49
+ }
117
+ }
50
+ }
118
+ }
51
}
119
for (i = 0; i < array->len; i++) {
52
120
printf("%s\n", (char *)array->pdata[i]);
53
/*
54
@@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, int64_t offset, int bytes)
55
ret = bdrv_check_byte_request(bs, offset, bytes);
56
if (ret < 0) {
57
return ret;
58
- } else if (bs->read_only) {
59
- return -EPERM;
60
}
121
}
61
- assert(!(bs->open_flags & BDRV_O_INACTIVE));
122
@@ -XXX,XX +XXX,XX @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params,
62
123
opts = opts_parse(list, params, permit_abbrev, false, &invalidp, &err);
63
/* Do nothing if disabled. */
124
if (err) {
64
if (!(bs->open_flags & BDRV_O_UNMAP)) {
125
if (invalidp && has_help_option(params)) {
65
@@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, int64_t offset, int bytes)
126
- qemu_opts_print_help(list);
66
bdrv_inc_in_flight(bs);
127
+ qemu_opts_print_help(list, true);
67
tracked_request_begin(&req, bs, offset, bytes, BDRV_TRACKED_DISCARD);
128
error_free(err);
68
129
} else {
69
- ret = notifier_with_return_list_notify(&bs->before_write_notifiers, &req);
130
error_report_err(err);
70
+ ret = bdrv_co_write_req_prepare(child, offset, bytes, &req, 0);
131
diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out
71
if (ret < 0) {
132
index XXXXXXX..XXXXXXX 100644
72
goto out;
133
--- a/tests/qemu-iotests/082.out
73
}
134
+++ b/tests/qemu-iotests/082.out
74
@@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, int64_t offset, int bytes)
135
@@ -XXX,XX +XXX,XX @@ cluster_size: 8192
75
}
136
76
ret = 0;
137
Testing: create -f qcow2 -o help TEST_DIR/t.qcow2 128M
77
out:
138
Supported options:
78
- atomic_inc(&bs->write_gen);
139
-size Virtual disk size
79
- bdrv_set_dirty(bs, req.offset, req.bytes);
140
-compat Compatibility level (0.10 or 1.1)
80
+ bdrv_co_write_req_finish(child, req.offset, req.bytes, &req, ret);
141
-backing_file File name of a base image
81
tracked_request_end(&req);
142
-backing_fmt Image format of the base image
82
bdrv_dec_in_flight(bs);
143
-encryption Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
83
return ret;
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
84
--
1221
--
85
2.13.6
1222
2.19.1
86
1223
87
1224
diff view generated by jsdifflib
1
From: Max Reitz <mreitz@redhat.com>
2
3
Following the example of qemu_opts_print_help(), indent all entries in
4
the list of character devices.
5
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
1
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2
---
9
---
3
tests/test-bdrv-drain.c | 43 +++++++++++++++++++++++++++++++++++++++++++
10
chardev/char.c | 2 +-
4
1 file changed, 43 insertions(+)
11
1 file changed, 1 insertion(+), 1 deletion(-)
5
12
6
diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c
13
diff --git a/chardev/char.c b/chardev/char.c
7
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
8
--- a/tests/test-bdrv-drain.c
15
--- a/chardev/char.c
9
+++ b/tests/test-bdrv-drain.c
16
+++ b/chardev/char.c
10
@@ -XXX,XX +XXX,XX @@ static void test_detach_by_driver_cb(void)
17
@@ -XXX,XX +XXX,XX @@ help_string_append(const char *name, void *opaque)
11
test_detach_indirect(false);
18
{
19
GString *str = opaque;
20
21
- g_string_append_printf(str, "\n%s", name);
22
+ g_string_append_printf(str, "\n %s", name);
12
}
23
}
13
24
14
+static void test_append_to_drained(void)
25
static const char *chardev_alias_translate(const char *name)
15
+{
16
+ BlockBackend *blk;
17
+ BlockDriverState *base, *overlay;
18
+ BDRVTestState *base_s, *overlay_s;
19
+
20
+ blk = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
21
+ base = bdrv_new_open_driver(&bdrv_test, "base", BDRV_O_RDWR, &error_abort);
22
+ base_s = base->opaque;
23
+ blk_insert_bs(blk, base, &error_abort);
24
+
25
+ overlay = bdrv_new_open_driver(&bdrv_test, "overlay", BDRV_O_RDWR,
26
+ &error_abort);
27
+ overlay_s = overlay->opaque;
28
+
29
+ do_drain_begin(BDRV_DRAIN, base);
30
+ g_assert_cmpint(base->quiesce_counter, ==, 1);
31
+ g_assert_cmpint(base_s->drain_count, ==, 1);
32
+ g_assert_cmpint(base->in_flight, ==, 0);
33
+
34
+ /* Takes ownership of overlay, so we don't have to unref it later */
35
+ bdrv_append(overlay, base, &error_abort);
36
+ g_assert_cmpint(base->in_flight, ==, 0);
37
+ g_assert_cmpint(overlay->in_flight, ==, 0);
38
+
39
+ g_assert_cmpint(base->quiesce_counter, ==, 1);
40
+ g_assert_cmpint(base_s->drain_count, ==, 1);
41
+ g_assert_cmpint(overlay->quiesce_counter, ==, 1);
42
+ g_assert_cmpint(overlay_s->drain_count, ==, 1);
43
+
44
+ do_drain_end(BDRV_DRAIN, base);
45
+
46
+ g_assert_cmpint(base->quiesce_counter, ==, 0);
47
+ g_assert_cmpint(base_s->drain_count, ==, 0);
48
+ g_assert_cmpint(overlay->quiesce_counter, ==, 0);
49
+ g_assert_cmpint(overlay_s->drain_count, ==, 0);
50
+
51
+ bdrv_unref(base);
52
+ blk_unref(blk);
53
+}
54
+
55
int main(int argc, char **argv)
56
{
57
int ret;
58
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv)
59
g_test_add_func("/bdrv-drain/detach/parent_cb", test_detach_by_parent_cb);
60
g_test_add_func("/bdrv-drain/detach/driver_cb", test_detach_by_driver_cb);
61
62
+ g_test_add_func("/bdrv-drain/attach/drain", test_append_to_drained);
63
+
64
ret = g_test_run();
65
qemu_event_destroy(&done_event);
66
return ret;
67
--
26
--
68
2.13.6
27
2.19.1
69
28
70
29
diff view generated by jsdifflib
1
From: Fam Zheng <famz@redhat.com>
1
From: Max Reitz <mreitz@redhat.com>
2
2
3
If we are growing the image and potentially using preallocation for the
3
Just like in qemu_opts_print_help(), print the device name as a caption
4
new area, we need to make sure that no write requests are made to the
4
instead of on every single line, indent all options, add angle brackets
5
"preallocated" area which is [@old_size, @offset), not
5
around types, and align the descriptions after 24 characters. Also,
6
[@offset, offset * 2 - @old_size).
6
separate the descriptions with " - " instead of putting them in
7
parentheses, because that is what we do everywhere else. This does look
8
a bit funny here because basically all bits have the description
9
"on/off", but funny does not mean it is less readable.
7
10
8
Signed-off-by: Fam Zheng <famz@redhat.com>
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
Reviewed-by: Eric Blake <eblake@redhat.com>
12
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
10
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11
---
14
---
12
block/io.c | 3 ++-
15
qdev-monitor.c | 13 +++++++++++--
13
1 file changed, 2 insertions(+), 1 deletion(-)
16
1 file changed, 11 insertions(+), 2 deletions(-)
14
17
15
diff --git a/block/io.c b/block/io.c
18
diff --git a/qdev-monitor.c b/qdev-monitor.c
16
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
17
--- a/block/io.c
20
--- a/qdev-monitor.c
18
+++ b/block/io.c
21
+++ b/qdev-monitor.c
19
@@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset,
22
@@ -XXX,XX +XXX,XX @@ int qdev_device_help(QemuOpts *opts)
23
goto error;
20
}
24
}
21
25
22
bdrv_inc_in_flight(bs);
26
+ if (prop_list) {
23
- tracked_request_begin(&req, bs, offset, new_bytes, BDRV_TRACKED_TRUNCATE);
27
+ out_printf("%s options:\n", driver);
24
+ tracked_request_begin(&req, bs, offset - new_bytes, new_bytes,
28
+ } else {
25
+ BDRV_TRACKED_TRUNCATE);
29
+ out_printf("There are no options for %s.\n", driver);
26
30
+ }
27
/* If we are growing the image and potentially using preallocation for the
31
for (prop = prop_list; prop; prop = prop->next) {
28
* new area, we need to make sure that no write requests are made to it
32
- out_printf("%s.%s=%s", driver, prop->value->name, prop->value->type);
33
+ int len;
34
+ out_printf(" %s=<%s>%n", prop->value->name, prop->value->type, &len);
35
if (prop->value->has_description) {
36
- out_printf(" (%s)\n", prop->value->description);
37
+ if (len < 24) {
38
+ out_printf("%*s", 24 - len, "");
39
+ }
40
+ out_printf(" - %s\n", prop->value->description);
41
} else {
42
out_printf("\n");
43
}
29
--
44
--
30
2.13.6
45
2.19.1
31
46
32
47
diff view generated by jsdifflib
1
From: Fam Zheng <famz@redhat.com>
1
From: Max Reitz <mreitz@redhat.com>
2
2
3
Two problems exist when a write request that enlarges the image (i.e.
3
Just like in qemu_opts_print_help(), print the object name as a caption
4
write beyond EOF) finishes:
4
instead of on every single line, indent all options, add angle brackets
5
around types, and align the descriptions after 24 characters.
5
6
6
1) parent is not notified about size change;
7
Also, indent every object name in the list of available objects.
7
2) dirty bitmap is not resized although we try to set the dirty bits;
8
8
9
Fix them just like how bdrv_co_truncate works.
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
10
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
11
Reported-by: Kevin Wolf <kwolf@redhat.com>
12
Signed-off-by: Fam Zheng <famz@redhat.com>
13
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14
---
12
---
15
block/io.c | 10 +++++++---
13
vl.c | 13 ++++++++++---
16
1 file changed, 7 insertions(+), 3 deletions(-)
14
1 file changed, 10 insertions(+), 3 deletions(-)
17
15
18
diff --git a/block/io.c b/block/io.c
16
diff --git a/vl.c b/vl.c
19
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
20
--- a/block/io.c
18
--- a/vl.c
21
+++ b/block/io.c
19
+++ b/vl.c
22
@@ -XXX,XX +XXX,XX @@
20
@@ -XXX,XX +XXX,XX @@ static bool object_create_initial(const char *type, QemuOpts *opts)
23
21
list = object_class_get_list_sorted(TYPE_USER_CREATABLE, false);
24
static AioWait drain_all_aio_wait;
22
for (l = list; l != NULL; l = l->next) {
25
23
ObjectClass *oc = OBJECT_CLASS(l->data);
26
+static void bdrv_parent_cb_resize(BlockDriverState *bs);
24
- printf("%s\n", object_class_get_name(oc));
27
static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
25
+ printf(" %s\n", object_class_get_name(oc));
28
int64_t offset, int bytes, BdrvRequestFlags flags);
26
}
29
27
g_slist_free(list);
30
@@ -XXX,XX +XXX,XX @@ bdrv_co_write_req_finish(BdrvChild *child, int64_t offset, uint64_t bytes,
28
exit(0);
31
BlockDriverState *bs = child->bs;
29
@@ -XXX,XX +XXX,XX @@ static bool object_create_initial(const char *type, QemuOpts *opts)
32
30
}
33
atomic_inc(&bs->write_gen);
31
34
- bdrv_set_dirty(bs, offset, bytes);
32
str = g_string_new(NULL);
35
33
- g_string_append_printf(str, "%s.%s=%s", type,
36
stat64_max(&bs->wr_highest_offset, offset + bytes);
34
- prop->name, prop->type);
37
35
+ g_string_append_printf(str, " %s=<%s>", prop->name, prop->type);
38
- if (ret == 0) {
36
if (prop->description) {
39
- bs->total_sectors = MAX(bs->total_sectors, end_sector);
37
+ if (str->len < 24) {
40
+ if (ret == 0 &&
38
+ g_string_append_printf(str, "%*s", 24 - (int)str->len, "");
41
+ end_sector > bs->total_sectors) {
39
+ }
42
+ bs->total_sectors = end_sector;
40
g_string_append_printf(str, " - %s", prop->description);
43
+ bdrv_parent_cb_resize(bs);
41
}
44
+ bdrv_dirty_bitmap_truncate(bs, end_sector << BDRV_SECTOR_BITS);
42
g_ptr_array_add(array, g_string_free(str, false));
45
}
43
}
46
+ bdrv_set_dirty(bs, offset, bytes);
44
g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0);
47
}
45
+ if (array->len > 0) {
48
46
+ printf("%s options:\n", type);
49
/*
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]);
52
}
50
--
53
--
51
2.13.6
54
2.19.1
52
55
53
56
diff view generated by jsdifflib
1
From: Fam Zheng <famz@redhat.com>
1
From: Max Reitz <mreitz@redhat.com>
2
2
3
This matches the types used for bytes in the rest parts of block layer.
3
There is no good reason why there should be a newline in this
4
In the case of bdrv_co_truncate, new_bytes can be the image size which
4
description, so remove it.
5
probably doesn't fit in a 32 bit int.
6
5
7
Signed-off-by: Fam Zheng <famz@redhat.com>
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9
---
10
---
10
include/block/block_int.h | 4 ++--
11
vl.c | 2 +-
11
block/io.c | 8 +++++---
12
1 file changed, 1 insertion(+), 1 deletion(-)
12
2 files changed, 7 insertions(+), 5 deletions(-)
13
13
14
diff --git a/include/block/block_int.h b/include/block/block_int.h
14
diff --git a/vl.c b/vl.c
15
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
16
--- a/include/block/block_int.h
16
--- a/vl.c
17
+++ b/include/block/block_int.h
17
+++ b/vl.c
18
@@ -XXX,XX +XXX,XX @@ enum BdrvTrackedRequestType {
18
@@ -XXX,XX +XXX,XX @@ static QemuOptsList qemu_fw_cfg_opts = {
19
typedef struct BdrvTrackedRequest {
19
}, {
20
BlockDriverState *bs;
20
.name = "file",
21
int64_t offset;
21
.type = QEMU_OPT_STRING,
22
- unsigned int bytes;
22
- .help = "Sets the name of the file from which\n"
23
+ uint64_t bytes;
23
+ .help = "Sets the name of the file from which "
24
enum BdrvTrackedRequestType type;
24
"the fw_cfg blob will be loaded",
25
25
}, {
26
bool serialising;
26
.name = "string",
27
int64_t overlap_offset;
28
- unsigned int overlap_bytes;
29
+ uint64_t overlap_bytes;
30
31
QLIST_ENTRY(BdrvTrackedRequest) list;
32
Coroutine *co; /* owner, used for deadlock detection */
33
diff --git a/block/io.c b/block/io.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/block/io.c
36
+++ b/block/io.c
37
@@ -XXX,XX +XXX,XX @@ static void tracked_request_end(BdrvTrackedRequest *req)
38
static void tracked_request_begin(BdrvTrackedRequest *req,
39
BlockDriverState *bs,
40
int64_t offset,
41
- unsigned int bytes,
42
+ uint64_t bytes,
43
enum BdrvTrackedRequestType type)
44
{
45
+ assert(bytes <= INT64_MAX && offset <= INT64_MAX - bytes);
46
+
47
*req = (BdrvTrackedRequest){
48
.bs = bs,
49
.offset = offset,
50
@@ -XXX,XX +XXX,XX @@ static void tracked_request_begin(BdrvTrackedRequest *req,
51
static void mark_request_serialising(BdrvTrackedRequest *req, uint64_t align)
52
{
53
int64_t overlap_offset = req->offset & ~(align - 1);
54
- unsigned int overlap_bytes = ROUND_UP(req->offset + req->bytes, align)
55
+ uint64_t overlap_bytes = ROUND_UP(req->offset + req->bytes, align)
56
- overlap_offset;
57
58
if (!req->serialising) {
59
@@ -XXX,XX +XXX,XX @@ static int bdrv_get_cluster_size(BlockDriverState *bs)
60
}
61
62
static bool tracked_request_overlaps(BdrvTrackedRequest *req,
63
- int64_t offset, unsigned int bytes)
64
+ int64_t offset, uint64_t bytes)
65
{
66
/* aaaa bbbb */
67
if (offset >= req->overlap_offset + req->overlap_bytes) {
68
--
27
--
69
2.13.6
28
2.19.1
70
29
71
30
diff view generated by jsdifflib
1
From: Ari Sundholm <ari@tuxera.com>
1
From: Leonid Bloch <lbloch@janustech.com>
2
2
3
The sector size needs to be large enough to accommodate the data
3
If an expression is used to define DEFAULT_CLUSTER_SIZE, when compiled,
4
structures for the log super block and log write entries. This was
4
it will be embedded as a literal expression in the binary (as the
5
previously not properly checked, which made it possible to cause
5
default value) because it is stringified to mark the size of the default
6
QEMU to badly misbehave.
6
value. Now this is fixed by using a defined number to define this value.
7
7
8
Signed-off-by: Ari Sundholm <ari@tuxera.com>
8
Signed-off-by: Leonid Bloch <lbloch@janustech.com>
9
Reviewed-by: Stefan Weil <sw@weilnetz.de>
9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10
---
11
---
11
block/blklogwrites.c | 5 ++++-
12
block/vdi.c | 4 ++--
12
1 file changed, 4 insertions(+), 1 deletion(-)
13
1 file changed, 2 insertions(+), 2 deletions(-)
13
14
14
diff --git a/block/blklogwrites.c b/block/blklogwrites.c
15
diff --git a/block/vdi.c b/block/vdi.c
15
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
16
--- a/block/blklogwrites.c
17
--- a/block/vdi.c
17
+++ b/block/blklogwrites.c
18
+++ b/block/vdi.c
18
@@ -XXX,XX +XXX,XX @@ static inline uint32_t blk_log_writes_log2(uint32_t value)
19
@@ -XXX,XX +XXX,XX @@
19
20
#define BLOCK_OPT_STATIC "static"
20
static inline bool blk_log_writes_sector_size_valid(uint32_t sector_size)
21
21
{
22
#define SECTOR_SIZE 512
22
- return sector_size < (1ull << 24) && is_power_of_2(sector_size);
23
-#define DEFAULT_CLUSTER_SIZE (1 * MiB)
23
+ return is_power_of_2(sector_size) &&
24
+#define DEFAULT_CLUSTER_SIZE S_1MiB
24
+ sector_size >= sizeof(struct log_write_super) &&
25
25
+ sector_size >= sizeof(struct log_write_entry) &&
26
#if defined(CONFIG_VDI_DEBUG)
26
+ sector_size < (1ull << 24);
27
#define VDI_DEBUG 1
27
}
28
@@ -XXX,XX +XXX,XX @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
28
29
goto fail;
29
static uint64_t blk_log_writes_find_cur_log_sector(BdrvChild *log,
30
} else if (header.block_size != DEFAULT_CLUSTER_SIZE) {
31
error_setg(errp, "unsupported VDI image (block size %" PRIu32
32
- " is not %" PRIu64 ")",
33
+ " is not %" PRIu32 ")",
34
header.block_size, DEFAULT_CLUSTER_SIZE);
35
ret = -ENOTSUP;
36
goto fail;
30
--
37
--
31
2.13.6
38
2.19.1
32
39
33
40
diff view generated by jsdifflib
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
From: Leonid Bloch <lbloch@janustech.com>
2
2
3
Fleecing scheme works as follows: we want a kind of temporary snapshot
3
The lookup table for power-of-two sizes was added in commit 540b8492618eb
4
of active drive A. We create temporary image B, with B->backing = A.
4
for the purpose of having convenient shortcuts for these sizes in cases
5
Then we start backup(sync=none) from A to B. From this point, B reads
5
when the literal number has to be present at compile time, and
6
as point-in-time snapshot of A (A continues to be active drive,
6
expressions as '(1 * KiB)' can not be used. One such case is the
7
accepting guest IO).
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.
8
10
9
This scheme needs some additional synchronization between reads from B
11
Despite its convenience, this table introduced 55 lines of "dumb" code,
10
and backup COW operations, otherwise, the following situation is
12
the purpose and origin of which are obscure without reading the message
11
theoretically possible:
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).
12
19
13
(assume B is qcow2, client is NBD client, reading from B)
20
Signed-off-by: Leonid Bloch <lbloch@janustech.com>
14
15
1. client starts reading and take qcow2 mutex in qcow2_co_preadv, and
16
goes up to l2 table loading (assume cache miss)
17
18
2) guest write => backup COW => qcow2 write =>
19
try to take qcow2 mutex => waiting
20
21
3. l2 table loaded, we see that cluster is UNALLOCATED, go to
22
"case QCOW2_CLUSTER_UNALLOCATED" and unlock mutex before
23
bdrv_co_preadv(bs->backing, ...)
24
25
4) aha, mutex unlocked, backup COW continues, and we finally finish
26
guest write and change cluster in our active disk A
27
28
5. actually, do bdrv_co_preadv(bs->backing, ...) and read
29
_new updated_ data.
30
31
To avoid this, let's make backup writes serializing, to not intersect
32
with reads from B.
33
34
Note: we expand range of handled cases from (sync=none and
35
B->backing = A) to just (A in backing chain of B), to finally allow
36
safe reading from B during backup for all cases when A in backing chain
37
of B, i.e. B formally looks like point-in-time snapshot of A.
38
39
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
40
Reviewed-by: Fam Zheng <famz@redhat.com>
41
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
21
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
42
---
22
---
43
block/backup.c | 20 ++++++++++++++------
23
include/qemu/units.h | 18 ++++++++++++++++++
44
1 file changed, 14 insertions(+), 6 deletions(-)
24
1 file changed, 18 insertions(+)
45
25
46
diff --git a/block/backup.c b/block/backup.c
26
diff --git a/include/qemu/units.h b/include/qemu/units.h
47
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
48
--- a/block/backup.c
28
--- a/include/qemu/units.h
49
+++ b/block/backup.c
29
+++ b/include/qemu/units.h
50
@@ -XXX,XX +XXX,XX @@ typedef struct BackupBlockJob {
30
@@ -XXX,XX +XXX,XX @@
51
HBitmap *copy_bitmap;
31
#define PiB (INT64_C(1) << 50)
52
bool use_copy_range;
32
#define EiB (INT64_C(1) << 60)
53
int64_t copy_range_size;
33
34
+/*
35
+ * The following lookup table is intended to be used when a literal string of
36
+ * the number of bytes is required (for example if it needs to be stringified).
37
+ * It can also be used for generic shortcuts of power-of-two sizes.
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
+ */
54
+
51
+
55
+ bool serialize_target_writes;
52
#define S_1KiB 1024
56
} BackupBlockJob;
53
#define S_2KiB 2048
57
54
#define S_4KiB 4096
58
static const BlockJobDriver backup_job_driver;
59
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn backup_cow_with_bounce_buffer(BackupBlockJob *job,
60
QEMUIOVector qiov;
61
BlockBackend *blk = job->common.blk;
62
int nbytes;
63
+ int read_flags = is_write_notifier ? BDRV_REQ_NO_SERIALISING : 0;
64
+ int write_flags = job->serialize_target_writes ? BDRV_REQ_SERIALISING : 0;
65
66
hbitmap_reset(job->copy_bitmap, start / job->cluster_size, 1);
67
nbytes = MIN(job->cluster_size, job->len - start);
68
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn backup_cow_with_bounce_buffer(BackupBlockJob *job,
69
iov.iov_len = nbytes;
70
qemu_iovec_init_external(&qiov, &iov, 1);
71
72
- ret = blk_co_preadv(blk, start, qiov.size, &qiov,
73
- is_write_notifier ? BDRV_REQ_NO_SERIALISING : 0);
74
+ ret = blk_co_preadv(blk, start, qiov.size, &qiov, read_flags);
75
if (ret < 0) {
76
trace_backup_do_cow_read_fail(job, start, ret);
77
if (error_is_read) {
78
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn backup_cow_with_bounce_buffer(BackupBlockJob *job,
79
80
if (qemu_iovec_is_zero(&qiov)) {
81
ret = blk_co_pwrite_zeroes(job->target, start,
82
- qiov.size, BDRV_REQ_MAY_UNMAP);
83
+ qiov.size, write_flags | BDRV_REQ_MAY_UNMAP);
84
} else {
85
ret = blk_co_pwritev(job->target, start,
86
- qiov.size, &qiov,
87
- job->compress ? BDRV_REQ_WRITE_COMPRESSED : 0);
88
+ qiov.size, &qiov, write_flags |
89
+ (job->compress ? BDRV_REQ_WRITE_COMPRESSED : 0));
90
}
91
if (ret < 0) {
92
trace_backup_do_cow_write_fail(job, start, ret);
93
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn backup_cow_with_offload(BackupBlockJob *job,
94
int nr_clusters;
95
BlockBackend *blk = job->common.blk;
96
int nbytes;
97
+ int read_flags = is_write_notifier ? BDRV_REQ_NO_SERIALISING : 0;
98
+ int write_flags = job->serialize_target_writes ? BDRV_REQ_SERIALISING : 0;
99
100
assert(QEMU_IS_ALIGNED(job->copy_range_size, job->cluster_size));
101
nbytes = MIN(job->copy_range_size, end - start);
102
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn backup_cow_with_offload(BackupBlockJob *job,
103
hbitmap_reset(job->copy_bitmap, start / job->cluster_size,
104
nr_clusters);
105
ret = blk_co_copy_range(blk, start, job->target, start, nbytes,
106
- is_write_notifier ? BDRV_REQ_NO_SERIALISING : 0, 0);
107
+ read_flags, write_flags);
108
if (ret < 0) {
109
trace_backup_do_cow_copy_range_fail(job, start, ret);
110
hbitmap_set(job->copy_bitmap, start / job->cluster_size,
111
@@ -XXX,XX +XXX,XX @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
112
sync_bitmap : NULL;
113
job->compress = compress;
114
115
+ /* Detect image-fleecing (and similar) schemes */
116
+ job->serialize_target_writes = bdrv_chain_contains(target, bs);
117
+
118
/* If there is no backing file on the target, we cannot rely on COW if our
119
* backup cluster size is smaller than the target cluster size. Even for
120
* targets with a backing file, try to avoid COW if possible. */
121
--
55
--
122
2.13.6
56
2.19.1
123
57
124
58
diff view generated by jsdifflib