1
The following changes since commit 98b2faeaee96ab084d0b1669918688d8895c155f:
1
The following changes since commit 2b483739791b33c46e6084b51edcf62107058ae1:
2
2
3
Merge remote-tracking branch 'remotes/jnsnow/tags/ide-pull-request' into staging (2017-02-10 18:07:02 +0000)
3
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20170904-2' into staging (2017-09-04 17:21:24 +0100)
4
4
5
are available in the git repository at:
5
are available in the git repository at:
6
6
7
git://github.com/XanClic/qemu.git tags/pull-block-2017-02-12
7
git://github.com/stefanha/qemu.git tags/block-pull-request
8
8
9
for you to fetch changes up to 10d6eda1926804a09aa0710ca62933087813de0b:
9
for you to fetch changes up to b461151ff31c7925f271c297e8abed20231ac7d3:
10
10
11
qemu-img: Avoid setting ret to unused value in img_convert() (2017-02-12 00:56:32 +0100)
11
block: document semantics of bdrv_co_preadv|pwritev (2017-09-05 11:07:02 +0100)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Block patches
15
14
16
----------------------------------------------------------------
15
----------------------------------------------------------------
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
20
16
21
Daniel P. Berrange (1):
17
Daniel P. Berrange (1):
22
iotests: record separate timings per format,protocol pair
18
block: document semantics of bdrv_co_preadv|pwritev
23
19
24
Dou Liyang (2):
20
Stefan Hajnoczi (3):
25
block/qapi: reduce the coupling between the bdrv_query_stats and bdrv_query_bds_stats
21
qemu.py: make VM() a context manager
26
block/qapi: reduce the execution time of qmp_query_blockstats
22
iotests.py: add FilePath context manager
23
qemu-iotests: use context managers for resource cleanup in 194
27
24
28
Fam Zheng (2):
25
include/block/block_int.h | 31 +++++++++++
29
qapi: Tweak error message of bdrv_query_image_info
26
scripts/qemu.py | 16 +++++-
30
iotests: Fix reference output for 059
27
tests/qemu-iotests/194 | 117 +++++++++++++++++++++---------------------
28
tests/qemu-iotests/iotests.py | 26 ++++++++++
29
4 files changed, 130 insertions(+), 60 deletions(-)
31
30
32
Jeff Cody (3):
31
--
33
block: check full backing filename when searching protocol filenames
32
2.13.5
34
qemu-iotests: Don't create fifos / pidfiles with protocol paths
35
qemu-iotest: test to lookup protocol-based image with relative backing
36
33
37
Max Reitz (1):
38
qemu-img: Improve commit invalid base message
39
34
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
Deleted patch
1
From: QingFeng Hao <haoqf@linux.vnet.ibm.com>
2
1
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
Deleted 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.
7
1
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
1
From: Peter Maydell <peter.maydell@linaro.org>
1
There are a number of ways to ensure that the QEMU process is shut down
2
when the test ends, including atexit.register(), try: finally:, or
3
unittest.teardown() methods. All of these require extra code and the
4
programmer must remember to add vm.shutdown().
2
5
3
Coverity points out that we assign the return value from
6
A nice solution is context managers:
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
7
10
(Fixes CID 1247240.)
8
with VM(binary) as vm:
9
...
10
# vm is guaranteed to be shut down here
11
11
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Cc: Eduardo Habkost <ehabkost@redhat.com>
13
Message-id: 1486744104-15590-3-git-send-email-peter.maydell@linaro.org
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
15
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
Message-id: 20170824072202.26818-2-stefanha@redhat.com
16
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
16
---
17
---
17
qemu-img.c | 8 ++++----
18
scripts/qemu.py | 16 +++++++++++++++-
18
1 file changed, 4 insertions(+), 4 deletions(-)
19
1 file changed, 15 insertions(+), 1 deletion(-)
19
20
20
diff --git a/qemu-img.c b/qemu-img.c
21
diff --git a/scripts/qemu.py b/scripts/qemu.py
21
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
22
--- a/qemu-img.c
23
--- a/scripts/qemu.py
23
+++ b/qemu-img.c
24
+++ b/scripts/qemu.py
24
@@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv)
25
@@ -XXX,XX +XXX,XX @@ import qmp.qmp
25
}
26
26
27
27
if (sn_opts) {
28
class QEMUMachine(object):
28
- ret = bdrv_snapshot_load_tmp(bs[0],
29
- '''A QEMU VM'''
29
- qemu_opt_get(sn_opts, SNAPSHOT_OPT_ID),
30
+ '''A QEMU VM
30
- qemu_opt_get(sn_opts, SNAPSHOT_OPT_NAME),
31
+
31
- &local_err);
32
+ Use this object as a context manager to ensure the QEMU process terminates::
32
+ bdrv_snapshot_load_tmp(bs[0],
33
+
33
+ qemu_opt_get(sn_opts, SNAPSHOT_OPT_ID),
34
+ with VM(binary) as vm:
34
+ qemu_opt_get(sn_opts, SNAPSHOT_OPT_NAME),
35
+ ...
35
+ &local_err);
36
+ # vm is guaranteed to be shut down here
36
} else if (snapshot_name != NULL) {
37
+ '''
37
if (bs_n > 1) {
38
38
error_report("No support for concatenating multiple snapshot");
39
def __init__(self, binary, args=[], wrapper=[], name=None, test_dir="/var/tmp",
40
monitor_address=None, socket_scm_helper=None, debug=False):
41
@@ -XXX,XX +XXX,XX @@ class QEMUMachine(object):
42
self._socket_scm_helper = socket_scm_helper
43
self._debug = debug
44
45
+ def __enter__(self):
46
+ return self
47
+
48
+ def __exit__(self, exc_type, exc_val, exc_tb):
49
+ self.shutdown()
50
+ return False
51
+
52
# This can be used to add an unused monitor instance.
53
def add_monitor_telnet(self, ip, port):
54
args = 'tcp:%s:%d,server,nowait,telnet' % (ip, port)
39
--
55
--
40
2.11.0
56
2.13.5
41
57
42
58
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
The scratch/ (TEST_DIR) directory is not automatically cleaned up after
2
test execution. It is the responsibility of tests to remove any files
3
they create.
2
4
3
Passing a request size larger than BDRV_REQUEST_MAX_BYTES to any of the
5
A nice way of doing this is to declare files at the beginning of the
4
I/O commands results in an error. While 'read' and 'write' handle the
6
test and automatically remove them with a context manager:
5
error correctly, 'aio_read' and 'aio_write' hit an assertion:
6
7
7
blk_aio_read_entry: Assertion `rwco->qiov->size == acb->bytes' failed.
8
with iotests.FilePath('test.img') as img_path:
9
qemu_img(...)
10
qemu_io(...)
11
# img_path is guaranteed to be deleted here
8
12
9
The reason is that the QEMU I/O code cannot handle request sizes
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10
larger than BDRV_REQUEST_MAX_BYTES, so this patch makes qemu-io check
14
Message-id: 20170824072202.26818-3-stefanha@redhat.com
11
that all values are within range.
15
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
16
---
17
tests/qemu-iotests/iotests.py | 26 ++++++++++++++++++++++++++
18
1 file changed, 26 insertions(+)
12
19
13
Signed-off-by: Alberto Garcia <berto@igalia.com>
20
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
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>
17
---
18
qemu-io-cmds.c | 20 +++++++++++++-------
19
1 file changed, 13 insertions(+), 7 deletions(-)
20
21
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
22
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
23
--- a/qemu-io-cmds.c
22
--- a/tests/qemu-iotests/iotests.py
24
+++ b/qemu-io-cmds.c
23
+++ b/tests/qemu-iotests/iotests.py
25
@@ -XXX,XX +XXX,XX @@ create_iovec(BlockBackend *blk, QEMUIOVector *qiov, char **argv, int nr_iov,
24
@@ -XXX,XX +XXX,XX @@ class Timeout:
26
goto fail;
25
def timeout(self, signum, frame):
27
}
26
raise Exception(self.errmsg)
28
27
29
- if (len > SIZE_MAX) {
30
- printf("Argument '%s' exceeds maximum size %llu\n", arg,
31
- (unsigned long long)SIZE_MAX);
32
+ if (len > BDRV_REQUEST_MAX_BYTES) {
33
+ printf("Argument '%s' exceeds maximum size %" PRIu64 "\n", arg,
34
+ (uint64_t)BDRV_REQUEST_MAX_BYTES);
35
+ goto fail;
36
+ }
37
+
28
+
38
+ if (count > BDRV_REQUEST_MAX_BYTES - len) {
29
+class FilePath(object):
39
+ printf("The total number of bytes exceed the maximum size %" PRIu64
30
+ '''An auto-generated filename that cleans itself up.
40
+ "\n", (uint64_t)BDRV_REQUEST_MAX_BYTES);
31
+
41
goto fail;
32
+ Use this context manager to generate filenames and ensure that the file
42
}
33
+ gets deleted::
43
34
+
44
@@ -XXX,XX +XXX,XX @@ static int read_f(BlockBackend *blk, int argc, char **argv)
35
+ with TestFilePath('test.img') as img_path:
45
if (count < 0) {
36
+ qemu_img('create', img_path, '1G')
46
print_cvtnum_err(count, argv[optind]);
37
+ # migration_sock_path is automatically deleted
47
return 0;
38
+ '''
48
- } else if (count > SIZE_MAX) {
39
+ def __init__(self, name):
49
+ } else if (count > BDRV_REQUEST_MAX_BYTES) {
40
+ filename = '{0}-{1}'.format(os.getpid(), name)
50
printf("length cannot exceed %" PRIu64 ", given %s\n",
41
+ self.path = os.path.join(test_dir, filename)
51
- (uint64_t) SIZE_MAX, argv[optind]);
42
+
52
+ (uint64_t)BDRV_REQUEST_MAX_BYTES, argv[optind]);
43
+ def __enter__(self):
53
return 0;
44
+ return self.path
54
}
45
+
55
46
+ def __exit__(self, exc_type, exc_val, exc_tb):
56
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
47
+ try:
57
if (count < 0) {
48
+ os.remove(self.path)
58
print_cvtnum_err(count, argv[optind]);
49
+ except OSError:
59
return 0;
50
+ pass
60
- } else if (count > SIZE_MAX) {
51
+ return False
61
+ } else if (count > BDRV_REQUEST_MAX_BYTES) {
52
+
62
printf("length cannot exceed %" PRIu64 ", given %s\n",
53
+
63
- (uint64_t) SIZE_MAX, argv[optind]);
54
class VM(qtest.QEMUQtestMachine):
64
+ (uint64_t)BDRV_REQUEST_MAX_BYTES, argv[optind]);
55
'''A QEMU VM'''
65
return 0;
66
}
67
56
68
--
57
--
69
2.11.0
58
2.13.5
70
59
71
60
diff view generated by jsdifflib
1
From: Peter Maydell <peter.maydell@linaro.org>
1
Switch from atexit.register() to a more elegant idiom of declaring
2
resources in a with statement:
2
3
3
Some of the argument parsing in qemu-img uses strtoul() to parse
4
with FilePath('monitor.sock') as monitor_path,
4
integer arguments. This is tricky to get correct and in fact the
5
VM() as vm:
5
code does not get it right, because it assigns the result of
6
...
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
7
9
Rewrite to use qemu_strtoul(), which has a saner convention for
8
The files and VMs will be automatically cleaned up whether the test
10
reporting conversion failures.
9
passes or fails.
11
10
12
(Fixes CID 1356421, CID 1356422, CID 1356423.)
11
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12
Message-id: 20170824072202.26818-4-stefanha@redhat.com
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14
---
15
tests/qemu-iotests/194 | 117 ++++++++++++++++++++++++-------------------------
16
1 file changed, 58 insertions(+), 59 deletions(-)
13
17
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
diff --git a/tests/qemu-iotests/194 b/tests/qemu-iotests/194
15
Message-id: 1486744104-15590-2-git-send-email-peter.maydell@linaro.org
19
index XXXXXXX..XXXXXXX 100755
16
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
20
--- a/tests/qemu-iotests/194
17
Signed-off-by: Max Reitz <mreitz@redhat.com>
21
+++ b/tests/qemu-iotests/194
18
---
22
@@ -XXX,XX +XXX,XX @@
19
qemu-img.c | 32 ++++++++++++++++----------------
23
#
20
1 file changed, 16 insertions(+), 16 deletions(-)
24
# Non-shared storage migration test using NBD server and drive-mirror
21
25
22
diff --git a/qemu-img.c b/qemu-img.c
26
-import os
23
index XXXXXXX..XXXXXXX 100644
27
-import atexit
24
--- a/qemu-img.c
28
import iotests
25
+++ b/qemu-img.c
29
26
@@ -XXX,XX +XXX,XX @@ static int img_bench(int argc, char **argv)
30
iotests.verify_platform(['linux'])
27
break;
31
28
case 'c':
32
-img_size = '1G'
29
{
33
-source_img_path = os.path.join(iotests.test_dir, 'source.img')
30
- char *end;
34
-dest_img_path = os.path.join(iotests.test_dir, 'dest.img')
31
- errno = 0;
35
-iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, source_img_path, img_size)
32
- count = strtoul(optarg, &end, 0);
36
-iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, dest_img_path, img_size)
33
- if (errno || *end || count > INT_MAX) {
37
-
34
+ unsigned long res;
38
-iotests.log('Launching VMs...')
39
-migration_sock_path = os.path.join(iotests.test_dir, 'migration.sock')
40
-nbd_sock_path = os.path.join(iotests.test_dir, 'nbd.sock')
41
-source_vm = iotests.VM('source').add_drive(source_img_path)
42
-dest_vm = (iotests.VM('dest').add_drive(dest_img_path)
43
- .add_incoming('unix:{0}'.format(migration_sock_path)))
44
-source_vm.launch()
45
-atexit.register(source_vm.shutdown)
46
-dest_vm.launch()
47
-atexit.register(dest_vm.shutdown)
48
-
49
-iotests.log('Launching NBD server on destination...')
50
-iotests.log(dest_vm.qmp('nbd-server-start', addr={'type': 'unix', 'data': {'path': nbd_sock_path}}))
51
-iotests.log(dest_vm.qmp('nbd-server-add', device='drive0', writable=True))
52
-
53
-iotests.log('Starting `drive-mirror` on source...')
54
-iotests.log(source_vm.qmp(
55
- 'drive-mirror',
56
- device='drive0',
57
- target='nbd+unix:///drive0?socket={0}'.format(nbd_sock_path),
58
- sync='full',
59
- format='raw', # always raw, the server handles the format
60
- mode='existing',
61
- job_id='mirror-job0'))
62
-
63
-iotests.log('Waiting for `drive-mirror` to complete...')
64
-iotests.log(source_vm.event_wait('BLOCK_JOB_READY'),
65
- filters=[iotests.filter_qmp_event])
66
-
67
-iotests.log('Starting migration...')
68
-source_vm.qmp('migrate-set-capabilities',
69
- capabilities=[{'capability': 'events', 'state': True}])
70
-dest_vm.qmp('migrate-set-capabilities',
71
- capabilities=[{'capability': 'events', 'state': True}])
72
-iotests.log(source_vm.qmp('migrate', uri='unix:{0}'.format(migration_sock_path)))
73
-
74
-while True:
75
- event1 = source_vm.event_wait('MIGRATION')
76
- iotests.log(event1, filters=[iotests.filter_qmp_event])
77
- if event1['data']['status'] in ('completed', 'failed'):
78
- iotests.log('Gracefully ending the `drive-mirror` job on source...')
79
- iotests.log(source_vm.qmp('block-job-cancel', device='mirror-job0'))
80
- break
81
-
82
-while True:
83
- event2 = source_vm.event_wait('BLOCK_JOB_COMPLETED')
84
- iotests.log(event2, filters=[iotests.filter_qmp_event])
85
- if event2['event'] == 'BLOCK_JOB_COMPLETED':
86
- iotests.log('Stopping the NBD server on destination...')
87
- iotests.log(dest_vm.qmp('nbd-server-stop'))
88
- break
89
+with iotests.FilePath('source.img') as source_img_path, \
90
+ iotests.FilePath('dest.img') as dest_img_path, \
91
+ iotests.FilePath('migration.sock') as migration_sock_path, \
92
+ iotests.FilePath('nbd.sock') as nbd_sock_path, \
93
+ iotests.VM('source') as source_vm, \
94
+ iotests.VM('dest') as dest_vm:
35
+
95
+
36
+ if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > INT_MAX) {
96
+ img_size = '1G'
37
error_report("Invalid request count specified");
97
+ iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, source_img_path, img_size)
38
return 1;
98
+ iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, dest_img_path, img_size)
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
+
99
+
51
+ if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > INT_MAX) {
100
+ iotests.log('Launching VMs...')
52
error_report("Invalid queue depth specified");
101
+ (source_vm.add_drive(source_img_path)
53
return 1;
102
+ .launch())
54
}
103
+ (dest_vm.add_drive(dest_img_path)
55
+ depth = res;
104
+ .add_incoming('unix:{0}'.format(migration_sock_path))
56
break;
105
+ .launch())
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
+
106
+
69
+ if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > 0xff) {
107
+ iotests.log('Launching NBD server on destination...')
70
error_report("Invalid pattern byte specified");
108
+ iotests.log(dest_vm.qmp('nbd-server-start', addr={'type': 'unix', 'data': {'path': nbd_sock_path}}))
71
return 1;
109
+ iotests.log(dest_vm.qmp('nbd-server-add', device='drive0', writable=True))
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
+
110
+
84
+ if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > INT_MAX) {
111
+ iotests.log('Starting `drive-mirror` on source...')
85
error_report("Invalid flush interval specified");
112
+ iotests.log(source_vm.qmp(
86
return 1;
113
+ 'drive-mirror',
87
}
114
+ device='drive0',
88
+ flush_interval = res;
115
+ target='nbd+unix:///drive0?socket={0}'.format(nbd_sock_path),
89
break;
116
+ sync='full',
90
}
117
+ format='raw', # always raw, the server handles the format
91
case OPTION_NO_DRAIN:
118
+ mode='existing',
119
+ job_id='mirror-job0'))
120
+
121
+ iotests.log('Waiting for `drive-mirror` to complete...')
122
+ iotests.log(source_vm.event_wait('BLOCK_JOB_READY'),
123
+ filters=[iotests.filter_qmp_event])
124
+
125
+ iotests.log('Starting migration...')
126
+ source_vm.qmp('migrate-set-capabilities',
127
+ capabilities=[{'capability': 'events', 'state': True}])
128
+ dest_vm.qmp('migrate-set-capabilities',
129
+ capabilities=[{'capability': 'events', 'state': True}])
130
+ iotests.log(source_vm.qmp('migrate', uri='unix:{0}'.format(migration_sock_path)))
131
+
132
+ while True:
133
+ event1 = source_vm.event_wait('MIGRATION')
134
+ iotests.log(event1, filters=[iotests.filter_qmp_event])
135
+ if event1['data']['status'] in ('completed', 'failed'):
136
+ iotests.log('Gracefully ending the `drive-mirror` job on source...')
137
+ iotests.log(source_vm.qmp('block-job-cancel', device='mirror-job0'))
138
+ break
139
+
140
+ while True:
141
+ event2 = source_vm.event_wait('BLOCK_JOB_COMPLETED')
142
+ iotests.log(event2, filters=[iotests.filter_qmp_event])
143
+ if event2['event'] == 'BLOCK_JOB_COMPLETED':
144
+ iotests.log('Stopping the NBD server on destination...')
145
+ iotests.log(dest_vm.qmp('nbd-server-stop'))
146
+ break
92
--
147
--
93
2.11.0
148
2.13.5
94
149
95
150
diff view generated by jsdifflib
1
From: Fam Zheng <famz@redhat.com>
1
From: "Daniel P. Berrange" <berrange@redhat.com>
2
2
3
@bs doesn't always have a device name, such as when it comes from
3
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
4
"qemu-img info". Report file name instead.
4
Reviewed-by: Eric Blake <eblake@redhat.com>
5
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
6
Message-id: 20170831105456.9558-1-berrange@redhat.com
7
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8
---
9
include/block/block_int.h | 31 +++++++++++++++++++++++++++++++
10
1 file changed, 31 insertions(+)
5
11
6
Signed-off-by: Fam Zheng <famz@redhat.com>
12
diff --git a/include/block/block_int.h b/include/block/block_int.h
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
13
index XXXXXXX..XXXXXXX 100644
16
--- a/block/qapi.c
14
--- a/include/block/block_int.h
17
+++ b/block/qapi.c
15
+++ b/include/block/block_int.h
18
@@ -XXX,XX +XXX,XX @@ void bdrv_query_image_info(BlockDriverState *bs,
16
@@ -XXX,XX +XXX,XX @@ struct BlockDriver {
19
17
20
size = bdrv_getlength(bs);
18
int coroutine_fn (*bdrv_co_readv)(BlockDriverState *bs,
21
if (size < 0) {
19
int64_t sector_num, int nb_sectors, QEMUIOVector *qiov);
22
- error_setg_errno(errp, -size, "Can't get size of device '%s'",
20
+
23
- bdrv_get_device_name(bs));
21
+ /**
24
+ error_setg_errno(errp, -size, "Can't get image size '%s'",
22
+ * @offset: position in bytes to read at
25
+ bs->exact_filename);
23
+ * @bytes: number of bytes to read
26
goto out;
24
+ * @qiov: the buffers to fill with read data
27
}
25
+ * @flags: currently unused, always 0
26
+ *
27
+ * @offset and @bytes will be a multiple of 'request_alignment',
28
+ * but the length of individual @qiov elements does not have to
29
+ * be a multiple.
30
+ *
31
+ * @bytes will always equal the total size of @qiov, and will be
32
+ * no larger than 'max_transfer'.
33
+ *
34
+ * The buffer in @qiov may point directly to guest memory.
35
+ */
36
int coroutine_fn (*bdrv_co_preadv)(BlockDriverState *bs,
37
uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags);
38
int coroutine_fn (*bdrv_co_writev)(BlockDriverState *bs,
39
int64_t sector_num, int nb_sectors, QEMUIOVector *qiov);
40
int coroutine_fn (*bdrv_co_writev_flags)(BlockDriverState *bs,
41
int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, int flags);
42
+ /**
43
+ * @offset: position in bytes to write at
44
+ * @bytes: number of bytes to write
45
+ * @qiov: the buffers containing data to write
46
+ * @flags: zero or more bits allowed by 'supported_write_flags'
47
+ *
48
+ * @offset and @bytes will be a multiple of 'request_alignment',
49
+ * but the length of individual @qiov elements does not have to
50
+ * be a multiple.
51
+ *
52
+ * @bytes will always equal the total size of @qiov, and will be
53
+ * no larger than 'max_transfer'.
54
+ *
55
+ * The buffer in @qiov may point directly to guest memory.
56
+ */
57
int coroutine_fn (*bdrv_co_pwritev)(BlockDriverState *bs,
58
uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags);
28
59
29
--
60
--
30
2.11.0
61
2.13.5
31
62
32
63
diff view generated by jsdifflib
Deleted patch
1
From: Dou Liyang <douly.fnst@cn.fujitsu.com>
2
1
3
The bdrv_query_stats and bdrv_query_bds_stats functions need to call
4
each other, that increases the coupling. it also makes the program
5
complicated and makes some unnecessary tests.
6
7
Remove the call from bdrv_query_bds_stats to bdrv_query_stats, just
8
take some recursion to make it clearly.
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>
17
---
18
block/qapi.c | 26 ++++++++++++++------------
19
1 file changed, 14 insertions(+), 12 deletions(-)
20
21
diff --git a/block/qapi.c b/block/qapi.c
22
index XXXXXXX..XXXXXXX 100644
23
--- a/block/qapi.c
24
+++ b/block/qapi.c
25
@@ -XXX,XX +XXX,XX @@ static void bdrv_query_info(BlockBackend *blk, BlockInfo **p_info,
26
qapi_free_BlockInfo(info);
27
}
28
29
-static BlockStats *bdrv_query_stats(BlockBackend *blk,
30
- const BlockDriverState *bs,
31
- bool query_backing);
32
-
33
static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk)
34
{
35
BlockAcctStats *stats = blk_get_stats(blk);
36
@@ -XXX,XX +XXX,XX @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk)
37
}
38
}
39
40
-static void bdrv_query_bds_stats(BlockStats *s, const BlockDriverState *bs,
41
+static BlockStats *bdrv_query_bds_stats(const BlockDriverState *bs,
42
bool query_backing)
43
{
44
+ BlockStats *s = NULL;
45
+
46
+ s = g_malloc0(sizeof(*s));
47
+ s->stats = g_malloc0(sizeof(*s->stats));
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);
62
}
63
64
if (query_backing && bs->backing) {
65
s->has_backing = true;
66
- s->backing = bdrv_query_stats(NULL, bs->backing->bs, query_backing);
67
+ s->backing = bdrv_query_bds_stats(bs->backing->bs, query_backing);
68
}
69
70
+ return s;
71
}
72
73
static BlockStats *bdrv_query_stats(BlockBackend *blk,
74
@@ -XXX,XX +XXX,XX @@ static BlockStats *bdrv_query_stats(BlockBackend *blk,
75
{
76
BlockStats *s;
77
78
- s = g_malloc0(sizeof(*s));
79
- s->stats = g_malloc0(sizeof(*s->stats));
80
+ s = bdrv_query_bds_stats(bs, query_backing);
81
82
if (blk) {
83
s->has_device = true;
84
s->device = g_strdup(blk_name(blk));
85
bdrv_query_blk_stats(s->stats, blk);
86
}
87
- if (bs) {
88
- bdrv_query_bds_stats(s, bs, query_backing);
89
- }
90
91
return s;
92
}
93
--
94
2.11.0
95
96
diff view generated by jsdifflib
Deleted patch
1
From: Dou Liyang <douly.fnst@cn.fujitsu.com>
2
1
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.
8
9
The original qmp_query_blockstats calls next_query_bds to get
10
the next objects in each loops. In the next_query_bds, it checks
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>
25
---
26
block/qapi.c | 73 ++++++++++++++++++++++++------------------------------------
27
1 file changed, 29 insertions(+), 44 deletions(-)
28
29
diff --git a/block/qapi.c b/block/qapi.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/block/qapi.c
32
+++ b/block/qapi.c
33
@@ -XXX,XX +XXX,XX @@ static BlockStats *bdrv_query_bds_stats(const BlockDriverState *bs,
34
return s;
35
}
36
37
-static BlockStats *bdrv_query_stats(BlockBackend *blk,
38
- const BlockDriverState *bs,
39
- bool query_backing)
40
-{
41
- BlockStats *s;
42
-
43
- s = bdrv_query_bds_stats(bs, query_backing);
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);
49
- }
50
-
51
- return s;
52
-}
53
-
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;
67
- }
68
-
69
- *blk = blk_next(*blk);
70
- *bs = *blk ? blk_bs(*blk) : NULL;
71
-
72
- return !!*blk;
73
-}
74
-
75
BlockStatsList *qmp_query_blockstats(bool has_query_nodes,
76
bool query_nodes,
77
Error **errp)
78
{
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;
87
-
88
- while (next_query_bds(&blk, &bs, query_nodes)) {
89
- BlockStatsList *info = g_malloc0(sizeof(*info));
90
- AioContext *ctx = blk ? blk_get_aio_context(blk)
91
- : bdrv_get_aio_context(bs);
92
+ if (has_query_nodes && query_nodes) {
93
+ for (bs = bdrv_next_node(NULL); bs; bs = bdrv_next_node(bs)) {
94
+ BlockStatsList *info = g_malloc0(sizeof(*info));
95
+ AioContext *ctx = bdrv_get_aio_context(bs);
96
97
- aio_context_acquire(ctx);
98
- info->value = bdrv_query_stats(blk, bs, !query_nodes);
99
- aio_context_release(ctx);
100
+ aio_context_acquire(ctx);
101
+ info->value = bdrv_query_bds_stats(bs, false);
102
+ aio_context_release(ctx);
103
104
- *p_next = info;
105
- p_next = &info->next;
106
+ *p_next = info;
107
+ p_next = &info->next;
108
+ }
109
+ } else {
110
+ for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {
111
+ BlockStatsList *info = g_malloc0(sizeof(*info));
112
+ AioContext *ctx = blk_get_aio_context(blk);
113
+ BlockStats *s;
114
+
115
+ aio_context_acquire(ctx);
116
+ s = bdrv_query_bds_stats(blk_bs(blk), true);
117
+ s->has_device = true;
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;
129
--
130
2.11.0
131
132
diff view generated by jsdifflib
Deleted patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
1
3
Current implementation invalidates firstly parent bds and then its
4
children. This leads to the following bug:
5
6
after incoming migration, in bdrv_invalidate_cache_all:
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
12
13
This patch fixes it by just changing invalidate sequence: invalidate
14
children first.
15
16
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
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(-)
24
25
diff --git a/block.c b/block.c
26
index XXXXXXX..XXXXXXX 100644
27
--- a/block.c
28
+++ b/block.c
29
@@ -XXX,XX +XXX,XX @@ void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp)
30
if (!(bs->open_flags & BDRV_O_INACTIVE)) {
31
return;
32
}
33
- bs->open_flags &= ~BDRV_O_INACTIVE;
34
35
- if (bs->drv->bdrv_invalidate_cache) {
36
- bs->drv->bdrv_invalidate_cache(bs, &local_err);
37
+ QLIST_FOREACH(child, &bs->children, next) {
38
+ bdrv_invalidate_cache(child->bs, &local_err);
39
if (local_err) {
40
- bs->open_flags |= BDRV_O_INACTIVE;
41
error_propagate(errp, local_err);
42
return;
43
}
44
}
45
46
- QLIST_FOREACH(child, &bs->children, next) {
47
- bdrv_invalidate_cache(child->bs, &local_err);
48
+ bs->open_flags &= ~BDRV_O_INACTIVE;
49
+ if (bs->drv->bdrv_invalidate_cache) {
50
+ bs->drv->bdrv_invalidate_cache(bs, &local_err);
51
if (local_err) {
52
bs->open_flags |= BDRV_O_INACTIVE;
53
error_propagate(errp, local_err);
54
--
55
2.11.0
56
57
diff view generated by jsdifflib
Deleted patch
1
From: Peter Lieven <pl@kamp.de>
2
1
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
Deleted patch
1
From: Peter Lieven <pl@kamp.de>
2
1
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
Deleted patch
1
From: Nir Soffer <nirsof@gmail.com>
2
1
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
Deleted patch
1
From: Nir Soffer <nirsof@gmail.com>
2
1
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
Deleted patch
1
From: Nir Soffer <nirsof@gmail.com>
2
1
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
Deleted patch
1
From: Alberto Garcia <berto@igalia.com>
2
1
3
The metadata overlap checks introduced in a40f1c2add help detect
4
corruption in the qcow2 image by verifying that data writes don't
5
overlap with existing metadata sections.
6
7
The 'refcount-block' check in particular iterates over the refcount
8
table in order to get the addresses of all refcount blocks and check
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>
33
---
34
block/qcow2.h | 1 +
35
block/qcow2-refcount.c | 24 +++++++++++++++++++++++-
36
block/qcow2.c | 1 +
37
3 files changed, 25 insertions(+), 1 deletion(-)
38
39
diff --git a/block/qcow2.h b/block/qcow2.h
40
index XXXXXXX..XXXXXXX 100644
41
--- a/block/qcow2.h
42
+++ b/block/qcow2.h
43
@@ -XXX,XX +XXX,XX @@ typedef struct BDRVQcow2State {
44
uint64_t *refcount_table;
45
uint64_t refcount_table_offset;
46
uint32_t refcount_table_size;
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)
60
+{
61
+ unsigned i = s->refcount_table_size - 1;
62
+ while (i > 0 && (s->refcount_table[i] & REFT_OFFSET_MASK) == 0) {
63
+ i--;
64
+ }
65
+ /* Set s->max_refcount_table_index to the index of the last used entry */
66
+ s->max_refcount_table_index = i;
67
+}
68
+
69
int qcow2_refcount_init(BlockDriverState *bs)
70
{
71
BDRVQcow2State *s = bs->opaque;
72
@@ -XXX,XX +XXX,XX @@ int qcow2_refcount_init(BlockDriverState *bs)
73
}
74
for(i = 0; i < s->refcount_table_size; i++)
75
be64_to_cpus(&s->refcount_table[i]);
76
+ update_max_refcount_table_index(s);
77
}
78
return 0;
79
fail:
80
@@ -XXX,XX +XXX,XX @@ static int alloc_refcount_block(BlockDriverState *bs,
81
}
82
83
s->refcount_table[refcount_table_index] = new_block;
84
+ /* If there's a hole in s->refcount_table then it can happen
85
+ * that refcount_table_index < s->max_refcount_table_index */
86
+ s->max_refcount_table_index =
87
+ MAX(s->max_refcount_table_index, refcount_table_index);
88
89
/* The new refcount block may be where the caller intended to put its
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,
108
}
109
110
if ((chk & QCOW2_OL_REFCOUNT_BLOCK) && s->refcount_table) {
111
- for (i = 0; i < s->refcount_table_size; i++) {
112
+ unsigned last_entry = s->max_refcount_table_index;
113
+ assert(last_entry < s->refcount_table_size);
114
+ assert(last_entry + 1 == s->refcount_table_size ||
115
+ (s->refcount_table[last_entry + 1] & REFT_OFFSET_MASK) == 0);
116
+ for (i = 0; i <= last_entry; i++) {
117
if ((s->refcount_table[i] & REFT_OFFSET_MASK) &&
118
overlaps_with(s->refcount_table[i] & REFT_OFFSET_MASK,
119
s->cluster_size)) {
120
@@ -XXX,XX +XXX,XX @@ int qcow2_change_refcount_order(BlockDriverState *bs, int refcount_order,
121
/* Now update the rest of the in-memory information */
122
old_reftable = s->refcount_table;
123
s->refcount_table = new_reftable;
124
+ update_max_refcount_table_index(s);
125
126
s->refcount_bits = 1 << refcount_order;
127
s->refcount_max = UINT64_C(1) << (s->refcount_bits - 1);
128
diff --git a/block/qcow2.c b/block/qcow2.c
129
index XXXXXXX..XXXXXXX 100644
130
--- a/block/qcow2.c
131
+++ b/block/qcow2.c
132
@@ -XXX,XX +XXX,XX @@ static int make_completely_empty(BlockDriverState *bs)
133
134
s->refcount_table_offset = s->cluster_size;
135
s->refcount_table_size = s->cluster_size / sizeof(uint64_t);
136
+ s->max_refcount_table_index = 0;
137
138
g_free(s->refcount_table);
139
s->refcount_table = new_reftable;
140
--
141
2.11.0
142
143
diff view generated by jsdifflib