1
The following changes since commit 9964e96dc9999cf7f7c936ee854a795415d19b60:
1
The following changes since commit 718d7f4f9cf772e5784093d8e6085680a235acdb:
2
2
3
Merge remote-tracking branch 'jasowang/tags/net-pull-request' into staging (2017-05-23 15:01:31 +0100)
3
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging (2017-07-18 13:09:51 +0100)
4
4
5
are available in the git repository at:
5
are available in the git repository at:
6
6
7
7
8
git://repo.or.cz/qemu/kevin.git tags/for-upstream
8
git://repo.or.cz/qemu/kevin.git tags/for-upstream
9
9
10
for you to fetch changes up to 42a48128417b3bfade93d1a4721348cc480e9e50:
10
for you to fetch changes up to 6e6e55f5c2e5b520d6506c2716287ba3b5d1bbc8:
11
11
12
Merge remote-tracking branch 'mreitz/tags/pull-block-2017-05-29-v3' into queue-block (2017-05-29 16:34:27 +0200)
12
qemu-img: Check for backing image if specified during create (2017-07-18 15:27:37 +0200)
13
13
14
----------------------------------------------------------------
14
----------------------------------------------------------------
15
16
Block layer patches
15
Block layer patches
17
16
18
----------------------------------------------------------------
17
----------------------------------------------------------------
19
Alberto Garcia (2):
18
Hervé Poussineau (4):
20
stream: fix crash in stream_start() when block_job_create() fails
19
vvfat: add constants for special values of name[0]
21
qcow2: remove extra local_error variable
20
vvfat: add a constant for bootsector name
21
vvfat: correctly parse non-ASCII short and long file names
22
vvfat: initialize memory after allocating it
22
23
23
Daniel P. Berrange (4):
24
John Snow (2):
24
qemu-img: add support for --object with 'dd' command
25
blockdev: move BDRV_O_NO_BACKING option forward
25
qemu-img: fix --image-opts usage with dd command
26
qemu-img: Check for backing image if specified during create
26
qemu-img: introduce --target-image-opts for 'convert' command
27
qemu-img: copy *key-secret opts when opening newly created files
28
27
29
Eric Blake (1):
28
Kevin Wolf (10):
30
block: Tweak error message related to qemu-img amend
29
commit: Add NULL check for overlay_bs
30
block: Make blk_get_attached_dev_id() public
31
block/qapi: Add qdev device name to query-block
32
block: Make blk_all_next() public
33
block/qapi: Use blk_all_next() for query-block
34
block: List anonymous device BBs in query-block
35
ide: bdrv_attach_dev() for empty CD-ROM
36
scsi-disk: bdrv_attach_dev() for empty CD-ROM
37
qemu-iotests: Test 'info block'
38
qemu-iotests: Test unplug of -device without drive
31
39
32
Fam Zheng (3):
40
Manos Pitsidianakis (2):
33
iotests: 147: Don't test inet6 if not available
41
block: add clock_type field to ThrottleGroup
34
qemu-img: Fix documentation of convert
42
block: remove timer canceling in throttle_config()
35
qemu-img: Fix leakage of options on error
36
43
37
Kevin Wolf (3):
44
Max Reitz (1):
38
qemu-iotests: Test streaming with missing job ID
45
block/vvfat: Fix compiler warning with gcc 7
39
mirror: Drop permissions on s->target on completion
40
Merge remote-tracking branch 'mreitz/tags/pull-block-2017-05-29-v3' into queue-block
41
46
42
Max Reitz (2):
47
Peter Maydell (2):
43
block: Fix backing paths for filenames with colons
48
block/vmdk: Report failures in vmdk_read_cid()
44
block/file-*: *_parse_filename() and colons
49
block/vpc.c: Handle write failures in get_image_offset()
45
50
46
Stephen Bates (1):
51
block.c | 94 ++++----
47
nvme: Add support for Controller Memory Buffers
52
block/block-backend.c | 5 +-
53
block/commit.c | 4 +-
54
block/qapi.c | 20 +-
55
block/throttle-groups.c | 28 +--
56
block/vmdk.c | 44 +++-
57
block/vpc.c | 30 ++-
58
block/vvfat.c | 90 +++++---
59
blockdev.c | 11 +-
60
fsdev/qemu-fsdev-throttle.c | 2 +-
61
hmp.c | 11 +-
62
hw/ide/qdev.c | 3 +
63
hw/scsi/scsi-disk.c | 5 +
64
include/qemu/throttle.h | 2 +-
65
include/sysemu/block-backend.h | 2 +
66
qapi/block-core.json | 9 +-
67
qemu-img-cmds.hx | 4 +-
68
qemu-img.c | 16 +-
69
qemu-img.texi | 9 +-
70
tests/qemu-iotests/067 | 13 ++
71
tests/qemu-iotests/067.out | 40 ++++
72
tests/qemu-iotests/082 | 4 +-
73
tests/qemu-iotests/082.out | 4 +-
74
tests/qemu-iotests/085 | 2 +-
75
tests/qemu-iotests/111.out | 1 +
76
tests/qemu-iotests/139 | 2 +-
77
tests/qemu-iotests/156 | 2 +-
78
tests/qemu-iotests/158 | 2 +-
79
tests/qemu-iotests/186 | 147 +++++++++++++
80
tests/qemu-iotests/186.out | 489 +++++++++++++++++++++++++++++++++++++++++
81
tests/qemu-iotests/189 | 2 +-
82
tests/qemu-iotests/group | 1 +
83
tests/test-throttle.c | 4 +-
84
util/throttle.c | 18 +-
85
34 files changed, 958 insertions(+), 162 deletions(-)
86
create mode 100755 tests/qemu-iotests/186
87
create mode 100644 tests/qemu-iotests/186.out
48
88
49
block.c | 50 +++++++++++++--
50
block/file-posix.c | 17 +-----
51
block/file-win32.c | 12 +---
52
block/mirror.c | 7 ++-
53
block/qcow2-cluster.c | 3 +-
54
block/qcow2.c | 5 +-
55
block/stream.c | 2 +-
56
hw/block/nvme.c | 75 +++++++++++++++++++++--
57
hw/block/nvme.h | 73 ++++++++++++++++++++++
58
include/block/block_int.h | 3 +
59
qemu-img-cmds.hx | 4 +-
60
qemu-img.c | 148 +++++++++++++++++++++++++++++++++++----------
61
qemu-img.texi | 12 +++-
62
tests/qemu-iotests/030 | 4 ++
63
tests/qemu-iotests/030.out | 4 +-
64
tests/qemu-iotests/060.out | 2 +-
65
tests/qemu-iotests/147 | 7 +++
66
17 files changed, 351 insertions(+), 77 deletions(-)
67
diff view generated by jsdifflib
1
This fixes an assertion failure that was triggered by qemu-iotests 129
1
I can't see how overlay_bs could become NULL with the current code, but
2
on some CI host, while the same test case didn't seem to fail on other
2
other code in this function already checks it and we can make Coverity
3
hosts.
3
happy with this check, so let's add it.
4
5
Essentially the problem is that the blk_unref(s->target) in
6
mirror_exit() doesn't necessarily mean that the BlockBackend goes away
7
immediately. It is possible that the job completion was triggered nested
8
in mirror_drain(), which looks like this:
9
10
BlockBackend *target = s->target;
11
blk_ref(target);
12
blk_drain(target);
13
blk_unref(target);
14
15
In this case, the write permissions for s->target are retained until
16
after blk_drain(), which makes removing mirror_top_bs fail for the
17
active commit case (can't have a writable backing file in the chain
18
without the filter driver).
19
20
Explicitly dropping the permissions first means that the additional
21
reference doesn't hurt and the job can complete successfully even if
22
called from the nested blk_drain().
23
4
24
Cc: qemu-stable@nongnu.org
5
Cc: qemu-stable@nongnu.org
25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
6
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
7
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
27
Reviewed-by: Max Reitz <mreitz@redhat.com>
28
---
8
---
29
block/mirror.c | 7 ++++++-
9
block/commit.c | 4 +++-
30
1 file changed, 6 insertions(+), 1 deletion(-)
10
1 file changed, 3 insertions(+), 1 deletion(-)
31
11
32
diff --git a/block/mirror.c b/block/mirror.c
12
diff --git a/block/commit.c b/block/commit.c
33
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
34
--- a/block/mirror.c
14
--- a/block/commit.c
35
+++ b/block/mirror.c
15
+++ b/block/commit.c
36
@@ -XXX,XX +XXX,XX @@ static void mirror_exit(BlockJob *job, void *opaque)
16
@@ -XXX,XX +XXX,XX @@ static void commit_complete(BlockJob *job, void *opaque)
37
17
38
/* Remove target parent that still uses BLK_PERM_WRITE/RESIZE before
18
/* Make sure overlay_bs and top stay around until bdrv_set_backing_hd() */
39
* inserting target_bs at s->to_replace, where we might not be able to get
19
bdrv_ref(top);
40
- * these permissions. */
20
- bdrv_ref(overlay_bs);
41
+ * these permissions.
21
+ if (overlay_bs) {
42
+ *
22
+ bdrv_ref(overlay_bs);
43
+ * Note that blk_unref() alone doesn't necessarily drop permissions because
23
+ }
44
+ * we might be running nested inside mirror_drain(), which takes an extra
24
45
+ * reference, so use an explicit blk_set_perm() first. */
25
/* Remove base node parent that still uses BLK_PERM_WRITE/RESIZE before
46
+ blk_set_perm(s->target, 0, BLK_PERM_ALL, &error_abort);
26
* the normal backing chain can be restored. */
47
blk_unref(s->target);
48
s->target = NULL;
49
50
--
27
--
51
1.8.3.1
28
1.8.3.1
52
29
53
30
diff view generated by jsdifflib
New patch
1
From: Manos Pitsidianakis <el13635@mail.ntua.gr>
1
2
3
Clock type in throttling is currently inferred by the ThrottleTimer's
4
clock type even though it is a per-ThrottleGroup property; it doesn't
5
make sense to have different clock types in the same group. Moving this
6
to a field in ThrottleGroup can simplify some of the throttle functions.
7
8
Signed-off-by: Manos Pitsidianakis <el13635@mail.ntua.gr>
9
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
10
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11
---
12
block/throttle-groups.c | 20 ++++++++++----------
13
fsdev/qemu-fsdev-throttle.c | 2 +-
14
include/qemu/throttle.h | 1 +
15
tests/test-throttle.c | 4 ++--
16
util/throttle.c | 4 +++-
17
5 files changed, 17 insertions(+), 14 deletions(-)
18
19
diff --git a/block/throttle-groups.c b/block/throttle-groups.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/block/throttle-groups.c
22
+++ b/block/throttle-groups.c
23
@@ -XXX,XX +XXX,XX @@ typedef struct ThrottleGroup {
24
QLIST_HEAD(, BlockBackendPublic) head;
25
BlockBackend *tokens[2];
26
bool any_timer_armed[2];
27
+ QEMUClockType clock_type;
28
29
/* These two are protected by the global throttle_groups_lock */
30
unsigned refcount;
31
@@ -XXX,XX +XXX,XX @@ ThrottleState *throttle_group_incref(const char *name)
32
if (!tg) {
33
tg = g_new0(ThrottleGroup, 1);
34
tg->name = g_strdup(name);
35
+ tg->clock_type = QEMU_CLOCK_REALTIME;
36
+
37
+ if (qtest_enabled()) {
38
+ /* For testing block IO throttling only */
39
+ tg->clock_type = QEMU_CLOCK_VIRTUAL;
40
+ }
41
qemu_mutex_init(&tg->lock);
42
throttle_init(&tg->ts);
43
QLIST_INIT(&tg->head);
44
@@ -XXX,XX +XXX,XX @@ static void schedule_next_request(BlockBackend *blk, bool is_write)
45
token = blk;
46
} else {
47
ThrottleTimers *tt = &blk_get_public(token)->throttle_timers;
48
- int64_t now = qemu_clock_get_ns(tt->clock_type);
49
+ int64_t now = qemu_clock_get_ns(tg->clock_type);
50
timer_mod(tt->timers[is_write], now);
51
tg->any_timer_armed[is_write] = true;
52
}
53
@@ -XXX,XX +XXX,XX @@ void throttle_group_config(BlockBackend *blk, ThrottleConfig *cfg)
54
if (timer_pending(tt->timers[1])) {
55
tg->any_timer_armed[1] = false;
56
}
57
- throttle_config(ts, tt, cfg);
58
+ throttle_config(ts, tg->clock_type, tt, cfg);
59
qemu_mutex_unlock(&tg->lock);
60
61
throttle_group_restart_blk(blk);
62
@@ -XXX,XX +XXX,XX @@ void throttle_group_register_blk(BlockBackend *blk, const char *groupname)
63
BlockBackendPublic *blkp = blk_get_public(blk);
64
ThrottleState *ts = throttle_group_incref(groupname);
65
ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts);
66
- int clock_type = QEMU_CLOCK_REALTIME;
67
-
68
- if (qtest_enabled()) {
69
- /* For testing block IO throttling only */
70
- clock_type = QEMU_CLOCK_VIRTUAL;
71
- }
72
-
73
blkp->throttle_state = ts;
74
75
qemu_mutex_lock(&tg->lock);
76
@@ -XXX,XX +XXX,XX @@ void throttle_group_register_blk(BlockBackend *blk, const char *groupname)
77
78
throttle_timers_init(&blkp->throttle_timers,
79
blk_get_aio_context(blk),
80
- clock_type,
81
+ tg->clock_type,
82
read_timer_cb,
83
write_timer_cb,
84
blk);
85
diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c
86
index XXXXXXX..XXXXXXX 100644
87
--- a/fsdev/qemu-fsdev-throttle.c
88
+++ b/fsdev/qemu-fsdev-throttle.c
89
@@ -XXX,XX +XXX,XX @@ void fsdev_throttle_init(FsThrottle *fst)
90
fsdev_throttle_read_timer_cb,
91
fsdev_throttle_write_timer_cb,
92
fst);
93
- throttle_config(&fst->ts, &fst->tt, &fst->cfg);
94
+ throttle_config(&fst->ts, QEMU_CLOCK_REALTIME, &fst->tt, &fst->cfg);
95
qemu_co_queue_init(&fst->throttled_reqs[0]);
96
qemu_co_queue_init(&fst->throttled_reqs[1]);
97
}
98
diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h
99
index XXXXXXX..XXXXXXX 100644
100
--- a/include/qemu/throttle.h
101
+++ b/include/qemu/throttle.h
102
@@ -XXX,XX +XXX,XX @@ bool throttle_enabled(ThrottleConfig *cfg);
103
bool throttle_is_valid(ThrottleConfig *cfg, Error **errp);
104
105
void throttle_config(ThrottleState *ts,
106
+ QEMUClockType clock_type,
107
ThrottleTimers *tt,
108
ThrottleConfig *cfg);
109
110
diff --git a/tests/test-throttle.c b/tests/test-throttle.c
111
index XXXXXXX..XXXXXXX 100644
112
--- a/tests/test-throttle.c
113
+++ b/tests/test-throttle.c
114
@@ -XXX,XX +XXX,XX @@ static void test_config_functions(void)
115
read_timer_cb, write_timer_cb, &ts);
116
/* structure reset by throttle_init previous_leak should be null */
117
g_assert(!ts.previous_leak);
118
- throttle_config(&ts, &tt, &orig_cfg);
119
+ throttle_config(&ts, QEMU_CLOCK_VIRTUAL, &tt, &orig_cfg);
120
121
/* has previous leak been initialized by throttle_config ? */
122
g_assert(ts.previous_leak);
123
@@ -XXX,XX +XXX,XX @@ static bool do_test_accounting(bool is_ops, /* are we testing bps or ops */
124
throttle_init(&ts);
125
throttle_timers_init(&tt, ctx, QEMU_CLOCK_VIRTUAL,
126
read_timer_cb, write_timer_cb, &ts);
127
- throttle_config(&ts, &tt, &cfg);
128
+ throttle_config(&ts, QEMU_CLOCK_VIRTUAL, &tt, &cfg);
129
130
/* account a read */
131
throttle_account(&ts, false, size);
132
diff --git a/util/throttle.c b/util/throttle.c
133
index XXXXXXX..XXXXXXX 100644
134
--- a/util/throttle.c
135
+++ b/util/throttle.c
136
@@ -XXX,XX +XXX,XX @@ static void throttle_cancel_timer(QEMUTimer *timer)
137
/* Used to configure the throttle
138
*
139
* @ts: the throttle state we are working on
140
+ * @clock_type: the group's clock_type
141
* @tt: the throttle timers we use in this aio context
142
* @cfg: the config to set
143
*/
144
void throttle_config(ThrottleState *ts,
145
+ QEMUClockType clock_type,
146
ThrottleTimers *tt,
147
ThrottleConfig *cfg)
148
{
149
@@ -XXX,XX +XXX,XX @@ void throttle_config(ThrottleState *ts,
150
throttle_fix_bucket(&ts->cfg.buckets[i]);
151
}
152
153
- ts->previous_leak = qemu_clock_get_ns(tt->clock_type);
154
+ ts->previous_leak = qemu_clock_get_ns(clock_type);
155
156
for (i = 0; i < 2; i++) {
157
throttle_cancel_timer(tt->timers[i]);
158
--
159
1.8.3.1
160
161
diff view generated by jsdifflib
1
From: "Daniel P. Berrange" <berrange@redhat.com>
1
From: Manos Pitsidianakis <el13635@mail.ntua.gr>
2
2
3
The qemu-img dd/convert commands will create an image file and
3
throttle_config() cancels the timers of the calling BlockBackend. This
4
then try to open it. Historically it has been possible to open
4
doesn't make sense because other BlockBackends in the group remain
5
new files without passing any options. With encrypted files
5
untouched. There's no need to cancel the timers in the one specific
6
though, the *key-secret options are mandatory, so we need to
6
BlockBackend so let's not do that. Throttled requests will run as
7
provide those options when opening the newly created file.
7
scheduled and future requests will follow the new configuration. This
8
also allows a throttle group's configuration to be changed even when it
9
has no members.
8
10
9
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11
Signed-off-by: Manos Pitsidianakis <el13635@mail.ntua.gr>
10
Message-id: 20170515164712.6643-5-berrange@redhat.com
12
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
11
Reviewed-by: Max Reitz <mreitz@redhat.com>
13
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12
Signed-off-by: Max Reitz <mreitz@redhat.com>
13
---
14
---
14
qemu-img.c | 42 +++++++++++++++++++++++++++++++++++++-----
15
block/throttle-groups.c | 10 +---------
15
1 file changed, 37 insertions(+), 5 deletions(-)
16
fsdev/qemu-fsdev-throttle.c | 2 +-
17
include/qemu/throttle.h | 1 -
18
tests/test-throttle.c | 4 ++--
19
util/throttle.c | 14 --------------
20
5 files changed, 4 insertions(+), 27 deletions(-)
16
21
17
diff --git a/qemu-img.c b/qemu-img.c
22
diff --git a/block/throttle-groups.c b/block/throttle-groups.c
18
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
19
--- a/qemu-img.c
24
--- a/block/throttle-groups.c
20
+++ b/qemu-img.c
25
+++ b/block/throttle-groups.c
21
@@ -XXX,XX +XXX,XX @@ static BlockBackend *img_open_opts(const char *optstr,
26
@@ -XXX,XX +XXX,XX @@ void throttle_group_restart_blk(BlockBackend *blk)
27
void throttle_group_config(BlockBackend *blk, ThrottleConfig *cfg)
28
{
29
BlockBackendPublic *blkp = blk_get_public(blk);
30
- ThrottleTimers *tt = &blkp->throttle_timers;
31
ThrottleState *ts = blkp->throttle_state;
32
ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts);
33
qemu_mutex_lock(&tg->lock);
34
- /* throttle_config() cancels the timers */
35
- if (timer_pending(tt->timers[0])) {
36
- tg->any_timer_armed[0] = false;
37
- }
38
- if (timer_pending(tt->timers[1])) {
39
- tg->any_timer_armed[1] = false;
40
- }
41
- throttle_config(ts, tg->clock_type, tt, cfg);
42
+ throttle_config(ts, tg->clock_type, cfg);
43
qemu_mutex_unlock(&tg->lock);
44
45
throttle_group_restart_blk(blk);
46
diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c
47
index XXXXXXX..XXXXXXX 100644
48
--- a/fsdev/qemu-fsdev-throttle.c
49
+++ b/fsdev/qemu-fsdev-throttle.c
50
@@ -XXX,XX +XXX,XX @@ void fsdev_throttle_init(FsThrottle *fst)
51
fsdev_throttle_read_timer_cb,
52
fsdev_throttle_write_timer_cb,
53
fst);
54
- throttle_config(&fst->ts, QEMU_CLOCK_REALTIME, &fst->tt, &fst->cfg);
55
+ throttle_config(&fst->ts, QEMU_CLOCK_REALTIME, &fst->cfg);
56
qemu_co_queue_init(&fst->throttled_reqs[0]);
57
qemu_co_queue_init(&fst->throttled_reqs[1]);
58
}
59
diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h
60
index XXXXXXX..XXXXXXX 100644
61
--- a/include/qemu/throttle.h
62
+++ b/include/qemu/throttle.h
63
@@ -XXX,XX +XXX,XX @@ bool throttle_is_valid(ThrottleConfig *cfg, Error **errp);
64
65
void throttle_config(ThrottleState *ts,
66
QEMUClockType clock_type,
67
- ThrottleTimers *tt,
68
ThrottleConfig *cfg);
69
70
void throttle_get_config(ThrottleState *ts, ThrottleConfig *cfg);
71
diff --git a/tests/test-throttle.c b/tests/test-throttle.c
72
index XXXXXXX..XXXXXXX 100644
73
--- a/tests/test-throttle.c
74
+++ b/tests/test-throttle.c
75
@@ -XXX,XX +XXX,XX @@ static void test_config_functions(void)
76
read_timer_cb, write_timer_cb, &ts);
77
/* structure reset by throttle_init previous_leak should be null */
78
g_assert(!ts.previous_leak);
79
- throttle_config(&ts, QEMU_CLOCK_VIRTUAL, &tt, &orig_cfg);
80
+ throttle_config(&ts, QEMU_CLOCK_VIRTUAL, &orig_cfg);
81
82
/* has previous leak been initialized by throttle_config ? */
83
g_assert(ts.previous_leak);
84
@@ -XXX,XX +XXX,XX @@ static bool do_test_accounting(bool is_ops, /* are we testing bps or ops */
85
throttle_init(&ts);
86
throttle_timers_init(&tt, ctx, QEMU_CLOCK_VIRTUAL,
87
read_timer_cb, write_timer_cb, &ts);
88
- throttle_config(&ts, QEMU_CLOCK_VIRTUAL, &tt, &cfg);
89
+ throttle_config(&ts, QEMU_CLOCK_VIRTUAL, &cfg);
90
91
/* account a read */
92
throttle_account(&ts, false, size);
93
diff --git a/util/throttle.c b/util/throttle.c
94
index XXXXXXX..XXXXXXX 100644
95
--- a/util/throttle.c
96
+++ b/util/throttle.c
97
@@ -XXX,XX +XXX,XX @@ static void throttle_unfix_bucket(LeakyBucket *bkt)
98
}
22
}
99
}
23
100
24
static BlockBackend *img_open_file(const char *filename,
101
-/* take care of canceling a timer */
25
+ QDict *options,
102
-static void throttle_cancel_timer(QEMUTimer *timer)
26
const char *fmt, int flags,
103
-{
27
bool writethrough, bool quiet,
104
- assert(timer != NULL);
28
bool force_share)
105
-
106
- timer_del(timer);
107
-}
108
-
109
/* Used to configure the throttle
110
*
111
* @ts: the throttle state we are working on
112
* @clock_type: the group's clock_type
113
- * @tt: the throttle timers we use in this aio context
114
* @cfg: the config to set
115
*/
116
void throttle_config(ThrottleState *ts,
117
QEMUClockType clock_type,
118
- ThrottleTimers *tt,
119
ThrottleConfig *cfg)
29
{
120
{
30
BlockBackend *blk;
121
int i;
31
Error *local_err = NULL;
122
@@ -XXX,XX +XXX,XX @@ void throttle_config(ThrottleState *ts,
32
- QDict *options = qdict_new();
33
34
+ if (!options) {
35
+ options = qdict_new();
36
+ }
37
if (fmt) {
38
qdict_put_str(options, "driver", fmt);
39
}
123
}
40
@@ -XXX,XX +XXX,XX @@ static BlockBackend *img_open_file(const char *filename,
124
125
ts->previous_leak = qemu_clock_get_ns(clock_type);
126
-
127
- for (i = 0; i < 2; i++) {
128
- throttle_cancel_timer(tt->timers[i]);
129
- }
41
}
130
}
42
131
43
132
/* used to get config
44
+static int img_add_key_secrets(void *opaque,
45
+ const char *name, const char *value,
46
+ Error **errp)
47
+{
48
+ QDict *options = opaque;
49
+
50
+ if (g_str_has_suffix(name, "key-secret")) {
51
+ qdict_put(options, name, qstring_from_str(value));
52
+ }
53
+
54
+ return 0;
55
+}
56
+
57
+static BlockBackend *img_open_new_file(const char *filename,
58
+ QemuOpts *create_opts,
59
+ const char *fmt, int flags,
60
+ bool writethrough, bool quiet,
61
+ bool force_share)
62
+{
63
+ QDict *options = NULL;
64
+
65
+ options = qdict_new();
66
+ qemu_opt_foreach(create_opts, img_add_key_secrets, options, &error_abort);
67
+
68
+ return img_open_file(filename, options, fmt, flags, writethrough, quiet,
69
+ force_share);
70
+}
71
+
72
+
73
static BlockBackend *img_open(bool image_opts,
74
const char *filename,
75
const char *fmt, int flags, bool writethrough,
76
@@ -XXX,XX +XXX,XX @@ static BlockBackend *img_open(bool image_opts,
77
blk = img_open_opts(filename, opts, flags, writethrough, quiet,
78
force_share);
79
} else {
80
- blk = img_open_file(filename, fmt, flags, writethrough, quiet,
81
+ blk = img_open_file(filename, NULL, fmt, flags, writethrough, quiet,
82
force_share);
83
}
84
return blk;
85
@@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv)
86
* That has to wait for bdrv_create to be improved
87
* to allow filenames in option syntax
88
*/
89
- s.target = img_open_file(out_filename, out_fmt, flags,
90
- writethrough, quiet, false);
91
+ s.target = img_open_new_file(out_filename, opts, out_fmt,
92
+ flags, writethrough, quiet, false);
93
}
94
if (!s.target) {
95
ret = -1;
96
@@ -XXX,XX +XXX,XX @@ static int img_dd(int argc, char **argv)
97
* with the bdrv_create() call above which does not
98
* support image-opts style.
99
*/
100
- blk2 = img_open_file(out.filename, out_fmt, BDRV_O_RDWR,
101
+ blk2 = img_open_file(out.filename, NULL, out_fmt, BDRV_O_RDWR,
102
false, false, false);
103
104
if (!blk2) {
105
--
133
--
106
1.8.3.1
134
1.8.3.1
107
135
108
136
diff view generated by jsdifflib
New patch
1
From: Peter Maydell <peter.maydell@linaro.org>
1
2
3
The function vmdk_read_cid() can fail if the read on the underlying
4
block device fails, or if there's a format error in the VMDK file.
5
However its API doesn't provide a mechanism to report these errors,
6
and in some cases we were returning a CID of 0 and in some cases a
7
CID of 0xffffffff, either of which might potentially be valid values.
8
9
Change the function to return 0 on success or a negative errno, and
10
return the CID via a uint32_t* argument. Update the callsites to
11
handle and propagate the error appropriately.
12
13
This fixes in passing a Coverity-spotted issue (CID 1350038) where
14
we weren't checking the return value from sscanf().
15
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Fam Zheng <famz@redhat.com>
18
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
19
---
20
block/vmdk.c | 44 ++++++++++++++++++++++++++++++++------------
21
1 file changed, 32 insertions(+), 12 deletions(-)
22
23
diff --git a/block/vmdk.c b/block/vmdk.c
24
index XXXXXXX..XXXXXXX 100644
25
--- a/block/vmdk.c
26
+++ b/block/vmdk.c
27
@@ -XXX,XX +XXX,XX @@ static void vmdk_free_last_extent(BlockDriverState *bs)
28
s->extents = g_renew(VmdkExtent, s->extents, s->num_extents);
29
}
30
31
-static uint32_t vmdk_read_cid(BlockDriverState *bs, int parent)
32
+/* Return -ve errno, or 0 on success and write CID into *pcid. */
33
+static int vmdk_read_cid(BlockDriverState *bs, int parent, uint32_t *pcid)
34
{
35
char *desc;
36
- uint32_t cid = 0xffffffff;
37
+ uint32_t cid;
38
const char *p_name, *cid_str;
39
size_t cid_str_size;
40
BDRVVmdkState *s = bs->opaque;
41
@@ -XXX,XX +XXX,XX @@ static uint32_t vmdk_read_cid(BlockDriverState *bs, int parent)
42
desc = g_malloc0(DESC_SIZE);
43
ret = bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE);
44
if (ret < 0) {
45
- g_free(desc);
46
- return 0;
47
+ goto out;
48
}
49
50
if (parent) {
51
@@ -XXX,XX +XXX,XX @@ static uint32_t vmdk_read_cid(BlockDriverState *bs, int parent)
52
53
desc[DESC_SIZE - 1] = '\0';
54
p_name = strstr(desc, cid_str);
55
- if (p_name != NULL) {
56
- p_name += cid_str_size;
57
- sscanf(p_name, "%" SCNx32, &cid);
58
+ if (p_name == NULL) {
59
+ ret = -EINVAL;
60
+ goto out;
61
}
62
+ p_name += cid_str_size;
63
+ if (sscanf(p_name, "%" SCNx32, &cid) != 1) {
64
+ ret = -EINVAL;
65
+ goto out;
66
+ }
67
+ *pcid = cid;
68
+ ret = 0;
69
70
+out:
71
g_free(desc);
72
- return cid;
73
+ return ret;
74
}
75
76
static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid)
77
@@ -XXX,XX +XXX,XX @@ static int vmdk_is_cid_valid(BlockDriverState *bs)
78
if (!s->cid_checked && bs->backing) {
79
BlockDriverState *p_bs = bs->backing->bs;
80
81
- cur_pcid = vmdk_read_cid(p_bs, 0);
82
+ if (vmdk_read_cid(p_bs, 0, &cur_pcid) != 0) {
83
+ /* read failure: report as not valid */
84
+ return 0;
85
+ }
86
if (s->parent_cid != cur_pcid) {
87
/* CID not valid */
88
return 0;
89
@@ -XXX,XX +XXX,XX @@ static int vmdk_open(BlockDriverState *bs, QDict *options, int flags,
90
if (ret) {
91
goto fail;
92
}
93
- s->cid = vmdk_read_cid(bs, 0);
94
- s->parent_cid = vmdk_read_cid(bs, 1);
95
+ ret = vmdk_read_cid(bs, 0, &s->cid);
96
+ if (ret) {
97
+ goto fail;
98
+ }
99
+ ret = vmdk_read_cid(bs, 1, &s->parent_cid);
100
+ if (ret) {
101
+ goto fail;
102
+ }
103
qemu_co_mutex_init(&s->lock);
104
105
/* Disable migration when VMDK images are used */
106
@@ -XXX,XX +XXX,XX @@ static int vmdk_create(const char *filename, QemuOpts *opts, Error **errp)
107
ret = -EINVAL;
108
goto exit;
109
}
110
- parent_cid = vmdk_read_cid(blk_bs(blk), 0);
111
+ ret = vmdk_read_cid(blk_bs(blk), 0, &parent_cid);
112
blk_unref(blk);
113
+ if (ret) {
114
+ goto exit;
115
+ }
116
snprintf(parent_desc_line, BUF_SIZE,
117
"parentFileNameHint=\"%s\"", backing_file);
118
}
119
--
120
1.8.3.1
121
122
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Peter Maydell <peter.maydell@linaro.org>
2
2
3
The code that tries to reopen a BlockDriverState in stream_start()
3
Coverity (CID 1355236) points out that get_image_offset() doesn't check that
4
when the creation of a new block job fails crashes because it attempts
4
it actually succeeded in writing the updated block bitmap to the file.
5
to dereference a pointer that is known to be NULL.
5
Check the error return from bdrv_pwrite_sync() and propagate an error
6
response back up to the function which calls get_image_offset() for
7
a write so that it can return the error to its caller.
6
8
7
This is a regression introduced in a170a91fd3eab6155da39e740381867e,
9
get_sector_offset() is only used for reads, but we move it to the
8
likely because the code was copied from stream_complete().
10
same API for consistency.
9
11
10
Cc: qemu-stable@nongnu.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reported-by: Kashyap Chamarthy <kchamart@redhat.com>
12
Signed-off-by: Alberto Garcia <berto@igalia.com>
13
Tested-by: Kashyap Chamarthy <kchamart@redhat.com>
14
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
15
---
14
---
16
block/stream.c | 2 +-
15
block/vpc.c | 30 +++++++++++++++++++++++-------
17
1 file changed, 1 insertion(+), 1 deletion(-)
16
1 file changed, 23 insertions(+), 7 deletions(-)
18
17
19
diff --git a/block/stream.c b/block/stream.c
18
diff --git a/block/vpc.c b/block/vpc.c
20
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
21
--- a/block/stream.c
20
--- a/block/vpc.c
22
+++ b/block/stream.c
21
+++ b/block/vpc.c
23
@@ -XXX,XX +XXX,XX @@ void stream_start(const char *job_id, BlockDriverState *bs,
22
@@ -XXX,XX +XXX,XX @@ static int vpc_reopen_prepare(BDRVReopenState *state,
23
/*
24
* Returns the absolute byte offset of the given sector in the image file.
25
* If the sector is not allocated, -1 is returned instead.
26
+ * If an error occurred trying to write an updated block bitmap back to
27
+ * the file, -2 is returned, and the error value is written to *err.
28
+ * This can only happen for a write operation.
29
*
30
* The parameter write must be 1 if the offset will be used for a write
31
* operation (the block bitmaps is updated then), 0 otherwise.
32
+ * If write is true then err must not be NULL.
33
*/
34
static inline int64_t get_image_offset(BlockDriverState *bs, uint64_t offset,
35
- bool write)
36
+ bool write, int *err)
37
{
38
BDRVVPCState *s = bs->opaque;
39
uint64_t bitmap_offset, block_offset;
40
uint32_t pagetable_index, offset_in_block;
41
42
+ assert(!(write && err == NULL));
43
+
44
pagetable_index = offset / s->block_size;
45
offset_in_block = offset % s->block_size;
46
47
@@ -XXX,XX +XXX,XX @@ static inline int64_t get_image_offset(BlockDriverState *bs, uint64_t offset,
48
correctness. */
49
if (write && (s->last_bitmap_offset != bitmap_offset)) {
50
uint8_t bitmap[s->bitmap_size];
51
+ int r;
52
53
s->last_bitmap_offset = bitmap_offset;
54
memset(bitmap, 0xff, s->bitmap_size);
55
- bdrv_pwrite_sync(bs->file, bitmap_offset, bitmap, s->bitmap_size);
56
+ r = bdrv_pwrite_sync(bs->file, bitmap_offset, bitmap, s->bitmap_size);
57
+ if (r < 0) {
58
+ *err = r;
59
+ return -2;
60
+ }
61
}
62
63
return block_offset;
64
@@ -XXX,XX +XXX,XX @@ static int64_t alloc_block(BlockDriverState* bs, int64_t offset)
65
if (ret < 0)
66
goto fail;
67
68
- return get_image_offset(bs, offset, false);
69
+ return get_image_offset(bs, offset, false, NULL);
24
70
25
fail:
71
fail:
26
if (orig_bs_flags != bdrv_get_flags(bs)) {
72
s->free_data_block_offset -= (s->block_size + s->bitmap_size);
27
- bdrv_reopen(bs, s->bs_flags, NULL);
73
@@ -XXX,XX +XXX,XX @@ vpc_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
28
+ bdrv_reopen(bs, orig_bs_flags, NULL);
74
qemu_iovec_init(&local_qiov, qiov->niov);
29
}
75
30
}
76
while (bytes > 0) {
77
- image_offset = get_image_offset(bs, offset, false);
78
+ image_offset = get_image_offset(bs, offset, false, NULL);
79
n_bytes = MIN(bytes, s->block_size - (offset % s->block_size));
80
81
if (image_offset == -1) {
82
@@ -XXX,XX +XXX,XX @@ vpc_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
83
qemu_iovec_init(&local_qiov, qiov->niov);
84
85
while (bytes > 0) {
86
- image_offset = get_image_offset(bs, offset, true);
87
+ image_offset = get_image_offset(bs, offset, true, &ret);
88
+ if (image_offset == -2) {
89
+ /* Failed to write block bitmap: can't proceed with write */
90
+ goto fail;
91
+ }
92
n_bytes = MIN(bytes, s->block_size - (offset % s->block_size));
93
94
if (image_offset == -1) {
95
@@ -XXX,XX +XXX,XX @@ static int64_t coroutine_fn vpc_co_get_block_status(BlockDriverState *bs,
96
97
qemu_co_mutex_lock(&s->lock);
98
99
- offset = get_image_offset(bs, sector_num << BDRV_SECTOR_BITS, false);
100
+ offset = get_image_offset(bs, sector_num << BDRV_SECTOR_BITS, false, NULL);
101
start = offset;
102
allocated = (offset != -1);
103
*pnum = 0;
104
@@ -XXX,XX +XXX,XX @@ static int64_t coroutine_fn vpc_co_get_block_status(BlockDriverState *bs,
105
if (nb_sectors == 0) {
106
break;
107
}
108
- offset = get_image_offset(bs, sector_num << BDRV_SECTOR_BITS, false);
109
+ offset = get_image_offset(bs, sector_num << BDRV_SECTOR_BITS, false,
110
+ NULL);
111
} while (offset == -1);
112
113
qemu_co_mutex_unlock(&s->lock);
31
--
114
--
32
1.8.3.1
115
1.8.3.1
33
116
34
117
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
Reviewed-by: John Snow <jsnow@redhat.com>
4
---
5
block/block-backend.c | 3 +--
6
include/sysemu/block-backend.h | 1 +
7
2 files changed, 2 insertions(+), 2 deletions(-)
1
8
9
diff --git a/block/block-backend.c b/block/block-backend.c
10
index XXXXXXX..XXXXXXX 100644
11
--- a/block/block-backend.c
12
+++ b/block/block-backend.c
13
@@ -XXX,XX +XXX,XX @@ static const AIOCBInfo block_backend_aiocb_info = {
14
15
static void drive_info_del(DriveInfo *dinfo);
16
static BlockBackend *bdrv_first_blk(BlockDriverState *bs);
17
-static char *blk_get_attached_dev_id(BlockBackend *blk);
18
19
/* All BlockBackends */
20
static QTAILQ_HEAD(, BlockBackend) block_backends =
21
@@ -XXX,XX +XXX,XX @@ void *blk_get_attached_dev(BlockBackend *blk)
22
23
/* Return the qdev ID, or if no ID is assigned the QOM path, of the block
24
* device attached to the BlockBackend. */
25
-static char *blk_get_attached_dev_id(BlockBackend *blk)
26
+char *blk_get_attached_dev_id(BlockBackend *blk)
27
{
28
DeviceState *dev;
29
30
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
31
index XXXXXXX..XXXXXXX 100644
32
--- a/include/sysemu/block-backend.h
33
+++ b/include/sysemu/block-backend.h
34
@@ -XXX,XX +XXX,XX @@ int blk_attach_dev(BlockBackend *blk, DeviceState *dev);
35
void blk_attach_dev_legacy(BlockBackend *blk, void *dev);
36
void blk_detach_dev(BlockBackend *blk, void *dev);
37
void *blk_get_attached_dev(BlockBackend *blk);
38
+char *blk_get_attached_dev_id(BlockBackend *blk);
39
BlockBackend *blk_by_dev(void *dev);
40
BlockBackend *blk_by_qdev_id(const char *id, Error **errp);
41
void blk_set_dev_ops(BlockBackend *blk, const BlockDevOps *ops, void *opaque);
42
--
43
1.8.3.1
44
45
diff view generated by jsdifflib
New patch
1
With -blockdev/-device, users can indirectly create anonymous
2
BlockBackends, while the state of such backends is still of interest. As
3
a preparation for making such BBs visible in query-block, make sure that
4
they can be identified even without a name by adding the ID/QOM path of
5
their qdev device to BlockInfo.
1
6
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
Reviewed-by: John Snow <jsnow@redhat.com>
9
---
10
block/qapi.c | 10 ++++++++++
11
hmp.c | 3 +++
12
qapi/block-core.json | 9 ++++++++-
13
tests/qemu-iotests/067.out | 1 +
14
4 files changed, 22 insertions(+), 1 deletion(-)
15
16
diff --git a/block/qapi.c b/block/qapi.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/block/qapi.c
19
+++ b/block/qapi.c
20
@@ -XXX,XX +XXX,XX @@ static void bdrv_query_info(BlockBackend *blk, BlockInfo **p_info,
21
{
22
BlockInfo *info = g_malloc0(sizeof(*info));
23
BlockDriverState *bs = blk_bs(blk);
24
+ char *qdev;
25
+
26
info->device = g_strdup(blk_name(blk));
27
info->type = g_strdup("unknown");
28
info->locked = blk_dev_is_medium_locked(blk);
29
info->removable = blk_dev_has_removable_media(blk);
30
31
+ qdev = blk_get_attached_dev_id(blk);
32
+ if (qdev && *qdev) {
33
+ info->has_qdev = true;
34
+ info->qdev = qdev;
35
+ } else {
36
+ g_free(qdev);
37
+ }
38
+
39
if (blk_dev_has_tray(blk)) {
40
info->has_tray_open = true;
41
info->tray_open = blk_dev_is_tray_open(blk);
42
diff --git a/hmp.c b/hmp.c
43
index XXXXXXX..XXXXXXX 100644
44
--- a/hmp.c
45
+++ b/hmp.c
46
@@ -XXX,XX +XXX,XX @@ static void print_block_info(Monitor *mon, BlockInfo *info,
47
}
48
49
if (info) {
50
+ if (info->has_qdev) {
51
+ monitor_printf(mon, " Attached to: %s\n", info->qdev);
52
+ }
53
if (info->has_io_status && info->io_status != BLOCK_DEVICE_IO_STATUS_OK) {
54
monitor_printf(mon, " I/O status: %s\n",
55
BlockDeviceIoStatus_lookup[info->io_status]);
56
diff --git a/qapi/block-core.json b/qapi/block-core.json
57
index XXXXXXX..XXXXXXX 100644
58
--- a/qapi/block-core.json
59
+++ b/qapi/block-core.json
60
@@ -XXX,XX +XXX,XX @@
61
#
62
# @device: The device name associated with the virtual device.
63
#
64
+# @qdev: The qdev ID, or if no ID is assigned, the QOM path of the block
65
+# device. (since 2.10)
66
+#
67
# @type: This field is returned only for compatibility reasons, it should
68
# not be used (always returns 'unknown')
69
#
70
@@ -XXX,XX +XXX,XX @@
71
# Since: 0.14.0
72
##
73
{ 'struct': 'BlockInfo',
74
- 'data': {'device': 'str', 'type': 'str', 'removable': 'bool',
75
+ 'data': {'device': 'str', '*qdev': 'str', 'type': 'str', 'removable': 'bool',
76
'locked': 'bool', '*inserted': 'BlockDeviceInfo',
77
'*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus',
78
'*dirty-bitmaps': ['BlockDirtyInfo'] } }
79
@@ -XXX,XX +XXX,XX @@
80
# }
81
# }
82
# },
83
+# "qdev": "ide_disk",
84
# "type":"unknown"
85
# },
86
# {
87
@@ -XXX,XX +XXX,XX @@
88
# "device":"ide1-cd0",
89
# "locked":false,
90
# "removable":true,
91
+# "qdev": "/machine/unattached/device[23]",
92
+# "tray_open": false,
93
# "type":"unknown"
94
# },
95
# {
96
# "device":"floppy0",
97
# "locked":false,
98
# "removable":true,
99
+# "qdev": "/machine/unattached/device[20]",
100
# "type":"unknown"
101
# },
102
# {
103
diff --git a/tests/qemu-iotests/067.out b/tests/qemu-iotests/067.out
104
index XXXXXXX..XXXXXXX 100644
105
--- a/tests/qemu-iotests/067.out
106
+++ b/tests/qemu-iotests/067.out
107
@@ -XXX,XX +XXX,XX @@ Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,if=none,id=disk -device virti
108
"file": "TEST_DIR/t.qcow2",
109
"encryption_key_missing": false
110
},
111
+ "qdev": "/machine/peripheral/virtio0/virtio-backend",
112
"type": "unknown"
113
}
114
]
115
--
116
1.8.3.1
117
118
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
Reviewed-by: John Snow <jsnow@redhat.com>
4
---
5
block/block-backend.c | 2 +-
6
include/sysemu/block-backend.h | 1 +
7
2 files changed, 2 insertions(+), 1 deletion(-)
1
8
9
diff --git a/block/block-backend.c b/block/block-backend.c
10
index XXXXXXX..XXXXXXX 100644
11
--- a/block/block-backend.c
12
+++ b/block/block-backend.c
13
@@ -XXX,XX +XXX,XX @@ void blk_unref(BlockBackend *blk)
14
* Behaves similarly to blk_next() but iterates over all BlockBackends, even the
15
* ones which are hidden (i.e. are not referenced by the monitor).
16
*/
17
-static BlockBackend *blk_all_next(BlockBackend *blk)
18
+BlockBackend *blk_all_next(BlockBackend *blk)
19
{
20
return blk ? QTAILQ_NEXT(blk, link)
21
: QTAILQ_FIRST(&block_backends);
22
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
23
index XXXXXXX..XXXXXXX 100644
24
--- a/include/sysemu/block-backend.h
25
+++ b/include/sysemu/block-backend.h
26
@@ -XXX,XX +XXX,XX @@ void blk_remove_all_bs(void);
27
const char *blk_name(const BlockBackend *blk);
28
BlockBackend *blk_by_name(const char *name);
29
BlockBackend *blk_next(BlockBackend *blk);
30
+BlockBackend *blk_all_next(BlockBackend *blk);
31
bool monitor_add_blk(BlockBackend *blk, const char *name, Error **errp);
32
void monitor_remove_blk(BlockBackend *blk);
33
34
--
35
1.8.3.1
36
37
diff view generated by jsdifflib
New patch
1
This patch replaces the blk_next() loop in query-block by a
2
blk_all_next() one so that we also get access to BlockBackends that
3
aren't owned by the monitor. For now, the next thing we do is check
4
whether each BB has a name, so there is no semantic difference.
1
5
6
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7
Reviewed-by: Eric Blake <eblake@redhat.com>
8
Reviewed-by: John Snow <jsnow@redhat.com>
9
---
10
block/qapi.c | 10 ++++++++--
11
1 file changed, 8 insertions(+), 2 deletions(-)
12
13
diff --git a/block/qapi.c b/block/qapi.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/block/qapi.c
16
+++ b/block/qapi.c
17
@@ -XXX,XX +XXX,XX @@ BlockInfoList *qmp_query_block(Error **errp)
18
BlockBackend *blk;
19
Error *local_err = NULL;
20
21
- for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {
22
- BlockInfoList *info = g_malloc0(sizeof(*info));
23
+ for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) {
24
+ BlockInfoList *info;
25
+
26
+ if (!*blk_name(blk)) {
27
+ continue;
28
+ }
29
+
30
+ info = g_malloc0(sizeof(*info));
31
bdrv_query_info(blk, &info->value, &local_err);
32
if (local_err) {
33
error_propagate(errp, local_err);
34
--
35
1.8.3.1
36
37
diff view generated by jsdifflib
1
From: Eric Blake <eblake@redhat.com>
1
Instead of listing only monitor-owned BlockBackends in query-block, also
2
add those anonymous BlockBackends that are owned by a qdev device and as
3
such under the control of the user.
2
4
3
When converting a 1.1 image down to 0.10, qemu-iotests 060 forces
5
This allows using query-block to inspect BlockBackends for the modern
4
a contrived failure where allocating a cluster used to replace a
6
configuration syntax with -blockdev and -device.
5
zero cluster reads unaligned data. Since it is a zero cluster
6
rather than a data cluster being converted, changing the error
7
message to match our earlier change in 'qcow2: Make distinction
8
between zero cluster types obvious' is worthwhile.
9
7
10
Suggested-by: Max Reitz <mreitz@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11
Signed-off-by: Eric Blake <eblake@redhat.com>
9
Reviewed-by: Eric Blake <eblake@redhat.com>
12
Message-id: 20170508171302.17805-1-eblake@redhat.com
10
Reviewed-by: John Snow <jsnow@redhat.com>
13
[mreitz: Commit message fixes]
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
11
---
16
block/qcow2-cluster.c | 3 ++-
12
block/qapi.c | 2 +-
17
tests/qemu-iotests/060.out | 2 +-
13
hmp.c | 8 ++++----
18
2 files changed, 3 insertions(+), 2 deletions(-)
14
2 files changed, 5 insertions(+), 5 deletions(-)
19
15
20
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
16
diff --git a/block/qapi.c b/block/qapi.c
21
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
22
--- a/block/qcow2-cluster.c
18
--- a/block/qapi.c
23
+++ b/block/qcow2-cluster.c
19
+++ b/block/qapi.c
24
@@ -XXX,XX +XXX,XX @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table,
20
@@ -XXX,XX +XXX,XX @@ BlockInfoList *qmp_query_block(Error **errp)
25
}
21
for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) {
26
22
BlockInfoList *info;
27
if (offset_into_cluster(s, offset)) {
23
28
- qcow2_signal_corruption(bs, true, -1, -1, "Data cluster offset "
24
- if (!*blk_name(blk)) {
29
+ qcow2_signal_corruption(bs, true, -1, -1,
25
+ if (!*blk_name(blk) && !blk_get_attached_dev(blk)) {
30
+ "Cluster allocation offset "
26
continue;
31
"%#" PRIx64 " unaligned (L2 offset: %#"
27
}
32
PRIx64 ", L2 index: %#x)", offset,
28
33
l2_offset, j);
29
diff --git a/hmp.c b/hmp.c
34
diff --git a/tests/qemu-iotests/060.out b/tests/qemu-iotests/060.out
35
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
36
--- a/tests/qemu-iotests/060.out
31
--- a/hmp.c
37
+++ b/tests/qemu-iotests/060.out
32
+++ b/hmp.c
38
@@ -XXX,XX +XXX,XX @@ read failed: Input/output error
33
@@ -XXX,XX +XXX,XX @@ static void print_block_info(Monitor *mon, BlockInfo *info,
39
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
34
40
wrote 65536/65536 bytes at offset 0
35
assert(!info || !info->has_inserted || info->inserted == inserted);
41
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
36
42
-qcow2: Marking image as corrupt: Data cluster offset 0x52a00 unaligned (L2 offset: 0x40000, L2 index: 0); further corruption events will be suppressed
37
- if (info) {
43
+qcow2: Marking image as corrupt: Cluster allocation offset 0x52a00 unaligned (L2 offset: 0x40000, L2 index: 0); further corruption events will be suppressed
38
+ if (info && *info->device) {
44
qemu-img: Error while amending options: Input/output error
39
monitor_printf(mon, "%s", info->device);
45
40
if (inserted && inserted->has_node_name) {
46
=== Testing unaligned reftable entry ===
41
monitor_printf(mon, " (%s)", inserted->node_name);
42
}
43
} else {
44
- assert(inserted);
45
+ assert(info || inserted);
46
monitor_printf(mon, "%s",
47
- inserted->has_node_name
48
- ? inserted->node_name
49
+ inserted && inserted->has_node_name ? inserted->node_name
50
+ : info && info->has_qdev ? info->qdev
51
: "<anonymous>");
52
}
53
47
--
54
--
48
1.8.3.1
55
1.8.3.1
49
56
50
57
diff view generated by jsdifflib
1
From: "Daniel P. Berrange" <berrange@redhat.com>
1
If no drive=... option is passed (for an empty drive), we don't only
2
lack the BlockBackend normally created by parse_drive(), but we also
3
need to manually call blk_attach_dev().
2
4
3
The qemu-img dd command added --image-opts support, but missed
5
IDE does not support hot unplug, but if it did, qdev would take care to
4
the corresponding --object support. This prevented passing
6
call the matching blk_detach_dev() on unplug.
5
secrets (eg auth passwords) needed by certain disk images.
6
7
7
Reviewed-by: Fam Zheng <famz@redhat.com>
8
This fixes at least the bug that such devices didn't show up in
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
9
query-block, and probably some more problems.
10
11
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9
Reviewed-by: Eric Blake <eblake@redhat.com>
12
Reviewed-by: Eric Blake <eblake@redhat.com>
10
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
13
Reviewed-by: John Snow <jsnow@redhat.com>
11
Message-id: 20170515164712.6643-2-berrange@redhat.com
12
Signed-off-by: Max Reitz <mreitz@redhat.com>
13
---
14
---
14
qemu-img.c | 18 ++++++++++++++++++
15
hw/ide/qdev.c | 3 +++
15
1 file changed, 18 insertions(+)
16
1 file changed, 3 insertions(+)
16
17
17
diff --git a/qemu-img.c b/qemu-img.c
18
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
18
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
19
--- a/qemu-img.c
20
--- a/hw/ide/qdev.c
20
+++ b/qemu-img.c
21
+++ b/hw/ide/qdev.c
21
@@ -XXX,XX +XXX,XX @@ static int img_dd(int argc, char **argv)
22
@@ -XXX,XX +XXX,XX @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
22
};
23
IDEBus *bus = DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus);
23
const struct option long_options[] = {
24
IDEState *s = bus->ifs + dev->unit;
24
{ "help", no_argument, 0, 'h'},
25
Error *err = NULL;
25
+ { "object", required_argument, 0, OPTION_OBJECT},
26
+ int ret;
26
{ "image-opts", no_argument, 0, OPTION_IMAGE_OPTS},
27
27
{ "force-share", no_argument, 0, 'U'},
28
if (!dev->conf.blk) {
28
{ 0, 0, 0, 0 }
29
if (kind != IDE_CD) {
29
@@ -XXX,XX +XXX,XX @@ static int img_dd(int argc, char **argv)
30
@@ -XXX,XX +XXX,XX @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
30
case 'U':
31
} else {
31
force_share = true;
32
/* Anonymous BlockBackend for an empty drive */
32
break;
33
dev->conf.blk = blk_new(0, BLK_PERM_ALL);
33
+ case OPTION_OBJECT: {
34
+ ret = blk_attach_dev(dev->conf.blk, &dev->qdev);
34
+ QemuOpts *opts;
35
+ assert(ret == 0);
35
+ opts = qemu_opts_parse_noisily(&qemu_object_opts,
36
}
36
+ optarg, true);
37
+ if (!opts) {
38
+ ret = -1;
39
+ goto out;
40
+ }
41
+ } break;
42
case OPTION_IMAGE_OPTS:
43
image_opts = true;
44
break;
45
@@ -XXX,XX +XXX,XX @@ static int img_dd(int argc, char **argv)
46
ret = -1;
47
goto out;
48
}
37
}
49
+
50
+ if (qemu_opts_foreach(&qemu_object_opts,
51
+ user_creatable_add_opts_foreach,
52
+ NULL, NULL)) {
53
+ ret = -1;
54
+ goto out;
55
+ }
56
+
57
blk1 = img_open(image_opts, in.filename, fmt, 0, false, false,
58
force_share);
59
38
60
--
39
--
61
1.8.3.1
40
1.8.3.1
62
41
63
42
diff view generated by jsdifflib
1
From: "Daniel P. Berrange" <berrange@redhat.com>
1
If no drive=... option is passed (for an empty drive), we don't only
2
lack the BlockBackend normally created by parse_drive(), but we also
3
need to manually call blk_attach_dev().
2
4
3
The --image-opts flag can only be used to affect the parsing
5
This fixes at least a segfault when unplugging such devices, the bug
4
of the source image. The target image has to be specified in
6
that they didn't show up in query-block, and probably some more
5
the traditional style regardless, since it needs to be passed
7
problems.
6
to the bdrv_create() API which does not support the new style
7
opts.
8
8
9
Reviewed-by: Fam Zheng <famz@redhat.com>
9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10
Reviewed-by: Max Reitz <mreitz@redhat.com>
10
Reviewed-by: Eric Blake <eblake@redhat.com>
11
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11
Reviewed-by: John Snow <jsnow@redhat.com>
12
Message-id: 20170515164712.6643-3-berrange@redhat.com
13
Signed-off-by: Max Reitz <mreitz@redhat.com>
14
---
12
---
15
qemu-img.c | 9 +++++++--
13
hw/scsi/scsi-disk.c | 5 +++++
16
1 file changed, 7 insertions(+), 2 deletions(-)
14
1 file changed, 5 insertions(+)
17
15
18
diff --git a/qemu-img.c b/qemu-img.c
16
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
19
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
20
--- a/qemu-img.c
18
--- a/hw/scsi/scsi-disk.c
21
+++ b/qemu-img.c
19
+++ b/hw/scsi/scsi-disk.c
22
@@ -XXX,XX +XXX,XX @@ static int img_dd(int argc, char **argv)
20
@@ -XXX,XX +XXX,XX @@ static void scsi_hd_realize(SCSIDevice *dev, Error **errp)
23
goto out;
21
static void scsi_cd_realize(SCSIDevice *dev, Error **errp)
22
{
23
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
24
+ int ret;
25
26
if (!dev->conf.blk) {
27
+ /* Anonymous BlockBackend for an empty drive. As we put it into
28
+ * dev->conf, qdev takes care of detaching on unplug. */
29
dev->conf.blk = blk_new(0, BLK_PERM_ALL);
30
+ ret = blk_attach_dev(dev->conf.blk, &dev->qdev);
31
+ assert(ret == 0);
24
}
32
}
25
33
26
- blk2 = img_open(image_opts, out.filename, out_fmt, BDRV_O_RDWR,
34
s->qdev.blocksize = 2048;
27
- false, false, false);
28
+ /* TODO, we can't honour --image-opts for the target,
29
+ * since it needs to be given in a format compatible
30
+ * with the bdrv_create() call above which does not
31
+ * support image-opts style.
32
+ */
33
+ blk2 = img_open_file(out.filename, out_fmt, BDRV_O_RDWR,
34
+ false, false, false);
35
36
if (!blk2) {
37
ret = -1;
38
--
35
--
39
1.8.3.1
36
1.8.3.1
40
37
41
38
diff view generated by jsdifflib
1
This adds a small test for the image streaming error path for failing
1
This test makes sure that all block devices show up on 'info block',
2
block_job_create(), which would have found the null pointer dereference
2
with all of the expected information, in different configurations.
3
in commit a170a91f.
4
3
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
6
Reviewed-by: Alberto Garcia <berto@igalia.com>
5
Reviewed-by: Eric Blake <eblake@redhat.com>
7
Reviewed-by: Kashyap Chamarthy <kchamart@redhat.com>
6
Reviewed-by: John Snow <jsnow@redhat.com>
8
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Reviewed-by: Jeff Cody <jcody@redhat.com>
10
---
7
---
11
tests/qemu-iotests/030 | 4 ++++
8
tests/qemu-iotests/186 | 147 ++++++++++++++
12
tests/qemu-iotests/030.out | 4 ++--
9
tests/qemu-iotests/186.out | 489 +++++++++++++++++++++++++++++++++++++++++++++
13
2 files changed, 6 insertions(+), 2 deletions(-)
10
tests/qemu-iotests/group | 1 +
11
3 files changed, 637 insertions(+)
12
create mode 100755 tests/qemu-iotests/186
13
create mode 100644 tests/qemu-iotests/186.out
14
14
15
diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030
15
diff --git a/tests/qemu-iotests/186 b/tests/qemu-iotests/186
16
index XXXXXXX..XXXXXXX 100755
16
new file mode 100755
17
--- a/tests/qemu-iotests/030
17
index XXXXXXX..XXXXXXX
18
+++ b/tests/qemu-iotests/030
18
--- /dev/null
19
@@ -XXX,XX +XXX,XX @@ class TestSingleDrive(iotests.QMPTestCase):
19
+++ b/tests/qemu-iotests/186
20
result = self.vm.qmp('block-stream', device='nonexistent')
20
@@ -XXX,XX +XXX,XX @@
21
self.assert_qmp(result, 'error/class', 'GenericError')
21
+#!/bin/bash
22
22
+#
23
+ def test_job_id_missing(self):
23
+# Test 'info block' with all kinds of configurations
24
+ result = self.vm.qmp('block-stream', device='mid')
24
+#
25
+ self.assert_qmp(result, 'error/class', 'GenericError')
25
+# Copyright (C) 2017 Red Hat, Inc.
26
+
26
+#
27
27
+# This program is free software; you can redistribute it and/or modify
28
class TestParallelOps(iotests.QMPTestCase):
28
+# it under the terms of the GNU General Public License as published by
29
num_ops = 4 # Number of parallel block-stream operations
29
+# the Free Software Foundation; either version 2 of the License, or
30
diff --git a/tests/qemu-iotests/030.out b/tests/qemu-iotests/030.out
30
+# (at your option) any later version.
31
+#
32
+# This program is distributed in the hope that it will be useful,
33
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
34
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35
+# GNU General Public License for more details.
36
+#
37
+# You should have received a copy of the GNU General Public License
38
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
39
+#
40
+
41
+# creator
42
+owner=kwolf@redhat.com
43
+
44
+seq=`basename $0`
45
+echo "QA output created by $seq"
46
+
47
+here=`pwd`
48
+status=1    # failure is the default!
49
+
50
+_cleanup()
51
+{
52
+    _cleanup_test_img
53
+}
54
+trap "_cleanup; exit \$status" 0 1 2 3 15
55
+
56
+# get standard environment, filters and checks
57
+. ./common.rc
58
+. ./common.filter
59
+
60
+_supported_fmt qcow2
61
+_supported_proto file
62
+_supported_os Linux
63
+
64
+if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
65
+ _notrun "Requires a PC machine"
66
+fi
67
+
68
+function do_run_qemu()
69
+{
70
+ echo Testing: "$@"
71
+
72
+ (
73
+ if ! test -t 0; then
74
+ while read cmd; do
75
+ echo $cmd
76
+ done
77
+ fi
78
+ echo quit
79
+ ) | $QEMU -S -nodefaults -display none -device virtio-scsi-pci -monitor stdio "$@"
80
+ echo
81
+}
82
+
83
+function check_info_block()
84
+{
85
+ echo "info block" |
86
+ QEMU_OPTIONS="" do_run_qemu "$@" | _filter_win32 | _filter_hmp |
87
+ _filter_qemu | _filter_generated_node_ids
88
+}
89
+
90
+
91
+size=64M
92
+_make_test_img $size
93
+
94
+removable="floppy ide-cd scsi-cd"
95
+fixed="ide-hd scsi-hd virtio-blk-pci"
96
+
97
+echo
98
+echo "=== Empty drives ==="
99
+echo
100
+
101
+for dev in $removable; do
102
+ check_info_block -device $dev
103
+ check_info_block -device $dev,id=qdev_id
104
+done
105
+
106
+echo
107
+echo "=== -blockdev/-device=<node-name> ==="
108
+echo
109
+
110
+for dev in $fixed $removable; do
111
+ check_info_block -blockdev driver=null-co,node-name=null -device $dev,drive=null
112
+ check_info_block -blockdev driver=null-co,node-name=null -device $dev,drive=null,id=qdev_id
113
+done
114
+
115
+echo
116
+echo "=== -drive if=none/-device=<node-name> ==="
117
+echo
118
+
119
+# This creates two BlockBackends that will show up in 'info block'!
120
+# A monitor-owned one from -drive, and anonymous one from -device
121
+for dev in $fixed $removable; do
122
+ check_info_block -drive if=none,driver=null-co,node-name=null -device $dev,drive=null,id=qdev_id
123
+done
124
+
125
+echo
126
+echo "=== -drive if=none/-device=<bb-name> (with medium) ==="
127
+echo
128
+
129
+for dev in $fixed $removable; do
130
+ check_info_block -drive if=none,driver=null-co,node-name=null -device $dev,drive=none0
131
+ check_info_block -drive if=none,driver=null-co,node-name=null -device $dev,drive=none0,id=qdev_id
132
+done
133
+
134
+echo
135
+echo "=== -drive if=none/-device=<bb-name> (without medium) ==="
136
+echo
137
+
138
+check_info_block -drive if=none
139
+
140
+for dev in $removable; do
141
+ check_info_block -drive if=none -device $dev,drive=none0
142
+ check_info_block -drive if=none -device $dev,drive=none0,id=qdev_id
143
+done
144
+
145
+echo
146
+echo "=== -drive if=... ==="
147
+echo
148
+
149
+check_info_block -drive if=floppy
150
+check_info_block -drive if=floppy,driver=null-co
151
+
152
+check_info_block -drive if=ide,driver=null-co
153
+check_info_block -drive if=ide,media=cdrom
154
+check_info_block -drive if=ide,driver=null-co,media=cdrom
155
+
156
+check_info_block -drive if=scsi,driver=null-co
157
+check_info_block -drive if=scsi,media=cdrom
158
+check_info_block -drive if=scsi,driver=null-co,media=cdrom
159
+
160
+check_info_block -drive if=virtio,driver=null-co
161
+
162
+check_info_block -drive if=pflash,driver=null-co,size=1M
163
+
164
+# success, all done
165
+echo "*** done"
166
+rm -f $seq.full
167
+status=0
168
diff --git a/tests/qemu-iotests/186.out b/tests/qemu-iotests/186.out
169
new file mode 100644
170
index XXXXXXX..XXXXXXX
171
--- /dev/null
172
+++ b/tests/qemu-iotests/186.out
173
@@ -XXX,XX +XXX,XX @@
174
+QA output created by 186
175
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
176
+
177
+=== Empty drives ===
178
+
179
+Testing: -device floppy
180
+QEMU X.Y.Z monitor - type 'help' for more information
181
+(qemu) info block
182
+/machine/peripheral-anon/device[1]: [not inserted]
183
+ Attached to: /machine/peripheral-anon/device[1]
184
+ Removable device: not locked, tray closed
185
+(qemu) quit
186
+
187
+Testing: -device floppy,id=qdev_id
188
+QEMU X.Y.Z monitor - type 'help' for more information
189
+(qemu) info block
190
+qdev_id: [not inserted]
191
+ Attached to: qdev_id
192
+ Removable device: not locked, tray closed
193
+(qemu) quit
194
+
195
+Testing: -device ide-cd
196
+QEMU X.Y.Z monitor - type 'help' for more information
197
+(qemu) info block
198
+/machine/peripheral-anon/device[1]: [not inserted]
199
+ Attached to: /machine/peripheral-anon/device[1]
200
+ Removable device: not locked, tray closed
201
+(qemu) quit
202
+
203
+Testing: -device ide-cd,id=qdev_id
204
+QEMU X.Y.Z monitor - type 'help' for more information
205
+(qemu) info block
206
+qdev_id: [not inserted]
207
+ Attached to: qdev_id
208
+ Removable device: not locked, tray closed
209
+(qemu) quit
210
+
211
+Testing: -device scsi-cd
212
+QEMU X.Y.Z monitor - type 'help' for more information
213
+(qemu) info block
214
+/machine/peripheral-anon/device[1]: [not inserted]
215
+ Attached to: /machine/peripheral-anon/device[1]
216
+ Removable device: not locked, tray closed
217
+(qemu) quit
218
+
219
+Testing: -device scsi-cd,id=qdev_id
220
+QEMU X.Y.Z monitor - type 'help' for more information
221
+(qemu) info block
222
+qdev_id: [not inserted]
223
+ Attached to: qdev_id
224
+ Removable device: not locked, tray closed
225
+(qemu) quit
226
+
227
+
228
+=== -blockdev/-device=<node-name> ===
229
+
230
+Testing: -blockdev driver=null-co,node-name=null -device ide-hd,drive=null
231
+QEMU X.Y.Z monitor - type 'help' for more information
232
+(qemu) info block
233
+null: null-co:// (null-co)
234
+ Attached to: /machine/peripheral-anon/device[1]
235
+ Cache mode: writeback
236
+(qemu) quit
237
+
238
+Testing: -blockdev driver=null-co,node-name=null -device ide-hd,drive=null,id=qdev_id
239
+QEMU X.Y.Z monitor - type 'help' for more information
240
+(qemu) info block
241
+null: null-co:// (null-co)
242
+ Attached to: qdev_id
243
+ Cache mode: writeback
244
+(qemu) quit
245
+
246
+Testing: -blockdev driver=null-co,node-name=null -device scsi-hd,drive=null
247
+QEMU X.Y.Z monitor - type 'help' for more information
248
+(qemu) info block
249
+null: null-co:// (null-co)
250
+ Attached to: /machine/peripheral-anon/device[1]
251
+ Cache mode: writeback
252
+(qemu) quit
253
+
254
+Testing: -blockdev driver=null-co,node-name=null -device scsi-hd,drive=null,id=qdev_id
255
+QEMU X.Y.Z monitor - type 'help' for more information
256
+(qemu) info block
257
+null: null-co:// (null-co)
258
+ Attached to: qdev_id
259
+ Cache mode: writeback
260
+(qemu) quit
261
+
262
+Testing: -blockdev driver=null-co,node-name=null -device virtio-blk-pci,drive=null
263
+QEMU X.Y.Z monitor - type 'help' for more information
264
+(qemu) info block
265
+null: null-co:// (null-co)
266
+ Attached to: /machine/peripheral-anon/device[1]/virtio-backend
267
+ Cache mode: writeback
268
+(qemu) quit
269
+
270
+Testing: -blockdev driver=null-co,node-name=null -device virtio-blk-pci,drive=null,id=qdev_id
271
+QEMU X.Y.Z monitor - type 'help' for more information
272
+(qemu) info block
273
+null: null-co:// (null-co)
274
+ Attached to: /machine/peripheral/qdev_id/virtio-backend
275
+ Cache mode: writeback
276
+(qemu) quit
277
+
278
+Testing: -blockdev driver=null-co,node-name=null -device floppy,drive=null
279
+QEMU X.Y.Z monitor - type 'help' for more information
280
+(qemu) info block
281
+null: null-co:// (null-co)
282
+ Attached to: /machine/peripheral-anon/device[1]
283
+ Removable device: not locked, tray closed
284
+ Cache mode: writeback
285
+(qemu) quit
286
+
287
+Testing: -blockdev driver=null-co,node-name=null -device floppy,drive=null,id=qdev_id
288
+QEMU X.Y.Z monitor - type 'help' for more information
289
+(qemu) info block
290
+null: null-co:// (null-co)
291
+ Attached to: qdev_id
292
+ Removable device: not locked, tray closed
293
+ Cache mode: writeback
294
+(qemu) quit
295
+
296
+Testing: -blockdev driver=null-co,node-name=null -device ide-cd,drive=null
297
+QEMU X.Y.Z monitor - type 'help' for more information
298
+(qemu) info block
299
+null: null-co:// (null-co)
300
+ Attached to: /machine/peripheral-anon/device[1]
301
+ Removable device: not locked, tray closed
302
+ Cache mode: writeback
303
+(qemu) quit
304
+
305
+Testing: -blockdev driver=null-co,node-name=null -device ide-cd,drive=null,id=qdev_id
306
+QEMU X.Y.Z monitor - type 'help' for more information
307
+(qemu) info block
308
+null: null-co:// (null-co)
309
+ Attached to: qdev_id
310
+ Removable device: not locked, tray closed
311
+ Cache mode: writeback
312
+(qemu) quit
313
+
314
+Testing: -blockdev driver=null-co,node-name=null -device scsi-cd,drive=null
315
+QEMU X.Y.Z monitor - type 'help' for more information
316
+(qemu) info block
317
+null: null-co:// (null-co)
318
+ Attached to: /machine/peripheral-anon/device[1]
319
+ Removable device: not locked, tray closed
320
+ Cache mode: writeback
321
+(qemu) quit
322
+
323
+Testing: -blockdev driver=null-co,node-name=null -device scsi-cd,drive=null,id=qdev_id
324
+QEMU X.Y.Z monitor - type 'help' for more information
325
+(qemu) info block
326
+null: null-co:// (null-co)
327
+ Attached to: qdev_id
328
+ Removable device: not locked, tray closed
329
+ Cache mode: writeback
330
+(qemu) quit
331
+
332
+
333
+=== -drive if=none/-device=<node-name> ===
334
+
335
+Testing: -drive if=none,driver=null-co,node-name=null -device ide-hd,drive=null,id=qdev_id
336
+QEMU X.Y.Z monitor - type 'help' for more information
337
+(qemu) info block
338
+none0 (null): null-co:// (null-co)
339
+ Removable device: not locked, tray closed
340
+ Cache mode: writeback
341
+
342
+null: null-co:// (null-co)
343
+ Attached to: qdev_id
344
+ Cache mode: writeback
345
+(qemu) quit
346
+
347
+Testing: -drive if=none,driver=null-co,node-name=null -device scsi-hd,drive=null,id=qdev_id
348
+QEMU X.Y.Z monitor - type 'help' for more information
349
+(qemu) info block
350
+none0 (null): null-co:// (null-co)
351
+ Removable device: not locked, tray closed
352
+ Cache mode: writeback
353
+
354
+null: null-co:// (null-co)
355
+ Attached to: qdev_id
356
+ Cache mode: writeback
357
+(qemu) quit
358
+
359
+Testing: -drive if=none,driver=null-co,node-name=null -device virtio-blk-pci,drive=null,id=qdev_id
360
+QEMU X.Y.Z monitor - type 'help' for more information
361
+(qemu) info block
362
+none0 (null): null-co:// (null-co)
363
+ Removable device: not locked, tray closed
364
+ Cache mode: writeback
365
+
366
+null: null-co:// (null-co)
367
+ Attached to: /machine/peripheral/qdev_id/virtio-backend
368
+ Cache mode: writeback
369
+(qemu) quit
370
+
371
+Testing: -drive if=none,driver=null-co,node-name=null -device floppy,drive=null,id=qdev_id
372
+QEMU X.Y.Z monitor - type 'help' for more information
373
+(qemu) info block
374
+none0 (null): null-co:// (null-co)
375
+ Removable device: not locked, tray closed
376
+ Cache mode: writeback
377
+
378
+null: null-co:// (null-co)
379
+ Attached to: qdev_id
380
+ Removable device: not locked, tray closed
381
+ Cache mode: writeback
382
+(qemu) quit
383
+
384
+Testing: -drive if=none,driver=null-co,node-name=null -device ide-cd,drive=null,id=qdev_id
385
+QEMU X.Y.Z monitor - type 'help' for more information
386
+(qemu) info block
387
+none0 (null): null-co:// (null-co)
388
+ Removable device: not locked, tray closed
389
+ Cache mode: writeback
390
+
391
+null: null-co:// (null-co)
392
+ Attached to: qdev_id
393
+ Removable device: not locked, tray closed
394
+ Cache mode: writeback
395
+(qemu) quit
396
+
397
+Testing: -drive if=none,driver=null-co,node-name=null -device scsi-cd,drive=null,id=qdev_id
398
+QEMU X.Y.Z monitor - type 'help' for more information
399
+(qemu) info block
400
+none0 (null): null-co:// (null-co)
401
+ Removable device: not locked, tray closed
402
+ Cache mode: writeback
403
+
404
+null: null-co:// (null-co)
405
+ Attached to: qdev_id
406
+ Removable device: not locked, tray closed
407
+ Cache mode: writeback
408
+(qemu) quit
409
+
410
+
411
+=== -drive if=none/-device=<bb-name> (with medium) ===
412
+
413
+Testing: -drive if=none,driver=null-co,node-name=null -device ide-hd,drive=none0
414
+QEMU X.Y.Z monitor - type 'help' for more information
415
+(qemu) info block
416
+none0 (null): null-co:// (null-co)
417
+ Attached to: /machine/peripheral-anon/device[1]
418
+ Cache mode: writeback
419
+(qemu) quit
420
+
421
+Testing: -drive if=none,driver=null-co,node-name=null -device ide-hd,drive=none0,id=qdev_id
422
+QEMU X.Y.Z monitor - type 'help' for more information
423
+(qemu) info block
424
+none0 (null): null-co:// (null-co)
425
+ Attached to: qdev_id
426
+ Cache mode: writeback
427
+(qemu) quit
428
+
429
+Testing: -drive if=none,driver=null-co,node-name=null -device scsi-hd,drive=none0
430
+QEMU X.Y.Z monitor - type 'help' for more information
431
+(qemu) info block
432
+none0 (null): null-co:// (null-co)
433
+ Attached to: /machine/peripheral-anon/device[1]
434
+ Cache mode: writeback
435
+(qemu) quit
436
+
437
+Testing: -drive if=none,driver=null-co,node-name=null -device scsi-hd,drive=none0,id=qdev_id
438
+QEMU X.Y.Z monitor - type 'help' for more information
439
+(qemu) info block
440
+none0 (null): null-co:// (null-co)
441
+ Attached to: qdev_id
442
+ Cache mode: writeback
443
+(qemu) quit
444
+
445
+Testing: -drive if=none,driver=null-co,node-name=null -device virtio-blk-pci,drive=none0
446
+QEMU X.Y.Z monitor - type 'help' for more information
447
+(qemu) info block
448
+none0 (null): null-co:// (null-co)
449
+ Attached to: /machine/peripheral-anon/device[1]/virtio-backend
450
+ Cache mode: writeback
451
+(qemu) quit
452
+
453
+Testing: -drive if=none,driver=null-co,node-name=null -device virtio-blk-pci,drive=none0,id=qdev_id
454
+QEMU X.Y.Z monitor - type 'help' for more information
455
+(qemu) info block
456
+none0 (null): null-co:// (null-co)
457
+ Attached to: /machine/peripheral/qdev_id/virtio-backend
458
+ Cache mode: writeback
459
+(qemu) quit
460
+
461
+Testing: -drive if=none,driver=null-co,node-name=null -device floppy,drive=none0
462
+QEMU X.Y.Z monitor - type 'help' for more information
463
+(qemu) info block
464
+none0 (null): null-co:// (null-co)
465
+ Attached to: /machine/peripheral-anon/device[1]
466
+ Removable device: not locked, tray closed
467
+ Cache mode: writeback
468
+(qemu) quit
469
+
470
+Testing: -drive if=none,driver=null-co,node-name=null -device floppy,drive=none0,id=qdev_id
471
+QEMU X.Y.Z monitor - type 'help' for more information
472
+(qemu) info block
473
+none0 (null): null-co:// (null-co)
474
+ Attached to: qdev_id
475
+ Removable device: not locked, tray closed
476
+ Cache mode: writeback
477
+(qemu) quit
478
+
479
+Testing: -drive if=none,driver=null-co,node-name=null -device ide-cd,drive=none0
480
+QEMU X.Y.Z monitor - type 'help' for more information
481
+(qemu) info block
482
+none0 (null): null-co:// (null-co)
483
+ Attached to: /machine/peripheral-anon/device[1]
484
+ Removable device: not locked, tray closed
485
+ Cache mode: writeback
486
+(qemu) quit
487
+
488
+Testing: -drive if=none,driver=null-co,node-name=null -device ide-cd,drive=none0,id=qdev_id
489
+QEMU X.Y.Z monitor - type 'help' for more information
490
+(qemu) info block
491
+none0 (null): null-co:// (null-co)
492
+ Attached to: qdev_id
493
+ Removable device: not locked, tray closed
494
+ Cache mode: writeback
495
+(qemu) quit
496
+
497
+Testing: -drive if=none,driver=null-co,node-name=null -device scsi-cd,drive=none0
498
+QEMU X.Y.Z monitor - type 'help' for more information
499
+(qemu) info block
500
+none0 (null): null-co:// (null-co)
501
+ Attached to: /machine/peripheral-anon/device[1]
502
+ Removable device: not locked, tray closed
503
+ Cache mode: writeback
504
+(qemu) quit
505
+
506
+Testing: -drive if=none,driver=null-co,node-name=null -device scsi-cd,drive=none0,id=qdev_id
507
+QEMU X.Y.Z monitor - type 'help' for more information
508
+(qemu) info block
509
+none0 (null): null-co:// (null-co)
510
+ Attached to: qdev_id
511
+ Removable device: not locked, tray closed
512
+ Cache mode: writeback
513
+(qemu) quit
514
+
515
+
516
+=== -drive if=none/-device=<bb-name> (without medium) ===
517
+
518
+Testing: -drive if=none
519
+QEMU X.Y.Z monitor - type 'help' for more information
520
+(qemu) info block
521
+none0: [not inserted]
522
+ Removable device: not locked, tray closed
523
+(qemu) quit
524
+
525
+Testing: -drive if=none -device floppy,drive=none0
526
+QEMU X.Y.Z monitor - type 'help' for more information
527
+(qemu) info block
528
+none0: [not inserted]
529
+ Attached to: /machine/peripheral-anon/device[1]
530
+ Removable device: not locked, tray closed
531
+(qemu) quit
532
+
533
+Testing: -drive if=none -device floppy,drive=none0,id=qdev_id
534
+QEMU X.Y.Z monitor - type 'help' for more information
535
+(qemu) info block
536
+none0: [not inserted]
537
+ Attached to: qdev_id
538
+ Removable device: not locked, tray closed
539
+(qemu) quit
540
+
541
+Testing: -drive if=none -device ide-cd,drive=none0
542
+QEMU X.Y.Z monitor - type 'help' for more information
543
+(qemu) info block
544
+none0: [not inserted]
545
+ Attached to: /machine/peripheral-anon/device[1]
546
+ Removable device: not locked, tray closed
547
+(qemu) quit
548
+
549
+Testing: -drive if=none -device ide-cd,drive=none0,id=qdev_id
550
+QEMU X.Y.Z monitor - type 'help' for more information
551
+(qemu) info block
552
+none0: [not inserted]
553
+ Attached to: qdev_id
554
+ Removable device: not locked, tray closed
555
+(qemu) quit
556
+
557
+Testing: -drive if=none -device scsi-cd,drive=none0
558
+QEMU X.Y.Z monitor - type 'help' for more information
559
+(qemu) info block
560
+none0: [not inserted]
561
+ Attached to: /machine/peripheral-anon/device[1]
562
+ Removable device: not locked, tray closed
563
+(qemu) quit
564
+
565
+Testing: -drive if=none -device scsi-cd,drive=none0,id=qdev_id
566
+QEMU X.Y.Z monitor - type 'help' for more information
567
+(qemu) info block
568
+none0: [not inserted]
569
+ Attached to: qdev_id
570
+ Removable device: not locked, tray closed
571
+(qemu) quit
572
+
573
+
574
+=== -drive if=... ===
575
+
576
+Testing: -drive if=floppy
577
+QEMU X.Y.Z monitor - type 'help' for more information
578
+(qemu) info block
579
+floppy0: [not inserted]
580
+ Attached to: /machine/unattached/device[17]
581
+ Removable device: not locked, tray closed
582
+(qemu) quit
583
+
584
+Testing: -drive if=floppy,driver=null-co
585
+QEMU X.Y.Z monitor - type 'help' for more information
586
+(qemu) info block
587
+floppy0 (NODE_NAME): null-co:// (null-co)
588
+ Attached to: /machine/unattached/device[17]
589
+ Removable device: not locked, tray closed
590
+ Cache mode: writeback
591
+(qemu) quit
592
+
593
+Testing: -drive if=ide,driver=null-co
594
+QEMU X.Y.Z monitor - type 'help' for more information
595
+(qemu) info block
596
+ide0-hd0 (NODE_NAME): null-co:// (null-co)
597
+ Attached to: /machine/unattached/device[18]
598
+ Cache mode: writeback
599
+(qemu) quit
600
+
601
+Testing: -drive if=ide,media=cdrom
602
+QEMU X.Y.Z monitor - type 'help' for more information
603
+(qemu) info block
604
+ide0-cd0: [not inserted]
605
+ Attached to: /machine/unattached/device[18]
606
+ Removable device: not locked, tray closed
607
+(qemu) quit
608
+
609
+Testing: -drive if=ide,driver=null-co,media=cdrom
610
+QEMU X.Y.Z monitor - type 'help' for more information
611
+(qemu) info block
612
+ide0-cd0 (NODE_NAME): null-co:// (null-co, read-only)
613
+ Attached to: /machine/unattached/device[18]
614
+ Removable device: not locked, tray closed
615
+ Cache mode: writeback
616
+(qemu) quit
617
+
618
+warning: qemu-system-x86_64: -drive if=scsi,driver=null-co: bus=0,unit=0 is deprecated with this machine type
619
+Testing: -drive if=scsi,driver=null-co
620
+QEMU X.Y.Z monitor - type 'help' for more information
621
+(qemu) info block
622
+scsi0-hd0 (NODE_NAME): null-co:// (null-co)
623
+ Attached to: /machine/unattached/device[27]/scsi.0/legacy[0]
624
+ Cache mode: writeback
625
+(qemu) quit
626
+
627
+warning: qemu-system-x86_64: -drive if=scsi,media=cdrom: bus=0,unit=0 is deprecated with this machine type
628
+Testing: -drive if=scsi,media=cdrom
629
+QEMU X.Y.Z monitor - type 'help' for more information
630
+(qemu) info block
631
+scsi0-cd0: [not inserted]
632
+ Attached to: /machine/unattached/device[27]/scsi.0/legacy[0]
633
+ Removable device: not locked, tray closed
634
+(qemu) quit
635
+
636
+warning: qemu-system-x86_64: -drive if=scsi,driver=null-co,media=cdrom: bus=0,unit=0 is deprecated with this machine type
637
+Testing: -drive if=scsi,driver=null-co,media=cdrom
638
+QEMU X.Y.Z monitor - type 'help' for more information
639
+(qemu) info block
640
+scsi0-cd0 (NODE_NAME): null-co:// (null-co, read-only)
641
+ Attached to: /machine/unattached/device[27]/scsi.0/legacy[0]
642
+ Removable device: not locked, tray closed
643
+ Cache mode: writeback
644
+(qemu) quit
645
+
646
+Testing: -drive if=virtio,driver=null-co
647
+QEMU X.Y.Z monitor - type 'help' for more information
648
+(qemu) info block
649
+virtio0 (NODE_NAME): null-co:// (null-co)
650
+ Attached to: /machine/peripheral-anon/device[1]/virtio-backend
651
+ Cache mode: writeback
652
+(qemu) quit
653
+
654
+Testing: -drive if=pflash,driver=null-co,size=1M
655
+QEMU X.Y.Z monitor - type 'help' for more information
656
+(qemu) info block
657
+pflash0 (NODE_NAME): json:{"driver": "null-co", "size": "1M"} (null-co)
658
+ Attached to: /machine/unattached/device[2]
659
+ Cache mode: writeback
660
+(qemu) quit
661
+
662
+*** done
663
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
31
index XXXXXXX..XXXXXXX 100644
664
index XXXXXXX..XXXXXXX 100644
32
--- a/tests/qemu-iotests/030.out
665
--- a/tests/qemu-iotests/group
33
+++ b/tests/qemu-iotests/030.out
666
+++ b/tests/qemu-iotests/group
34
@@ -XXX,XX +XXX,XX @@
667
@@ -XXX,XX +XXX,XX @@
35
-......................
668
182 rw auto quick
36
+.......................
669
183 rw auto migration
37
----------------------------------------------------------------------
670
185 rw auto
38
-Ran 22 tests
671
+186 rw auto
39
+Ran 23 tests
672
188 rw auto quick
40
673
189 rw auto quick
41
OK
42
--
674
--
43
1.8.3.1
675
1.8.3.1
44
676
45
677
diff view generated by jsdifflib
1
From: Max Reitz <mreitz@redhat.com>
1
This caused an assertion failure until recently because the BlockBackend
2
would be detached on unplug, but was in fact never attached in the first
3
place. Add a regression test.
2
4
3
The file drivers' *_parse_filename() implementations just strip the
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4
optional protocol prefix off the filename. However, for e.g.
6
Reviewed-by: Eric Blake <eblake@redhat.com>
5
"file:foo:bar", this would lead to "foo:bar" being stored as the BDS's
7
Reviewed-by: John Snow <jsnow@redhat.com>
6
filename which looks like it should be managed using the "foo" protocol.
8
---
7
This is especially troublesome if you then try to resolve a backing
9
tests/qemu-iotests/067 | 13 +++++++++++++
8
filename based on "foo:bar".
10
tests/qemu-iotests/067.out | 39 +++++++++++++++++++++++++++++++++++++++
11
2 files changed, 52 insertions(+)
9
12
10
This issue can only occur if the stripped part is a relative filename
13
diff --git a/tests/qemu-iotests/067 b/tests/qemu-iotests/067
11
("file:/foo:bar" will be shortened to "/foo:bar" and having a slash
14
index XXXXXXX..XXXXXXX 100755
12
before the first colon means that "/foo" is not recognized as a protocol
15
--- a/tests/qemu-iotests/067
13
part). Therefore, we can easily fix it by prepending "./" to such
16
+++ b/tests/qemu-iotests/067
14
filenames.
17
@@ -XXX,XX +XXX,XX @@ run_qemu <<EOF
15
18
{ "execute": "quit" }
16
Before this patch:
19
EOF
17
$ ./qemu-img create -f qcow2 backing.qcow2 64M
20
18
Formatting 'backing.qcow2', fmt=qcow2 size=67108864 encryption=off
21
+echo
19
cluster_size=65536 lazy_refcounts=off refcount_bits=16
22
+echo === Empty drive with -device and device_del ===
20
$ ./qemu-img create -f qcow2 -b backing.qcow2 file:top:image.qcow2
23
+echo
21
Formatting 'file:top:image.qcow2', fmt=qcow2 size=67108864
24
+
22
backing_file=backing.qcow2 encryption=off cluster_size=65536
25
+run_qemu -device virtio-scsi-pci -device scsi-cd,id=cd0 <<EOF
23
lazy_refcounts=off refcount_bits=16
26
+{ "execute": "qmp_capabilities" }
24
$ ./qemu-io file:top:image.qcow2
27
+{ "execute": "query-block" }
25
can't open device file:top:image.qcow2: Could not open backing file:
28
+{ "execute": "device_del", "arguments": { "id": "cd0" } }
26
Unknown protocol 'top'
29
+{ "execute": "system_reset" }
27
30
+{ "execute": "query-block" }
28
After this patch:
31
+{ "execute": "quit" }
29
$ ./qemu-io file:top:image.qcow2
32
+EOF
30
[no error]
33
+
31
34
# success, all done
32
Signed-off-by: Max Reitz <mreitz@redhat.com>
35
echo "*** done"
33
Message-id: 20170522195217.12991-3-mreitz@redhat.com
36
rm -f $seq.full
34
Reviewed-by: Eric Blake <eblake@redhat.com>
37
diff --git a/tests/qemu-iotests/067.out b/tests/qemu-iotests/067.out
35
Signed-off-by: Max Reitz <mreitz@redhat.com>
36
---
37
block.c | 35 +++++++++++++++++++++++++++++++++++
38
block/file-posix.c | 17 +++--------------
39
block/file-win32.c | 12 ++----------
40
include/block/block_int.h | 3 +++
41
4 files changed, 43 insertions(+), 24 deletions(-)
42
43
diff --git a/block.c b/block.c
44
index XXXXXXX..XXXXXXX 100644
38
index XXXXXXX..XXXXXXX 100644
45
--- a/block.c
39
--- a/tests/qemu-iotests/067.out
46
+++ b/block.c
40
+++ b/tests/qemu-iotests/067.out
47
@@ -XXX,XX +XXX,XX @@ void path_combine(char *dest, int dest_size,
41
@@ -XXX,XX +XXX,XX @@ Testing:
42
"return": {
48
}
43
}
49
}
44
}
50
45
+
51
+/*
46
+=== Empty drive with -device and device_del ===
52
+ * Helper function for bdrv_parse_filename() implementations to remove optional
47
+
53
+ * protocol prefixes (especially "file:") from a filename and for putting the
48
+Testing: -device virtio-scsi-pci -device scsi-cd,id=cd0
54
+ * stripped filename into the options QDict if there is such a prefix.
55
+ */
56
+void bdrv_parse_filename_strip_prefix(const char *filename, const char *prefix,
57
+ QDict *options)
58
+{
49
+{
59
+ if (strstart(filename, prefix, &filename)) {
50
+ QMP_VERSION
60
+ /* Stripping the explicit protocol prefix may result in a protocol
51
+}
61
+ * prefix being (wrongly) detected (if the filename contains a colon) */
52
+{
62
+ if (path_has_protocol(filename)) {
53
+ "return": {
63
+ QString *fat_filename;
64
+
65
+ /* This means there is some colon before the first slash; therefore,
66
+ * this cannot be an absolute path */
67
+ assert(!path_is_absolute(filename));
68
+
69
+ /* And we can thus fix the protocol detection issue by prefixing it
70
+ * by "./" */
71
+ fat_filename = qstring_from_str("./");
72
+ qstring_append(fat_filename, filename);
73
+
74
+ assert(!path_has_protocol(qstring_get_str(fat_filename)));
75
+
76
+ qdict_put(options, "filename", fat_filename);
77
+ } else {
78
+ /* If no protocol prefix was detected, we can use the shortened
79
+ * filename as-is */
80
+ qdict_put_str(options, "filename", filename);
81
+ }
82
+ }
54
+ }
83
+}
55
+}
84
+
56
+{
85
+
57
+ "return": [
86
/* Returns whether the image file is opened as read-only. Note that this can
58
+ {
87
* return false and writing to the image file is still not possible because the
59
+ "device": "",
88
* image is inactivated. */
60
+ "locked": false,
89
diff --git a/block/file-posix.c b/block/file-posix.c
61
+ "removable": true,
90
index XXXXXXX..XXXXXXX 100644
62
+ "qdev": "cd0",
91
--- a/block/file-posix.c
63
+ "tray_open": false,
92
+++ b/block/file-posix.c
64
+ "type": "unknown"
93
@@ -XXX,XX +XXX,XX @@ static void raw_parse_flags(int bdrv_flags, int *open_flags)
65
+ }
94
static void raw_parse_filename(const char *filename, QDict *options,
66
+ ]
95
Error **errp)
67
+}
96
{
68
+{
97
- /* The filename does not have to be prefixed by the protocol name, since
69
+ "return": {
98
- * "file" is the default protocol; therefore, the return value of this
70
+ }
99
- * function call can be ignored. */
71
+}
100
- strstart(filename, "file:", &filename);
72
+{
101
-
73
+ "return": {
102
- qdict_put_str(options, "filename", filename);
74
+ }
103
+ bdrv_parse_filename_strip_prefix(filename, "file:", options);
75
+}
104
}
76
+{
105
77
+ "return": [
106
static QemuOptsList raw_runtime_opts = {
78
+ ]
107
@@ -XXX,XX +XXX,XX @@ static int check_hdev_writable(BDRVRawState *s)
79
+}
108
static void hdev_parse_filename(const char *filename, QDict *options,
80
+{
109
Error **errp)
81
+ "return": {
110
{
82
+ }
111
- /* The prefix is optional, just as for "file". */
83
+}
112
- strstart(filename, "host_device:", &filename);
84
*** done
113
-
114
- qdict_put_str(options, "filename", filename);
115
+ bdrv_parse_filename_strip_prefix(filename, "host_device:", options);
116
}
117
118
static bool hdev_is_sg(BlockDriverState *bs)
119
@@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_host_device = {
120
static void cdrom_parse_filename(const char *filename, QDict *options,
121
Error **errp)
122
{
123
- /* The prefix is optional, just as for "file". */
124
- strstart(filename, "host_cdrom:", &filename);
125
-
126
- qdict_put_str(options, "filename", filename);
127
+ bdrv_parse_filename_strip_prefix(filename, "host_cdrom:", options);
128
}
129
#endif
130
131
diff --git a/block/file-win32.c b/block/file-win32.c
132
index XXXXXXX..XXXXXXX 100644
133
--- a/block/file-win32.c
134
+++ b/block/file-win32.c
135
@@ -XXX,XX +XXX,XX @@ static void raw_parse_flags(int flags, bool use_aio, int *access_flags,
136
static void raw_parse_filename(const char *filename, QDict *options,
137
Error **errp)
138
{
139
- /* The filename does not have to be prefixed by the protocol name, since
140
- * "file" is the default protocol; therefore, the return value of this
141
- * function call can be ignored. */
142
- strstart(filename, "file:", &filename);
143
-
144
- qdict_put_str(options, "filename", filename);
145
+ bdrv_parse_filename_strip_prefix(filename, "file:", options);
146
}
147
148
static QemuOptsList raw_runtime_opts = {
149
@@ -XXX,XX +XXX,XX @@ static int hdev_probe_device(const char *filename)
150
static void hdev_parse_filename(const char *filename, QDict *options,
151
Error **errp)
152
{
153
- /* The prefix is optional, just as for "file". */
154
- strstart(filename, "host_device:", &filename);
155
-
156
- qdict_put_str(options, "filename", filename);
157
+ bdrv_parse_filename_strip_prefix(filename, "host_device:", options);
158
}
159
160
static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
161
diff --git a/include/block/block_int.h b/include/block/block_int.h
162
index XXXXXXX..XXXXXXX 100644
163
--- a/include/block/block_int.h
164
+++ b/include/block/block_int.h
165
@@ -XXX,XX +XXX,XX @@ int get_tmp_filename(char *filename, int size);
166
BlockDriver *bdrv_probe_all(const uint8_t *buf, int buf_size,
167
const char *filename);
168
169
+void bdrv_parse_filename_strip_prefix(const char *filename, const char *prefix,
170
+ QDict *options);
171
+
172
173
/**
174
* bdrv_add_before_write_notifier:
175
--
85
--
176
1.8.3.1
86
1.8.3.1
177
87
178
88
diff view generated by jsdifflib
1
From: Stephen Bates <sbates@raithlin.com>
1
From: Hervé Poussineau <hpoussin@reactos.org>
2
2
3
Implement NVMe Controller Memory Buffers (CMBs) which were added in
3
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
4
version 1.2 of the NVMe Specification. This patch adds an optional
5
argument (cmb_size_mb) which indicates the size of the CMB (in
6
MB). Currently only the Submission Queue Support (SQS) is enabled
7
which aligns with the current Linux driver for NVMe.
8
9
Signed-off-by: Stephen Bates <sbates@raithlin.com>
10
Acked-by: Keith Busch <keith.busch@intel.com>
11
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12
---
5
---
13
hw/block/nvme.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
6
block/vvfat.c | 17 +++++++++++------
14
hw/block/nvme.h | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
7
1 file changed, 11 insertions(+), 6 deletions(-)
15
2 files changed, 144 insertions(+), 4 deletions(-)
16
8
17
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
9
diff --git a/block/vvfat.c b/block/vvfat.c
18
index XXXXXXX..XXXXXXX 100644
10
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/block/nvme.c
11
--- a/block/vvfat.c
20
+++ b/hw/block/nvme.c
12
+++ b/block/vvfat.c
21
@@ -XXX,XX +XXX,XX @@
13
@@ -XXX,XX +XXX,XX @@ void nonono(const char* file, int line, const char* msg) {
22
*/
14
23
15
#endif
24
/**
16
25
- * Reference Specs: http://www.nvmexpress.org, 1.1, 1.0e
17
+#define DIR_DELETED 0xe5
26
+ * Reference Specs: http://www.nvmexpress.org, 1.2, 1.1, 1.0e
18
+#define DIR_KANJI DIR_DELETED
27
*
19
+#define DIR_KANJI_FAKE 0x05
28
* http://www.nvmexpress.org/resources/
20
+#define DIR_FREE 0x00
29
*/
30
@@ -XXX,XX +XXX,XX @@
31
/**
32
* Usage: add options:
33
* -drive file=<file>,if=none,id=<drive_id>
34
- * -device nvme,drive=<drive_id>,serial=<serial>,id=<id[optional]>
35
+ * -device nvme,drive=<drive_id>,serial=<serial>,id=<id[optional]>, \
36
+ * cmb_size_mb=<cmb_size_mb[optional]>
37
+ *
38
+ * Note cmb_size_mb denotes size of CMB in MB. CMB is assumed to be at
39
+ * offset 0 in BAR2 and supports SQS only for now.
40
*/
41
42
#include "qemu/osdep.h"
43
@@ -XXX,XX +XXX,XX @@
44
45
static void nvme_process_sq(void *opaque);
46
47
+static void nvme_addr_read(NvmeCtrl *n, hwaddr addr, void *buf, int size)
48
+{
49
+ if (n->cmbsz && addr >= n->ctrl_mem.addr &&
50
+ addr < (n->ctrl_mem.addr + int128_get64(n->ctrl_mem.size))) {
51
+ memcpy(buf, (void *)&n->cmbuf[addr - n->ctrl_mem.addr], size);
52
+ } else {
53
+ pci_dma_read(&n->parent_obj, addr, buf, size);
54
+ }
55
+}
56
+
21
+
57
static int nvme_check_sqid(NvmeCtrl *n, uint16_t sqid)
22
/* dynamic array functions */
23
typedef struct array_t {
24
char* pointer;
25
@@ -XXX,XX +XXX,XX @@ static direntry_t *create_long_filename(BDRVVVFATState *s, const char *filename)
26
27
static char is_free(const direntry_t* direntry)
58
{
28
{
59
return sqid < n->num_queues && n->sq[sqid] != NULL ? 0 : -1;
29
- return direntry->name[0]==0xe5 || direntry->name[0]==0x00;
60
@@ -XXX,XX +XXX,XX @@ static void nvme_process_sq(void *opaque)
30
+ return direntry->name[0] == DIR_DELETED || direntry->name[0] == DIR_FREE;
61
31
}
62
while (!(nvme_sq_empty(sq) || QTAILQ_EMPTY(&sq->req_list))) {
32
63
addr = sq->dma_addr + sq->head * n->sqe_size;
33
static char is_volume_label(const direntry_t* direntry)
64
- pci_dma_read(&n->parent_obj, addr, (void *)&cmd, sizeof(cmd));
34
@@ -XXX,XX +XXX,XX @@ static char is_short_name(const direntry_t* direntry)
65
+ nvme_addr_read(n, addr, (void *)&cmd, sizeof(cmd));
35
66
nvme_inc_sq_head(sq);
36
static char is_directory(const direntry_t* direntry)
67
68
req = QTAILQ_FIRST(&sq->req_list);
69
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps nvme_mmio_ops = {
70
},
71
};
72
73
+static void nvme_cmb_write(void *opaque, hwaddr addr, uint64_t data,
74
+ unsigned size)
75
+{
76
+ NvmeCtrl *n = (NvmeCtrl *)opaque;
77
+ memcpy(&n->cmbuf[addr], &data, size);
78
+}
79
+
80
+static uint64_t nvme_cmb_read(void *opaque, hwaddr addr, unsigned size)
81
+{
82
+ uint64_t val;
83
+ NvmeCtrl *n = (NvmeCtrl *)opaque;
84
+
85
+ memcpy(&val, &n->cmbuf[addr], size);
86
+ return val;
87
+}
88
+
89
+static const MemoryRegionOps nvme_cmb_ops = {
90
+ .read = nvme_cmb_read,
91
+ .write = nvme_cmb_write,
92
+ .endianness = DEVICE_LITTLE_ENDIAN,
93
+ .impl = {
94
+ .min_access_size = 2,
95
+ .max_access_size = 8,
96
+ },
97
+};
98
+
99
static int nvme_init(PCIDevice *pci_dev)
100
{
37
{
101
NvmeCtrl *n = NVME(pci_dev);
38
- return direntry->attributes & 0x10 && direntry->name[0] != 0xe5;
102
@@ -XXX,XX +XXX,XX @@ static int nvme_init(PCIDevice *pci_dev)
39
+ return direntry->attributes & 0x10 && direntry->name[0] != DIR_DELETED;
103
NVME_CAP_SET_CSS(n->bar.cap, 1);
104
NVME_CAP_SET_MPSMAX(n->bar.cap, 4);
105
106
- n->bar.vs = 0x00010100;
107
+ n->bar.vs = 0x00010200;
108
n->bar.intmc = n->bar.intms = 0;
109
110
+ if (n->cmb_size_mb) {
111
+
112
+ NVME_CMBLOC_SET_BIR(n->bar.cmbloc, 2);
113
+ NVME_CMBLOC_SET_OFST(n->bar.cmbloc, 0);
114
+
115
+ NVME_CMBSZ_SET_SQS(n->bar.cmbsz, 1);
116
+ NVME_CMBSZ_SET_CQS(n->bar.cmbsz, 0);
117
+ NVME_CMBSZ_SET_LISTS(n->bar.cmbsz, 0);
118
+ NVME_CMBSZ_SET_RDS(n->bar.cmbsz, 0);
119
+ NVME_CMBSZ_SET_WDS(n->bar.cmbsz, 0);
120
+ NVME_CMBSZ_SET_SZU(n->bar.cmbsz, 2); /* MBs */
121
+ NVME_CMBSZ_SET_SZ(n->bar.cmbsz, n->cmb_size_mb);
122
+
123
+ n->cmbuf = g_malloc0(NVME_CMBSZ_GETSIZE(n->bar.cmbsz));
124
+ memory_region_init_io(&n->ctrl_mem, OBJECT(n), &nvme_cmb_ops, n,
125
+ "nvme-cmb", NVME_CMBSZ_GETSIZE(n->bar.cmbsz));
126
+ pci_register_bar(&n->parent_obj, NVME_CMBLOC_BIR(n->bar.cmbloc),
127
+ PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64 |
128
+ PCI_BASE_ADDRESS_MEM_PREFETCH, &n->ctrl_mem);
129
+
130
+ }
131
+
132
for (i = 0; i < n->num_namespaces; i++) {
133
NvmeNamespace *ns = &n->namespaces[i];
134
NvmeIdNs *id_ns = &ns->id_ns;
135
@@ -XXX,XX +XXX,XX @@ static void nvme_exit(PCIDevice *pci_dev)
136
g_free(n->namespaces);
137
g_free(n->cq);
138
g_free(n->sq);
139
+ if (n->cmbsz) {
140
+ memory_region_unref(&n->ctrl_mem);
141
+ }
142
+
143
msix_uninit_exclusive_bar(pci_dev);
144
}
40
}
145
41
146
static Property nvme_props[] = {
42
static inline char is_dot(const direntry_t* direntry)
147
DEFINE_BLOCK_PROPERTIES(NvmeCtrl, conf),
43
@@ -XXX,XX +XXX,XX @@ static direntry_t *create_short_filename(BDRVVVFATState *s,
148
DEFINE_PROP_STRING("serial", NvmeCtrl, serial),
44
}
149
+ DEFINE_PROP_UINT32("cmb_size_mb", NvmeCtrl, cmb_size_mb, 0),
45
}
150
DEFINE_PROP_END_OF_LIST(),
46
151
};
47
- if (entry->name[0] == 0xe5) {
152
48
- entry->name[0] = 0x05;
153
diff --git a/hw/block/nvme.h b/hw/block/nvme.h
49
+ if (entry->name[0] == DIR_KANJI) {
154
index XXXXXXX..XXXXXXX 100644
50
+ entry->name[0] = DIR_KANJI_FAKE;
155
--- a/hw/block/nvme.h
51
}
156
+++ b/hw/block/nvme.h
52
157
@@ -XXX,XX +XXX,XX @@ typedef struct NvmeBar {
53
/* numeric-tail generation */
158
uint32_t aqa;
54
@@ -XXX,XX +XXX,XX @@ static int parse_short_name(BDRVVVFATState* s,
159
uint64_t asq;
55
} else
160
uint64_t acq;
56
lfn->name[i + j + 1] = '\0';
161
+ uint32_t cmbloc;
57
162
+ uint32_t cmbsz;
58
- if (lfn->name[0] == 0x05) {
163
} NvmeBar;
59
- lfn->name[0] = 0xe5;
164
60
+ if (lfn->name[0] == DIR_KANJI_FAKE) {
165
enum NvmeCapShift {
61
+ lfn->name[0] = DIR_KANJI;
166
@@ -XXX,XX +XXX,XX @@ enum NvmeAqaMask {
62
}
167
#define NVME_AQA_ASQS(aqa) ((aqa >> AQA_ASQS_SHIFT) & AQA_ASQS_MASK)
63
lfn->len = strlen((char*)lfn->name);
168
#define NVME_AQA_ACQS(aqa) ((aqa >> AQA_ACQS_SHIFT) & AQA_ACQS_MASK)
64
169
170
+enum NvmeCmblocShift {
171
+ CMBLOC_BIR_SHIFT = 0,
172
+ CMBLOC_OFST_SHIFT = 12,
173
+};
174
+
175
+enum NvmeCmblocMask {
176
+ CMBLOC_BIR_MASK = 0x7,
177
+ CMBLOC_OFST_MASK = 0xfffff,
178
+};
179
+
180
+#define NVME_CMBLOC_BIR(cmbloc) ((cmbloc >> CMBLOC_BIR_SHIFT) & \
181
+ CMBLOC_BIR_MASK)
182
+#define NVME_CMBLOC_OFST(cmbloc)((cmbloc >> CMBLOC_OFST_SHIFT) & \
183
+ CMBLOC_OFST_MASK)
184
+
185
+#define NVME_CMBLOC_SET_BIR(cmbloc, val) \
186
+ (cmbloc |= (uint64_t)(val & CMBLOC_BIR_MASK) << CMBLOC_BIR_SHIFT)
187
+#define NVME_CMBLOC_SET_OFST(cmbloc, val) \
188
+ (cmbloc |= (uint64_t)(val & CMBLOC_OFST_MASK) << CMBLOC_OFST_SHIFT)
189
+
190
+enum NvmeCmbszShift {
191
+ CMBSZ_SQS_SHIFT = 0,
192
+ CMBSZ_CQS_SHIFT = 1,
193
+ CMBSZ_LISTS_SHIFT = 2,
194
+ CMBSZ_RDS_SHIFT = 3,
195
+ CMBSZ_WDS_SHIFT = 4,
196
+ CMBSZ_SZU_SHIFT = 8,
197
+ CMBSZ_SZ_SHIFT = 12,
198
+};
199
+
200
+enum NvmeCmbszMask {
201
+ CMBSZ_SQS_MASK = 0x1,
202
+ CMBSZ_CQS_MASK = 0x1,
203
+ CMBSZ_LISTS_MASK = 0x1,
204
+ CMBSZ_RDS_MASK = 0x1,
205
+ CMBSZ_WDS_MASK = 0x1,
206
+ CMBSZ_SZU_MASK = 0xf,
207
+ CMBSZ_SZ_MASK = 0xfffff,
208
+};
209
+
210
+#define NVME_CMBSZ_SQS(cmbsz) ((cmbsz >> CMBSZ_SQS_SHIFT) & CMBSZ_SQS_MASK)
211
+#define NVME_CMBSZ_CQS(cmbsz) ((cmbsz >> CMBSZ_CQS_SHIFT) & CMBSZ_CQS_MASK)
212
+#define NVME_CMBSZ_LISTS(cmbsz)((cmbsz >> CMBSZ_LISTS_SHIFT) & CMBSZ_LISTS_MASK)
213
+#define NVME_CMBSZ_RDS(cmbsz) ((cmbsz >> CMBSZ_RDS_SHIFT) & CMBSZ_RDS_MASK)
214
+#define NVME_CMBSZ_WDS(cmbsz) ((cmbsz >> CMBSZ_WDS_SHIFT) & CMBSZ_WDS_MASK)
215
+#define NVME_CMBSZ_SZU(cmbsz) ((cmbsz >> CMBSZ_SZU_SHIFT) & CMBSZ_SZU_MASK)
216
+#define NVME_CMBSZ_SZ(cmbsz) ((cmbsz >> CMBSZ_SZ_SHIFT) & CMBSZ_SZ_MASK)
217
+
218
+#define NVME_CMBSZ_SET_SQS(cmbsz, val) \
219
+ (cmbsz |= (uint64_t)(val & CMBSZ_SQS_MASK) << CMBSZ_SQS_SHIFT)
220
+#define NVME_CMBSZ_SET_CQS(cmbsz, val) \
221
+ (cmbsz |= (uint64_t)(val & CMBSZ_CQS_MASK) << CMBSZ_CQS_SHIFT)
222
+#define NVME_CMBSZ_SET_LISTS(cmbsz, val) \
223
+ (cmbsz |= (uint64_t)(val & CMBSZ_LISTS_MASK) << CMBSZ_LISTS_SHIFT)
224
+#define NVME_CMBSZ_SET_RDS(cmbsz, val) \
225
+ (cmbsz |= (uint64_t)(val & CMBSZ_RDS_MASK) << CMBSZ_RDS_SHIFT)
226
+#define NVME_CMBSZ_SET_WDS(cmbsz, val) \
227
+ (cmbsz |= (uint64_t)(val & CMBSZ_WDS_MASK) << CMBSZ_WDS_SHIFT)
228
+#define NVME_CMBSZ_SET_SZU(cmbsz, val) \
229
+ (cmbsz |= (uint64_t)(val & CMBSZ_SZU_MASK) << CMBSZ_SZU_SHIFT)
230
+#define NVME_CMBSZ_SET_SZ(cmbsz, val) \
231
+ (cmbsz |= (uint64_t)(val & CMBSZ_SZ_MASK) << CMBSZ_SZ_SHIFT)
232
+
233
+#define NVME_CMBSZ_GETSIZE(cmbsz) \
234
+ (NVME_CMBSZ_SZ(cmbsz) * (1 << (12 + 4 * NVME_CMBSZ_SZU(cmbsz))))
235
+
236
typedef struct NvmeCmd {
237
uint8_t opcode;
238
uint8_t fuse;
239
@@ -XXX,XX +XXX,XX @@ typedef struct NvmeNamespace {
240
typedef struct NvmeCtrl {
241
PCIDevice parent_obj;
242
MemoryRegion iomem;
243
+ MemoryRegion ctrl_mem;
244
NvmeBar bar;
245
BlockConf conf;
246
247
@@ -XXX,XX +XXX,XX @@ typedef struct NvmeCtrl {
248
uint32_t num_queues;
249
uint32_t max_q_ents;
250
uint64_t ns_size;
251
+ uint32_t cmb_size_mb;
252
+ uint32_t cmbsz;
253
+ uint32_t cmbloc;
254
+ uint8_t *cmbuf;
255
256
char *serial;
257
NvmeNamespace *namespaces;
258
--
65
--
259
1.8.3.1
66
1.8.3.1
260
67
261
68
diff view generated by jsdifflib
1
From: Fam Zheng <famz@redhat.com>
1
From: Hervé Poussineau <hpoussin@reactos.org>
2
2
3
It got lost in commit a8d16f9ca "qemu-img: Update documentation for -U".
3
Also add links to related compatibility problems.
4
4
5
Reported-by: Max Reitz <mreitz@redhat.com>
5
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
6
Signed-off-by: Fam Zheng <famz@redhat.com>
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Message-id: 20170515103551.31313-1-famz@redhat.com
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
Reviewed-by: Eric Blake <eblake@redhat.com>
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
---
8
---
11
qemu-img-cmds.hx | 4 ++--
9
block/vvfat.c | 8 +++++++-
12
1 file changed, 2 insertions(+), 2 deletions(-)
10
1 file changed, 7 insertions(+), 1 deletion(-)
13
11
14
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
12
diff --git a/block/vvfat.c b/block/vvfat.c
15
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
16
--- a/qemu-img-cmds.hx
14
--- a/block/vvfat.c
17
+++ b/qemu-img-cmds.hx
15
+++ b/block/vvfat.c
18
@@ -XXX,XX +XXX,XX @@ STEXI
16
@@ -XXX,XX +XXX,XX @@ void nonono(const char* file, int line, const char* msg) {
19
ETEXI
17
20
18
#endif
21
DEF("convert", img_convert,
19
22
- "convert [--object objectdef] [--image-opts] [-U] [-c] [-p] [-q] [-n] [-f fmt] [-t cache] [-T src_cache] [-O output_fmt] [-o options] [-s snapshot_id_or_name] [-l snapshot_param] [-S sparse_size] [-m num_coroutines] [-W] filename [filename2 [...]] output_filename")
20
+/* bootsector OEM name. see related compatibility problems at:
23
+ "convert [--object objectdef] [--image-opts] [-U] [-c] [-p] [-q] [-n] [-f fmt] [-t cache] [-T src_cache] [-O output_fmt] [-B backing_file] [-o options] [-s snapshot_id_or_name] [-l snapshot_param] [-S sparse_size] [-m num_coroutines] [-W] filename [filename2 [...]] output_filename")
21
+ * https://jdebp.eu/FGA/volume-boot-block-oem-name-field.html
24
STEXI
22
+ * http://seasip.info/Misc/oemid.html
25
-@item convert [--object @var{objectdef}] [--image-opts] [-U] [-c] [-p] [-q] [-n] [-f @var{fmt}] [-t @var{cache}] [-T @var{src_cache}] [-O @var{output_fmt}] [-o @var{options}] [-s @var{snapshot_id_or_name}] [-l @var{snapshot_param}] [-S @var{sparse_size}] [-m @var{num_coroutines}] [-W] @var{filename} [@var{filename2} [...]] @var{output_filename}
23
+ */
26
+@item convert [--object @var{objectdef}] [--image-opts] [-U] [-c] [-p] [-q] [-n] [-f @var{fmt}] [-t @var{cache}] [-T @var{src_cache}] [-O @var{output_fmt}] [-B @var{backing_file}] [-o @var{options}] [-s @var{snapshot_id_or_name}] [-l @var{snapshot_param}] [-S @var{sparse_size}] [-m @var{num_coroutines}] [-W] @var{filename} [@var{filename2} [...]] @var{output_filename}
24
+#define BOOTSECTOR_OEM_NAME "MSWIN4.1"
27
ETEXI
25
+
28
26
#define DIR_DELETED 0xe5
29
DEF("dd", img_dd,
27
#define DIR_KANJI DIR_DELETED
28
#define DIR_KANJI_FAKE 0x05
29
@@ -XXX,XX +XXX,XX @@ static int init_directories(BDRVVVFATState* s,
30
bootsector->jump[0]=0xeb;
31
bootsector->jump[1]=0x3e;
32
bootsector->jump[2]=0x90;
33
- memcpy(bootsector->name, "MSWIN4.1", 8);
34
+ memcpy(bootsector->name, BOOTSECTOR_OEM_NAME, 8);
35
bootsector->sector_size=cpu_to_le16(0x200);
36
bootsector->sectors_per_cluster=s->sectors_per_cluster;
37
bootsector->reserved_sectors=cpu_to_le16(1);
30
--
38
--
31
1.8.3.1
39
1.8.3.1
32
40
33
41
diff view generated by jsdifflib
1
From: Fam Zheng <famz@redhat.com>
1
From: Hervé Poussineau <hpoussin@reactos.org>
2
2
3
This is the case in our docker tests, as we use --net=none there. Skip
3
Write support works again when image contains non-ASCII names. It is either the
4
this method.
4
case when user created a non-ASCII filename, or when initial directory contained
5
a non-ASCII filename (since 0c36111f57ec2188f679e7fa810291b7386bdca1)
5
6
6
Signed-off-by: Fam Zheng <famz@redhat.com>
7
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
---
9
---
9
tests/qemu-iotests/147 | 7 +++++++
10
block/vvfat.c | 59 +++++++++++++++++++++++++++++++++++++----------------------
10
1 file changed, 7 insertions(+)
11
1 file changed, 37 insertions(+), 22 deletions(-)
11
12
12
diff --git a/tests/qemu-iotests/147 b/tests/qemu-iotests/147
13
diff --git a/block/vvfat.c b/block/vvfat.c
13
index XXXXXXX..XXXXXXX 100755
14
index XXXXXXX..XXXXXXX 100644
14
--- a/tests/qemu-iotests/147
15
--- a/block/vvfat.c
15
+++ b/tests/qemu-iotests/147
16
+++ b/block/vvfat.c
16
@@ -XXX,XX +XXX,XX @@ class BuiltinNBD(NBDBlockdevAddBase):
17
@@ -XXX,XX +XXX,XX @@ typedef struct {
17
self._server_down()
18
* filename length is 0x3f * 13 bytes.
18
19
*/
19
def test_inet6(self):
20
unsigned char name[0x3f * 13 + 1];
20
+ try:
21
+ gunichar2 name2[0x3f * 13 + 1];
21
+ socket.getaddrinfo("::0", "0", socket.AF_INET6,
22
int checksum, len;
22
+ socket.SOCK_STREAM, socket.IPPROTO_TCP,
23
int sequence_number;
23
+ socket.AI_ADDRCONFIG | socket.AI_CANONNAME)
24
} long_file_name;
24
+ except socket.gaierror:
25
@@ -XXX,XX +XXX,XX @@ static int parse_long_name(long_file_name* lfn,
25
+ # IPv6 not available, skip
26
return 1;
26
+ return
27
27
address = { 'type': 'inet',
28
if (pointer[0] & 0x40) {
28
'data': {
29
+ /* first entry; do some initialization */
29
'host': '::1',
30
lfn->sequence_number = pointer[0] & 0x3f;
31
lfn->checksum = pointer[13];
32
lfn->name[0] = 0;
33
lfn->name[lfn->sequence_number * 13] = 0;
34
- } else if ((pointer[0] & 0x3f) != --lfn->sequence_number)
35
+ } else if ((pointer[0] & 0x3f) != --lfn->sequence_number) {
36
+ /* not the expected sequence number */
37
return -1;
38
- else if (pointer[13] != lfn->checksum)
39
+ } else if (pointer[13] != lfn->checksum) {
40
+ /* not the expected checksum */
41
return -2;
42
- else if (pointer[12] || pointer[26] || pointer[27])
43
+ } else if (pointer[12] || pointer[26] || pointer[27]) {
44
+ /* invalid zero fields */
45
return -3;
46
+ }
47
48
offset = 13 * (lfn->sequence_number - 1);
49
for (i = 0, j = 1; i < 13; i++, j+=2) {
50
@@ -XXX,XX +XXX,XX @@ static int parse_long_name(long_file_name* lfn,
51
else if (j == 26)
52
j = 28;
53
54
- if (pointer[j+1] == 0)
55
- lfn->name[offset + i] = pointer[j];
56
- else if (pointer[j+1] != 0xff || (pointer[0] & 0x40) == 0)
57
- return -4;
58
- else
59
- lfn->name[offset + i] = 0;
60
+ if (pointer[j] == 0 && pointer[j + 1] == 0) {
61
+ /* end of long file name */
62
+ break;
63
+ }
64
+ gunichar2 c = (pointer[j + 1] << 8) + pointer[j];
65
+ lfn->name2[offset + i] = c;
66
}
67
68
- if (pointer[0] & 0x40)
69
- lfn->len = offset + strlen((char*)lfn->name + offset);
70
+ if (pointer[0] & 0x40) {
71
+ /* first entry; set len */
72
+ lfn->len = offset + i;
73
+ }
74
+ if ((pointer[0] & 0x3f) == 0x01) {
75
+ /* last entry; finalize entry */
76
+ glong olen;
77
+ gchar *utf8 = g_utf16_to_utf8(lfn->name2, lfn->len, NULL, &olen, NULL);
78
+ if (!utf8) {
79
+ return -4;
80
+ }
81
+ lfn->len = olen;
82
+ memcpy(lfn->name, utf8, olen + 1);
83
+ g_free(utf8);
84
+ }
85
86
return 0;
87
}
88
@@ -XXX,XX +XXX,XX @@ static int parse_short_name(BDRVVVFATState* s,
89
90
for (j = 7; j >= 0 && direntry->name[j] == ' '; j--);
91
for (i = 0; i <= j; i++) {
92
- if (direntry->name[i] <= ' ' || direntry->name[i] > 0x7f)
93
+ uint8_t c = direntry->name[i];
94
+ if (c != to_valid_short_char(c)) {
95
return -1;
96
- else if (s->downcase_short_names)
97
+ } else if (s->downcase_short_names) {
98
lfn->name[i] = qemu_tolower(direntry->name[i]);
99
- else
100
+ } else {
101
lfn->name[i] = direntry->name[i];
102
+ }
103
}
104
105
for (j = 2; j >= 0 && direntry->name[8 + j] == ' '; j--) {
106
@@ -XXX,XX +XXX,XX @@ static int parse_short_name(BDRVVVFATState* s,
107
lfn->name[i + j + 1] = '\0';
108
for (;j >= 0; j--) {
109
uint8_t c = direntry->name[8 + j];
110
- if (c <= ' ' || c > 0x7f) {
111
+ if (c != to_valid_short_char(c)) {
112
return -2;
113
} else if (s->downcase_short_names) {
114
lfn->name[i + j] = qemu_tolower(c);
115
@@ -XXX,XX +XXX,XX @@ DLOG(checkpoint());
116
/*
117
* Some sanity checks:
118
* - do not allow writing to the boot sector
119
- * - do not allow to write non-ASCII filenames
120
*/
121
122
if (sector_num < s->offset_to_fat)
123
@@ -XXX,XX +XXX,XX @@ DLOG(checkpoint());
124
direntries = (direntry_t*)(buf + 0x200 * (begin - sector_num));
125
126
for (k = 0; k < (end - begin) * 0x10; k++) {
127
- /* do not allow non-ASCII filenames */
128
- if (parse_long_name(&lfn, direntries + k) < 0) {
129
- fprintf(stderr, "Warning: non-ASCII filename\n");
130
- return -1;
131
- }
132
/* no access to the direntry of a read-only file */
133
- else if (is_short_name(direntries+k) &&
134
+ if (is_short_name(direntries + k) &&
135
(direntries[k].attributes & 1)) {
136
if (memcmp(direntries + k,
137
array_get(&(s->directory), dir_index + k),
30
--
138
--
31
1.8.3.1
139
1.8.3.1
32
140
33
141
diff view generated by jsdifflib
1
From: Fam Zheng <famz@redhat.com>
1
From: Hervé Poussineau <hpoussin@reactos.org>
2
2
3
Reported by Coverity.
3
This prevents some host to guest memory content leaks.
4
4
5
Signed-off-by: Fam Zheng <famz@redhat.com>
5
Fixes: https://bugs.launchpad.net/qemu/+bug/1599539
6
Message-id: 20170515141014.25793-1-famz@redhat.com
6
7
Reviewed-by: Eric Blake <eblake@redhat.com>
7
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9
---
9
---
10
qemu-img.c | 1 +
10
block/vvfat.c | 1 +
11
1 file changed, 1 insertion(+)
11
1 file changed, 1 insertion(+)
12
12
13
diff --git a/qemu-img.c b/qemu-img.c
13
diff --git a/block/vvfat.c b/block/vvfat.c
14
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
15
--- a/qemu-img.c
15
--- a/block/vvfat.c
16
+++ b/qemu-img.c
16
+++ b/block/vvfat.c
17
@@ -XXX,XX +XXX,XX @@ static BlockBackend *img_open_opts(const char *optstr,
17
@@ -XXX,XX +XXX,XX @@ static inline int array_ensure_allocated(array_t* array, int index)
18
if (qdict_haskey(options, BDRV_OPT_FORCE_SHARE)
18
array->pointer = g_realloc(array->pointer, new_size);
19
&& !qdict_get_bool(options, BDRV_OPT_FORCE_SHARE)) {
19
if (!array->pointer)
20
error_report("--force-share/-U conflicts with image options");
20
return -1;
21
+ QDECREF(options);
21
+ memset(array->pointer + array->size, 0, new_size - array->size);
22
return NULL;
22
array->size = new_size;
23
}
23
array->next = index + 1;
24
qdict_put(options, BDRV_OPT_FORCE_SHARE, qbool_from_bool(true));
24
}
25
--
25
--
26
1.8.3.1
26
1.8.3.1
27
27
28
28
diff view generated by jsdifflib
1
From: Max Reitz <mreitz@redhat.com>
1
From: Max Reitz <mreitz@redhat.com>
2
2
3
path_combine() naturally tries to preserve a protocol prefix. However,
3
gcc 7 complains that the sprintf() might write a null byte beyond the
4
it recognizes such a prefix by scanning for the first colon; which is
4
end of the tail buffer. That is wrong, but we can silence it by making
5
different from what path_has_protocol() does: There only is a protocol
5
i unsigned (it can never be negative anyway, see the if condition right
6
prefix if there is a colon before the first slash.
6
before). For some reason, this allows gcc to suddenly accurately
7
calculate the range of i so we can give the tail[] array the exact size
8
it needs to have (which is 8 bytes) without gcc complaining.
7
9
8
A protocol prefix that is not recognized by path_has_protocol() is none,
10
In addition, let us convert the sprintf() to snprintf(), because that is
9
and should thus not be taken as one.
11
always nicer, and add an assertion about the range of the return value
12
afterwards so we can see that "8 - len" will never be negative and thus
13
"entry->name + MIN(j, 8 - len)" will never be out of bounds.
10
14
11
Case in point, before this patch:
12
$ ./qemu-img create -f qcow2 -b backing.qcow2 ./top:image.qcow2
13
qemu-img: ./top:image.qcow2: Could not open './top:backing.qcow2':
14
No such file or directory
15
16
Afterwards:
17
$ ./qemu-img create -f qcow2 -b backing.qcow2 ./top:image.qcow2
18
qemu-img: ./top:image.qcow2: Could not open './backing.qcow2':
19
No such file or directory
20
21
Reported-by: yangyang <yangyang@redhat.com>
22
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
Signed-off-by: Max Reitz <mreitz@redhat.com>
23
Reviewed-by: Eric Blake <eblake@redhat.com>
16
Reviewed-by: Eric Blake <eblake@redhat.com>
24
Message-id: 20170522195217.12991-2-mreitz@redhat.com
17
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
25
Signed-off-by: Max Reitz <mreitz@redhat.com>
26
---
18
---
27
block.c | 15 ++++++++++-----
19
block/vvfat.c | 5 +++--
28
1 file changed, 10 insertions(+), 5 deletions(-)
20
1 file changed, 3 insertions(+), 2 deletions(-)
29
21
30
diff --git a/block.c b/block.c
22
diff --git a/block/vvfat.c b/block/vvfat.c
31
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
32
--- a/block.c
24
--- a/block/vvfat.c
33
+++ b/block.c
25
+++ b/block/vvfat.c
34
@@ -XXX,XX +XXX,XX @@ void path_combine(char *dest, int dest_size,
26
@@ -XXX,XX +XXX,XX @@ static direntry_t *create_short_filename(BDRVVVFATState *s,
35
if (path_is_absolute(filename)) {
27
const gchar *p, *last_dot = NULL;
36
pstrcpy(dest, dest_size, filename);
28
gunichar c;
37
} else {
29
bool lossy_conversion = false;
38
- p = strchr(base_path, ':');
30
- char tail[11];
39
- if (p)
31
+ char tail[8];
40
- p++;
32
41
- else
33
if (!entry) {
42
- p = base_path;
34
return NULL;
43
+ const char *protocol_stripped = NULL;
35
@@ -XXX,XX +XXX,XX @@ static direntry_t *create_short_filename(BDRVVVFATState *s,
44
+
36
for (i = lossy_conversion ? 1 : 0; i < 999999; i++) {
45
+ if (path_has_protocol(base_path)) {
37
direntry_t *entry1;
46
+ protocol_stripped = strchr(base_path, ':');
38
if (i > 0) {
47
+ if (protocol_stripped) {
39
- int len = sprintf(tail, "~%d", i);
48
+ protocol_stripped++;
40
+ int len = snprintf(tail, sizeof(tail), "~%u", (unsigned)i);
49
+ }
41
+ assert(len <= 7);
50
+ }
42
memcpy(entry->name + MIN(j, 8 - len), tail, len);
51
+ p = protocol_stripped ?: base_path;
43
}
52
+
44
for (entry1 = array_get(&(s->directory), directory_start);
53
p1 = strrchr(base_path, '/');
54
#ifdef _WIN32
55
{
56
--
45
--
57
1.8.3.1
46
1.8.3.1
58
47
59
48
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: John Snow <jsnow@redhat.com>
2
2
3
Commit d7086422b1c1e75e320519cfe26176db6ec97a37 added a local_err
3
For both external_snapshot_prepare and qmp_drive_mirror, we eventually
4
variable global to the qcow2_amend_options() function, so there's no
4
append the option BDRV_O_NO_BACKING. However, we generally do so after
5
need to have this other one.
5
we create the image.
6
6
7
Signed-off-by: Alberto Garcia <berto@igalia.com>
7
To accommodate image creation wanting to verify that a backing file
8
Message-id: 20170511150337.21470-1-berto@igalia.com
8
exists or not, add this option prior to create to override checking
9
the existence of the backing file. This prevents QEMU from trying to
10
re-open a backing file that's already in use (thanks to qcow2 locking).
11
12
Signed-off-by: John Snow <jsnow@redhat.com>
9
Reviewed-by: Eric Blake <eblake@redhat.com>
13
Reviewed-by: Eric Blake <eblake@redhat.com>
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
14
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11
---
15
---
12
block/qcow2.c | 5 ++---
16
blockdev.c | 11 ++++++-----
13
1 file changed, 2 insertions(+), 3 deletions(-)
17
1 file changed, 6 insertions(+), 5 deletions(-)
14
18
15
diff --git a/block/qcow2.c b/block/qcow2.c
19
diff --git a/blockdev.c b/blockdev.c
16
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
17
--- a/block/qcow2.c
21
--- a/blockdev.c
18
+++ b/block/qcow2.c
22
+++ b/blockdev.c
19
@@ -XXX,XX +XXX,XX @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
23
@@ -XXX,XX +XXX,XX @@ static void external_snapshot_prepare(BlkActionState *common,
20
21
if (s->refcount_bits != refcount_bits) {
22
int refcount_order = ctz32(refcount_bits);
23
- Error *local_error = NULL;
24
25
if (new_version < 3 && refcount_bits != 16) {
26
error_report("Different refcount widths than 16 bits require "
27
@@ -XXX,XX +XXX,XX @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
28
helper_cb_info.current_operation = QCOW2_CHANGING_REFCOUNT_ORDER;
29
ret = qcow2_change_refcount_order(bs, refcount_order,
30
&qcow2_amend_helper_cb,
31
- &helper_cb_info, &local_error);
32
+ &helper_cb_info, &local_err);
33
if (ret < 0) {
34
- error_report_err(local_error);
35
+ error_report_err(local_err);
36
return ret;
37
}
24
}
25
26
flags = state->old_bs->open_flags;
27
- flags &= ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING | BDRV_O_COPY_ON_READ);
28
+ flags &= ~(BDRV_O_SNAPSHOT | BDRV_O_COPY_ON_READ);
29
+ flags |= BDRV_O_NO_BACKING;
30
31
/* create new image w/backing file */
32
mode = s->has_mode ? s->mode : NEW_IMAGE_MODE_ABSOLUTE_PATHS;
33
@@ -XXX,XX +XXX,XX @@ static void external_snapshot_prepare(BlkActionState *common,
34
qdict_put_str(options, "node-name", snapshot_node_name);
35
}
36
qdict_put_str(options, "driver", format);
37
-
38
- flags |= BDRV_O_NO_BACKING;
39
}
40
41
state->new_bs = bdrv_open(new_image_file, snapshot_ref, options, flags,
42
@@ -XXX,XX +XXX,XX @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
43
backing_mode = MIRROR_OPEN_BACKING_CHAIN;
44
}
45
46
+ /* Don't open backing image in create() */
47
+ flags |= BDRV_O_NO_BACKING;
48
+
49
if ((arg->sync == MIRROR_SYNC_MODE_FULL || !source)
50
&& arg->mode != NEW_IMAGE_MODE_EXISTING)
51
{
52
@@ -XXX,XX +XXX,XX @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
53
/* Mirroring takes care of copy-on-write using the source's backing
54
* file.
55
*/
56
- target_bs = bdrv_open(arg->target, NULL, options,
57
- flags | BDRV_O_NO_BACKING, errp);
58
+ target_bs = bdrv_open(arg->target, NULL, options, flags, errp);
59
if (!target_bs) {
60
goto out;
38
}
61
}
39
--
62
--
40
1.8.3.1
63
1.8.3.1
41
64
42
65
diff view generated by jsdifflib
1
From: "Daniel P. Berrange" <berrange@redhat.com>
1
From: John Snow <jsnow@redhat.com>
2
2
3
The '--image-opts' flag indicates whether the source filename
3
Or, rather, force the open of a backing image if one was specified
4
includes options. The target filename has to remain in the
4
for creation. Using a similar -unsafe option as rebase, allow qemu-img
5
plain filename format though, since it needs to be passed to
5
to ignore the backing file validation if possible.
6
bdrv_create(). When using --skip-create though, it would be
6
7
possible to use image-opts syntax. This adds --target-image-opts
7
It may not always be possible, as in the existing case when a filesize
8
to indicate that the target filename includes options. Currently
8
for the new image was not specified.
9
this mandates use of the --skip-create flag too.
9
10
10
This is accomplished by shifting around the conditionals in
11
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11
bdrv_img_create, such that a backing file is always opened unless we
12
Message-id: 20170515164712.6643-4-berrange@redhat.com
12
provide BDRV_O_NO_BACKING. qemu-img is adjusted to pass this new flag
13
Reviewed-by: Max Reitz <mreitz@redhat.com>
13
when -u is provided to create.
14
Reviewed-by: Eric Blake <eblake@redhat.com>
14
15
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
Sorry for the heinous looking diffstat, but it's mostly whitespace.
16
17
Inspired by: https://bugzilla.redhat.com/show_bug.cgi?id=1213786
18
19
Signed-off-by: John Snow <jsnow@redhat.com>
20
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
16
---
21
---
17
qemu-img-cmds.hx | 4 +--
22
block.c | 94 +++++++++++++++++++++++++---------------------
18
qemu-img.c | 84 ++++++++++++++++++++++++++++++++++++++------------------
23
qemu-img-cmds.hx | 4 +-
19
qemu-img.texi | 12 ++++++--
24
qemu-img.c | 16 +++++---
20
3 files changed, 69 insertions(+), 31 deletions(-)
25
qemu-img.texi | 9 ++++-
21
26
tests/qemu-iotests/082 | 4 +-
27
tests/qemu-iotests/082.out | 4 +-
28
tests/qemu-iotests/085 | 2 +-
29
tests/qemu-iotests/111.out | 1 +
30
tests/qemu-iotests/139 | 2 +-
31
tests/qemu-iotests/156 | 2 +-
32
tests/qemu-iotests/158 | 2 +-
33
tests/qemu-iotests/189 | 2 +-
34
12 files changed, 83 insertions(+), 59 deletions(-)
35
36
diff --git a/block.c b/block.c
37
index XXXXXXX..XXXXXXX 100644
38
--- a/block.c
39
+++ b/block.c
40
@@ -XXX,XX +XXX,XX @@ void bdrv_img_create(const char *filename, const char *fmt,
41
42
backing_fmt = qemu_opt_get(opts, BLOCK_OPT_BACKING_FMT);
43
44
- // The size for the image must always be specified, with one exception:
45
- // If we are using a backing file, we can obtain the size from there
46
+ /* The size for the image must always be specified, unless we have a backing
47
+ * file and we have not been forbidden from opening it. */
48
size = qemu_opt_get_size(opts, BLOCK_OPT_SIZE, 0);
49
- if (size == -1) {
50
- if (backing_file) {
51
- BlockDriverState *bs;
52
- char *full_backing = g_new0(char, PATH_MAX);
53
- int64_t size;
54
- int back_flags;
55
- QDict *backing_options = NULL;
56
-
57
- bdrv_get_full_backing_filename_from_filename(filename, backing_file,
58
- full_backing, PATH_MAX,
59
- &local_err);
60
- if (local_err) {
61
- g_free(full_backing);
62
- goto out;
63
- }
64
+ if (backing_file && !(flags & BDRV_O_NO_BACKING)) {
65
+ BlockDriverState *bs;
66
+ char *full_backing = g_new0(char, PATH_MAX);
67
+ int back_flags;
68
+ QDict *backing_options = NULL;
69
+
70
+ bdrv_get_full_backing_filename_from_filename(filename, backing_file,
71
+ full_backing, PATH_MAX,
72
+ &local_err);
73
+ if (local_err) {
74
+ g_free(full_backing);
75
+ goto out;
76
+ }
77
78
- /* backing files always opened read-only */
79
- back_flags = flags;
80
- back_flags &= ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);
81
+ /* backing files always opened read-only */
82
+ back_flags = flags;
83
+ back_flags &= ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);
84
85
- if (backing_fmt) {
86
- backing_options = qdict_new();
87
- qdict_put_str(backing_options, "driver", backing_fmt);
88
- }
89
+ if (backing_fmt) {
90
+ backing_options = qdict_new();
91
+ qdict_put_str(backing_options, "driver", backing_fmt);
92
+ }
93
94
- bs = bdrv_open(full_backing, NULL, backing_options, back_flags,
95
- &local_err);
96
- g_free(full_backing);
97
- if (!bs) {
98
- goto out;
99
- }
100
- size = bdrv_getlength(bs);
101
- if (size < 0) {
102
- error_setg_errno(errp, -size, "Could not get size of '%s'",
103
- backing_file);
104
- bdrv_unref(bs);
105
- goto out;
106
+ bs = bdrv_open(full_backing, NULL, backing_options, back_flags,
107
+ &local_err);
108
+ g_free(full_backing);
109
+ if (!bs && size != -1) {
110
+ /* Couldn't open BS, but we have a size, so it's nonfatal */
111
+ warn_reportf_err(local_err,
112
+ "Could not verify backing image. "
113
+ "This may become an error in future versions.\n");
114
+ local_err = NULL;
115
+ } else if (!bs) {
116
+ /* Couldn't open bs, do not have size */
117
+ error_append_hint(&local_err,
118
+ "Could not open backing image to determine size.\n");
119
+ goto out;
120
+ } else {
121
+ if (size == -1) {
122
+ /* Opened BS, have no size */
123
+ size = bdrv_getlength(bs);
124
+ if (size < 0) {
125
+ error_setg_errno(errp, -size, "Could not get size of '%s'",
126
+ backing_file);
127
+ bdrv_unref(bs);
128
+ goto out;
129
+ }
130
+ qemu_opt_set_number(opts, BLOCK_OPT_SIZE, size, &error_abort);
131
}
132
-
133
- qemu_opt_set_number(opts, BLOCK_OPT_SIZE, size, &error_abort);
134
-
135
bdrv_unref(bs);
136
- } else {
137
- error_setg(errp, "Image creation needs a size parameter");
138
- goto out;
139
}
140
+ } /* (backing_file && !(flags & BDRV_O_NO_BACKING)) */
141
+
142
+ if (size == -1) {
143
+ error_setg(errp, "Image creation needs a size parameter");
144
+ goto out;
145
}
146
147
if (!quiet) {
22
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
148
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
23
index XXXXXXX..XXXXXXX 100644
149
index XXXXXXX..XXXXXXX 100644
24
--- a/qemu-img-cmds.hx
150
--- a/qemu-img-cmds.hx
25
+++ b/qemu-img-cmds.hx
151
+++ b/qemu-img-cmds.hx
26
@@ -XXX,XX +XXX,XX @@ STEXI
152
@@ -XXX,XX +XXX,XX @@ STEXI
27
ETEXI
153
ETEXI
28
154
29
DEF("convert", img_convert,
155
DEF("create", img_create,
30
- "convert [--object objectdef] [--image-opts] [-U] [-c] [-p] [-q] [-n] [-f fmt] [-t cache] [-T src_cache] [-O output_fmt] [-B backing_file] [-o options] [-s snapshot_id_or_name] [-l snapshot_param] [-S sparse_size] [-m num_coroutines] [-W] filename [filename2 [...]] output_filename")
156
- "create [-q] [--object objectdef] [-f fmt] [-b backing_file] [-F backing_fmt] [-o options] filename [size]")
31
+ "convert [--object objectdef] [--image-opts] [--target-image-opts] [-U] [-c] [-p] [-q] [-n] [-f fmt] [-t cache] [-T src_cache] [-O output_fmt] [-B backing_file] [-o options] [-s snapshot_id_or_name] [-l snapshot_param] [-S sparse_size] [-m num_coroutines] [-W] filename [filename2 [...]] output_filename")
157
+ "create [-q] [--object objectdef] [-f fmt] [-b backing_file] [-F backing_fmt] [-u] [-o options] filename [size]")
32
STEXI
158
STEXI
33
-@item convert [--object @var{objectdef}] [--image-opts] [-U] [-c] [-p] [-q] [-n] [-f @var{fmt}] [-t @var{cache}] [-T @var{src_cache}] [-O @var{output_fmt}] [-B @var{backing_file}] [-o @var{options}] [-s @var{snapshot_id_or_name}] [-l @var{snapshot_param}] [-S @var{sparse_size}] [-m @var{num_coroutines}] [-W] @var{filename} [@var{filename2} [...]] @var{output_filename}
159
-@item create [--object @var{objectdef}] [-q] [-f @var{fmt}] [-b @var{backing_file}] [-F @var{backing_fmt}] [-o @var{options}] @var{filename} [@var{size}]
34
+@item convert [--object @var{objectdef}] [--image-opts] [--target-image-opts] [-U] [-c] [-p] [-q] [-n] [-f @var{fmt}] [-t @var{cache}] [-T @var{src_cache}] [-O @var{output_fmt}] [-B @var{backing_file}] [-o @var{options}] [-s @var{snapshot_id_or_name}] [-l @var{snapshot_param}] [-S @var{sparse_size}] [-m @var{num_coroutines}] [-W] @var{filename} [@var{filename2} [...]] @var{output_filename}
160
+@item create [--object @var{objectdef}] [-q] [-f @var{fmt}] [-b @var{backing_file}] [-F @var{backing_fmt}] [-u] [-o @var{options}] @var{filename} [@var{size}]
35
ETEXI
161
ETEXI
36
162
37
DEF("dd", img_dd,
163
DEF("commit", img_commit,
38
diff --git a/qemu-img.c b/qemu-img.c
164
diff --git a/qemu-img.c b/qemu-img.c
39
index XXXXXXX..XXXXXXX 100644
165
index XXXXXXX..XXXXXXX 100644
40
--- a/qemu-img.c
166
--- a/qemu-img.c
41
+++ b/qemu-img.c
167
+++ b/qemu-img.c
42
@@ -XXX,XX +XXX,XX @@ enum {
168
@@ -XXX,XX +XXX,XX @@ static void QEMU_NORETURN help(void)
43
OPTION_PATTERN = 260,
169
" 'snapshot_id_or_name' is deprecated, use 'snapshot_param'\n"
44
OPTION_FLUSH_INTERVAL = 261,
170
" instead\n"
45
OPTION_NO_DRAIN = 262,
171
" '-c' indicates that target image must be compressed (qcow format only)\n"
46
+ OPTION_TARGET_IMAGE_OPTS = 263,
172
- " '-u' enables unsafe rebasing. It is assumed that old and new backing file\n"
47
};
173
- " match exactly. The image doesn't need a working backing file before\n"
48
174
- " rebasing in this case (useful for renaming the backing file)\n"
49
typedef enum OutputFormat {
175
+ " '-u' allows unsafe backing chains. For rebasing, it is assumed that old and\n"
50
@@ -XXX,XX +XXX,XX @@ static int convert_do_copy(ImgConvertState *s)
176
+ " new backing file match exactly. The image doesn't need a working\n"
51
static int img_convert(int argc, char **argv)
177
+ " backing file before rebasing in this case (useful for renaming the\n"
52
{
178
+ " backing file). For image creation, allow creating without attempting\n"
53
int c, bs_i, flags, src_flags = 0;
179
+ " to open the backing file.\n"
54
- const char *fmt = NULL, *out_fmt = "raw", *cache = "unsafe",
180
" '-h' with or without a command shows this help and lists the supported formats\n"
55
+ const char *fmt = NULL, *out_fmt = NULL, *cache = "unsafe",
181
" '-p' show progress of command (only certain commands)\n"
56
*src_cache = BDRV_DEFAULT_CACHE, *out_baseimg = NULL,
182
" '-q' use Quiet mode - do not print any output (except errors)\n"
57
*out_filename, *out_baseimg_param, *snapshot_name = NULL;
183
@@ -XXX,XX +XXX,XX @@ static int img_create(int argc, char **argv)
58
- BlockDriver *drv, *proto_drv;
59
+ BlockDriver *drv = NULL, *proto_drv = NULL;
60
BlockDriverInfo bdi;
61
BlockDriverState *out_bs;
62
QemuOpts *opts = NULL, *sn_opts = NULL;
63
@@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv)
64
char *options = NULL;
184
char *options = NULL;
65
Error *local_err = NULL;
185
Error *local_err = NULL;
66
bool writethrough, src_writethrough, quiet = false, image_opts = false,
186
bool quiet = false;
67
- skip_create = false, progress = false;
187
+ int flags = 0;
68
+ skip_create = false, progress = false, tgt_image_opts = false;
188
69
int64_t ret = -EINVAL;
189
for(;;) {
70
bool force_share = false;
190
static const struct option long_options[] = {
71
191
@@ -XXX,XX +XXX,XX @@ static int img_create(int argc, char **argv)
72
@@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv)
73
{"object", required_argument, 0, OPTION_OBJECT},
192
{"object", required_argument, 0, OPTION_OBJECT},
74
{"image-opts", no_argument, 0, OPTION_IMAGE_OPTS},
75
{"force-share", no_argument, 0, 'U'},
76
+ {"target-image-opts", no_argument, 0, OPTION_TARGET_IMAGE_OPTS},
77
{0, 0, 0, 0}
193
{0, 0, 0, 0}
78
};
194
};
79
c = getopt_long(argc, argv, ":hf:O:B:ce6o:s:l:S:pt:T:qnm:WU",
195
- c = getopt_long(argc, argv, ":F:b:f:ho:q",
80
@@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv)
196
+ c = getopt_long(argc, argv, ":F:b:f:ho:qu",
81
case OPTION_IMAGE_OPTS:
197
long_options, NULL);
82
image_opts = true;
198
if (c == -1) {
83
break;
199
break;
84
+ case OPTION_TARGET_IMAGE_OPTS:
200
@@ -XXX,XX +XXX,XX @@ static int img_create(int argc, char **argv)
85
+ tgt_image_opts = true;
201
case 'q':
202
quiet = true;
203
break;
204
+ case 'u':
205
+ flags |= BDRV_O_NO_BACKING;
86
+ break;
206
+ break;
87
}
207
case OPTION_OBJECT: {
208
QemuOpts *opts;
209
opts = qemu_opts_parse_noisily(&qemu_object_opts,
210
@@ -XXX,XX +XXX,XX @@ static int img_create(int argc, char **argv)
88
}
211
}
89
212
90
+ if (!out_fmt && !tgt_image_opts) {
213
bdrv_img_create(filename, fmt, base_filename, base_fmt,
91
+ out_fmt = "raw";
214
- options, img_size, 0, quiet, &local_err);
92
+ }
215
+ options, img_size, flags, quiet, &local_err);
93
+
216
if (local_err) {
94
if (qemu_opts_foreach(&qemu_object_opts,
217
error_reportf_err(local_err, "%s: ", filename);
95
user_creatable_add_opts_foreach,
218
goto fail;
96
NULL, NULL)) {
97
@@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv)
98
goto fail_getopt;
99
}
100
101
+ if (tgt_image_opts && !skip_create) {
102
+ error_report("--target-image-opts requires use of -n flag");
103
+ goto fail_getopt;
104
+ }
105
+
106
s.src_num = argc - optind - 1;
107
out_filename = s.src_num >= 1 ? argv[argc - 1] : NULL;
108
109
if (options && has_help_option(options)) {
110
- ret = print_block_option_help(out_filename, out_fmt);
111
- goto fail_getopt;
112
+ if (out_fmt) {
113
+ ret = print_block_option_help(out_filename, out_fmt);
114
+ goto fail_getopt;
115
+ } else {
116
+ error_report("Option help requires a format be specified");
117
+ goto fail_getopt;
118
+ }
119
}
120
121
if (s.src_num < 1) {
122
@@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv)
123
goto out;
124
}
125
126
- /* Find driver and parse its options */
127
- drv = bdrv_find_format(out_fmt);
128
- if (!drv) {
129
- error_report("Unknown file format '%s'", out_fmt);
130
- ret = -1;
131
- goto out;
132
- }
133
+ if (!skip_create) {
134
+ /* Find driver and parse its options */
135
+ drv = bdrv_find_format(out_fmt);
136
+ if (!drv) {
137
+ error_report("Unknown file format '%s'", out_fmt);
138
+ ret = -1;
139
+ goto out;
140
+ }
141
142
- proto_drv = bdrv_find_protocol(out_filename, true, &local_err);
143
- if (!proto_drv) {
144
- error_report_err(local_err);
145
- ret = -1;
146
- goto out;
147
- }
148
+ proto_drv = bdrv_find_protocol(out_filename, true, &local_err);
149
+ if (!proto_drv) {
150
+ error_report_err(local_err);
151
+ ret = -1;
152
+ goto out;
153
+ }
154
155
- if (!skip_create) {
156
if (!drv->create_opts) {
157
error_report("Format driver '%s' does not support image creation",
158
drv->format_name);
159
@@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv)
160
const char *preallocation =
161
qemu_opt_get(opts, BLOCK_OPT_PREALLOC);
162
163
- if (!drv->bdrv_co_pwritev_compressed) {
164
+ if (drv && !drv->bdrv_co_pwritev_compressed) {
165
error_report("Compression not supported for this file format");
166
ret = -1;
167
goto out;
168
@@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv)
169
goto out;
170
}
171
172
- /* XXX we should allow --image-opts to trigger use of
173
- * img_open() here, but then we have trouble with
174
- * the bdrv_create() call which takes different params.
175
- * Not critical right now, so fix can wait...
176
- */
177
- s.target = img_open_file(out_filename, out_fmt, flags, writethrough, quiet,
178
- false);
179
+ if (skip_create) {
180
+ s.target = img_open(tgt_image_opts, out_filename, out_fmt,
181
+ flags, writethrough, quiet, false);
182
+ } else {
183
+ /* TODO ultimately we should allow --target-image-opts
184
+ * to be used even when -n is not given.
185
+ * That has to wait for bdrv_create to be improved
186
+ * to allow filenames in option syntax
187
+ */
188
+ s.target = img_open_file(out_filename, out_fmt, flags,
189
+ writethrough, quiet, false);
190
+ }
191
if (!s.target) {
192
ret = -1;
193
goto out;
194
}
195
out_bs = blk_bs(s.target);
196
197
+ if (s.compressed && !out_bs->drv->bdrv_co_pwritev_compressed) {
198
+ error_report("Compression not supported for this file format");
199
+ ret = -1;
200
+ goto out;
201
+ }
202
+
203
/* increase bufsectors from the default 4096 (2M) if opt_transfer
204
* or discard_alignment of the out_bs is greater. Limit to 32768 (16MB)
205
* as maximum. */
206
diff --git a/qemu-img.texi b/qemu-img.texi
219
diff --git a/qemu-img.texi b/qemu-img.texi
207
index XXXXXXX..XXXXXXX 100644
220
index XXXXXXX..XXXXXXX 100644
208
--- a/qemu-img.texi
221
--- a/qemu-img.texi
209
+++ b/qemu-img.texi
222
+++ b/qemu-img.texi
210
@@ -XXX,XX +XXX,XX @@ keys.
223
@@ -XXX,XX +XXX,XX @@ If @code{-r} is specified, exit codes representing the image state refer to the
211
224
state after (the attempt at) repairing it. That is, a successful @code{-r all}
212
@item --image-opts
225
will yield the exit code 0, independently of the image state before.
213
226
214
-Indicates that the @var{filename} parameter is to be interpreted as a
227
-@item create [-f @var{fmt}] [-b @var{backing_file}] [-F @var{backing_fmt}] [-o @var{options}] @var{filename} [@var{size}]
215
+Indicates that the source @var{filename} parameter is to be interpreted as a
228
+@item create [-f @var{fmt}] [-b @var{backing_file}] [-F @var{backing_fmt}] [-u] [-o @var{options}] @var{filename} [@var{size}]
216
full option string, not a plain filename. This parameter is mutually
229
217
-exclusive with the @var{-f} and @var{-F} parameters.
230
Create the new disk image @var{filename} of size @var{size} and format
218
+exclusive with the @var{-f} parameter.
231
@var{fmt}. Depending on the file format, you can add one or more @var{options}
232
@@ -XXX,XX +XXX,XX @@ only the differences from @var{backing_file}. No size needs to be specified in
233
this case. @var{backing_file} will never be modified unless you use the
234
@code{commit} monitor command (or qemu-img commit).
235
236
+Note that a given backing file will be opened to check that it is valid. Use
237
+the @code{-u} option to enable unsafe backing file mode, which means that the
238
+image will be created even if the associated backing file cannot be opened. A
239
+matching backing file must be created or additional options be used to make the
240
+backing file specification valid when you want to use an image created this
241
+way.
219
+
242
+
220
+@item --target-image-opts
243
The size can also be specified using the @var{size} option with @code{-o},
221
+
244
it doesn't need to be specified separately in this case.
222
+Indicates that the @var{output_filename} parameter(s) are to be interpreted as
245
223
+a full option string, not a plain filename. This parameter is mutually
246
diff --git a/tests/qemu-iotests/082 b/tests/qemu-iotests/082
224
+exclusive with the @var{-O} parameters. It is currently required to also use
247
index XXXXXXX..XXXXXXX 100755
225
+the @var{-n} parameter to skip image creation. This restriction may be relaxed
248
--- a/tests/qemu-iotests/082
226
+in a future release.
249
+++ b/tests/qemu-iotests/082
227
250
@@ -XXX,XX +XXX,XX @@ run_qemu_img create -f $IMGFMT -o cluster_size=4k -o help "$TEST_IMG" $size
228
@item fmt
251
run_qemu_img create -f $IMGFMT -o cluster_size=4k -o \? "$TEST_IMG" $size
229
is the disk image format. It is guessed automatically in most cases. See below
252
253
# Looks like a help option, but is part of the backing file name
254
-run_qemu_img create -f $IMGFMT -o backing_file="$TEST_IMG",,help "$TEST_IMG" $size
255
-run_qemu_img create -f $IMGFMT -o backing_file="$TEST_IMG",,\? "$TEST_IMG" $size
256
+run_qemu_img create -f $IMGFMT -u -o backing_file="$TEST_IMG",,help "$TEST_IMG" $size
257
+run_qemu_img create -f $IMGFMT -u -o backing_file="$TEST_IMG",,\? "$TEST_IMG" $size
258
259
# Try to trick qemu-img into creating escaped commas
260
run_qemu_img create -f $IMGFMT -o backing_file="$TEST_IMG", -o help "$TEST_IMG" $size
261
diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out
262
index XXXXXXX..XXXXXXX 100644
263
--- a/tests/qemu-iotests/082.out
264
+++ b/tests/qemu-iotests/082.out
265
@@ -XXX,XX +XXX,XX @@ lazy_refcounts Postpone refcount updates
266
refcount_bits Width of a reference count entry in bits
267
nocow Turn off copy-on-write (valid only on btrfs)
268
269
-Testing: create -f qcow2 -o backing_file=TEST_DIR/t.qcow2,,help TEST_DIR/t.qcow2 128M
270
+Testing: create -f qcow2 -u -o backing_file=TEST_DIR/t.qcow2,,help TEST_DIR/t.qcow2 128M
271
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
272
273
-Testing: create -f qcow2 -o backing_file=TEST_DIR/t.qcow2,,? TEST_DIR/t.qcow2 128M
274
+Testing: create -f qcow2 -u -o backing_file=TEST_DIR/t.qcow2,,? TEST_DIR/t.qcow2 128M
275
Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/t.qcow2,,? cluster_size=65536 lazy_refcounts=off refcount_bits=16
276
277
Testing: create -f qcow2 -o backing_file=TEST_DIR/t.qcow2, -o help TEST_DIR/t.qcow2 128M
278
diff --git a/tests/qemu-iotests/085 b/tests/qemu-iotests/085
279
index XXXXXXX..XXXXXXX 100755
280
--- a/tests/qemu-iotests/085
281
+++ b/tests/qemu-iotests/085
282
@@ -XXX,XX +XXX,XX @@ function add_snapshot_image()
283
{
284
base_image="${TEST_DIR}/$((${1}-1))-${snapshot_virt0}"
285
snapshot_file="${TEST_DIR}/${1}-${snapshot_virt0}"
286
- _make_test_img -b "${base_image}" "$size"
287
+ _make_test_img -u -b "${base_image}" "$size"
288
mv "${TEST_IMG}" "${snapshot_file}"
289
do_blockdev_add "$1" "'backing': '', " "${snapshot_file}"
290
}
291
diff --git a/tests/qemu-iotests/111.out b/tests/qemu-iotests/111.out
292
index XXXXXXX..XXXXXXX 100644
293
--- a/tests/qemu-iotests/111.out
294
+++ b/tests/qemu-iotests/111.out
295
@@ -XXX,XX +XXX,XX @@
296
QA output created by 111
297
qemu-img: TEST_DIR/t.IMGFMT: Could not open 'TEST_DIR/t.IMGFMT.inexistent': No such file or directory
298
+Could not open backing image to determine size.
299
*** done
300
diff --git a/tests/qemu-iotests/139 b/tests/qemu-iotests/139
301
index XXXXXXX..XXXXXXX 100644
302
--- a/tests/qemu-iotests/139
303
+++ b/tests/qemu-iotests/139
304
@@ -XXX,XX +XXX,XX @@ class TestBlockdevDel(iotests.QMPTestCase):
305
# Add a BlockDriverState that will be used as overlay for the base_img BDS
306
def addBlockDriverStateOverlay(self, node):
307
self.checkBlockDriverState(node, False)
308
- iotests.qemu_img('create', '-f', iotests.imgfmt,
309
+ iotests.qemu_img('create', '-u', '-f', iotests.imgfmt,
310
'-b', base_img, new_img, '1M')
311
opts = {'driver': iotests.imgfmt,
312
'node-name': node,
313
diff --git a/tests/qemu-iotests/156 b/tests/qemu-iotests/156
314
index XXXXXXX..XXXXXXX 100755
315
--- a/tests/qemu-iotests/156
316
+++ b/tests/qemu-iotests/156
317
@@ -XXX,XX +XXX,XX @@ _send_qemu_cmd $QEMU_HANDLE \
318
'return'
319
320
# Create snapshot
321
-TEST_IMG="$TEST_IMG.overlay" _make_test_img -b "$TEST_IMG" 1M
322
+TEST_IMG="$TEST_IMG.overlay" _make_test_img -u -b "$TEST_IMG" 1M
323
_send_qemu_cmd $QEMU_HANDLE \
324
"{ 'execute': 'blockdev-snapshot-sync',
325
'arguments': { 'device': 'source',
326
diff --git a/tests/qemu-iotests/158 b/tests/qemu-iotests/158
327
index XXXXXXX..XXXXXXX 100755
328
--- a/tests/qemu-iotests/158
329
+++ b/tests/qemu-iotests/158
330
@@ -XXX,XX +XXX,XX @@ echo "== verify pattern =="
331
$QEMU_IO --object $SECRET -c "read -P 0xa 0 $size" --image-opts $IMGSPECBASE | _filter_qemu_io | _filter_testdir
332
333
echo "== create overlay =="
334
-_make_test_img --object $SECRET -o "encryption=on,encrypt.key-secret=sec0" -b "$TEST_IMG_BASE" $size
335
+_make_test_img -u --object $SECRET -o "encryption=on,encrypt.key-secret=sec0" -b "$TEST_IMG_BASE" $size
336
337
echo
338
echo "== writing part of a cluster =="
339
diff --git a/tests/qemu-iotests/189 b/tests/qemu-iotests/189
340
index XXXXXXX..XXXXXXX 100755
341
--- a/tests/qemu-iotests/189
342
+++ b/tests/qemu-iotests/189
343
@@ -XXX,XX +XXX,XX @@ echo "== verify pattern =="
344
$QEMU_IO --object $SECRET0 -c "read -P 0xa 0 $size" --image-opts $IMGSPECBASE | _filter_qemu_io | _filter_testdir
345
346
echo "== create overlay =="
347
-_make_test_img --object $SECRET1 -o "encrypt.format=luks,encrypt.key-secret=sec1,encrypt.iter-time=10" -b "$TEST_IMG_BASE" $size
348
+_make_test_img --object $SECRET1 -o "encrypt.format=luks,encrypt.key-secret=sec1,encrypt.iter-time=10" -u -b "$TEST_IMG_BASE" $size
349
350
echo
351
echo "== writing part of a cluster =="
230
--
352
--
231
1.8.3.1
353
1.8.3.1
232
354
233
355
diff view generated by jsdifflib