1
The following changes since commit a0def594286d9110a6035e02eef558cf3cf5d847:
1
The following changes since commit 98b2faeaee96ab084d0b1669918688d8895c155f:
2
2
3
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2017-01-30 10:23:20 +0000)
3
Merge remote-tracking branch 'remotes/jnsnow/tags/ide-pull-request' into staging (2017-02-10 18:07:02 +0000)
4
4
5
are available in the git repository at:
5
are available in the git repository at:
6
6
7
https://github.com/codyprime/qemu-kvm-jtc.git tags/block-pull-request
7
git://github.com/XanClic/qemu.git tags/pull-block-2017-02-12
8
8
9
for you to fetch changes up to acf6e5f0962c4be670d4a93ede77423512521876:
9
for you to fetch changes up to 10d6eda1926804a09aa0710ca62933087813de0b:
10
10
11
sheepdog: reorganize check for overlapping requests (2017-02-01 00:17:20 -0500)
11
qemu-img: Avoid setting ret to unused value in img_convert() (2017-02-12 00:56:32 +0100)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Block patches
14
Block patches
15
15
----------------------------------------------------------------
16
----------------------------------------------------------------
17
Alberto Garcia (2):
18
qcow2: Optimize the refcount-block overlap check
19
qemu-io: don't allow I/O operations larger than BDRV_REQUEST_MAX_BYTES
16
20
17
Paolo Bonzini (5):
21
Daniel P. Berrange (1):
18
sheepdog: remove unused cancellation support
22
iotests: record separate timings per format,protocol pair
19
sheepdog: reorganize coroutine flow
20
sheepdog: do not use BlockAIOCB
21
sheepdog: simplify inflight_aio_head management
22
sheepdog: reorganize check for overlapping requests
23
23
24
block/sheepdog.c | 289 ++++++++++++++++---------------------------------------
24
Dou Liyang (2):
25
1 file changed, 84 insertions(+), 205 deletions(-)
25
block/qapi: reduce the coupling between the bdrv_query_stats and bdrv_query_bds_stats
26
block/qapi: reduce the execution time of qmp_query_blockstats
26
27
27
--
28
Fam Zheng (2):
28
2.9.3
29
qapi: Tweak error message of bdrv_query_image_info
30
iotests: Fix reference output for 059
29
31
32
Jeff Cody (3):
33
block: check full backing filename when searching protocol filenames
34
qemu-iotests: Don't create fifos / pidfiles with protocol paths
35
qemu-iotest: test to lookup protocol-based image with relative backing
30
36
37
Max Reitz (1):
38
qemu-img: Improve commit invalid base message
39
40
Nir Soffer (3):
41
qemu-io: Return non-zero exit code on failure
42
qemu-iotests: Add _unsupported_fmt helper
43
qemu-io: Add failure regression tests
44
45
Peter Lieven (2):
46
block/nfs: fix NULL pointer dereference in URI parsing
47
block/nfs: fix naming of runtime opts
48
49
Peter Maydell (2):
50
qemu-img: Use qemu_strtoul() rather than raw strtoul()
51
qemu-img: Avoid setting ret to unused value in img_convert()
52
53
QingFeng Hao (2):
54
iotests: Fix a problem in common.filter
55
block/vmdk: Fix the endian problem of buf_len and lba
56
57
Vladimir Sementsov-Ogievskiy (1):
58
block: bdrv_invalidate_cache: invalidate children first
59
60
tests/qemu-iotests/Makefile | 2 +-
61
block/qcow2.h | 1 +
62
block.c | 24 +++++++---
63
block/nfs.c | 49 ++++++++++----------
64
block/qapi.c | 99 +++++++++++++++++-----------------------
65
block/qcow2-refcount.c | 24 +++++++++-
66
block/qcow2.c | 1 +
67
block/vmdk.c | 4 +-
68
qemu-img.c | 44 +++++++++---------
69
qemu-io-cmds.c | 20 +++++---
70
qemu-io.c | 8 +++-
71
tests/qemu-iotests/.gitignore | 2 +-
72
tests/qemu-iotests/059.out | 5 +-
73
tests/qemu-iotests/070.out | 1 -
74
tests/qemu-iotests/075.out | 7 ---
75
tests/qemu-iotests/076.out | 3 --
76
tests/qemu-iotests/078.out | 6 ---
77
tests/qemu-iotests/080.out | 18 --------
78
tests/qemu-iotests/083.out | 17 -------
79
tests/qemu-iotests/088.out | 6 ---
80
tests/qemu-iotests/092.out | 12 -----
81
tests/qemu-iotests/116.out | 7 ---
82
tests/qemu-iotests/131.out | 1 -
83
tests/qemu-iotests/140.out | 1 -
84
tests/qemu-iotests/173 | 97 +++++++++++++++++++++++++++++++++++++++
85
tests/qemu-iotests/173.out | 12 +++++
86
tests/qemu-iotests/174 | 59 ++++++++++++++++++++++++
87
tests/qemu-iotests/174.out | 7 +++
88
tests/qemu-iotests/check | 12 +++--
89
tests/qemu-iotests/common.config | 6 ++-
90
tests/qemu-iotests/common.filter | 2 +-
91
tests/qemu-iotests/common.qemu | 10 ++--
92
tests/qemu-iotests/common.rc | 17 +++++--
93
tests/qemu-iotests/group | 2 +
94
34 files changed, 366 insertions(+), 220 deletions(-)
95
create mode 100755 tests/qemu-iotests/173
96
create mode 100644 tests/qemu-iotests/173.out
97
create mode 100755 tests/qemu-iotests/174
98
create mode 100644 tests/qemu-iotests/174.out
99
diff view generated by jsdifflib
New patch
1
From: QingFeng Hao <haoqf@linux.vnet.ibm.com>
1
2
3
If TEST_DIR is set to /tmp, test case 144 will fail. The reason is that
4
TEST_DIR resembles 144's test image name tmp.qcow2.
5
When 144 is testing $TEST_DIR/tmp.qcow2, it wants to replace
6
$TEST_DIR/tmp.qcow2 to TEST_DIR/tmp.qcow2, but actually it will fail
7
and get TEST_DIRTEST_DIR.qcow2 in this case.
8
The fix is just to modify the code to replace $TEST_DIR/ with TEST_DIR/.
9
10
Signed-off-by: QingFeng Hao <haoqf@linux.vnet.ibm.com>
11
Message-id: 20161216054723.96055-2-haoqf@linux.vnet.ibm.com
12
Reviewed-by: Eric Blake <eblake@redhat.com>
13
[mreitz: Fixed commit message and dropped superfluous escaping]
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
16
tests/qemu-iotests/common.filter | 2 +-
17
1 file changed, 1 insertion(+), 1 deletion(-)
18
19
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
20
index XXXXXXX..XXXXXXX 100644
21
--- a/tests/qemu-iotests/common.filter
22
+++ b/tests/qemu-iotests/common.filter
23
@@ -XXX,XX +XXX,XX @@ _filter_generated_node_ids()
24
# replace occurrences of the actual TEST_DIR value with TEST_DIR
25
_filter_testdir()
26
{
27
- sed -e "s#$TEST_DIR#TEST_DIR#g"
28
+ sed -e "s#$TEST_DIR/#TEST_DIR/#g"
29
}
30
31
# replace occurrences of the actual IMGFMT value with IMGFMT
32
--
33
2.11.0
34
35
diff view generated by jsdifflib
New patch
1
When trying to invoke qemu-img commit with a base image file name that
2
is not part of the top image's backing chain, the user receives a rather
3
plain "Base not found" error message. This is not really helpful because
4
it does not explain what "not found" means, potentially leaving the user
5
wondering why qemu cannot find a file despite it clearly existing in the
6
file system.
1
7
8
Improve the error message by clarifying that "not found" means "not
9
found in the top image's backing chain".
10
11
Reported-by: Ala Hino <ahino@redhat.com>
12
Signed-off-by: Max Reitz <mreitz@redhat.com>
13
Message-id: 20161201020508.24417-1-mreitz@redhat.com
14
Reviewed-by: Eric Blake <eblake@redhat.com>
15
Signed-off-by: Max Reitz <mreitz@redhat.com>
16
---
17
qemu-img.c | 4 +++-
18
1 file changed, 3 insertions(+), 1 deletion(-)
19
20
diff --git a/qemu-img.c b/qemu-img.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/qemu-img.c
23
+++ b/qemu-img.c
24
@@ -XXX,XX +XXX,XX @@ static int img_commit(int argc, char **argv)
25
if (base) {
26
base_bs = bdrv_find_backing_image(bs, base);
27
if (!base_bs) {
28
- error_setg(&local_err, QERR_BASE_NOT_FOUND, base);
29
+ error_setg(&local_err,
30
+ "Did not find '%s' in the backing chain of '%s'",
31
+ base, filename);
32
goto done;
33
}
34
} else {
35
--
36
2.11.0
37
38
diff view generated by jsdifflib
New patch
1
From: Fam Zheng <famz@redhat.com>
1
2
3
@bs doesn't always have a device name, such as when it comes from
4
"qemu-img info". Report file name instead.
5
6
Signed-off-by: Fam Zheng <famz@redhat.com>
7
Message-id: 20170119130759.28319-2-famz@redhat.com
8
Reviewed-by: Eric Blake <eblake@redhat.com>
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
---
11
block/qapi.c | 4 ++--
12
1 file changed, 2 insertions(+), 2 deletions(-)
13
14
diff --git a/block/qapi.c b/block/qapi.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/block/qapi.c
17
+++ b/block/qapi.c
18
@@ -XXX,XX +XXX,XX @@ void bdrv_query_image_info(BlockDriverState *bs,
19
20
size = bdrv_getlength(bs);
21
if (size < 0) {
22
- error_setg_errno(errp, -size, "Can't get size of device '%s'",
23
- bdrv_get_device_name(bs));
24
+ error_setg_errno(errp, -size, "Can't get image size '%s'",
25
+ bs->exact_filename);
26
goto out;
27
}
28
29
--
30
2.11.0
31
32
diff view generated by jsdifflib
1
From: Paolo Bonzini <pbonzini@redhat.com>
1
From: Dou Liyang <douly.fnst@cn.fujitsu.com>
2
2
3
Add to the list in add_aio_request and, indirectly, resend_aioreq. Inline
3
The bdrv_query_stats and bdrv_query_bds_stats functions need to call
4
free_aio_req in the caller, it does not simply undo alloc_aio_req's job.
4
each other, that increases the coupling. it also makes the program
5
complicated and makes some unnecessary tests.
5
6
6
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7
Remove the call from bdrv_query_bds_stats to bdrv_query_stats, just
7
Message-id: 20161129113245.32724-5-pbonzini@redhat.com
8
take some recursion to make it clearly.
8
Signed-off-by: Jeff Cody <jcody@redhat.com>
9
10
Avoid testing whether the blk is NULL during querying the bds stats.
11
It is unnecessary.
12
13
Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
14
Message-id: 1484467275-27919-2-git-send-email-douly.fnst@cn.fujitsu.com
15
Reviewed-by: Markus Armbruster <armbru@redhat.com>
16
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
17
---
10
block/sheepdog.c | 23 ++++++-----------------
18
block/qapi.c | 26 ++++++++++++++------------
11
1 file changed, 6 insertions(+), 17 deletions(-)
19
1 file changed, 14 insertions(+), 12 deletions(-)
12
20
13
diff --git a/block/sheepdog.c b/block/sheepdog.c
21
diff --git a/block/qapi.c b/block/qapi.c
14
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
15
--- a/block/sheepdog.c
23
--- a/block/qapi.c
16
+++ b/block/sheepdog.c
24
+++ b/block/qapi.c
17
@@ -XXX,XX +XXX,XX @@ static inline AIOReq *alloc_aio_req(BDRVSheepdogState *s, SheepdogAIOCB *acb,
25
@@ -XXX,XX +XXX,XX @@ static void bdrv_query_info(BlockBackend *blk, BlockInfo **p_info,
18
return aio_req;
26
qapi_free_BlockInfo(info);
19
}
27
}
20
28
21
-static inline void free_aio_req(BDRVSheepdogState *s, AIOReq *aio_req)
29
-static BlockStats *bdrv_query_stats(BlockBackend *blk,
22
-{
30
- const BlockDriverState *bs,
23
- SheepdogAIOCB *acb = aio_req->aiocb;
31
- bool query_backing);
24
-
32
-
25
- QLIST_REMOVE(aio_req, aio_siblings);
33
static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk)
26
- g_free(aio_req);
34
{
27
-
35
BlockAcctStats *stats = blk_get_stats(blk);
28
- acb->nr_pending--;
36
@@ -XXX,XX +XXX,XX @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk)
29
-}
30
-
31
static void sd_aio_setup(SheepdogAIOCB *acb, BDRVSheepdogState *s,
32
QEMUIOVector *qiov, int64_t sector_num, int nb_sectors,
33
int type)
34
@@ -XXX,XX +XXX,XX @@ static coroutine_fn void reconnect_to_sdog(void *opaque)
35
while (!QLIST_EMPTY(&s->failed_aio_head)) {
36
aio_req = QLIST_FIRST(&s->failed_aio_head);
37
QLIST_REMOVE(aio_req, aio_siblings);
38
- QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings);
39
resend_aioreq(s, aio_req);
40
}
37
}
41
}
38
}
42
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn aio_read_response(void *opaque)
39
43
*/
40
-static void bdrv_query_bds_stats(BlockStats *s, const BlockDriverState *bs,
44
s->co_recv = NULL;
41
+static BlockStats *bdrv_query_bds_stats(const BlockDriverState *bs,
45
42
bool query_backing)
46
+ QLIST_REMOVE(aio_req, aio_siblings);
43
{
47
switch (rsp.result) {
44
+ BlockStats *s = NULL;
48
case SD_RES_SUCCESS:
45
+
49
break;
46
+ s = g_malloc0(sizeof(*s));
50
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn aio_read_response(void *opaque)
47
+ s->stats = g_malloc0(sizeof(*s->stats));
51
break;
48
+
49
+ if (!bs) {
50
+ return s;
51
+ }
52
+
53
if (bdrv_get_node_name(bs)[0]) {
54
s->has_node_name = true;
55
s->node_name = g_strdup(bdrv_get_node_name(bs));
56
@@ -XXX,XX +XXX,XX @@ static void bdrv_query_bds_stats(BlockStats *s, const BlockDriverState *bs,
57
58
if (bs->file) {
59
s->has_parent = true;
60
- s->parent = bdrv_query_stats(NULL, bs->file->bs, query_backing);
61
+ s->parent = bdrv_query_bds_stats(bs->file->bs, query_backing);
52
}
62
}
53
63
54
- free_aio_req(s, aio_req);
64
if (query_backing && bs->backing) {
55
- if (!acb->nr_pending) {
65
s->has_backing = true;
56
+ g_free(aio_req);
66
- s->backing = bdrv_query_stats(NULL, bs->backing->bs, query_backing);
57
+
67
+ s->backing = bdrv_query_bds_stats(bs->backing->bs, query_backing);
58
+ if (!--acb->nr_pending) {
59
/*
60
* We've finished all requests which belong to the AIOCB, so
61
* we can switch back to sd_co_readv/writev now.
62
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req,
63
uint64_t old_oid = aio_req->base_oid;
64
bool create = aio_req->create;
65
66
+ QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings);
67
+
68
if (!nr_copies) {
69
error_report("bug");
70
}
68
}
71
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn sd_write_done(SheepdogAIOCB *acb)
69
72
iov.iov_len = sizeof(s->inode);
70
+ return s;
73
aio_req = alloc_aio_req(s, acb, vid_to_vdi_oid(s->inode.vdi_id),
71
}
74
data_len, offset, 0, false, 0, offset);
72
75
- QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings);
73
static BlockStats *bdrv_query_stats(BlockBackend *blk,
76
add_aio_request(s, aio_req, &iov, 1, AIOCB_WRITE_UDATA);
74
@@ -XXX,XX +XXX,XX @@ static BlockStats *bdrv_query_stats(BlockBackend *blk,
77
if (--acb->nr_pending) {
75
{
78
qemu_coroutine_yield();
76
BlockStats *s;
79
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn sd_co_rw_vector(SheepdogAIOCB *acb)
77
80
old_oid,
78
- s = g_malloc0(sizeof(*s));
81
acb->aiocb_type == AIOCB_DISCARD_OBJ ?
79
- s->stats = g_malloc0(sizeof(*s->stats));
82
0 : done);
80
+ s = bdrv_query_bds_stats(bs, query_backing);
83
- QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings);
81
84
-
82
if (blk) {
85
add_aio_request(s, aio_req, acb->qiov->iov, acb->qiov->niov,
83
s->has_device = true;
86
acb->aiocb_type);
84
s->device = g_strdup(blk_name(blk));
87
done:
85
bdrv_query_blk_stats(s->stats, blk);
88
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn sd_co_flush_to_disk(BlockDriverState *bs)
86
}
89
acb.nr_pending++;
87
- if (bs) {
90
aio_req = alloc_aio_req(s, &acb, vid_to_vdi_oid(s->inode.vdi_id),
88
- bdrv_query_bds_stats(s, bs, query_backing);
91
0, 0, 0, false, 0, 0);
89
- }
92
- QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings);
90
93
add_aio_request(s, aio_req, NULL, 0, acb.aiocb_type);
91
return s;
94
92
}
95
if (--acb.nr_pending) {
96
--
93
--
97
2.9.3
94
2.11.0
98
95
99
96
diff view generated by jsdifflib
1
From: Paolo Bonzini <pbonzini@redhat.com>
1
From: Dou Liyang <douly.fnst@cn.fujitsu.com>
2
2
3
SheepdogAIOCB is internal to sheepdog.c, hence it is never canceled.
3
In order to reduce the execution time, this patch optimize
4
the qmp_query_blockstats():
5
Remove the next_query_bds function.
6
Remove the bdrv_query_stats function.
7
Remove some judgement sentence.
4
8
5
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9
The original qmp_query_blockstats calls next_query_bds to get
6
Message-id: 20161129113245.32724-2-pbonzini@redhat.com
10
the next objects in each loops. In the next_query_bds, it checks
7
Signed-off-by: Jeff Cody <jcody@redhat.com>
11
the query_nodes and blk. It also call bdrv_query_stats to get
12
the stats, In the bdrv_query_stats, it checks blk and bs each
13
times. This waste more times, which may stall the main loop a
14
bit. And if the disk is too many and donot use the dataplane
15
feature, this may affect the performance in main loop thread.
16
17
This patch removes that two functions, and makes the structure
18
clearly.
19
20
Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
21
Message-id: 1484467275-27919-3-git-send-email-douly.fnst@cn.fujitsu.com
22
Reviewed-by: Markus Armbruster <armbru@redhat.com>
23
[mreitz: Removed duplicate info->value assignment]
24
Signed-off-by: Max Reitz <mreitz@redhat.com>
8
---
25
---
9
block/sheepdog.c | 52 ----------------------------------------------------
26
block/qapi.c | 73 ++++++++++++++++++++++++------------------------------------
10
1 file changed, 52 deletions(-)
27
1 file changed, 29 insertions(+), 44 deletions(-)
11
28
12
diff --git a/block/sheepdog.c b/block/sheepdog.c
29
diff --git a/block/qapi.c b/block/qapi.c
13
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
14
--- a/block/sheepdog.c
31
--- a/block/qapi.c
15
+++ b/block/sheepdog.c
32
+++ b/block/qapi.c
16
@@ -XXX,XX +XXX,XX @@ struct SheepdogAIOCB {
33
@@ -XXX,XX +XXX,XX @@ static BlockStats *bdrv_query_bds_stats(const BlockDriverState *bs,
17
Coroutine *coroutine;
34
return s;
18
void (*aio_done_func)(SheepdogAIOCB *);
19
20
- bool cancelable;
21
int nr_pending;
22
23
uint32_t min_affect_data_idx;
24
@@ -XXX,XX +XXX,XX @@ static inline void free_aio_req(BDRVSheepdogState *s, AIOReq *aio_req)
25
{
26
SheepdogAIOCB *acb = aio_req->aiocb;
27
28
- acb->cancelable = false;
29
QLIST_REMOVE(aio_req, aio_siblings);
30
g_free(aio_req);
31
32
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn sd_finish_aiocb(SheepdogAIOCB *acb)
33
qemu_aio_unref(acb);
34
}
35
}
35
36
36
-/*
37
-static BlockStats *bdrv_query_stats(BlockBackend *blk,
37
- * Check whether the specified acb can be canceled
38
- const BlockDriverState *bs,
38
- *
39
- bool query_backing)
39
- * We can cancel aio when any request belonging to the acb is:
40
- * - Not processed by the sheepdog server.
41
- * - Not linked to the inflight queue.
42
- */
43
-static bool sd_acb_cancelable(const SheepdogAIOCB *acb)
44
-{
40
-{
45
- BDRVSheepdogState *s = acb->common.bs->opaque;
41
- BlockStats *s;
46
- AIOReq *aioreq;
47
-
42
-
48
- if (!acb->cancelable) {
43
- s = bdrv_query_bds_stats(bs, query_backing);
49
- return false;
44
-
45
- if (blk) {
46
- s->has_device = true;
47
- s->device = g_strdup(blk_name(blk));
48
- bdrv_query_blk_stats(s->stats, blk);
50
- }
49
- }
51
-
50
-
52
- QLIST_FOREACH(aioreq, &s->inflight_aio_head, aio_siblings) {
51
- return s;
53
- if (aioreq->aiocb == acb) {
52
-}
54
- return false;
53
-
55
- }
54
BlockInfoList *qmp_query_block(Error **errp)
55
{
56
BlockInfoList *head = NULL, **p_next = &head;
57
@@ -XXX,XX +XXX,XX @@ BlockInfoList *qmp_query_block(Error **errp)
58
return head;
59
}
60
61
-static bool next_query_bds(BlockBackend **blk, BlockDriverState **bs,
62
- bool query_nodes)
63
-{
64
- if (query_nodes) {
65
- *bs = bdrv_next_node(*bs);
66
- return !!*bs;
56
- }
67
- }
57
-
68
-
58
- return true;
69
- *blk = blk_next(*blk);
70
- *bs = *blk ? blk_bs(*blk) : NULL;
71
-
72
- return !!*blk;
59
-}
73
-}
60
-
74
-
61
-static void sd_aio_cancel(BlockAIOCB *blockacb)
75
BlockStatsList *qmp_query_blockstats(bool has_query_nodes,
62
-{
76
bool query_nodes,
63
- SheepdogAIOCB *acb = (SheepdogAIOCB *)blockacb;
77
Error **errp)
64
- BDRVSheepdogState *s = acb->common.bs->opaque;
78
{
65
- AIOReq *aioreq, *next;
79
BlockStatsList *head = NULL, **p_next = &head;
80
- BlockBackend *blk = NULL;
81
- BlockDriverState *bs = NULL;
82
+ BlockBackend *blk;
83
+ BlockDriverState *bs;
84
85
/* Just to be safe if query_nodes is not always initialized */
86
- query_nodes = has_query_nodes && query_nodes;
66
-
87
-
67
- if (sd_acb_cancelable(acb)) {
88
- while (next_query_bds(&blk, &bs, query_nodes)) {
68
- /* Remove outstanding requests from failed queue. */
89
- BlockStatsList *info = g_malloc0(sizeof(*info));
69
- QLIST_FOREACH_SAFE(aioreq, &s->failed_aio_head, aio_siblings,
90
- AioContext *ctx = blk ? blk_get_aio_context(blk)
70
- next) {
91
- : bdrv_get_aio_context(bs);
71
- if (aioreq->aiocb == acb) {
92
+ if (has_query_nodes && query_nodes) {
72
- free_aio_req(s, aioreq);
93
+ for (bs = bdrv_next_node(NULL); bs; bs = bdrv_next_node(bs)) {
73
- }
94
+ BlockStatsList *info = g_malloc0(sizeof(*info));
74
- }
95
+ AioContext *ctx = bdrv_get_aio_context(bs);
75
-
96
76
- assert(acb->nr_pending == 0);
97
- aio_context_acquire(ctx);
77
- if (acb->common.cb) {
98
- info->value = bdrv_query_stats(blk, bs, !query_nodes);
78
- acb->common.cb(acb->common.opaque, -ECANCELED);
99
- aio_context_release(ctx);
79
- }
100
+ aio_context_acquire(ctx);
80
- sd_finish_aiocb(acb);
101
+ info->value = bdrv_query_bds_stats(bs, false);
81
- }
102
+ aio_context_release(ctx);
82
-}
103
83
-
104
- *p_next = info;
84
static const AIOCBInfo sd_aiocb_info = {
105
- p_next = &info->next;
85
.aiocb_size = sizeof(SheepdogAIOCB),
106
+ *p_next = info;
86
- .cancel_async = sd_aio_cancel,
107
+ p_next = &info->next;
87
};
108
+ }
88
109
+ } else {
89
static SheepdogAIOCB *sd_aio_setup(BlockDriverState *bs, QEMUIOVector *qiov,
110
+ for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {
90
@@ -XXX,XX +XXX,XX @@ static SheepdogAIOCB *sd_aio_setup(BlockDriverState *bs, QEMUIOVector *qiov,
111
+ BlockStatsList *info = g_malloc0(sizeof(*info));
91
acb->nb_sectors = nb_sectors;
112
+ AioContext *ctx = blk_get_aio_context(blk);
92
113
+ BlockStats *s;
93
acb->aio_done_func = NULL;
114
+
94
- acb->cancelable = true;
115
+ aio_context_acquire(ctx);
95
acb->coroutine = qemu_coroutine_self();
116
+ s = bdrv_query_bds_stats(blk_bs(blk), true);
96
acb->ret = 0;
117
+ s->has_device = true;
97
acb->nr_pending = 0;
118
+ s->device = g_strdup(blk_name(blk));
119
+ bdrv_query_blk_stats(s->stats, blk);
120
+ aio_context_release(ctx);
121
+
122
+ info->value = s;
123
+ *p_next = info;
124
+ p_next = &info->next;
125
+ }
126
}
127
128
return head;
98
--
129
--
99
2.9.3
130
2.11.0
100
131
101
132
diff view generated by jsdifflib
1
From: Paolo Bonzini <pbonzini@redhat.com>
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
2
3
Delimit co_recv's lifetime clearly in aio_read_response.
3
Current implementation invalidates firstly parent bds and then its
4
children. This leads to the following bug:
4
5
5
Do a simple qemu_coroutine_enter in aio_read_response, letting
6
after incoming migration, in bdrv_invalidate_cache_all:
6
sd_co_writev call sd_write_done.
7
1. invalidate parent bds - reopen it with BDRV_O_INACTIVE cleared
8
2. child is not yet invalidated
9
3. parent check that its BDRV_O_INACTIVE is cleared
10
4. parent writes to child
11
5. assert in bdrv_co_pwritev, as BDRV_O_INACTIVE is set for child
7
12
8
Handle nr_pending in the same way in sd_co_rw_vector,
13
This patch fixes it by just changing invalidate sequence: invalidate
9
sd_write_done and sd_co_flush_to_disk.
14
children first.
10
15
11
Remove sd_co_rw_vector's return value; just leave with no
16
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
12
pending requests.
17
Message-id: 20170131112308.54189-1-vsementsov@virtuozzo.com
18
Reviewed-by: Max Reitz <mreitz@redhat.com>
19
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
20
Signed-off-by: Max Reitz <mreitz@redhat.com>
21
---
22
block.c | 11 +++++------
23
1 file changed, 5 insertions(+), 6 deletions(-)
13
24
14
[Jeff: added missing 'return' back, spotted by Paolo after
25
diff --git a/block.c b/block.c
15
series was applied.]
16
17
Signed-off-by: Jeff Cody <jcody@redhat.com>
18
---
19
block/sheepdog.c | 115 ++++++++++++++++++++-----------------------------------
20
1 file changed, 42 insertions(+), 73 deletions(-)
21
22
diff --git a/block/sheepdog.c b/block/sheepdog.c
23
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
24
--- a/block/sheepdog.c
27
--- a/block.c
25
+++ b/block/sheepdog.c
28
+++ b/block.c
26
@@ -XXX,XX +XXX,XX @@ struct SheepdogAIOCB {
29
@@ -XXX,XX +XXX,XX @@ void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp)
27
enum AIOCBState aiocb_type;
30
if (!(bs->open_flags & BDRV_O_INACTIVE)) {
28
31
return;
29
Coroutine *coroutine;
32
}
30
- void (*aio_done_func)(SheepdogAIOCB *);
33
- bs->open_flags &= ~BDRV_O_INACTIVE;
31
-
34
32
int nr_pending;
35
- if (bs->drv->bdrv_invalidate_cache) {
33
36
- bs->drv->bdrv_invalidate_cache(bs, &local_err);
34
uint32_t min_affect_data_idx;
37
+ QLIST_FOREACH(child, &bs->children, next) {
35
@@ -XXX,XX +XXX,XX @@ static const char * sd_strerror(int err)
38
+ bdrv_invalidate_cache(child->bs, &local_err);
36
*
39
if (local_err) {
37
* 1. In sd_co_rw_vector, we send the I/O requests to the server and
40
- bs->open_flags |= BDRV_O_INACTIVE;
38
* link the requests to the inflight_list in the
41
error_propagate(errp, local_err);
39
- * BDRVSheepdogState. The function exits without waiting for
42
return;
40
+ * BDRVSheepdogState. The function yields while waiting for
41
* receiving the response.
42
*
43
* 2. We receive the response in aio_read_response, the fd handler to
44
- * the sheepdog connection. If metadata update is needed, we send
45
- * the write request to the vdi object in sd_write_done, the write
46
- * completion function. We switch back to sd_co_readv/writev after
47
- * all the requests belonging to the AIOCB are finished.
48
+ * the sheepdog connection. We switch back to sd_co_readv/sd_writev
49
+ * after all the requests belonging to the AIOCB are finished. If
50
+ * needed, sd_co_writev will send another requests for the vdi object.
51
*/
52
53
static inline AIOReq *alloc_aio_req(BDRVSheepdogState *s, SheepdogAIOCB *acb,
54
@@ -XXX,XX +XXX,XX @@ static inline void free_aio_req(BDRVSheepdogState *s, AIOReq *aio_req)
55
acb->nr_pending--;
56
}
57
58
-static void coroutine_fn sd_finish_aiocb(SheepdogAIOCB *acb)
59
-{
60
- qemu_coroutine_enter(acb->coroutine);
61
- qemu_aio_unref(acb);
62
-}
63
-
64
static const AIOCBInfo sd_aiocb_info = {
65
.aiocb_size = sizeof(SheepdogAIOCB),
66
};
67
@@ -XXX,XX +XXX,XX @@ static SheepdogAIOCB *sd_aio_setup(BlockDriverState *bs, QEMUIOVector *qiov,
68
acb->sector_num = sector_num;
69
acb->nb_sectors = nb_sectors;
70
71
- acb->aio_done_func = NULL;
72
acb->coroutine = qemu_coroutine_self();
73
acb->ret = 0;
74
acb->nr_pending = 0;
75
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn aio_read_response(void *opaque)
76
77
switch (acb->aiocb_type) {
78
case AIOCB_WRITE_UDATA:
79
- /* this coroutine context is no longer suitable for co_recv
80
- * because we may send data to update vdi objects */
81
- s->co_recv = NULL;
82
if (!is_data_obj(aio_req->oid)) {
83
break;
84
}
85
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn aio_read_response(void *opaque)
86
}
43
}
87
}
44
}
88
45
89
+ /* No more data for this aio_req (reload_inode below uses its own file
46
- QLIST_FOREACH(child, &bs->children, next) {
90
+ * descriptor handler which doesn't use co_recv).
47
- bdrv_invalidate_cache(child->bs, &local_err);
91
+ */
48
+ bs->open_flags &= ~BDRV_O_INACTIVE;
92
+ s->co_recv = NULL;
49
+ if (bs->drv->bdrv_invalidate_cache) {
93
+
50
+ bs->drv->bdrv_invalidate_cache(bs, &local_err);
94
switch (rsp.result) {
51
if (local_err) {
95
case SD_RES_SUCCESS:
52
bs->open_flags |= BDRV_O_INACTIVE;
96
break;
53
error_propagate(errp, local_err);
97
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn aio_read_response(void *opaque)
98
aio_req->oid = vid_to_vdi_oid(s->inode.vdi_id);
99
}
100
resend_aioreq(s, aio_req);
101
- goto out;
102
+ return;
103
default:
104
acb->ret = -EIO;
105
error_report("%s", sd_strerror(rsp.result));
106
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn aio_read_response(void *opaque)
107
* We've finished all requests which belong to the AIOCB, so
108
* we can switch back to sd_co_readv/writev now.
109
*/
110
- acb->aio_done_func(acb);
111
+ qemu_coroutine_enter(acb->coroutine);
112
}
113
-out:
114
- s->co_recv = NULL;
115
+
116
return;
117
+
118
err:
119
- s->co_recv = NULL;
120
reconnect_to_sdog(opaque);
121
}
122
123
@@ -XXX,XX +XXX,XX @@ static int sd_truncate(BlockDriverState *bs, int64_t offset)
124
/*
125
* This function is called after writing data objects. If we need to
126
* update metadata, this sends a write request to the vdi object.
127
- * Otherwise, this switches back to sd_co_readv/writev.
128
*/
129
static void coroutine_fn sd_write_done(SheepdogAIOCB *acb)
130
{
131
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn sd_write_done(SheepdogAIOCB *acb)
132
mx = acb->max_dirty_data_idx;
133
if (mn <= mx) {
134
/* we need to update the vdi object. */
135
+ ++acb->nr_pending;
136
offset = sizeof(s->inode) - sizeof(s->inode.data_vdi_id) +
137
mn * sizeof(s->inode.data_vdi_id[0]);
138
data_len = (mx - mn + 1) * sizeof(s->inode.data_vdi_id[0]);
139
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn sd_write_done(SheepdogAIOCB *acb)
140
data_len, offset, 0, false, 0, offset);
141
QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings);
142
add_aio_request(s, aio_req, &iov, 1, AIOCB_WRITE_UDATA);
143
-
144
- acb->aio_done_func = sd_finish_aiocb;
145
- acb->aiocb_type = AIOCB_WRITE_UDATA;
146
- return;
147
+ if (--acb->nr_pending) {
148
+ qemu_coroutine_yield();
149
+ }
150
}
151
-
152
- sd_finish_aiocb(acb);
153
}
154
155
/* Delete current working VDI on the snapshot chain */
156
@@ -XXX,XX +XXX,XX @@ out:
157
* Returns 1 when we need to wait a response, 0 when there is no sent
158
* request and -errno in error cases.
159
*/
160
-static int coroutine_fn sd_co_rw_vector(void *p)
161
+static void coroutine_fn sd_co_rw_vector(void *p)
162
{
163
SheepdogAIOCB *acb = p;
164
int ret = 0;
165
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn sd_co_rw_vector(void *p)
166
ret = sd_create_branch(s);
167
if (ret) {
168
acb->ret = -EIO;
169
- goto out;
170
+ return;
171
}
172
}
173
174
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn sd_co_rw_vector(void *p)
175
idx++;
176
done += len;
177
}
178
-out:
179
- if (!--acb->nr_pending) {
180
- return acb->ret;
181
+ if (--acb->nr_pending) {
182
+ qemu_coroutine_yield();
183
}
184
- return 1;
185
}
186
187
static bool check_overlapping_aiocb(BDRVSheepdogState *s, SheepdogAIOCB *aiocb)
188
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int sd_co_writev(BlockDriverState *bs, int64_t sector_num,
189
}
190
191
acb = sd_aio_setup(bs, qiov, sector_num, nb_sectors);
192
- acb->aio_done_func = sd_write_done;
193
acb->aiocb_type = AIOCB_WRITE_UDATA;
194
195
retry:
196
@@ -XXX,XX +XXX,XX @@ retry:
197
goto retry;
198
}
199
200
- ret = sd_co_rw_vector(acb);
201
- if (ret <= 0) {
202
- QLIST_REMOVE(acb, aiocb_siblings);
203
- qemu_co_queue_restart_all(&s->overlapping_queue);
204
- qemu_aio_unref(acb);
205
- return ret;
206
- }
207
-
208
- qemu_coroutine_yield();
209
+ sd_co_rw_vector(acb);
210
+ sd_write_done(acb);
211
212
QLIST_REMOVE(acb, aiocb_siblings);
213
qemu_co_queue_restart_all(&s->overlapping_queue);
214
-
215
- return acb->ret;
216
+ ret = acb->ret;
217
+ qemu_aio_unref(acb);
218
+ return ret;
219
}
220
221
static coroutine_fn int sd_co_readv(BlockDriverState *bs, int64_t sector_num,
222
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int sd_co_readv(BlockDriverState *bs, int64_t sector_num,
223
224
acb = sd_aio_setup(bs, qiov, sector_num, nb_sectors);
225
acb->aiocb_type = AIOCB_READ_UDATA;
226
- acb->aio_done_func = sd_finish_aiocb;
227
228
retry:
229
if (check_overlapping_aiocb(s, acb)) {
230
@@ -XXX,XX +XXX,XX @@ retry:
231
goto retry;
232
}
233
234
- ret = sd_co_rw_vector(acb);
235
- if (ret <= 0) {
236
- QLIST_REMOVE(acb, aiocb_siblings);
237
- qemu_co_queue_restart_all(&s->overlapping_queue);
238
- qemu_aio_unref(acb);
239
- return ret;
240
- }
241
-
242
- qemu_coroutine_yield();
243
+ sd_co_rw_vector(acb);
244
245
QLIST_REMOVE(acb, aiocb_siblings);
246
qemu_co_queue_restart_all(&s->overlapping_queue);
247
- return acb->ret;
248
+ ret = acb->ret;
249
+ qemu_aio_unref(acb);
250
+ return ret;
251
}
252
253
static int coroutine_fn sd_co_flush_to_disk(BlockDriverState *bs)
254
{
255
BDRVSheepdogState *s = bs->opaque;
256
SheepdogAIOCB *acb;
257
+ int ret;
258
AIOReq *aio_req;
259
260
if (s->cache_flags != SD_FLAG_CMD_CACHE) {
261
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn sd_co_flush_to_disk(BlockDriverState *bs)
262
263
acb = sd_aio_setup(bs, NULL, 0, 0);
264
acb->aiocb_type = AIOCB_FLUSH_CACHE;
265
- acb->aio_done_func = sd_finish_aiocb;
266
267
+ acb->nr_pending++;
268
aio_req = alloc_aio_req(s, acb, vid_to_vdi_oid(s->inode.vdi_id),
269
0, 0, 0, false, 0, 0);
270
QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings);
271
add_aio_request(s, aio_req, NULL, 0, acb->aiocb_type);
272
273
- qemu_coroutine_yield();
274
- return acb->ret;
275
+ if (--acb->nr_pending) {
276
+ qemu_coroutine_yield();
277
+ }
278
+ ret = acb->ret;
279
+ qemu_aio_unref(acb);
280
+ return ret;
281
}
282
283
static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
284
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int sd_co_pdiscard(BlockDriverState *bs, int64_t offset,
285
acb = sd_aio_setup(bs, &discard_iov, offset >> BDRV_SECTOR_BITS,
286
count >> BDRV_SECTOR_BITS);
287
acb->aiocb_type = AIOCB_DISCARD_OBJ;
288
- acb->aio_done_func = sd_finish_aiocb;
289
290
retry:
291
if (check_overlapping_aiocb(s, acb)) {
292
@@ -XXX,XX +XXX,XX @@ retry:
293
goto retry;
294
}
295
296
- ret = sd_co_rw_vector(acb);
297
- if (ret <= 0) {
298
- QLIST_REMOVE(acb, aiocb_siblings);
299
- qemu_co_queue_restart_all(&s->overlapping_queue);
300
- qemu_aio_unref(acb);
301
- return ret;
302
- }
303
-
304
- qemu_coroutine_yield();
305
+ sd_co_rw_vector(acb);
306
307
QLIST_REMOVE(acb, aiocb_siblings);
308
qemu_co_queue_restart_all(&s->overlapping_queue);
309
-
310
- return acb->ret;
311
+ ret = acb->ret;
312
+ qemu_aio_unref(acb);
313
+ return ret;
314
}
315
316
static coroutine_fn int64_t
317
--
54
--
318
2.9.3
55
2.11.0
319
56
320
57
diff view generated by jsdifflib
New patch
1
From: Peter Lieven <pl@kamp.de>
1
2
3
parse_uint_full wants to put the parsed value into the
4
variable passed via its second argument which is NULL.
5
6
Fixes: 94d6a7a76e9df9919629428f6c598e2b97d9426c
7
Cc: qemu-stable@nongnu.org
8
Signed-off-by: Peter Lieven <pl@kamp.de>
9
Reviewed-by: Eric Blake <eblake@redhat.com>
10
Message-id: 1485942829-10756-2-git-send-email-pl@kamp.de
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
12
---
13
block/nfs.c | 3 ++-
14
1 file changed, 2 insertions(+), 1 deletion(-)
15
16
diff --git a/block/nfs.c b/block/nfs.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/block/nfs.c
19
+++ b/block/nfs.c
20
@@ -XXX,XX +XXX,XX @@ static int nfs_parse_uri(const char *filename, QDict *options, Error **errp)
21
qdict_put(options, "path", qstring_from_str(uri->path));
22
23
for (i = 0; i < qp->n; i++) {
24
+ unsigned long long val;
25
if (!qp->p[i].value) {
26
error_setg(errp, "Value for NFS parameter expected: %s",
27
qp->p[i].name);
28
goto out;
29
}
30
- if (parse_uint_full(qp->p[i].value, NULL, 0)) {
31
+ if (parse_uint_full(qp->p[i].value, &val, 0)) {
32
error_setg(errp, "Illegal value for NFS parameter: %s",
33
qp->p[i].name);
34
goto out;
35
--
36
2.11.0
37
38
diff view generated by jsdifflib
New patch
1
From: Peter Lieven <pl@kamp.de>
1
2
3
commit 94d6a7a accidentally left the naming of runtime opts and QAPI
4
scheme inconsistent. As one consequence passing of parameters in the
5
URI is broken. Sync the naming of the runtime opts to the QAPI
6
scheme.
7
8
Please note that this is technically backwards incompatible with the 2.8
9
release, but the 2.8 release is the only version that had the wrong naming.
10
Furthermore release 2.8 suffered from a NULL pointer dereference during
11
URI parsing.
12
13
Fixes: 94d6a7a76e9df9919629428f6c598e2b97d9426c
14
Cc: qemu-stable@nongnu.org
15
Signed-off-by: Peter Lieven <pl@kamp.de>
16
Message-id: 1485942829-10756-3-git-send-email-pl@kamp.de
17
[mreitz: Fixed commit message]
18
Reviewed-by: Eric Blake <eblake@redhat.com>
19
Signed-off-by: Max Reitz <mreitz@redhat.com>
20
---
21
block/nfs.c | 46 +++++++++++++++++++++++-----------------------
22
1 file changed, 23 insertions(+), 23 deletions(-)
23
24
diff --git a/block/nfs.c b/block/nfs.c
25
index XXXXXXX..XXXXXXX 100644
26
--- a/block/nfs.c
27
+++ b/block/nfs.c
28
@@ -XXX,XX +XXX,XX @@ static QemuOptsList runtime_opts = {
29
.help = "Path of the image on the host",
30
},
31
{
32
- .name = "uid",
33
+ .name = "user",
34
.type = QEMU_OPT_NUMBER,
35
.help = "UID value to use when talking to the server",
36
},
37
{
38
- .name = "gid",
39
+ .name = "group",
40
.type = QEMU_OPT_NUMBER,
41
.help = "GID value to use when talking to the server",
42
},
43
{
44
- .name = "tcp-syncnt",
45
+ .name = "tcp-syn-count",
46
.type = QEMU_OPT_NUMBER,
47
.help = "Number of SYNs to send during the session establish",
48
},
49
{
50
- .name = "readahead",
51
+ .name = "readahead-size",
52
.type = QEMU_OPT_NUMBER,
53
.help = "Set the readahead size in bytes",
54
},
55
{
56
- .name = "pagecache",
57
+ .name = "page-cache-size",
58
.type = QEMU_OPT_NUMBER,
59
.help = "Set the pagecache size in bytes",
60
},
61
@@ -XXX,XX +XXX,XX @@ static int64_t nfs_client_open(NFSClient *client, QDict *options,
62
goto fail;
63
}
64
65
- if (qemu_opt_get(opts, "uid")) {
66
- client->uid = qemu_opt_get_number(opts, "uid", 0);
67
+ if (qemu_opt_get(opts, "user")) {
68
+ client->uid = qemu_opt_get_number(opts, "user", 0);
69
nfs_set_uid(client->context, client->uid);
70
}
71
72
- if (qemu_opt_get(opts, "gid")) {
73
- client->gid = qemu_opt_get_number(opts, "gid", 0);
74
+ if (qemu_opt_get(opts, "group")) {
75
+ client->gid = qemu_opt_get_number(opts, "group", 0);
76
nfs_set_gid(client->context, client->gid);
77
}
78
79
- if (qemu_opt_get(opts, "tcp-syncnt")) {
80
- client->tcp_syncnt = qemu_opt_get_number(opts, "tcp-syncnt", 0);
81
+ if (qemu_opt_get(opts, "tcp-syn-count")) {
82
+ client->tcp_syncnt = qemu_opt_get_number(opts, "tcp-syn-count", 0);
83
nfs_set_tcp_syncnt(client->context, client->tcp_syncnt);
84
}
85
86
#ifdef LIBNFS_FEATURE_READAHEAD
87
- if (qemu_opt_get(opts, "readahead")) {
88
+ if (qemu_opt_get(opts, "readahead-size")) {
89
if (open_flags & BDRV_O_NOCACHE) {
90
error_setg(errp, "Cannot enable NFS readahead "
91
"if cache.direct = on");
92
goto fail;
93
}
94
- client->readahead = qemu_opt_get_number(opts, "readahead", 0);
95
+ client->readahead = qemu_opt_get_number(opts, "readahead-size", 0);
96
if (client->readahead > QEMU_NFS_MAX_READAHEAD_SIZE) {
97
error_report("NFS Warning: Truncating NFS readahead "
98
"size to %d", QEMU_NFS_MAX_READAHEAD_SIZE);
99
@@ -XXX,XX +XXX,XX @@ static int64_t nfs_client_open(NFSClient *client, QDict *options,
100
#endif
101
102
#ifdef LIBNFS_FEATURE_PAGECACHE
103
- if (qemu_opt_get(opts, "pagecache")) {
104
+ if (qemu_opt_get(opts, "page-cache-size")) {
105
if (open_flags & BDRV_O_NOCACHE) {
106
error_setg(errp, "Cannot enable NFS pagecache "
107
"if cache.direct = on");
108
goto fail;
109
}
110
- client->pagecache = qemu_opt_get_number(opts, "pagecache", 0);
111
+ client->pagecache = qemu_opt_get_number(opts, "page-cache-size", 0);
112
if (client->pagecache > QEMU_NFS_MAX_PAGECACHE_SIZE) {
113
error_report("NFS Warning: Truncating NFS pagecache "
114
"size to %d pages", QEMU_NFS_MAX_PAGECACHE_SIZE);
115
@@ -XXX,XX +XXX,XX @@ static void nfs_refresh_filename(BlockDriverState *bs, QDict *options)
116
qdict_put(opts, "path", qstring_from_str(client->path));
117
118
if (client->uid) {
119
- qdict_put(opts, "uid", qint_from_int(client->uid));
120
+ qdict_put(opts, "user", qint_from_int(client->uid));
121
}
122
if (client->gid) {
123
- qdict_put(opts, "gid", qint_from_int(client->gid));
124
+ qdict_put(opts, "group", qint_from_int(client->gid));
125
}
126
if (client->tcp_syncnt) {
127
- qdict_put(opts, "tcp-syncnt",
128
- qint_from_int(client->tcp_syncnt));
129
+ qdict_put(opts, "tcp-syn-cnt",
130
+ qint_from_int(client->tcp_syncnt));
131
}
132
if (client->readahead) {
133
- qdict_put(opts, "readahead",
134
- qint_from_int(client->readahead));
135
+ qdict_put(opts, "readahead-size",
136
+ qint_from_int(client->readahead));
137
}
138
if (client->pagecache) {
139
- qdict_put(opts, "pagecache",
140
- qint_from_int(client->pagecache));
141
+ qdict_put(opts, "page-cache-size",
142
+ qint_from_int(client->pagecache));
143
}
144
if (client->debug) {
145
qdict_put(opts, "debug", qint_from_int(client->debug));
146
--
147
2.11.0
148
149
diff view generated by jsdifflib
New patch
1
1
From: Nir Soffer <nirsof@gmail.com>
2
3
The result of openfile was not checked, leading to failure deep in the
4
actual command with confusing error message, and exiting with exit code 0.
5
6
Here is a simple example - trying to read with the wrong format:
7
8
$ touch file
9
$ qemu-io -f qcow2 -c 'read -P 1 0 1024' file; echo $?
10
can't open device file: Image is not in qcow2 format
11
no file open, try 'help open'
12
0
13
14
With this patch, we fail earlier with exit code 1:
15
16
$ ./qemu-io -f qcow2 -c 'read -P 1 0 1024' file; echo $?
17
can't open device file: Image is not in qcow2 format
18
1
19
20
Failing earlier, we don't log this error now:
21
22
no file open, try 'help open'
23
24
But some tests expected it; the line was removed from the test output.
25
26
Signed-off-by: Nir Soffer <nirsof@gmail.com>
27
Reviewed-by: Eric Blake <eblake@redhat.com>
28
Message-id: 20170201003120.23378-2-nirsof@gmail.com
29
Reviewed-by: Max Reitz <mreitz@redhat.com>
30
Signed-off-by: Max Reitz <mreitz@redhat.com>
31
---
32
qemu-io.c | 8 ++++++--
33
tests/qemu-iotests/059.out | 3 ---
34
tests/qemu-iotests/070.out | 1 -
35
tests/qemu-iotests/075.out | 7 -------
36
tests/qemu-iotests/076.out | 3 ---
37
tests/qemu-iotests/078.out | 6 ------
38
tests/qemu-iotests/080.out | 18 ------------------
39
tests/qemu-iotests/083.out | 17 -----------------
40
tests/qemu-iotests/088.out | 6 ------
41
tests/qemu-iotests/092.out | 12 ------------
42
tests/qemu-iotests/116.out | 7 -------
43
tests/qemu-iotests/131.out | 1 -
44
tests/qemu-iotests/140.out | 1 -
45
13 files changed, 6 insertions(+), 84 deletions(-)
46
47
diff --git a/qemu-io.c b/qemu-io.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/qemu-io.c
50
+++ b/qemu-io.c
51
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv)
52
exit(1);
53
}
54
opts = qemu_opts_to_qdict(qopts, NULL);
55
- openfile(NULL, flags, writethrough, opts);
56
+ if (openfile(NULL, flags, writethrough, opts)) {
57
+ exit(1);
58
+ }
59
} else {
60
if (format) {
61
opts = qdict_new();
62
qdict_put(opts, "driver", qstring_from_str(format));
63
}
64
- openfile(argv[optind], flags, writethrough, opts);
65
+ if (openfile(argv[optind], flags, writethrough, opts)) {
66
+ exit(1);
67
+ }
68
}
69
}
70
command_loop();
71
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
72
index XXXXXXX..XXXXXXX 100644
73
--- a/tests/qemu-iotests/059.out
74
+++ b/tests/qemu-iotests/059.out
75
@@ -XXX,XX +XXX,XX @@ QA output created by 059
76
=== Testing invalid granularity ===
77
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
78
can't open device TEST_DIR/t.vmdk: Invalid granularity, image may be corrupt
79
-no file open, try 'help open'
80
81
=== Testing too big L2 table size ===
82
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
83
can't open device TEST_DIR/t.vmdk: L2 table size too big
84
-no file open, try 'help open'
85
86
=== Testing too big L1 table size ===
87
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
88
can't open device TEST_DIR/t.vmdk: L1 size too big
89
-no file open, try 'help open'
90
91
=== Testing monolithicFlat creation and opening ===
92
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat
93
diff --git a/tests/qemu-iotests/070.out b/tests/qemu-iotests/070.out
94
index XXXXXXX..XXXXXXX 100644
95
--- a/tests/qemu-iotests/070.out
96
+++ b/tests/qemu-iotests/070.out
97
@@ -XXX,XX +XXX,XX @@ QA output created by 070
98
can't open device TEST_DIR/iotest-dirtylog-10G-4M.vhdx: VHDX image file 'TEST_DIR/iotest-dirtylog-10G-4M.vhdx' opened read-only, but contains a log that needs to be replayed
99
To replay the log, run:
100
qemu-img check -r all 'TEST_DIR/iotest-dirtylog-10G-4M.vhdx'
101
- no file open, try 'help open'
102
=== Verify open image replays log ===
103
read 18874368/18874368 bytes at offset 0
104
18 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
105
diff --git a/tests/qemu-iotests/075.out b/tests/qemu-iotests/075.out
106
index XXXXXXX..XXXXXXX 100644
107
--- a/tests/qemu-iotests/075.out
108
+++ b/tests/qemu-iotests/075.out
109
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 1048064
110
111
== block_size must be a multiple of 512 ==
112
can't open device TEST_DIR/simple-pattern.cloop: block_size 513 must be a multiple of 512
113
-no file open, try 'help open'
114
115
== block_size cannot be zero ==
116
can't open device TEST_DIR/simple-pattern.cloop: block_size cannot be zero
117
-no file open, try 'help open'
118
119
== huge block_size ===
120
can't open device TEST_DIR/simple-pattern.cloop: block_size 4294966784 must be 64 MB or less
121
-no file open, try 'help open'
122
123
== offsets_size overflow ===
124
can't open device TEST_DIR/simple-pattern.cloop: n_blocks 4294967295 must be 536870911 or less
125
-no file open, try 'help open'
126
127
== refuse images that require too many offsets ===
128
can't open device TEST_DIR/simple-pattern.cloop: image requires too many offsets, try increasing block size
129
-no file open, try 'help open'
130
131
== refuse images with non-monotonically increasing offsets ==
132
can't open device TEST_DIR/simple-pattern.cloop: offsets not monotonically increasing at index 1, image file is corrupt
133
-no file open, try 'help open'
134
135
== refuse images with invalid compressed block size ==
136
can't open device TEST_DIR/simple-pattern.cloop: invalid compressed block size at index 1, image file is corrupt
137
-no file open, try 'help open'
138
*** done
139
diff --git a/tests/qemu-iotests/076.out b/tests/qemu-iotests/076.out
140
index XXXXXXX..XXXXXXX 100644
141
--- a/tests/qemu-iotests/076.out
142
+++ b/tests/qemu-iotests/076.out
143
@@ -XXX,XX +XXX,XX @@ read 65536/65536 bytes at offset 0
144
145
== Negative catalog size ==
146
can't open device TEST_DIR/parallels-v1: Catalog too large
147
-no file open, try 'help open'
148
149
== Overflow in catalog allocation ==
150
can't open device TEST_DIR/parallels-v1: Catalog too large
151
-no file open, try 'help open'
152
153
== Zero sectors per track ==
154
can't open device TEST_DIR/parallels-v1: Invalid image: Zero sectors per track
155
-no file open, try 'help open'
156
157
== Read from a valid v2 image ==
158
read 65536/65536 bytes at offset 0
159
diff --git a/tests/qemu-iotests/078.out b/tests/qemu-iotests/078.out
160
index XXXXXXX..XXXXXXX 100644
161
--- a/tests/qemu-iotests/078.out
162
+++ b/tests/qemu-iotests/078.out
163
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 0
164
165
== Negative catalog size ==
166
can't open device TEST_DIR/empty.bochs: Catalog size is too large
167
-no file open, try 'help open'
168
169
== Overflow for catalog size * sizeof(uint32_t) ==
170
can't open device TEST_DIR/empty.bochs: Catalog size is too large
171
-no file open, try 'help open'
172
173
== Too small catalog bitmap for image size ==
174
can't open device TEST_DIR/empty.bochs: Catalog size is too small for this disk size
175
-no file open, try 'help open'
176
can't open device TEST_DIR/empty.bochs: Catalog size is too small for this disk size
177
-no file open, try 'help open'
178
179
== Negative extent size ==
180
can't open device TEST_DIR/empty.bochs: Extent size 2147483648 is too large
181
-no file open, try 'help open'
182
183
== Zero extent size ==
184
can't open device TEST_DIR/empty.bochs: Extent size must be at least 512
185
-no file open, try 'help open'
186
*** done
187
diff --git a/tests/qemu-iotests/080.out b/tests/qemu-iotests/080.out
188
index XXXXXXX..XXXXXXX 100644
189
--- a/tests/qemu-iotests/080.out
190
+++ b/tests/qemu-iotests/080.out
191
@@ -XXX,XX +XXX,XX @@ QA output created by 080
192
== Huge header size ==
193
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
194
can't open device TEST_DIR/t.qcow2: qcow2 header exceeds cluster size
195
-no file open, try 'help open'
196
can't open device TEST_DIR/t.qcow2: qcow2 header exceeds cluster size
197
-no file open, try 'help open'
198
199
== Huge unknown header extension ==
200
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
201
can't open device TEST_DIR/t.qcow2: Invalid backing file offset
202
-no file open, try 'help open'
203
can't open device TEST_DIR/t.qcow2: Header extension too large
204
-no file open, try 'help open'
205
can't open device TEST_DIR/t.qcow2: Header extension too large
206
-no file open, try 'help open'
207
208
== Huge refcount table size ==
209
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
210
can't open device TEST_DIR/t.qcow2: Reference count table too large
211
-no file open, try 'help open'
212
can't open device TEST_DIR/t.qcow2: Reference count table too large
213
-no file open, try 'help open'
214
215
== Misaligned refcount table ==
216
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
217
can't open device TEST_DIR/t.qcow2: Invalid reference count table offset
218
-no file open, try 'help open'
219
220
== Huge refcount offset ==
221
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
222
can't open device TEST_DIR/t.qcow2: Invalid reference count table offset
223
-no file open, try 'help open'
224
225
== Invalid snapshot table ==
226
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
227
can't open device TEST_DIR/t.qcow2: Too many snapshots
228
-no file open, try 'help open'
229
can't open device TEST_DIR/t.qcow2: Too many snapshots
230
-no file open, try 'help open'
231
can't open device TEST_DIR/t.qcow2: Invalid snapshot table offset
232
-no file open, try 'help open'
233
can't open device TEST_DIR/t.qcow2: Invalid snapshot table offset
234
-no file open, try 'help open'
235
236
== Hitting snapshot table size limit ==
237
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
238
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 0
239
== Invalid L1 table ==
240
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
241
can't open device TEST_DIR/t.qcow2: Active L1 table too large
242
-no file open, try 'help open'
243
can't open device TEST_DIR/t.qcow2: Active L1 table too large
244
-no file open, try 'help open'
245
can't open device TEST_DIR/t.qcow2: Invalid L1 table offset
246
-no file open, try 'help open'
247
can't open device TEST_DIR/t.qcow2: Invalid L1 table offset
248
-no file open, try 'help open'
249
250
== Invalid L1 table (with internal snapshot in the image) ==
251
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
252
@@ -XXX,XX +XXX,XX @@ qemu-img: Could not open 'TEST_DIR/t.IMGFMT': L1 table is too small
253
== Invalid backing file size ==
254
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
255
can't open device TEST_DIR/t.qcow2: Backing file name too long
256
-no file open, try 'help open'
257
258
== Invalid L2 entry (huge physical offset) ==
259
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
260
diff --git a/tests/qemu-iotests/083.out b/tests/qemu-iotests/083.out
261
index XXXXXXX..XXXXXXX 100644
262
--- a/tests/qemu-iotests/083.out
263
+++ b/tests/qemu-iotests/083.out
264
@@ -XXX,XX +XXX,XX @@ QA output created by 083
265
=== Check disconnect before neg1 ===
266
267
can't open device nbd:127.0.0.1:PORT:exportname=foo
268
-no file open, try 'help open'
269
270
=== Check disconnect after neg1 ===
271
272
can't open device nbd:127.0.0.1:PORT:exportname=foo
273
-no file open, try 'help open'
274
275
=== Check disconnect 8 neg1 ===
276
277
can't open device nbd:127.0.0.1:PORT:exportname=foo
278
-no file open, try 'help open'
279
280
=== Check disconnect 16 neg1 ===
281
282
can't open device nbd:127.0.0.1:PORT:exportname=foo
283
-no file open, try 'help open'
284
285
=== Check disconnect before export ===
286
287
can't open device nbd:127.0.0.1:PORT:exportname=foo
288
-no file open, try 'help open'
289
290
=== Check disconnect after export ===
291
292
can't open device nbd:127.0.0.1:PORT:exportname=foo
293
-no file open, try 'help open'
294
295
=== Check disconnect 4 export ===
296
297
can't open device nbd:127.0.0.1:PORT:exportname=foo
298
-no file open, try 'help open'
299
300
=== Check disconnect 12 export ===
301
302
can't open device nbd:127.0.0.1:PORT:exportname=foo
303
-no file open, try 'help open'
304
305
=== Check disconnect 16 export ===
306
307
can't open device nbd:127.0.0.1:PORT:exportname=foo
308
-no file open, try 'help open'
309
310
=== Check disconnect before neg2 ===
311
312
can't open device nbd:127.0.0.1:PORT:exportname=foo
313
-no file open, try 'help open'
314
315
=== Check disconnect after neg2 ===
316
317
@@ -XXX,XX +XXX,XX @@ read failed: Input/output error
318
=== Check disconnect 8 neg2 ===
319
320
can't open device nbd:127.0.0.1:PORT:exportname=foo
321
-no file open, try 'help open'
322
323
=== Check disconnect 10 neg2 ===
324
325
can't open device nbd:127.0.0.1:PORT:exportname=foo
326
-no file open, try 'help open'
327
328
=== Check disconnect before request ===
329
330
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 0
331
=== Check disconnect before neg-classic ===
332
333
can't open device nbd:127.0.0.1:PORT
334
-no file open, try 'help open'
335
336
=== Check disconnect 8 neg-classic ===
337
338
can't open device nbd:127.0.0.1:PORT
339
-no file open, try 'help open'
340
341
=== Check disconnect 16 neg-classic ===
342
343
can't open device nbd:127.0.0.1:PORT
344
-no file open, try 'help open'
345
346
=== Check disconnect 24 neg-classic ===
347
348
can't open device nbd:127.0.0.1:PORT
349
-no file open, try 'help open'
350
351
=== Check disconnect 28 neg-classic ===
352
353
can't open device nbd:127.0.0.1:PORT
354
-no file open, try 'help open'
355
356
=== Check disconnect after neg-classic ===
357
358
diff --git a/tests/qemu-iotests/088.out b/tests/qemu-iotests/088.out
359
index XXXXXXX..XXXXXXX 100644
360
--- a/tests/qemu-iotests/088.out
361
+++ b/tests/qemu-iotests/088.out
362
@@ -XXX,XX +XXX,XX @@ QA output created by 088
363
== Invalid block size ==
364
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
365
can't open device TEST_DIR/t.vpc: Invalid block size 0
366
-no file open, try 'help open'
367
can't open device TEST_DIR/t.vpc: Invalid block size 0
368
-no file open, try 'help open'
369
can't open device TEST_DIR/t.vpc: Invalid block size 128
370
-no file open, try 'help open'
371
can't open device TEST_DIR/t.vpc: Invalid block size 128
372
-no file open, try 'help open'
373
can't open device TEST_DIR/t.vpc: Invalid block size 305419896
374
-no file open, try 'help open'
375
can't open device TEST_DIR/t.vpc: Invalid block size 305419896
376
-no file open, try 'help open'
377
*** done
378
diff --git a/tests/qemu-iotests/092.out b/tests/qemu-iotests/092.out
379
index XXXXXXX..XXXXXXX 100644
380
--- a/tests/qemu-iotests/092.out
381
+++ b/tests/qemu-iotests/092.out
382
@@ -XXX,XX +XXX,XX @@ QA output created by 092
383
== Invalid cluster size ==
384
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
385
can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k
386
-no file open, try 'help open'
387
can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k
388
-no file open, try 'help open'
389
can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k
390
-no file open, try 'help open'
391
can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k
392
-no file open, try 'help open'
393
394
== Invalid L2 table size ==
395
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
396
can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k
397
-no file open, try 'help open'
398
can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k
399
-no file open, try 'help open'
400
can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k
401
-no file open, try 'help open'
402
can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k
403
-no file open, try 'help open'
404
405
== Invalid size ==
406
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
407
can't open device TEST_DIR/t.qcow: Image too large
408
-no file open, try 'help open'
409
can't open device TEST_DIR/t.qcow: Image too large
410
-no file open, try 'help open'
411
412
== Invalid backing file length ==
413
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
414
can't open device TEST_DIR/t.qcow: Backing file name too long
415
-no file open, try 'help open'
416
can't open device TEST_DIR/t.qcow: Backing file name too long
417
-no file open, try 'help open'
418
*** done
419
diff --git a/tests/qemu-iotests/116.out b/tests/qemu-iotests/116.out
420
index XXXXXXX..XXXXXXX 100644
421
--- a/tests/qemu-iotests/116.out
422
+++ b/tests/qemu-iotests/116.out
423
@@ -XXX,XX +XXX,XX @@ QA output created by 116
424
== truncated header cluster ==
425
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
426
can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument
427
-no file open, try 'help open'
428
429
== invalid header magic ==
430
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
431
can't open device TEST_DIR/t.qed: Image not in QED format
432
-no file open, try 'help open'
433
434
== invalid cluster size ==
435
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
436
can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument
437
-no file open, try 'help open'
438
439
== invalid table size ==
440
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
441
can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument
442
-no file open, try 'help open'
443
444
== invalid header size ==
445
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
446
can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument
447
-no file open, try 'help open'
448
449
== invalid L1 table offset ==
450
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
451
can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument
452
-no file open, try 'help open'
453
454
== invalid image size ==
455
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
456
can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument
457
-no file open, try 'help open'
458
*** done
459
diff --git a/tests/qemu-iotests/131.out b/tests/qemu-iotests/131.out
460
index XXXXXXX..XXXXXXX 100644
461
--- a/tests/qemu-iotests/131.out
462
+++ b/tests/qemu-iotests/131.out
463
@@ -XXX,XX +XXX,XX @@ read 32768/32768 bytes at offset 0
464
32 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
465
== Corrupt image ==
466
can't open device TEST_DIR/t.parallels: parallels: Image was not closed correctly; cannot be opened read/write
467
-no file open, try 'help open'
468
ERROR image was not closed correctly
469
470
1 errors were found on the image.
471
diff --git a/tests/qemu-iotests/140.out b/tests/qemu-iotests/140.out
472
index XXXXXXX..XXXXXXX 100644
473
--- a/tests/qemu-iotests/140.out
474
+++ b/tests/qemu-iotests/140.out
475
@@ -XXX,XX +XXX,XX @@ read 65536/65536 bytes at offset 0
476
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
477
{"return": {}}
478
can't open device nbd+unix:///drv?socket=TEST_DIR/nbd: No export with name 'drv' available
479
-no file open, try 'help open'
480
{"return": {}}
481
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"}
482
*** done
483
--
484
2.11.0
485
486
diff view generated by jsdifflib
New patch
1
From: Nir Soffer <nirsof@gmail.com>
1
2
3
This helper allows adding tests supporting any format expect the
4
specified formats. This may be useful to test that many formats behave
5
in a common way.
6
7
Signed-off-by: Nir Soffer <nirsof@gmail.com>
8
Message-id: 20170201003120.23378-3-nirsof@gmail.com
9
Reviewed-by: Max Reitz <mreitz@redhat.com>
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
---
12
tests/qemu-iotests/common.rc | 11 +++++++++++
13
1 file changed, 11 insertions(+)
14
15
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
16
index XXXXXXX..XXXXXXX 100644
17
--- a/tests/qemu-iotests/common.rc
18
+++ b/tests/qemu-iotests/common.rc
19
@@ -XXX,XX +XXX,XX @@ _supported_fmt()
20
_notrun "not suitable for this image format: $IMGFMT"
21
}
22
23
+# tests whether $IMGFMT is one of the unsupported image format for a test
24
+#
25
+_unsupported_fmt()
26
+{
27
+ for f; do
28
+ if [ "$f" = "$IMGFMT" ]; then
29
+ _notrun "not suitable for this image format: $IMGFMT"
30
+ fi
31
+ done
32
+}
33
+
34
# tests whether $IMGPROTO is one of the supported image protocols for a test
35
#
36
_supported_proto()
37
--
38
2.11.0
39
40
diff view generated by jsdifflib
New patch
1
From: Nir Soffer <nirsof@gmail.com>
1
2
3
Add regression tests checking that qemu-io fails with non-zero exit code
4
when reading non-existing file or using the wrong image format.
5
6
Signed-off-by: Nir Soffer <nirsof@gmail.com>
7
Message-id: 20170201003120.23378-4-nirsof@gmail.com
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
---
11
tests/qemu-iotests/174 | 59 ++++++++++++++++++++++++++++++++++++++++++++++
12
tests/qemu-iotests/174.out | 7 ++++++
13
tests/qemu-iotests/group | 1 +
14
3 files changed, 67 insertions(+)
15
create mode 100755 tests/qemu-iotests/174
16
create mode 100644 tests/qemu-iotests/174.out
17
18
diff --git a/tests/qemu-iotests/174 b/tests/qemu-iotests/174
19
new file mode 100755
20
index XXXXXXX..XXXXXXX
21
--- /dev/null
22
+++ b/tests/qemu-iotests/174
23
@@ -XXX,XX +XXX,XX @@
24
+#!/bin/bash
25
+#
26
+# Test that qemu-io fail with non-zero exit code
27
+#
28
+# Copyright (C) 2017 Nir Soffer <nirsof@gmail.com>
29
+#
30
+# This program is free software; you can redistribute it and/or modify
31
+# it under the terms of the GNU General Public License as published by
32
+# the Free Software Foundation; either version 2 of the License, or
33
+# (at your option) any later version.
34
+#
35
+# This program is distributed in the hope that it will be useful,
36
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
37
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38
+# GNU General Public License for more details.
39
+#
40
+# You should have received a copy of the GNU General Public License
41
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
42
+#
43
+
44
+# creator
45
+owner=nirsof@gmail.com
46
+
47
+seq=`basename $0`
48
+echo "QA output created by $seq"
49
+
50
+here=`pwd`
51
+status=1    # failure is the default!
52
+
53
+_cleanup()
54
+{
55
+    _cleanup_test_img
56
+}
57
+trap "_cleanup; exit \$status" 0 1 2 3 15
58
+
59
+# get standard environment, filters and checks
60
+. ./common.rc
61
+. ./common.filter
62
+
63
+_unsupported_fmt raw
64
+
65
+
66
+size=256K
67
+IMGFMT=raw IMGOPTS= _make_test_img $size | _filter_imgfmt
68
+
69
+echo
70
+echo "== reading wrong format should fail =="
71
+$QEMU_IO -f $IMGFMT -c "read 0 $size" "$TEST_IMG" 2>/dev/null
72
+test $? -eq 1 || _fail "did not fail"
73
+
74
+echo
75
+echo "== reading missing file should fail =="
76
+$QEMU_IO -c "read 0 $size" "$TEST_DIR/missing" 2>/dev/null
77
+test $? -eq 1 || _fail "did not fail"
78
+
79
+# success, all done
80
+echo "*** done"
81
+rm -f $seq.full
82
+status=0
83
diff --git a/tests/qemu-iotests/174.out b/tests/qemu-iotests/174.out
84
new file mode 100644
85
index XXXXXXX..XXXXXXX
86
--- /dev/null
87
+++ b/tests/qemu-iotests/174.out
88
@@ -XXX,XX +XXX,XX @@
89
+QA output created by 174
90
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=262144
91
+
92
+== reading wrong format should fail ==
93
+
94
+== reading missing file should fail ==
95
+*** done
96
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
97
index XXXXXXX..XXXXXXX 100644
98
--- a/tests/qemu-iotests/group
99
+++ b/tests/qemu-iotests/group
100
@@ -XXX,XX +XXX,XX @@
101
171 rw auto quick
102
172 auto
103
173 rw auto
104
+174 auto
105
--
106
2.11.0
107
108
diff view generated by jsdifflib
1
From: Paolo Bonzini <pbonzini@redhat.com>
1
From: Alberto Garcia <berto@igalia.com>
2
2
3
Wrap the code that was copied repeatedly in the two functions,
3
The metadata overlap checks introduced in a40f1c2add help detect
4
sd_aio_setup and sd_aio_complete.
4
corruption in the qcow2 image by verifying that data writes don't
5
overlap with existing metadata sections.
5
6
6
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7
The 'refcount-block' check in particular iterates over the refcount
7
Message-id: 20161129113245.32724-6-pbonzini@redhat.com
8
table in order to get the addresses of all refcount blocks and check
8
Signed-off-by: Jeff Cody <jcody@redhat.com>
9
that none of them overlap with the region where we want to write.
10
11
The problem with the refcount table is that since it always occupies
12
complete clusters its size is usually very big. With the default
13
values of cluster_size=64KB and refcount_bits=16 this table holds 8192
14
entries, each one of them enough to map 2GB worth of host clusters.
15
16
So unless we're using images with several TB of allocated data this
17
table is going to be mostly empty, and iterating over it is a waste of
18
CPU. If the storage backend is fast enough this can have an effect on
19
I/O performance.
20
21
This patch keeps the index of the last used (i.e. non-zero) entry in
22
the refcount table and updates it every time the table changes. The
23
refcount-block overlap check then uses that index instead of reading
24
the whole table.
25
26
In my tests with a 4GB qcow2 file stored in RAM this doubles the
27
amount of write IOPS.
28
29
Signed-off-by: Alberto Garcia <berto@igalia.com>
30
Message-id: 20170201123828.4815-1-berto@igalia.com
31
Reviewed-by: Max Reitz <mreitz@redhat.com>
32
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
33
---
10
block/sheepdog.c | 66 ++++++++++++++++++++++++++------------------------------
34
block/qcow2.h | 1 +
11
1 file changed, 30 insertions(+), 36 deletions(-)
35
block/qcow2-refcount.c | 24 +++++++++++++++++++++++-
36
block/qcow2.c | 1 +
37
3 files changed, 25 insertions(+), 1 deletion(-)
12
38
13
diff --git a/block/sheepdog.c b/block/sheepdog.c
39
diff --git a/block/qcow2.h b/block/qcow2.h
14
index XXXXXXX..XXXXXXX 100644
40
index XXXXXXX..XXXXXXX 100644
15
--- a/block/sheepdog.c
41
--- a/block/qcow2.h
16
+++ b/block/sheepdog.c
42
+++ b/block/qcow2.h
17
@@ -XXX,XX +XXX,XX @@ static inline AIOReq *alloc_aio_req(BDRVSheepdogState *s, SheepdogAIOCB *acb,
43
@@ -XXX,XX +XXX,XX @@ typedef struct BDRVQcow2State {
18
return aio_req;
44
uint64_t *refcount_table;
19
}
45
uint64_t refcount_table_offset;
20
46
uint32_t refcount_table_size;
21
+static void wait_for_overlapping_aiocb(BDRVSheepdogState *s, SheepdogAIOCB *acb)
47
+ uint32_t max_refcount_table_index; /* Last used entry in refcount_table */
48
uint64_t free_cluster_index;
49
uint64_t free_byte_offset;
50
51
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
52
index XXXXXXX..XXXXXXX 100644
53
--- a/block/qcow2-refcount.c
54
+++ b/block/qcow2-refcount.c
55
@@ -XXX,XX +XXX,XX @@ static Qcow2SetRefcountFunc *const set_refcount_funcs[] = {
56
/*********************************************************/
57
/* refcount handling */
58
59
+static void update_max_refcount_table_index(BDRVQcow2State *s)
22
+{
60
+{
23
+ SheepdogAIOCB *cb;
61
+ unsigned i = s->refcount_table_size - 1;
24
+
62
+ while (i > 0 && (s->refcount_table[i] & REFT_OFFSET_MASK) == 0) {
25
+retry:
63
+ i--;
26
+ QLIST_FOREACH(cb, &s->inflight_aiocb_head, aiocb_siblings) {
27
+ if (AIOCBOverlapping(acb, cb)) {
28
+ qemu_co_queue_wait(&s->overlapping_queue);
29
+ goto retry;
30
+ }
31
+ }
64
+ }
65
+ /* Set s->max_refcount_table_index to the index of the last used entry */
66
+ s->max_refcount_table_index = i;
32
+}
67
+}
33
+
68
+
34
static void sd_aio_setup(SheepdogAIOCB *acb, BDRVSheepdogState *s,
69
int qcow2_refcount_init(BlockDriverState *bs)
35
QEMUIOVector *qiov, int64_t sector_num, int nb_sectors,
70
{
36
int type)
71
BDRVQcow2State *s = bs->opaque;
37
@@ -XXX,XX +XXX,XX @@ static void sd_aio_setup(SheepdogAIOCB *acb, BDRVSheepdogState *s,
72
@@ -XXX,XX +XXX,XX @@ int qcow2_refcount_init(BlockDriverState *bs)
38
acb->min_dirty_data_idx = UINT32_MAX;
73
}
39
acb->max_dirty_data_idx = 0;
74
for(i = 0; i < s->refcount_table_size; i++)
40
acb->aiocb_type = type;
75
be64_to_cpus(&s->refcount_table[i]);
41
+
76
+ update_max_refcount_table_index(s);
42
+ if (type == AIOCB_FLUSH_CACHE) {
43
+ return;
44
+ }
45
+
46
+ wait_for_overlapping_aiocb(s, acb);
47
+ QLIST_INSERT_HEAD(&s->inflight_aiocb_head, acb, aiocb_siblings);
48
}
49
50
/* Return -EIO in case of error, file descriptor on success */
51
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn sd_co_rw_vector(SheepdogAIOCB *acb)
52
}
77
}
53
}
78
return 0;
54
79
fail:
55
-static bool check_overlapping_aiocb(BDRVSheepdogState *s, SheepdogAIOCB *aiocb)
80
@@ -XXX,XX +XXX,XX @@ static int alloc_refcount_block(BlockDriverState *bs,
56
+static void sd_aio_complete(SheepdogAIOCB *acb)
81
}
57
{
82
58
- SheepdogAIOCB *cb;
83
s->refcount_table[refcount_table_index] = new_block;
59
-
84
+ /* If there's a hole in s->refcount_table then it can happen
60
- QLIST_FOREACH(cb, &s->inflight_aiocb_head, aiocb_siblings) {
85
+ * that refcount_table_index < s->max_refcount_table_index */
61
- if (AIOCBOverlapping(aiocb, cb)) {
86
+ s->max_refcount_table_index =
62
- return true;
87
+ MAX(s->max_refcount_table_index, refcount_table_index);
63
- }
88
64
+ if (acb->aiocb_type == AIOCB_FLUSH_CACHE) {
89
/* The new refcount block may be where the caller intended to put its
65
+ return;
90
* data, so let it restart the search. */
91
@@ -XXX,XX +XXX,XX @@ static int alloc_refcount_block(BlockDriverState *bs,
92
s->refcount_table = new_table;
93
s->refcount_table_size = table_size;
94
s->refcount_table_offset = table_offset;
95
+ update_max_refcount_table_index(s);
96
97
/* Free old table. */
98
qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t),
99
@@ -XXX,XX +XXX,XX @@ write_refblocks:
100
s->refcount_table = on_disk_reftable;
101
s->refcount_table_offset = reftable_offset;
102
s->refcount_table_size = reftable_size;
103
+ update_max_refcount_table_index(s);
104
105
return 0;
106
107
@@ -XXX,XX +XXX,XX @@ int qcow2_check_metadata_overlap(BlockDriverState *bs, int ign, int64_t offset,
66
}
108
}
67
109
68
- QLIST_INSERT_HEAD(&s->inflight_aiocb_head, aiocb, aiocb_siblings);
110
if ((chk & QCOW2_OL_REFCOUNT_BLOCK) && s->refcount_table) {
69
- return false;
111
- for (i = 0; i < s->refcount_table_size; i++) {
70
+ QLIST_REMOVE(acb, aiocb_siblings);
112
+ unsigned last_entry = s->max_refcount_table_index;
71
+ qemu_co_queue_restart_all(&acb->s->overlapping_queue);
113
+ assert(last_entry < s->refcount_table_size);
72
}
114
+ assert(last_entry + 1 == s->refcount_table_size ||
73
115
+ (s->refcount_table[last_entry + 1] & REFT_OFFSET_MASK) == 0);
74
static coroutine_fn int sd_co_writev(BlockDriverState *bs, int64_t sector_num,
116
+ for (i = 0; i <= last_entry; i++) {
75
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int sd_co_writev(BlockDriverState *bs, int64_t sector_num,
117
if ((s->refcount_table[i] & REFT_OFFSET_MASK) &&
76
}
118
overlaps_with(s->refcount_table[i] & REFT_OFFSET_MASK,
77
119
s->cluster_size)) {
78
sd_aio_setup(&acb, s, qiov, sector_num, nb_sectors, AIOCB_WRITE_UDATA);
120
@@ -XXX,XX +XXX,XX @@ int qcow2_change_refcount_order(BlockDriverState *bs, int refcount_order,
79
-
121
/* Now update the rest of the in-memory information */
80
-retry:
122
old_reftable = s->refcount_table;
81
- if (check_overlapping_aiocb(s, &acb)) {
123
s->refcount_table = new_reftable;
82
- qemu_co_queue_wait(&s->overlapping_queue);
124
+ update_max_refcount_table_index(s);
83
- goto retry;
125
84
- }
126
s->refcount_bits = 1 << refcount_order;
85
-
127
s->refcount_max = UINT64_C(1) << (s->refcount_bits - 1);
86
sd_co_rw_vector(&acb);
128
diff --git a/block/qcow2.c b/block/qcow2.c
87
sd_write_done(&acb);
129
index XXXXXXX..XXXXXXX 100644
88
+ sd_aio_complete(&acb);
130
--- a/block/qcow2.c
89
131
+++ b/block/qcow2.c
90
- QLIST_REMOVE(&acb, aiocb_siblings);
132
@@ -XXX,XX +XXX,XX @@ static int make_completely_empty(BlockDriverState *bs)
91
- qemu_co_queue_restart_all(&s->overlapping_queue);
133
92
return acb.ret;
134
s->refcount_table_offset = s->cluster_size;
93
}
135
s->refcount_table_size = s->cluster_size / sizeof(uint64_t);
94
136
+ s->max_refcount_table_index = 0;
95
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int sd_co_readv(BlockDriverState *bs, int64_t sector_num,
137
96
BDRVSheepdogState *s = bs->opaque;
138
g_free(s->refcount_table);
97
139
s->refcount_table = new_reftable;
98
sd_aio_setup(&acb, s, qiov, sector_num, nb_sectors, AIOCB_READ_UDATA);
99
-
100
-retry:
101
- if (check_overlapping_aiocb(s, &acb)) {
102
- qemu_co_queue_wait(&s->overlapping_queue);
103
- goto retry;
104
- }
105
-
106
sd_co_rw_vector(&acb);
107
+ sd_aio_complete(&acb);
108
109
- QLIST_REMOVE(&acb, aiocb_siblings);
110
- qemu_co_queue_restart_all(&s->overlapping_queue);
111
return acb.ret;
112
}
113
114
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn sd_co_flush_to_disk(BlockDriverState *bs)
115
if (--acb.nr_pending) {
116
qemu_coroutine_yield();
117
}
118
+
119
+ sd_aio_complete(&acb);
120
return acb.ret;
121
}
122
123
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int sd_co_pdiscard(BlockDriverState *bs, int64_t offset,
124
}
125
sd_aio_setup(&acb, s, &discard_iov, offset >> BDRV_SECTOR_BITS,
126
count >> BDRV_SECTOR_BITS, AIOCB_DISCARD_OBJ);
127
-
128
-retry:
129
- if (check_overlapping_aiocb(s, &acb)) {
130
- qemu_co_queue_wait(&s->overlapping_queue);
131
- goto retry;
132
- }
133
-
134
sd_co_rw_vector(&acb);
135
+ sd_aio_complete(&acb);
136
137
- QLIST_REMOVE(&acb, aiocb_siblings);
138
- qemu_co_queue_restart_all(&s->overlapping_queue);
139
return acb.ret;
140
}
141
142
--
140
--
143
2.9.3
141
2.11.0
144
142
145
143
diff view generated by jsdifflib
1
From: Paolo Bonzini <pbonzini@redhat.com>
1
From: Alberto Garcia <berto@igalia.com>
2
2
3
Sheepdog's AIOCB are completely internal entities for a group of
3
Passing a request size larger than BDRV_REQUEST_MAX_BYTES to any of the
4
requests and do not need dynamic allocation.
4
I/O commands results in an error. While 'read' and 'write' handle the
5
error correctly, 'aio_read' and 'aio_write' hit an assertion:
5
6
6
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7
blk_aio_read_entry: Assertion `rwco->qiov->size == acb->bytes' failed.
7
Message-id: 20161129113245.32724-4-pbonzini@redhat.com
8
8
Signed-off-by: Jeff Cody <jcody@redhat.com>
9
The reason is that the QEMU I/O code cannot handle request sizes
10
larger than BDRV_REQUEST_MAX_BYTES, so this patch makes qemu-io check
11
that all values are within range.
12
13
Signed-off-by: Alberto Garcia <berto@igalia.com>
14
Message-id: 79f66648c685929a144396bda24d13a207131dcf.1485878688.git.berto@igalia.com
15
[mreitz: Use BDRV_REQUEST_MAX_BYTES instead of INT_MAX]
16
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
17
---
10
block/sheepdog.c | 99 ++++++++++++++++++++++----------------------------------
18
qemu-io-cmds.c | 20 +++++++++++++-------
11
1 file changed, 39 insertions(+), 60 deletions(-)
19
1 file changed, 13 insertions(+), 7 deletions(-)
12
20
13
diff --git a/block/sheepdog.c b/block/sheepdog.c
21
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
14
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
15
--- a/block/sheepdog.c
23
--- a/qemu-io-cmds.c
16
+++ b/block/sheepdog.c
24
+++ b/qemu-io-cmds.c
17
@@ -XXX,XX +XXX,XX @@ static inline size_t count_data_objs(const struct SheepdogInode *inode)
25
@@ -XXX,XX +XXX,XX @@ create_iovec(BlockBackend *blk, QEMUIOVector *qiov, char **argv, int nr_iov,
18
} while (0)
26
goto fail;
19
20
typedef struct SheepdogAIOCB SheepdogAIOCB;
21
+typedef struct BDRVSheepdogState BDRVSheepdogState;
22
23
typedef struct AIOReq {
24
SheepdogAIOCB *aiocb;
25
@@ -XXX,XX +XXX,XX @@ enum AIOCBState {
26
|| y->max_affect_data_idx < x->min_affect_data_idx))
27
28
struct SheepdogAIOCB {
29
- BlockAIOCB common;
30
+ BDRVSheepdogState *s;
31
32
QEMUIOVector *qiov;
33
34
@@ -XXX,XX +XXX,XX @@ struct SheepdogAIOCB {
35
QLIST_ENTRY(SheepdogAIOCB) aiocb_siblings;
36
};
37
38
-typedef struct BDRVSheepdogState {
39
+struct BDRVSheepdogState {
40
BlockDriverState *bs;
41
AioContext *aio_context;
42
43
@@ -XXX,XX +XXX,XX @@ typedef struct BDRVSheepdogState {
44
45
CoQueue overlapping_queue;
46
QLIST_HEAD(inflight_aiocb_head, SheepdogAIOCB) inflight_aiocb_head;
47
-} BDRVSheepdogState;
48
+};
49
50
typedef struct BDRVSheepdogReopenState {
51
int fd;
52
@@ -XXX,XX +XXX,XX @@ static inline void free_aio_req(BDRVSheepdogState *s, AIOReq *aio_req)
53
acb->nr_pending--;
54
}
55
56
-static const AIOCBInfo sd_aiocb_info = {
57
- .aiocb_size = sizeof(SheepdogAIOCB),
58
-};
59
-
60
-static SheepdogAIOCB *sd_aio_setup(BlockDriverState *bs, QEMUIOVector *qiov,
61
- int64_t sector_num, int nb_sectors)
62
+static void sd_aio_setup(SheepdogAIOCB *acb, BDRVSheepdogState *s,
63
+ QEMUIOVector *qiov, int64_t sector_num, int nb_sectors,
64
+ int type)
65
{
66
- SheepdogAIOCB *acb;
67
uint32_t object_size;
68
- BDRVSheepdogState *s = bs->opaque;
69
70
object_size = (UINT32_C(1) << s->inode.block_size_shift);
71
72
- acb = qemu_aio_get(&sd_aiocb_info, bs, NULL, NULL);
73
+ acb->s = s;
74
75
acb->qiov = qiov;
76
77
@@ -XXX,XX +XXX,XX @@ static SheepdogAIOCB *sd_aio_setup(BlockDriverState *bs, QEMUIOVector *qiov,
78
79
acb->min_dirty_data_idx = UINT32_MAX;
80
acb->max_dirty_data_idx = 0;
81
-
82
- return acb;
83
+ acb->aiocb_type = type;
84
}
85
86
/* Return -EIO in case of error, file descriptor on success */
87
@@ -XXX,XX +XXX,XX @@ static int sd_truncate(BlockDriverState *bs, int64_t offset)
88
*/
89
static void coroutine_fn sd_write_done(SheepdogAIOCB *acb)
90
{
91
- BDRVSheepdogState *s = acb->common.bs->opaque;
92
+ BDRVSheepdogState *s = acb->s;
93
struct iovec iov;
94
AIOReq *aio_req;
95
uint32_t offset, data_len, mn, mx;
96
@@ -XXX,XX +XXX,XX @@ out:
97
* Returns 1 when we need to wait a response, 0 when there is no sent
98
* request and -errno in error cases.
99
*/
100
-static void coroutine_fn sd_co_rw_vector(void *p)
101
+static void coroutine_fn sd_co_rw_vector(SheepdogAIOCB *acb)
102
{
103
- SheepdogAIOCB *acb = p;
104
int ret = 0;
105
unsigned long len, done = 0, total = acb->nb_sectors * BDRV_SECTOR_SIZE;
106
unsigned long idx;
107
uint32_t object_size;
108
uint64_t oid;
109
uint64_t offset;
110
- BDRVSheepdogState *s = acb->common.bs->opaque;
111
+ BDRVSheepdogState *s = acb->s;
112
SheepdogInode *inode = &s->inode;
113
AIOReq *aio_req;
114
115
@@ -XXX,XX +XXX,XX @@ static bool check_overlapping_aiocb(BDRVSheepdogState *s, SheepdogAIOCB *aiocb)
116
static coroutine_fn int sd_co_writev(BlockDriverState *bs, int64_t sector_num,
117
int nb_sectors, QEMUIOVector *qiov)
118
{
119
- SheepdogAIOCB *acb;
120
+ SheepdogAIOCB acb;
121
int ret;
122
int64_t offset = (sector_num + nb_sectors) * BDRV_SECTOR_SIZE;
123
BDRVSheepdogState *s = bs->opaque;
124
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int sd_co_writev(BlockDriverState *bs, int64_t sector_num,
125
}
27
}
126
}
28
127
29
- if (len > SIZE_MAX) {
128
- acb = sd_aio_setup(bs, qiov, sector_num, nb_sectors);
30
- printf("Argument '%s' exceeds maximum size %llu\n", arg,
129
- acb->aiocb_type = AIOCB_WRITE_UDATA;
31
- (unsigned long long)SIZE_MAX);
130
+ sd_aio_setup(&acb, s, qiov, sector_num, nb_sectors, AIOCB_WRITE_UDATA);
32
+ if (len > BDRV_REQUEST_MAX_BYTES) {
131
33
+ printf("Argument '%s' exceeds maximum size %" PRIu64 "\n", arg,
132
retry:
34
+ (uint64_t)BDRV_REQUEST_MAX_BYTES);
133
- if (check_overlapping_aiocb(s, acb)) {
35
+ goto fail;
134
+ if (check_overlapping_aiocb(s, &acb)) {
36
+ }
135
qemu_co_queue_wait(&s->overlapping_queue);
37
+
136
goto retry;
38
+ if (count > BDRV_REQUEST_MAX_BYTES - len) {
137
}
39
+ printf("The total number of bytes exceed the maximum size %" PRIu64
138
40
+ "\n", (uint64_t)BDRV_REQUEST_MAX_BYTES);
139
- sd_co_rw_vector(acb);
41
goto fail;
140
- sd_write_done(acb);
42
}
141
+ sd_co_rw_vector(&acb);
43
142
+ sd_write_done(&acb);
44
@@ -XXX,XX +XXX,XX @@ static int read_f(BlockBackend *blk, int argc, char **argv)
143
45
if (count < 0) {
144
- QLIST_REMOVE(acb, aiocb_siblings);
46
print_cvtnum_err(count, argv[optind]);
145
+ QLIST_REMOVE(&acb, aiocb_siblings);
47
return 0;
146
qemu_co_queue_restart_all(&s->overlapping_queue);
48
- } else if (count > SIZE_MAX) {
147
- ret = acb->ret;
49
+ } else if (count > BDRV_REQUEST_MAX_BYTES) {
148
- qemu_aio_unref(acb);
50
printf("length cannot exceed %" PRIu64 ", given %s\n",
149
- return ret;
51
- (uint64_t) SIZE_MAX, argv[optind]);
150
+ return acb.ret;
52
+ (uint64_t)BDRV_REQUEST_MAX_BYTES, argv[optind]);
151
}
152
153
static coroutine_fn int sd_co_readv(BlockDriverState *bs, int64_t sector_num,
154
int nb_sectors, QEMUIOVector *qiov)
155
{
156
- SheepdogAIOCB *acb;
157
- int ret;
158
+ SheepdogAIOCB acb;
159
BDRVSheepdogState *s = bs->opaque;
160
161
- acb = sd_aio_setup(bs, qiov, sector_num, nb_sectors);
162
- acb->aiocb_type = AIOCB_READ_UDATA;
163
+ sd_aio_setup(&acb, s, qiov, sector_num, nb_sectors, AIOCB_READ_UDATA);
164
165
retry:
166
- if (check_overlapping_aiocb(s, acb)) {
167
+ if (check_overlapping_aiocb(s, &acb)) {
168
qemu_co_queue_wait(&s->overlapping_queue);
169
goto retry;
170
}
171
172
- sd_co_rw_vector(acb);
173
+ sd_co_rw_vector(&acb);
174
175
- QLIST_REMOVE(acb, aiocb_siblings);
176
+ QLIST_REMOVE(&acb, aiocb_siblings);
177
qemu_co_queue_restart_all(&s->overlapping_queue);
178
- ret = acb->ret;
179
- qemu_aio_unref(acb);
180
- return ret;
181
+ return acb.ret;
182
}
183
184
static int coroutine_fn sd_co_flush_to_disk(BlockDriverState *bs)
185
{
186
BDRVSheepdogState *s = bs->opaque;
187
- SheepdogAIOCB *acb;
188
- int ret;
189
+ SheepdogAIOCB acb;
190
AIOReq *aio_req;
191
192
if (s->cache_flags != SD_FLAG_CMD_CACHE) {
193
return 0;
53
return 0;
194
}
54
}
195
55
196
- acb = sd_aio_setup(bs, NULL, 0, 0);
56
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
197
- acb->aiocb_type = AIOCB_FLUSH_CACHE;
57
if (count < 0) {
198
+ sd_aio_setup(&acb, s, NULL, 0, 0, AIOCB_FLUSH_CACHE);
58
print_cvtnum_err(count, argv[optind]);
199
59
return 0;
200
- acb->nr_pending++;
60
- } else if (count > SIZE_MAX) {
201
- aio_req = alloc_aio_req(s, acb, vid_to_vdi_oid(s->inode.vdi_id),
61
+ } else if (count > BDRV_REQUEST_MAX_BYTES) {
202
+ acb.nr_pending++;
62
printf("length cannot exceed %" PRIu64 ", given %s\n",
203
+ aio_req = alloc_aio_req(s, &acb, vid_to_vdi_oid(s->inode.vdi_id),
63
- (uint64_t) SIZE_MAX, argv[optind]);
204
0, 0, 0, false, 0, 0);
64
+ (uint64_t)BDRV_REQUEST_MAX_BYTES, argv[optind]);
205
QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings);
65
return 0;
206
- add_aio_request(s, aio_req, NULL, 0, acb->aiocb_type);
207
+ add_aio_request(s, aio_req, NULL, 0, acb.aiocb_type);
208
209
- if (--acb->nr_pending) {
210
+ if (--acb.nr_pending) {
211
qemu_coroutine_yield();
212
}
66
}
213
- ret = acb->ret;
67
214
- qemu_aio_unref(acb);
215
- return ret;
216
+ return acb.ret;
217
}
218
219
static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
220
@@ -XXX,XX +XXX,XX @@ static int sd_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
221
static coroutine_fn int sd_co_pdiscard(BlockDriverState *bs, int64_t offset,
222
int count)
223
{
224
- SheepdogAIOCB *acb;
225
+ SheepdogAIOCB acb;
226
BDRVSheepdogState *s = bs->opaque;
227
- int ret;
228
QEMUIOVector discard_iov;
229
struct iovec iov;
230
uint32_t zero = 0;
231
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int sd_co_pdiscard(BlockDriverState *bs, int64_t offset,
232
if (!QEMU_IS_ALIGNED(offset | count, BDRV_SECTOR_SIZE)) {
233
return -ENOTSUP;
234
}
235
- acb = sd_aio_setup(bs, &discard_iov, offset >> BDRV_SECTOR_BITS,
236
- count >> BDRV_SECTOR_BITS);
237
- acb->aiocb_type = AIOCB_DISCARD_OBJ;
238
+ sd_aio_setup(&acb, s, &discard_iov, offset >> BDRV_SECTOR_BITS,
239
+ count >> BDRV_SECTOR_BITS, AIOCB_DISCARD_OBJ);
240
241
retry:
242
- if (check_overlapping_aiocb(s, acb)) {
243
+ if (check_overlapping_aiocb(s, &acb)) {
244
qemu_co_queue_wait(&s->overlapping_queue);
245
goto retry;
246
}
247
248
- sd_co_rw_vector(acb);
249
+ sd_co_rw_vector(&acb);
250
251
- QLIST_REMOVE(acb, aiocb_siblings);
252
+ QLIST_REMOVE(&acb, aiocb_siblings);
253
qemu_co_queue_restart_all(&s->overlapping_queue);
254
- ret = acb->ret;
255
- qemu_aio_unref(acb);
256
- return ret;
257
+ return acb.ret;
258
}
259
260
static coroutine_fn int64_t
261
--
68
--
262
2.9.3
69
2.11.0
263
70
264
71
diff view generated by jsdifflib
New patch
1
From: Peter Maydell <peter.maydell@linaro.org>
1
2
3
Some of the argument parsing in qemu-img uses strtoul() to parse
4
integer arguments. This is tricky to get correct and in fact the
5
code does not get it right, because it assigns the result of
6
strtoul() to an 'int' variable and then tries to check for > INT_MAX.
7
Coverity correctly complains that the comparison is always false.
8
9
Rewrite to use qemu_strtoul(), which has a saner convention for
10
reporting conversion failures.
11
12
(Fixes CID 1356421, CID 1356422, CID 1356423.)
13
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Message-id: 1486744104-15590-2-git-send-email-peter.maydell@linaro.org
16
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
17
Signed-off-by: Max Reitz <mreitz@redhat.com>
18
---
19
qemu-img.c | 32 ++++++++++++++++----------------
20
1 file changed, 16 insertions(+), 16 deletions(-)
21
22
diff --git a/qemu-img.c b/qemu-img.c
23
index XXXXXXX..XXXXXXX 100644
24
--- a/qemu-img.c
25
+++ b/qemu-img.c
26
@@ -XXX,XX +XXX,XX @@ static int img_bench(int argc, char **argv)
27
break;
28
case 'c':
29
{
30
- char *end;
31
- errno = 0;
32
- count = strtoul(optarg, &end, 0);
33
- if (errno || *end || count > INT_MAX) {
34
+ unsigned long res;
35
+
36
+ if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > INT_MAX) {
37
error_report("Invalid request count specified");
38
return 1;
39
}
40
+ count = res;
41
break;
42
}
43
case 'd':
44
{
45
- char *end;
46
- errno = 0;
47
- depth = strtoul(optarg, &end, 0);
48
- if (errno || *end || depth > INT_MAX) {
49
+ unsigned long res;
50
+
51
+ if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > INT_MAX) {
52
error_report("Invalid queue depth specified");
53
return 1;
54
}
55
+ depth = res;
56
break;
57
}
58
case 'f':
59
@@ -XXX,XX +XXX,XX @@ static int img_bench(int argc, char **argv)
60
break;
61
case OPTION_PATTERN:
62
{
63
- char *end;
64
- errno = 0;
65
- pattern = strtoul(optarg, &end, 0);
66
- if (errno || *end || pattern > 0xff) {
67
+ unsigned long res;
68
+
69
+ if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > 0xff) {
70
error_report("Invalid pattern byte specified");
71
return 1;
72
}
73
+ pattern = res;
74
break;
75
}
76
case OPTION_FLUSH_INTERVAL:
77
{
78
- char *end;
79
- errno = 0;
80
- flush_interval = strtoul(optarg, &end, 0);
81
- if (errno || *end || flush_interval > INT_MAX) {
82
+ unsigned long res;
83
+
84
+ if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > INT_MAX) {
85
error_report("Invalid flush interval specified");
86
return 1;
87
}
88
+ flush_interval = res;
89
break;
90
}
91
case OPTION_NO_DRAIN:
92
--
93
2.11.0
94
95
diff view generated by jsdifflib
New patch
1
From: Peter Maydell <peter.maydell@linaro.org>
1
2
3
Coverity points out that we assign the return value from
4
bdrv_snapshot_load_tmp() to 'ret' in img_convert(), but then
5
never use that variable. (We check for failure by looking
6
at local_err instead.) Drop the unused assignment, bringing
7
the call into line with the following call to
8
bdrv_snapshot_laod_tmp_by_id_or_name().
9
10
(Fixes CID 1247240.)
11
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Message-id: 1486744104-15590-3-git-send-email-peter.maydell@linaro.org
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Signed-off-by: Max Reitz <mreitz@redhat.com>
16
---
17
qemu-img.c | 8 ++++----
18
1 file changed, 4 insertions(+), 4 deletions(-)
19
20
diff --git a/qemu-img.c b/qemu-img.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/qemu-img.c
23
+++ b/qemu-img.c
24
@@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv)
25
}
26
27
if (sn_opts) {
28
- ret = bdrv_snapshot_load_tmp(bs[0],
29
- qemu_opt_get(sn_opts, SNAPSHOT_OPT_ID),
30
- qemu_opt_get(sn_opts, SNAPSHOT_OPT_NAME),
31
- &local_err);
32
+ bdrv_snapshot_load_tmp(bs[0],
33
+ qemu_opt_get(sn_opts, SNAPSHOT_OPT_ID),
34
+ qemu_opt_get(sn_opts, SNAPSHOT_OPT_NAME),
35
+ &local_err);
36
} else if (snapshot_name != NULL) {
37
if (bs_n > 1) {
38
error_report("No support for concatenating multiple snapshot");
39
--
40
2.11.0
41
42
diff view generated by jsdifflib