1
The following changes since commit b98a66201dbc7cf3b962f4bb260f66100cc75578:
1
The following changes since commit 7bc8f9734213b76e76631a483be13d6737c2adbc:
2
2
3
Merge remote-tracking branch 'remotes/palmer/tags/riscv-for-master-4.0-rc0-2' into staging (2019-03-19 12:55:02 +0000)
3
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20191025' into staging (2019-10-25 13:12:16 +0100)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
git://repo.or.cz/qemu/kevin.git tags/for-upstream
7
git://repo.or.cz/qemu/kevin.git tags/for-upstream
8
8
9
for you to fetch changes up to 59fba0aaee7438002d9803a86c888f21a1070cc8:
9
for you to fetch changes up to 5e9785505210e2477e590e61b1ab100d0ec22b01:
10
10
11
qemu-iotests: Treat custom TEST_DIR in 051 (2019-03-19 15:51:31 +0100)
11
qcow2: Fix corruption bug in qcow2_detect_metadata_preallocation() (2019-10-25 15:18:55 +0200)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Block layer patches:
14
Block layer patches:
15
15
16
- mirror: Fix early return from drain (could cause deadlocks)
16
- qcow2: Fix data corruption bug that is triggered in partial cluster
17
- vmdk: Fixed probing for version 3 images
17
allocation with default options
18
- vl: Fix to create migration object before block backends again (fixes
18
- qapi: add support for blkreplay driver
19
segfault for block drivers that set migration blockers)
19
- doc: Describe missing generic -blockdev options
20
- Several minor fixes, documentation and test case improvements
20
- iotests: Fix 118 when run as root
21
- Minor code cleanups
21
22
22
----------------------------------------------------------------
23
----------------------------------------------------------------
23
Alberto Garcia (1):
24
Kevin Wolf (5):
24
block: Make bdrv_{copy_on_read,crypto_luks,replication} static
25
iotests: Skip read-only cases in 118 when run as root
26
blockdev: Use error_report() in hmp_commit()
27
doc: Describe missing generic -blockdev options
28
coroutine: Add qemu_co_mutex_assert_locked()
29
qcow2: Fix corruption bug in qcow2_detect_metadata_preallocation()
25
30
26
Kevin Wolf (3):
31
Pavel Dovgaluk (1):
27
qcow2: Fix data file error condition in qcow2_co_create()
32
qapi: add support for blkreplay driver
28
block: Silence Coverity in bdrv_drop_intermediate()
29
qemu-iotests: Fix 232 for non-qcow2
30
33
31
Lukáš Doktor (1):
34
Vladimir Sementsov-Ogievskiy (1):
32
qemu-iotests: Treat custom TEST_DIR in 051
35
block/backup: drop dead code from backup_job_create
33
36
34
Markus Armbruster (1):
37
qapi/block-core.json | 18 ++++++++++++++++--
35
vl: Fix to create migration object before block backends again
38
include/qemu/coroutine.h | 15 +++++++++++++++
39
block/backup.c | 5 +----
40
block/qcow2-refcount.c | 2 ++
41
block/qcow2.c | 3 ++-
42
blockdev.c | 7 +++----
43
qemu-options.hx | 22 +++++++++++++++++++++-
44
tests/qemu-iotests/118 | 3 +++
45
tests/qemu-iotests/iotests.py | 10 ++++++++++
46
9 files changed, 73 insertions(+), 12 deletions(-)
36
47
37
Max Reitz (1):
38
blockdev: Check @replaces in blockdev_mirror_common
39
48
40
Sam Eiderman (1):
41
vmdk: Support version=3 in VMDK descriptor files
42
43
Sergio Lopez (2):
44
mirror: Confirm we're quiesced only if the job is paused or cancelled
45
iotests: 153: Wait for an answer to QMP commands
46
47
Vladimir Sementsov-Ogievskiy (2):
48
qapi: fix block-latency-histogram-set description and examples
49
blockjob: fix user pause in block_job_error_action
50
51
qapi/block-core.json | 10 +++---
52
block.c | 7 ++--
53
block/copy-on-read.c | 2 +-
54
block/crypto.c | 2 +-
55
block/mirror.c | 16 ++++++++++
56
block/qcow2.c | 2 +-
57
block/replication.c | 2 +-
58
block/vmdk.c | 6 ++--
59
blockdev.c | 55 +++++++++++++++++++-------------
60
blockjob.c | 8 +++--
61
vl.c | 15 +++++----
62
tests/qemu-iotests/051 | 2 +-
63
tests/qemu-iotests/153 | 12 +++----
64
tests/qemu-iotests/153.out | 6 ++++
65
tests/qemu-iotests/232 | 30 ------------------
66
tests/qemu-iotests/232.out | 20 ------------
67
tests/qemu-iotests/247 | 79 ++++++++++++++++++++++++++++++++++++++++++++++
68
tests/qemu-iotests/247.out | 22 +++++++++++++
69
tests/qemu-iotests/group | 1 +
70
19 files changed, 193 insertions(+), 104 deletions(-)
71
create mode 100755 tests/qemu-iotests/247
72
create mode 100644 tests/qemu-iotests/247.out
73
diff view generated by jsdifflib
Deleted patch
1
From: Sergio Lopez <slp@redhat.com>
2
1
3
While child_job_drained_begin() calls to job_pause(), the job doesn't
4
actually transition between states until it runs again and reaches a
5
pause point. This means bdrv_drained_begin() may return with some jobs
6
using the node still having 'busy == true'.
7
8
As a consequence, block_job_detach_aio_context() may get into a
9
deadlock, waiting for the job to be actually paused, while the coroutine
10
servicing the job is yielding and doesn't get the opportunity to get
11
scheduled again. This situation can be reproduced by issuing a
12
'block-commit' immediately followed by a 'device_del'.
13
14
To ensure bdrv_drained_begin() only returns when the jobs have been
15
paused, we change mirror_drained_poll() to only confirm it's quiesced
16
when job->paused == true and there aren't any in-flight requests, except
17
if we reached that point by a drained section initiated by the
18
mirror/commit job itself.
19
20
The other block jobs shouldn't need any changes, as the default
21
drained_poll() behavior is to only confirm it's quiesced if the job is
22
not busy or completed.
23
24
Signed-off-by: Sergio Lopez <slp@redhat.com>
25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26
---
27
block/mirror.c | 16 ++++++++++++++++
28
1 file changed, 16 insertions(+)
29
30
diff --git a/block/mirror.c b/block/mirror.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/block/mirror.c
33
+++ b/block/mirror.c
34
@@ -XXX,XX +XXX,XX @@ typedef struct MirrorBlockJob {
35
bool initial_zeroing_ongoing;
36
int in_active_write_counter;
37
bool prepared;
38
+ bool in_drain;
39
} MirrorBlockJob;
40
41
typedef struct MirrorBDSOpaque {
42
@@ -XXX,XX +XXX,XX @@ static int mirror_exit_common(Job *job)
43
44
/* The mirror job has no requests in flight any more, but we need to
45
* drain potential other users of the BDS before changing the graph. */
46
+ assert(s->in_drain);
47
bdrv_drained_begin(target_bs);
48
bdrv_replace_node(to_replace, target_bs, &local_err);
49
bdrv_drained_end(target_bs);
50
@@ -XXX,XX +XXX,XX @@ static int mirror_exit_common(Job *job)
51
bs_opaque->job = NULL;
52
53
bdrv_drained_end(src);
54
+ s->in_drain = false;
55
bdrv_unref(mirror_top_bs);
56
bdrv_unref(src);
57
58
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
59
*/
60
trace_mirror_before_drain(s, cnt);
61
62
+ s->in_drain = true;
63
bdrv_drained_begin(bs);
64
cnt = bdrv_get_dirty_count(s->dirty_bitmap);
65
if (cnt > 0 || mirror_flush(s) < 0) {
66
bdrv_drained_end(bs);
67
+ s->in_drain = false;
68
continue;
69
}
70
71
@@ -XXX,XX +XXX,XX @@ immediate_exit:
72
bdrv_dirty_iter_free(s->dbi);
73
74
if (need_drain) {
75
+ s->in_drain = true;
76
bdrv_drained_begin(bs);
77
}
78
79
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn mirror_pause(Job *job)
80
static bool mirror_drained_poll(BlockJob *job)
81
{
82
MirrorBlockJob *s = container_of(job, MirrorBlockJob, common);
83
+
84
+ /* If the job isn't paused nor cancelled, we can't be sure that it won't
85
+ * issue more requests. We make an exception if we've reached this point
86
+ * from one of our own drain sections, to avoid a deadlock waiting for
87
+ * ourselves.
88
+ */
89
+ if (!s->common.job.paused && !s->common.job.cancelled && !s->in_drain) {
90
+ return true;
91
+ }
92
+
93
return !!s->in_flight;
94
}
95
96
--
97
2.20.1
98
99
diff view generated by jsdifflib
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
From: Pavel Dovgalyuk <pavel.dovgaluk@gmail.com>
2
2
3
There no @device parameter, only the @id one.
3
This patch adds support for blkreplay driver to the blockdev options.
4
Now blkreplay can be used with -blockdev command line option
5
in the following format:
6
-blockdev driver=blkreplay,image=file-node-name,node-name=replay-node-name
4
7
5
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
8
This option makes possible implementation of the better command
6
Reviewed-by: Eric Blake <eblake@redhat.com>
9
line support for record/replay invocations.
10
11
Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
---
13
---
9
qapi/block-core.json | 10 +++++-----
14
qapi/block-core.json | 18 ++++++++++++++++--
10
1 file changed, 5 insertions(+), 5 deletions(-)
15
1 file changed, 16 insertions(+), 2 deletions(-)
11
16
12
diff --git a/qapi/block-core.json b/qapi/block-core.json
17
diff --git a/qapi/block-core.json b/qapi/block-core.json
13
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
14
--- a/qapi/block-core.json
19
--- a/qapi/block-core.json
15
+++ b/qapi/block-core.json
20
+++ b/qapi/block-core.json
16
@@ -XXX,XX +XXX,XX @@
21
@@ -XXX,XX +XXX,XX @@
22
# @nvme: Since 2.12
23
# @copy-on-read: Since 3.0
24
# @blklogwrites: Since 3.0
25
+# @blkreplay: Since 4.2
17
#
26
#
18
# Manage read, write and flush latency histograms for the device.
27
# Since: 2.9
19
#
28
##
20
-# If only @device parameter is specified, remove all present latency histograms
29
{ 'enum': 'BlockdevDriver',
21
+# If only @id parameter is specified, remove all present latency histograms
30
- 'data': [ 'blkdebug', 'blklogwrites', 'blkverify', 'bochs', 'cloop',
22
# for the device. Otherwise, add/reset some of (or all) latency histograms.
31
- 'copy-on-read', 'dmg', 'file', 'ftp', 'ftps', 'gluster',
23
#
32
+ 'data': [ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify', 'bochs',
24
# @id: The name or QOM path of the guest device.
33
+ 'cloop', 'copy-on-read', 'dmg', 'file', 'ftp', 'ftps', 'gluster',
34
'host_cdrom', 'host_device', 'http', 'https', 'iscsi', 'luks',
35
'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels', 'qcow',
36
'qcow2', 'qed', 'quorum', 'raw', 'rbd',
25
@@ -XXX,XX +XXX,XX @@
37
@@ -XXX,XX +XXX,XX @@
26
# [0, 10), [10, 50), [50, 100), [100, +inf):
38
'data': { 'test': 'BlockdevRef',
27
#
39
'raw': 'BlockdevRef' } }
28
# -> { "execute": "block-latency-histogram-set",
40
29
-# "arguments": { "device": "drive0",
41
+##
30
+# "arguments": { "id": "drive0",
42
+# @BlockdevOptionsBlkreplay:
31
# "boundaries": [10, 50, 100] } }
43
+#
32
# <- { "return": {} }
44
+# Driver specific block device options for blkreplay.
45
+#
46
+# @image: disk image which should be controlled with blkreplay
47
+#
48
+# Since: 4.2
49
+##
50
+{ 'struct': 'BlockdevOptionsBlkreplay',
51
+ 'data': { 'image': 'BlockdevRef' } }
52
+
53
##
54
# @QuorumReadPattern:
33
#
55
#
34
@@ -XXX,XX +XXX,XX @@
56
@@ -XXX,XX +XXX,XX @@
35
# not changed (or not created):
57
'blkdebug': 'BlockdevOptionsBlkdebug',
36
#
58
'blklogwrites':'BlockdevOptionsBlklogwrites',
37
# -> { "execute": "block-latency-histogram-set",
59
'blkverify': 'BlockdevOptionsBlkverify',
38
-# "arguments": { "device": "drive0",
60
+ 'blkreplay': 'BlockdevOptionsBlkreplay',
39
+# "arguments": { "id": "drive0",
61
'bochs': 'BlockdevOptionsGenericFormat',
40
# "boundaries-write": [10, 50, 100] } }
62
'cloop': 'BlockdevOptionsGenericFormat',
41
# <- { "return": {} }
63
'copy-on-read':'BlockdevOptionsGenericFormat',
42
#
43
@@ -XXX,XX +XXX,XX @@
44
# write: [0, 1000), [1000, 5000), [5000, +inf)
45
#
46
# -> { "execute": "block-latency-histogram-set",
47
-# "arguments": { "device": "drive0",
48
+# "arguments": { "id": "drive0",
49
# "boundaries": [10, 50, 100],
50
# "boundaries-write": [1000, 5000] } }
51
# <- { "return": {} }
52
@@ -XXX,XX +XXX,XX @@
53
# Example: remove all latency histograms:
54
#
55
# -> { "execute": "block-latency-histogram-set",
56
-# "arguments": { "device": "drive0" } }
57
+# "arguments": { "id": "drive0" } }
58
# <- { "return": {} }
59
##
60
{ 'command': 'block-latency-histogram-set',
61
--
64
--
62
2.20.1
65
2.20.1
63
66
64
67
diff view generated by jsdifflib
1
Coverity doesn't like that the return value of bdrv_check_update_perm()
1
Some tests in 118 use chmod to remove write permissions from the file
2
stays unused only in this place (CID 1399710).
2
and assume that the image can indeed not be opened read-write
3
afterwards. This doesn't work when the test is run as root, because root
4
can still open the file as writable even when the permission bit isn't
5
set.
3
6
4
Even if checking local_err should be equivalent to checking ret < 0,
7
Introduce a @skip_if_root decorator and use it in 118 to skip the tests
5
let's switch to using the return value to be more consistent (and in
8
in question when the script is run as root.
6
case of a bug somewhere down the call chain, forgetting to assign errp
7
is more likely than returning 0 for an error case).
8
9
9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10
Reviewed-by: Alberto Garcia <berto@igalia.com>
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Markus Armbruster <armbru@redhat.com>
13
---
12
---
14
block.c | 7 +++----
13
tests/qemu-iotests/118 | 3 +++
15
1 file changed, 3 insertions(+), 4 deletions(-)
14
tests/qemu-iotests/iotests.py | 10 ++++++++++
15
2 files changed, 13 insertions(+)
16
16
17
diff --git a/block.c b/block.c
17
diff --git a/tests/qemu-iotests/118 b/tests/qemu-iotests/118
18
index XXXXXXX..XXXXXXX 100755
19
--- a/tests/qemu-iotests/118
20
+++ b/tests/qemu-iotests/118
21
@@ -XXX,XX +XXX,XX @@ class TestChangeReadOnly(ChangeBaseClass):
22
self.assert_qmp(result, 'return[0]/inserted/ro', True)
23
self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
24
25
+ @iotests.skip_if_user_is_root
26
def test_rw_ro_retain(self):
27
os.chmod(new_img, 0o444)
28
self.vm.add_drive(old_img, 'media=disk', 'none')
29
@@ -XXX,XX +XXX,XX @@ class TestChangeReadOnly(ChangeBaseClass):
30
self.assert_qmp(result, 'return[0]/inserted/ro', True)
31
self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
32
33
+ @iotests.skip_if_user_is_root
34
def test_make_ro_rw(self):
35
os.chmod(new_img, 0o444)
36
self.vm.add_drive(old_img, 'media=disk', 'none')
37
@@ -XXX,XX +XXX,XX @@ class TestChangeReadOnly(ChangeBaseClass):
38
self.assert_qmp(result, 'return[0]/inserted/ro', True)
39
self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
40
41
+ @iotests.skip_if_user_is_root
42
def test_make_ro_rw_by_retain(self):
43
os.chmod(new_img, 0o444)
44
self.vm.add_drive(old_img, 'media=disk', 'none')
45
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
18
index XXXXXXX..XXXXXXX 100644
46
index XXXXXXX..XXXXXXX 100644
19
--- a/block.c
47
--- a/tests/qemu-iotests/iotests.py
20
+++ b/block.c
48
+++ b/tests/qemu-iotests/iotests.py
21
@@ -XXX,XX +XXX,XX @@ int bdrv_drop_intermediate(BlockDriverState *top, BlockDriverState *base,
49
@@ -XXX,XX +XXX,XX @@ def skip_if_unsupported(required_formats=[], read_only=False):
22
QLIST_FOREACH_SAFE(c, &top->parents, next_parent, next) {
50
return func_wrapper
23
/* Check whether we are allowed to switch c from top to base */
51
return skip_test_decorator
24
GSList *ignore_children = g_slist_prepend(NULL, c);
52
25
- bdrv_check_update_perm(base, NULL, c->perm, c->shared_perm,
53
+def skip_if_user_is_root(func):
26
- ignore_children, &local_err);
54
+ '''Skip Test Decorator
27
+ ret = bdrv_check_update_perm(base, NULL, c->perm, c->shared_perm,
55
+ Runs the test only without root permissions'''
28
+ ignore_children, &local_err);
56
+ def func_wrapper(*args, **kwargs):
29
g_slist_free(ignore_children);
57
+ if os.getuid() == 0:
30
- if (local_err) {
58
+ case_notrun('{}: cannot be run as root'.format(args[0]))
31
- ret = -EPERM;
59
+ else:
32
+ if (ret < 0) {
60
+ return func(*args, **kwargs)
33
error_report_err(local_err);
61
+ return func_wrapper
34
goto exit;
62
+
35
}
63
def execute_unittest(output, verbosity, debug):
64
runner = unittest.TextTestRunner(stream=output, descriptions=True,
65
verbosity=verbosity)
36
--
66
--
37
2.20.1
67
2.20.1
38
68
39
69
diff view generated by jsdifflib
1
From: Max Reitz <mreitz@redhat.com>
1
Instead of using monitor_printf() to report errors, hmp_commit() should
2
use error_report() like other places do.
2
3
3
There is no reason why the constraints we put on @replaces should be
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4
limited to drive-mirror. Therefore, move the sanity checks from
5
qmp_drive_mirror() to blockdev_mirror_common() so they apply to
6
blockdev-mirror as well.
7
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
Reviewed-by: Eric Blake <eblake@redhat.com>
5
Reviewed-by: Eric Blake <eblake@redhat.com>
10
Reviewed-by: Alberto Garcia <berto@igalia.com>
6
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12
---
7
---
13
blockdev.c | 55 ++++++++++++++++++++++++++++++++----------------------
8
blockdev.c | 7 +++----
14
1 file changed, 33 insertions(+), 22 deletions(-)
9
1 file changed, 3 insertions(+), 4 deletions(-)
15
10
16
diff --git a/blockdev.c b/blockdev.c
11
diff --git a/blockdev.c b/blockdev.c
17
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
18
--- a/blockdev.c
13
--- a/blockdev.c
19
+++ b/blockdev.c
14
+++ b/blockdev.c
20
@@ -XXX,XX +XXX,XX @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
15
@@ -XXX,XX +XXX,XX @@ void hmp_commit(Monitor *mon, const QDict *qdict)
21
sync = MIRROR_SYNC_MODE_FULL;
16
17
blk = blk_by_name(device);
18
if (!blk) {
19
- monitor_printf(mon, "Device '%s' not found\n", device);
20
+ error_report("Device '%s' not found", device);
21
return;
22
}
23
if (!blk_is_available(blk)) {
24
- monitor_printf(mon, "Device '%s' has no medium\n", device);
25
+ error_report("Device '%s' has no medium", device);
26
return;
27
}
28
29
@@ -XXX,XX +XXX,XX @@ void hmp_commit(Monitor *mon, const QDict *qdict)
30
aio_context_release(aio_context);
22
}
31
}
23
32
if (ret < 0) {
24
+ if (has_replaces) {
33
- monitor_printf(mon, "'commit' error for '%s': %s\n", device,
25
+ BlockDriverState *to_replace_bs;
34
- strerror(-ret));
26
+ AioContext *replace_aio_context;
35
+ error_report("'commit' error for '%s': %s", device, strerror(-ret));
27
+ int64_t bs_size, replace_size;
28
+
29
+ bs_size = bdrv_getlength(bs);
30
+ if (bs_size < 0) {
31
+ error_setg_errno(errp, -bs_size, "Failed to query device's size");
32
+ return;
33
+ }
34
+
35
+ to_replace_bs = check_to_replace_node(bs, replaces, errp);
36
+ if (!to_replace_bs) {
37
+ return;
38
+ }
39
+
40
+ replace_aio_context = bdrv_get_aio_context(to_replace_bs);
41
+ aio_context_acquire(replace_aio_context);
42
+ replace_size = bdrv_getlength(to_replace_bs);
43
+ aio_context_release(replace_aio_context);
44
+
45
+ if (replace_size < 0) {
46
+ error_setg_errno(errp, -replace_size,
47
+ "Failed to query the replacement node's size");
48
+ return;
49
+ }
50
+ if (bs_size != replace_size) {
51
+ error_setg(errp, "cannot replace image with a mirror image of "
52
+ "different size");
53
+ return;
54
+ }
55
+ }
56
+
57
/* pass the node name to replace to mirror start since it's loose coupling
58
* and will allow to check whether the node still exist at mirror completion
59
*/
60
@@ -XXX,XX +XXX,XX @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
61
}
36
}
62
37
}
63
if (arg->has_replaces) {
38
64
- BlockDriverState *to_replace_bs;
65
- AioContext *replace_aio_context;
66
- int64_t replace_size;
67
-
68
if (!arg->has_node_name) {
69
error_setg(errp, "a node-name must be provided when replacing a"
70
" named node of the graph");
71
goto out;
72
}
73
-
74
- to_replace_bs = check_to_replace_node(bs, arg->replaces, &local_err);
75
-
76
- if (!to_replace_bs) {
77
- error_propagate(errp, local_err);
78
- goto out;
79
- }
80
-
81
- replace_aio_context = bdrv_get_aio_context(to_replace_bs);
82
- aio_context_acquire(replace_aio_context);
83
- replace_size = bdrv_getlength(to_replace_bs);
84
- aio_context_release(replace_aio_context);
85
-
86
- if (size != replace_size) {
87
- error_setg(errp, "cannot replace image with a mirror image of "
88
- "different size");
89
- goto out;
90
- }
91
}
92
93
if (arg->mode == NEW_IMAGE_MODE_ABSOLUTE_PATHS) {
94
--
39
--
95
2.20.1
40
2.20.1
96
41
97
42
diff view generated by jsdifflib
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
2
3
Job (especially mirror) may call block_job_error_action several
3
After commit 00e30f05de1d195, there is no more "goto error" points
4
times before actual pause if it has several in-flight requests.
4
after job creation, so after "error:" @job is always NULL and we don't
5
need roll-back job creation.
5
6
6
block_job_error_action will call job_pause more than once in this case,
7
Reported-by: Coverity (CID 1406402)
7
which lead to following block-job-resume qmp command can't actually
8
resume the job.
9
10
Fix it by do not increase pause level in block_job_error_action if
11
user_paused already set.
12
13
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
8
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
9
Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
15
---
11
---
16
blockjob.c | 8 +++++---
12
block/backup.c | 5 +----
17
1 file changed, 5 insertions(+), 3 deletions(-)
13
1 file changed, 1 insertion(+), 4 deletions(-)
18
14
19
diff --git a/blockjob.c b/blockjob.c
15
diff --git a/block/backup.c b/block/backup.c
20
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
21
--- a/blockjob.c
17
--- a/block/backup.c
22
+++ b/blockjob.c
18
+++ b/block/backup.c
23
@@ -XXX,XX +XXX,XX @@ BlockErrorAction block_job_error_action(BlockJob *job, BlockdevOnError on_err,
19
@@ -XXX,XX +XXX,XX @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
24
action);
20
if (sync_bitmap) {
21
bdrv_reclaim_dirty_bitmap(sync_bitmap, NULL);
25
}
22
}
26
if (action == BLOCK_ERROR_ACTION_STOP) {
23
- if (job) {
27
- job_pause(&job->job);
24
- backup_clean(&job->common.job);
28
- /* make the pause user visible, which will be resumed from QMP. */
25
- job_early_fail(&job->common.job);
29
- job->job.user_paused = true;
26
- } else if (backup_top) {
30
+ if (!job->job.user_paused) {
27
+ if (backup_top) {
31
+ job_pause(&job->job);
28
bdrv_backup_top_drop(backup_top);
32
+ /* make the pause user visible, which will be resumed from QMP. */
33
+ job->job.user_paused = true;
34
+ }
35
block_job_iostatus_set_err(job, error);
36
}
29
}
37
return action;
30
38
--
31
--
39
2.20.1
32
2.20.1
40
33
41
34
diff view generated by jsdifflib
1
232 is marked as generic, but commit 12efe428c9e added code that assumes
1
We added more generic options after introducing -blockdev and forgot to
2
qcow2. What the new test really needs is backing files and support for
2
update the documentation (man page and --help output) accordingly. Do
3
updating the backing file link (.bdrv_change_backing_file).
3
that now.
4
5
Split the non-generic code into a new test case 247 and make it work
6
with qed, too.
7
4
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
---
7
---
10
tests/qemu-iotests/232 | 30 ---------------
8
qemu-options.hx | 22 +++++++++++++++++++++-
11
tests/qemu-iotests/232.out | 20 ----------
9
1 file changed, 21 insertions(+), 1 deletion(-)
12
tests/qemu-iotests/247 | 79 ++++++++++++++++++++++++++++++++++++++
13
tests/qemu-iotests/247.out | 22 +++++++++++
14
tests/qemu-iotests/group | 1 +
15
5 files changed, 102 insertions(+), 50 deletions(-)
16
create mode 100755 tests/qemu-iotests/247
17
create mode 100644 tests/qemu-iotests/247.out
18
10
19
diff --git a/tests/qemu-iotests/232 b/tests/qemu-iotests/232
11
diff --git a/qemu-options.hx b/qemu-options.hx
20
index XXXXXXX..XXXXXXX 100755
21
--- a/tests/qemu-iotests/232
22
+++ b/tests/qemu-iotests/232
23
@@ -XXX,XX +XXX,XX @@ run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,a
24
run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=on
25
run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0
26
27
-echo
28
-echo "=== Try commit to backing file with auto-read-only ==="
29
-echo
30
-
31
-TEST_IMG="$TEST_IMG.0" _make_test_img $size
32
-TEST_IMG="$TEST_IMG.1" _make_test_img $size
33
-TEST_IMG="$TEST_IMG.2" _make_test_img $size
34
-TEST_IMG="$TEST_IMG.3" _make_test_img $size
35
-TEST_IMG="$TEST_IMG.4" _make_test_img $size
36
-
37
-(cat <<EOF
38
-{"execute":"qmp_capabilities"}
39
-{"execute":"block-commit",
40
- "arguments":{"device":"format-4", "top-node": "format-2", "base-node":"format-0", "job-id":"job0"}}
41
-EOF
42
-sleep 1
43
-echo '{"execute":"quit"}'
44
-) | $QEMU -qmp stdio -nographic -nodefaults \
45
- -blockdev file,node-name=file-0,filename=$TEST_IMG.0,auto-read-only=on \
46
- -blockdev qcow2,node-name=format-0,file=file-0,read-only=on \
47
- -blockdev file,node-name=file-1,filename=$TEST_IMG.1,auto-read-only=on \
48
- -blockdev qcow2,node-name=format-1,file=file-1,read-only=on,backing=format-0 \
49
- -blockdev file,node-name=file-2,filename=$TEST_IMG.2,auto-read-only=on \
50
- -blockdev qcow2,node-name=format-2,file=file-2,read-only=on,backing=format-1 \
51
- -blockdev file,node-name=file-3,filename=$TEST_IMG.3,auto-read-only=on \
52
- -blockdev qcow2,node-name=format-3,file=file-3,read-only=on,backing=format-2 \
53
- -blockdev file,node-name=file-4,filename=$TEST_IMG.4,auto-read-only=on \
54
- -blockdev qcow2,node-name=format-4,file=file-4,read-only=on,backing=format-3 |
55
- _filter_qmp
56
-
57
# success, all done
58
echo "*** done"
59
rm -f $seq.full
60
diff --git a/tests/qemu-iotests/232.out b/tests/qemu-iotests/232.out
61
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
62
--- a/tests/qemu-iotests/232.out
13
--- a/qemu-options.hx
63
+++ b/tests/qemu-iotests/232.out
14
+++ b/qemu-options.hx
64
@@ -XXX,XX +XXX,XX @@ QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,read
15
@@ -XXX,XX +XXX,XX @@ ETEXI
65
QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
16
DEF("blockdev", HAS_ARG, QEMU_OPTION_blockdev,
66
node0: TEST_DIR/t.IMGFMT (file)
17
"-blockdev [driver=]driver[,node-name=N][,discard=ignore|unmap]\n"
67
QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
18
" [,cache.direct=on|off][,cache.no-flush=on|off]\n"
68
-
19
- " [,read-only=on|off][,detect-zeroes=on|off|unmap]\n"
69
-=== Try commit to backing file with auto-read-only ===
20
+ " [,read-only=on|off][,auto-read-only=on|off]\n"
70
-
21
+ " [,force-share=on|off][,detect-zeroes=on|off|unmap]\n"
71
-Formatting 'TEST_DIR/t.IMGFMT.0', fmt=IMGFMT size=134217728
22
" [,driver specific parameters...]\n"
72
-Formatting 'TEST_DIR/t.IMGFMT.1', fmt=IMGFMT size=134217728
23
" configure a block backend\n", QEMU_ARCH_ALL)
73
-Formatting 'TEST_DIR/t.IMGFMT.2', fmt=IMGFMT size=134217728
24
STEXI
74
-Formatting 'TEST_DIR/t.IMGFMT.3', fmt=IMGFMT size=134217728
25
@@ -XXX,XX +XXX,XX @@ name is not intended to be predictable and changes between QEMU invocations.
75
-Formatting 'TEST_DIR/t.IMGFMT.4', fmt=IMGFMT size=134217728
26
For the top level, an explicit node name must be specified.
76
-QMP_VERSION
27
@item read-only
77
-{"return": {}}
28
Open the node read-only. Guest write attempts will fail.
78
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "job0"}}
79
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "job0"}}
80
-{"return": {}}
81
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "job0"}}
82
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "job0"}}
83
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "job0", "len": 134217728, "offset": 134217728, "speed": 0, "type": "commit"}}
84
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "job0"}}
85
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "job0"}}
86
-{"return": {}}
87
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}}
88
*** done
89
diff --git a/tests/qemu-iotests/247 b/tests/qemu-iotests/247
90
new file mode 100755
91
index XXXXXXX..XXXXXXX
92
--- /dev/null
93
+++ b/tests/qemu-iotests/247
94
@@ -XXX,XX +XXX,XX @@
95
+#!/usr/bin/env bash
96
+#
97
+# Test for auto-read-only with commit block job
98
+#
99
+# Copyright (C) 2019 Red Hat, Inc.
100
+#
101
+# This program is free software; you can redistribute it and/or modify
102
+# it under the terms of the GNU General Public License as published by
103
+# the Free Software Foundation; either version 2 of the License, or
104
+# (at your option) any later version.
105
+#
106
+# This program is distributed in the hope that it will be useful,
107
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
108
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
109
+# GNU General Public License for more details.
110
+#
111
+# You should have received a copy of the GNU General Public License
112
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
113
+#
114
+
29
+
115
+# creator
30
+Note that some block drivers support only read-only access, either generally or
116
+owner=kwolf@redhat.com
31
+in certain configurations. In this case, the default value
32
+@option{read-only=off} does not work and the option must be specified
33
+explicitly.
34
+@item auto-read-only
35
+If @option{auto-read-only=on} is set, QEMU may fall back to read-only usage
36
+even when @option{read-only=off} is requested, or even switch between modes as
37
+needed, e.g. depending on whether the image file is writable or whether a
38
+writing user is attached to the node.
39
+@item force-share
40
+Override the image locking system of QEMU by forcing the node to utilize
41
+weaker shared access for permissions where it would normally request exclusive
42
+access. When there is the potential for multiple instances to have the same
43
+file open (whether this invocation of QEMU is the first or the second
44
+instance), both instances must permit shared access for the second instance to
45
+succeed at opening the file.
117
+
46
+
118
+seq=`basename $0`
47
+Enabling @option{force-share=on} requires @option{read-only=on}.
119
+echo "QA output created by $seq"
48
@item cache.direct
120
+
49
The host page cache can be avoided with @option{cache.direct=on}. This will
121
+status=1    # failure is the default!
50
attempt to do disk IO directly to the guest's memory. QEMU may still perform an
122
+
123
+_cleanup()
124
+{
125
+ _cleanup_test_img
126
+ rm -f $TEST_IMG.[01234]
127
+}
128
+trap "_cleanup; exit \$status" 0 1 2 3 15
129
+
130
+# get standard environment, filters and checks
131
+. ./common.rc
132
+. ./common.filter
133
+
134
+# Requires backing files and .bdrv_change_backing_file support
135
+_supported_fmt qcow2 qed
136
+_supported_proto file
137
+_supported_os Linux
138
+
139
+size=128M
140
+
141
+echo
142
+echo "=== Try commit to backing file with auto-read-only ==="
143
+echo
144
+TEST_IMG="$TEST_IMG.0" _make_test_img $size
145
+TEST_IMG="$TEST_IMG.1" _make_test_img $size
146
+TEST_IMG="$TEST_IMG.2" _make_test_img $size
147
+TEST_IMG="$TEST_IMG.3" _make_test_img $size
148
+TEST_IMG="$TEST_IMG.4" _make_test_img $size
149
+
150
+(cat <<EOF
151
+{"execute":"qmp_capabilities"}
152
+{"execute":"block-commit",
153
+ "arguments":{"device":"format-4", "top-node": "format-2", "base-node":"format-0", "job-id":"job0"}}
154
+EOF
155
+sleep 1
156
+echo '{"execute":"quit"}'
157
+) | $QEMU -qmp stdio -nographic -nodefaults \
158
+ -blockdev file,node-name=file-0,filename=$TEST_IMG.0,auto-read-only=on \
159
+ -blockdev $IMGFMT,node-name=format-0,file=file-0,read-only=on \
160
+ -blockdev file,node-name=file-1,filename=$TEST_IMG.1,auto-read-only=on \
161
+ -blockdev $IMGFMT,node-name=format-1,file=file-1,read-only=on,backing=format-0 \
162
+ -blockdev file,node-name=file-2,filename=$TEST_IMG.2,auto-read-only=on \
163
+ -blockdev $IMGFMT,node-name=format-2,file=file-2,read-only=on,backing=format-1 \
164
+ -blockdev file,node-name=file-3,filename=$TEST_IMG.3,auto-read-only=on \
165
+ -blockdev $IMGFMT,node-name=format-3,file=file-3,read-only=on,backing=format-2 \
166
+ -blockdev file,node-name=file-4,filename=$TEST_IMG.4,auto-read-only=on \
167
+ -blockdev $IMGFMT,node-name=format-4,file=file-4,read-only=on,backing=format-3 |
168
+ _filter_qmp
169
+
170
+# success, all done
171
+echo "*** done"
172
+rm -f $seq.full
173
+status=0
174
diff --git a/tests/qemu-iotests/247.out b/tests/qemu-iotests/247.out
175
new file mode 100644
176
index XXXXXXX..XXXXXXX
177
--- /dev/null
178
+++ b/tests/qemu-iotests/247.out
179
@@ -XXX,XX +XXX,XX @@
180
+QA output created by 247
181
+
182
+=== Try commit to backing file with auto-read-only ===
183
+
184
+Formatting 'TEST_DIR/t.IMGFMT.0', fmt=IMGFMT size=134217728
185
+Formatting 'TEST_DIR/t.IMGFMT.1', fmt=IMGFMT size=134217728
186
+Formatting 'TEST_DIR/t.IMGFMT.2', fmt=IMGFMT size=134217728
187
+Formatting 'TEST_DIR/t.IMGFMT.3', fmt=IMGFMT size=134217728
188
+Formatting 'TEST_DIR/t.IMGFMT.4', fmt=IMGFMT size=134217728
189
+QMP_VERSION
190
+{"return": {}}
191
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "job0"}}
192
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "job0"}}
193
+{"return": {}}
194
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "job0"}}
195
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "job0"}}
196
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "job0", "len": 134217728, "offset": 134217728, "speed": 0, "type": "commit"}}
197
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "job0"}}
198
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "job0"}}
199
+{"return": {}}
200
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}}
201
+*** done
202
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
203
index XXXXXXX..XXXXXXX 100644
204
--- a/tests/qemu-iotests/group
205
+++ b/tests/qemu-iotests/group
206
@@ -XXX,XX +XXX,XX @@
207
244 rw auto quick
208
245 rw auto
209
246 rw auto quick
210
+247 rw auto quick
211
--
51
--
212
2.20.1
52
2.20.1
213
53
214
54
diff view generated by jsdifflib
1
From: Lukáš Doktor <ldoktor@redhat.com>
1
Some functions require that the caller holds a certain CoMutex for them
2
to operate correctly. Add a function so that they can assert the lock is
3
really held.
2
4
3
When custom TEST_DIR is specified the output includes it without leading
5
Cc: qemu-stable@nongnu.org
4
'/':
6
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7
Tested-by: Michael Weiser <michael.weiser@gmx.de>
8
Reviewed-by: Michael Weiser <michael.weiser@gmx.de>
9
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
10
Reviewed-by: Denis V. Lunev <den@openvz.org>
11
Reviewed-by: Max Reitz <mreitz@redhat.com>
12
---
13
include/qemu/coroutine.h | 15 +++++++++++++++
14
1 file changed, 15 insertions(+)
5
15
6
$ TEST_DIR=/var/tmp ./check -file -qcow2 051
16
diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h
7
....
17
index XXXXXXX..XXXXXXX 100644
8
-drive0 (NODE_NAME): json:{"backing": {"driver": "qcow2", "file":
18
--- a/include/qemu/coroutine.h
9
{"driver": "file", "filename": "TEST_DIR/t.qcow2"}}, "driver": "qcow2",
19
+++ b/include/qemu/coroutine.h
10
"file": {"driver": "file", "filename": SNAPSHOT_PATH}} (qcow2,
20
@@ -XXX,XX +XXX,XX @@ void coroutine_fn qemu_co_mutex_lock(CoMutex *mutex);
11
read-only)
21
*/
12
+drive0 (NODE_NAME): json:{"backing": {"driver": "qcow2", "file":
22
void coroutine_fn qemu_co_mutex_unlock(CoMutex *mutex);
13
{"driver": "file", "filename": "TEST_DIR/t.qcow2"}}, "driver": "qcow2",
23
14
"file": {"driver": "file", "filename": "TEST_DIR/vl.ziHfeP"}} (qcow2,
24
+/**
15
read-only)
25
+ * Assert that the current coroutine holds @mutex.
16
26
+ */
17
Let's remove it from the sed regexp.
27
+static inline coroutine_fn void qemu_co_mutex_assert_locked(CoMutex *mutex)
18
28
+{
19
Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
29
+ /*
20
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
30
+ * mutex->holder doesn't need any synchronisation if the assertion holds
21
---
31
+ * true because the mutex protects it. If it doesn't hold true, we still
22
tests/qemu-iotests/051 | 2 +-
32
+ * don't mind if another thread takes or releases mutex behind our back,
23
1 file changed, 1 insertion(+), 1 deletion(-)
33
+ * because the condition will be false no matter whether we read NULL or
24
34
+ * the pointer for any other coroutine.
25
diff --git a/tests/qemu-iotests/051 b/tests/qemu-iotests/051
35
+ */
26
index XXXXXXX..XXXXXXX 100755
36
+ assert(atomic_read(&mutex->locked) &&
27
--- a/tests/qemu-iotests/051
37
+ mutex->holder == qemu_coroutine_self());
28
+++ b/tests/qemu-iotests/051
38
+}
29
@@ -XXX,XX +XXX,XX @@ TMPDIR=/nonexistent run_qemu -drive driver=null-co,snapshot=on
39
30
echo "info block" |
40
/**
31
run_qemu -drive file="$TEST_IMG",snapshot=on,read-only=on,if=none,id=$device_id |
41
* CoQueues are a mechanism to queue coroutines in order to continue executing
32
_filter_qemu_io |
33
- sed -e 's#"/[^"]*/vl\.[A-Za-z0-9]\{6\}"#SNAPSHOT_PATH#g'
34
+ sed -e 's#"[^"]*/vl\.[A-Za-z0-9]\{6\}"#SNAPSHOT_PATH#g'
35
36
37
# success, all done
38
--
42
--
39
2.20.1
43
2.20.1
40
44
41
45
diff view generated by jsdifflib
1
We were trying to check whether bdrv_open_blockdev_ref() returned
1
qcow2_detect_metadata_preallocation() calls qcow2_get_refcount() which
2
success, but accidentally checked the wrong variable. Spotted by
2
requires s->lock to be taken to protect its accesses to the refcount
3
Coverity (CID 1399703).
3
table and refcount blocks. However, nothing in this code path actually
4
took the lock. This could cause the same cache entry to be used by two
5
requests at the same time, for different tables at different offsets,
6
resulting in image corruption.
4
7
8
As it would be preferable to base the detection on consistent data (even
9
though it's just heuristics), let's take the lock not only around the
10
qcow2_get_refcount() calls, but around the whole function.
11
12
This patch takes the lock in qcow2_co_block_status() earlier and asserts
13
in qcow2_detect_metadata_preallocation() that we hold the lock.
14
15
Fixes: 69f47505ee66afaa513305de0c1895a224e52c45
16
Cc: qemu-stable@nongnu.org
17
Reported-by: Michael Weiser <michael.weiser@gmx.de>
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
18
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
6
Reviewed-by: Eric Blake <eblake@redhat.com>
19
Tested-by: Michael Weiser <michael.weiser@gmx.de>
7
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
20
Reviewed-by: Michael Weiser <michael.weiser@gmx.de>
21
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
22
Reviewed-by: Max Reitz <mreitz@redhat.com>
8
---
23
---
9
block/qcow2.c | 2 +-
24
block/qcow2-refcount.c | 2 ++
10
1 file changed, 1 insertion(+), 1 deletion(-)
25
block/qcow2.c | 3 ++-
26
2 files changed, 4 insertions(+), 1 deletion(-)
11
27
28
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/block/qcow2-refcount.c
31
+++ b/block/qcow2-refcount.c
32
@@ -XXX,XX +XXX,XX @@ int qcow2_detect_metadata_preallocation(BlockDriverState *bs)
33
int64_t i, end_cluster, cluster_count = 0, threshold;
34
int64_t file_length, real_allocation, real_clusters;
35
36
+ qemu_co_mutex_assert_locked(&s->lock);
37
+
38
file_length = bdrv_getlength(bs->file->bs);
39
if (file_length < 0) {
40
return file_length;
12
diff --git a/block/qcow2.c b/block/qcow2.c
41
diff --git a/block/qcow2.c b/block/qcow2.c
13
index XXXXXXX..XXXXXXX 100644
42
index XXXXXXX..XXXXXXX 100644
14
--- a/block/qcow2.c
43
--- a/block/qcow2.c
15
+++ b/block/qcow2.c
44
+++ b/block/qcow2.c
16
@@ -XXX,XX +XXX,XX @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
45
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_co_block_status(BlockDriverState *bs,
17
goto out;
46
unsigned int bytes;
18
}
47
int status = 0;
19
data_bs = bdrv_open_blockdev_ref(qcow2_opts->data_file, errp);
48
20
- if (bs == NULL) {
49
+ qemu_co_mutex_lock(&s->lock);
21
+ if (data_bs == NULL) {
50
+
22
ret = -EIO;
51
if (!s->metadata_preallocation_checked) {
23
goto out;
52
ret = qcow2_detect_metadata_preallocation(bs);
24
}
53
s->metadata_preallocation = (ret == 1);
54
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_co_block_status(BlockDriverState *bs,
55
}
56
57
bytes = MIN(INT_MAX, count);
58
- qemu_co_mutex_lock(&s->lock);
59
ret = qcow2_get_cluster_offset(bs, offset, &bytes, &cluster_offset);
60
qemu_co_mutex_unlock(&s->lock);
61
if (ret < 0) {
25
--
62
--
26
2.20.1
63
2.20.1
27
64
28
65
diff view generated by jsdifflib
Deleted patch
1
From: Sam Eiderman <shmuel.eiderman@oracle.com>
2
1
3
Commit 509d39aa22909c0ed1aabf896865f19c81fb38a1 added support for read
4
only VMDKs of version 3.
5
6
This commit fixes the probe function to correctly handle descriptors of
7
version 3.
8
9
This commit has two effects:
10
1. We no longer need to supply '-f vmdk' when pointing to descriptor
11
files of version 3 in qemu/qemu-img command line arguments.
12
2. This fixes the scenario where a VMDK points to a parent version 3
13
descriptor file which is being probed as "raw" instead of "vmdk".
14
15
Reviewed-by: Arbel Moshe <arbel.moshe@oracle.com>
16
Reviewed-by: Mark Kanda <mark.kanda@oracle.com>
17
Signed-off-by: Shmuel Eiderman <shmuel.eiderman@oracle.com>
18
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
19
---
20
block/vmdk.c | 6 ++++--
21
1 file changed, 4 insertions(+), 2 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 int vmdk_probe(const uint8_t *buf, int buf_size, const char *filename)
28
}
29
if (end - p >= strlen("version=X\n")) {
30
if (strncmp("version=1\n", p, strlen("version=1\n")) == 0 ||
31
- strncmp("version=2\n", p, strlen("version=2\n")) == 0) {
32
+ strncmp("version=2\n", p, strlen("version=2\n")) == 0 ||
33
+ strncmp("version=3\n", p, strlen("version=3\n")) == 0) {
34
return 100;
35
}
36
}
37
if (end - p >= strlen("version=X\r\n")) {
38
if (strncmp("version=1\r\n", p, strlen("version=1\r\n")) == 0 ||
39
- strncmp("version=2\r\n", p, strlen("version=2\r\n")) == 0) {
40
+ strncmp("version=2\r\n", p, strlen("version=2\r\n")) == 0 ||
41
+ strncmp("version=3\r\n", p, strlen("version=3\r\n")) == 0) {
42
return 100;
43
}
44
}
45
--
46
2.20.1
47
48
diff view generated by jsdifflib
Deleted patch
1
From: Sergio Lopez <slp@redhat.com>
2
1
3
There are various actions in this test that must be executed
4
sequentially, as the result of it depends on the state triggered by the
5
previous one.
6
7
If the last argument of _send_qemu_cmd() is an empty string, it just
8
sends the QMP commands without waiting for an answer. While unlikely, it
9
may happen that the next action in the test gets invoked before QEMU
10
processes the QMP request.
11
12
This issue seems to be easier to reproduce on servers with limited
13
resources or highly loaded.
14
15
With this change, we wait for an answer on all _send_qemu_cmd() calls.
16
17
Signed-off-by: Sergio Lopez <slp@redhat.com>
18
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
19
---
20
tests/qemu-iotests/153 | 12 ++++++------
21
tests/qemu-iotests/153.out | 6 ++++++
22
2 files changed, 12 insertions(+), 6 deletions(-)
23
24
diff --git a/tests/qemu-iotests/153 b/tests/qemu-iotests/153
25
index XXXXXXX..XXXXXXX 100755
26
--- a/tests/qemu-iotests/153
27
+++ b/tests/qemu-iotests/153
28
@@ -XXX,XX +XXX,XX @@ for opts1 in "" "read-only=on" "read-only=on,force-share=on"; do
29
_img_info -U | grep 'file format'
30
fi
31
done
32
- _send_qemu_cmd $h "{ 'execute': 'quit', }" ""
33
+ _send_qemu_cmd $h "{ 'execute': 'quit' }" ''
34
echo
35
echo "Round done"
36
_cleanup_qemu
37
@@ -XXX,XX +XXX,XX @@ echo "Adding drive"
38
_send_qemu_cmd $QEMU_HANDLE \
39
"{ 'execute': 'human-monitor-command',
40
'arguments': { 'command-line': 'drive_add 0 if=none,id=d0,file=${TEST_IMG}' } }" \
41
- ""
42
+ 'return'
43
44
_run_cmd $QEMU_IO "${TEST_IMG}" -c 'write 0 512'
45
46
@@ -XXX,XX +XXX,XX @@ echo "== Closing an image should unlock it =="
47
_send_qemu_cmd $QEMU_HANDLE \
48
"{ 'execute': 'human-monitor-command',
49
'arguments': { 'command-line': 'drive_del d0' } }" \
50
- ""
51
+ 'return'
52
53
_run_cmd $QEMU_IO "${TEST_IMG}" -c 'write 0 512'
54
55
@@ -XXX,XX +XXX,XX @@ for d in d0 d1; do
56
_send_qemu_cmd $QEMU_HANDLE \
57
"{ 'execute': 'human-monitor-command',
58
'arguments': { 'command-line': 'drive_add 0 if=none,id=$d,file=${TEST_IMG},readonly=on' } }" \
59
- ""
60
+ 'return'
61
done
62
63
_run_cmd $QEMU_IMG info "${TEST_IMG}"
64
@@ -XXX,XX +XXX,XX @@ _run_cmd $QEMU_IMG info "${TEST_IMG}"
65
_send_qemu_cmd $QEMU_HANDLE \
66
"{ 'execute': 'human-monitor-command',
67
'arguments': { 'command-line': 'drive_del d0' } }" \
68
- ""
69
+ 'return'
70
71
_run_cmd $QEMU_IO "${TEST_IMG}" -c 'write 0 512'
72
73
@@ -XXX,XX +XXX,XX @@ echo "Closing the other"
74
_send_qemu_cmd $QEMU_HANDLE \
75
"{ 'execute': 'human-monitor-command',
76
'arguments': { 'command-line': 'drive_del d1' } }" \
77
- ""
78
+ 'return'
79
80
_run_cmd $QEMU_IO "${TEST_IMG}" -c 'write 0 512'
81
82
diff --git a/tests/qemu-iotests/153.out b/tests/qemu-iotests/153.out
83
index XXXXXXX..XXXXXXX 100644
84
--- a/tests/qemu-iotests/153.out
85
+++ b/tests/qemu-iotests/153.out
86
@@ -XXX,XX +XXX,XX @@ Is another process using the image [TEST_DIR/t.qcow2]?
87
_qemu_img_wrapper commit -b TEST_DIR/t.qcow2.b TEST_DIR/t.qcow2.c
88
{"return": {}}
89
Adding drive
90
+{"return": "OKrn"}
91
92
_qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512
93
can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
94
@@ -XXX,XX +XXX,XX @@ Creating overlay with qemu-img when the guest is running should be allowed
95
96
_qemu_img_wrapper create -f qcow2 -b TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.overlay
97
== Closing an image should unlock it ==
98
+{"return": ""}
99
100
_qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512
101
Adding two and closing one
102
+{"return": "OKrn"}
103
+{"return": "OKrn"}
104
105
_qemu_img_wrapper info TEST_DIR/t.qcow2
106
+{"return": ""}
107
108
_qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512
109
can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
110
Is another process using the image [TEST_DIR/t.qcow2]?
111
Closing the other
112
+{"return": ""}
113
114
_qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512
115
116
--
117
2.20.1
118
119
diff view generated by jsdifflib
Deleted patch
1
From: Markus Armbruster <armbru@redhat.com>
2
1
3
Recent commit cda4aa9a5a0 moved block backend creation before machine
4
property evaluation. This broke qemu-iotests 055. Turns out we need
5
to create the migration object before block backends, so block
6
backends can add migration blockers. Fix by calling
7
migration_object_init() earlier, right before configure_blockdev().
8
9
Fixes: cda4aa9a5a08777cf13e164c0543bd4888b8adce
10
Reported-by: Kevin Wolf <kwolf@redhat.com>
11
Signed-off-by: Markus Armbruster <armbru@redhat.com>
12
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13
---
14
vl.c | 15 ++++++++-------
15
1 file changed, 8 insertions(+), 7 deletions(-)
16
17
diff --git a/vl.c b/vl.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/vl.c
20
+++ b/vl.c
21
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv, char **envp)
22
exit(0);
23
}
24
25
+ /*
26
+ * Migration object can only be created after global properties
27
+ * are applied correctly.
28
+ */
29
+ migration_object_init();
30
+
31
/*
32
* Note: we need to create block backends before
33
* machine_set_property(), so machine properties can refer to
34
- * them.
35
+ * them, and after migration_object_init(), so we can create
36
+ * migration blockers.
37
*/
38
configure_blockdev(&bdo_queue, machine_class, snapshot);
39
40
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv, char **envp)
41
machine_class->name, machine_class->deprecation_reason);
42
}
43
44
- /*
45
- * Migration object can only be created after global properties
46
- * are applied correctly.
47
- */
48
- migration_object_init();
49
-
50
if (qtest_chrdev) {
51
qtest_init(qtest_chrdev, qtest_log, &error_fatal);
52
}
53
--
54
2.20.1
55
56
diff view generated by jsdifflib
Deleted patch
1
From: Alberto Garcia <berto@igalia.com>
2
1
3
Signed-off-by: Alberto Garcia <berto@igalia.com>
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
---
6
block/copy-on-read.c | 2 +-
7
block/crypto.c | 2 +-
8
block/replication.c | 2 +-
9
3 files changed, 3 insertions(+), 3 deletions(-)
10
11
diff --git a/block/copy-on-read.c b/block/copy-on-read.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/block/copy-on-read.c
14
+++ b/block/copy-on-read.c
15
@@ -XXX,XX +XXX,XX @@ static bool cor_recurse_is_first_non_filter(BlockDriverState *bs,
16
}
17
18
19
-BlockDriver bdrv_copy_on_read = {
20
+static BlockDriver bdrv_copy_on_read = {
21
.format_name = "copy-on-read",
22
23
.bdrv_open = cor_open,
24
diff --git a/block/crypto.c b/block/crypto.c
25
index XXXXXXX..XXXXXXX 100644
26
--- a/block/crypto.c
27
+++ b/block/crypto.c
28
@@ -XXX,XX +XXX,XX @@ static const char *const block_crypto_strong_runtime_opts[] = {
29
NULL
30
};
31
32
-BlockDriver bdrv_crypto_luks = {
33
+static BlockDriver bdrv_crypto_luks = {
34
.format_name = "luks",
35
.instance_size = sizeof(BlockCrypto),
36
.bdrv_probe = block_crypto_probe_luks,
37
diff --git a/block/replication.c b/block/replication.c
38
index XXXXXXX..XXXXXXX 100644
39
--- a/block/replication.c
40
+++ b/block/replication.c
41
@@ -XXX,XX +XXX,XX @@ static const char *const replication_strong_runtime_opts[] = {
42
NULL
43
};
44
45
-BlockDriver bdrv_replication = {
46
+static BlockDriver bdrv_replication = {
47
.format_name = "replication",
48
.instance_size = sizeof(BDRVReplicationState),
49
50
--
51
2.20.1
52
53
diff view generated by jsdifflib