Block fixes for 1.7.0
The following changes since commit 5c5432e7d630592ddcc1876ac8a1505f8f14ef15:
Merge remote-tracking branch 'luiz/queue/qmp' into staging (2013-11-13 11:49:27 -0800)
are available in the git repository at:
git://repo.or.cz/qemu/kevin.git tags/for-anthony
for you to fetch changes up to 06d22aa36706a3d6051b74c8a183ab554a0cb808:
block: Fail if requested driver is not available (2013-11-15 13:37:48 +0100)
----------------------------------------------------------------
Block fixes for 1.7.0
----------------------------------------------------------------
Amos Kong (1):
qmp: access the local QemuOptsLists for drive option
Fam Zheng (2):
block: Print its file name if backing file opening failed
qemu-img: Fix overwriting 'ret' before using
Kevin Wolf (2):
qemu-iotests: Test qcow2 count_contiguous_clusters()
block: Fail if requested driver is not available
Max Reitz (3):
qapi-schema: Update description for NewImageMode block/drive-mirror: Check for NULL backing_hd
qemu-iotests: Extend 041 for unbacked mirroring
Peter Lieven (1):
qcow2: fix possible corruption when reading multiple clusters
Stefan Hajnoczi (2):
MAINTAINERS: add block tree repo URLs
MAINTAINERS: add block driver sub-maintainers
MAINTAINERS | 42 ++++++++++++ block.c | 9 ++- block/qcow2-cluster.c | 2 +- block/raw-posix.c | 1 - block/raw-win32.c | 1 - blockdev.c | 5 +- include/qemu/config-file.h | 1 + include/sysemu/sysemu.h | 2 + qapi-schema.json | 3 +- qemu-img.c | 6 +- tests/qemu-iotests/041 | 25 +++++++ tests/qemu-iotests/041.out | 4 +- tests/qemu-iotests/048 | 34 ++++++++++ tests/qemu-iotests/048.out | 27 +++++++- tests/qemu-iotests/051 | 7 ++ tests/qemu-iotests/051.out | 11 ++- tests/qemu-iotests/069.out | 2 +- tests/qemu-iotests/073 | 166 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/073.out | 118 ++++++++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + util/qemu-config.c | 77 ++++++++++++++++++++- vl.c | 3 + 22 files changed, 531 insertions(+), 16 deletions(-) create mode 100755 tests/qemu-iotests/073 create mode 100644 tests/qemu-iotests/073.out
[Qemu-devel] [PULL 02/11] qapi-schema: Update description for NewImageMode
From: Max Reitz <[email protected]>
If the NewImageMode is "absolute-paths" but no backing file is available (e.g., when mirroring a device with an unbacked image), the target image will not be backed either. This patch updates the documentation in qapi-schema.json accordingly.
--- qapi-schema.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
qapi-schema.json +2 -1
@@ -1736,7 +1736,8 @@ # @existing: QEMU should look for an existing image file. # # @absolute-paths: QEMU should create a new image with absolute paths -# for the backing file. +# for the backing file. If there is no backing file available, the new +# image will not be backed either. # # Since: 1.1 ##
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 01/11] block: Print its file name if backing file opening failed
In reply to Kevin WolfFrom: Fam Zheng <[email protected]>
If backing file doesn't exist, the error message is confusing and misleading:
$ qemu /tmp/a.qcow2
qemu: could not open disk image /tmp/a.qcow2: Could not open file: No
such file or directoryBut...
$ ls /tmp/a.qcow2
/tmp/a.qcow2 $ qemu-img info /tmp/a.qcow2
image: /tmp/a.qcow2
file format: qcow2
virtual size: 8.0G (8589934592 bytes)
disk size: 196K
cluster_size: 65536
backing file: /tmp/b.qcow2Because...
$ ls /tmp/b.qcow2
ls: cannot access /tmp/b.qcow2: No such file or directoryThis is not intuitive. It's better to have the missing file's name in the error message. With this patch:
$ qemu-io -c 'read 0 512' /tmp/a.qcow2
qemu-io: can't open device /tmp/a.qcow2: Could not open backing
file: Could not open '/stor/vm/arch.raw': No such file or directory
no file open, try 'help open'Which is a little bit better.
--- block.c | 4 +++- block/raw-posix.c | 1 - block/raw-win32.c | 1 - tests/qemu-iotests/051.out | 2 +- tests/qemu-iotests/069.out | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
block.c +3 -1
@@ -1009,7 +1009,9 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)bdrv_unref (bs->backing_hd); bs->backing_hd =NULL ; bs->open_flags |=BDRV_O_NO_BACKING ; -error_propagate (errp, local_err); +error_setg (errp,"Could not open backing file: %s" , +error_get_pretty (local_err)); +error_free (local_err);return ret; } pstrcpy(bs->backing_file, sizeof(bs->backing_file),
block/raw-posix.c +0 -1
@@ -310,7 +310,6 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,if (ret == -EROFS ) { ret = -EACCES ; } -error_setg_errno (errp, -ret,"Could not open file" ); goto fail; } s->fd = fd;
block/raw-win32.c +0 -1
@@ -280,7 +280,6 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags, }else { ret = -EINVAL ; } -error_setg_errno (errp, -ret,"Could not open file" ); goto fail; }
tests/qemu-iotests/051.out +1 -1
@@ -226,6 +226,6 @@ Testing: -drive file=foo:bar QEMU_PROG: -drive file=foo:bar: could not open disk image foo:bar: Unknown protocol Testing: -drive file.filename=foo:bar -QEMU_PROG: -drive file.filename=foo:bar: could not open disk image ide0-hd0: Could not open file: No such file or directory +QEMU_PROG: -drive file.filename=foo:bar: could not open disk image ide0-hd0: Could not open 'foo:bar': No such file or directory *** done
tests/qemu-iotests/069.out +1 -1
@@ -4,5 +4,5 @@ QA output created by 069 Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=131072 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=131072 backing_file='TEST_DIR/t.IMGFMT.base' -qemu-io: can't open device TEST_DIR/t.IMGFMT: Could not open file: No such file or directory +qemu-io: can't open device TEST_DIR/t.IMGFMT: Could not open backing file: Could not open 'TEST_DIR/t.IMGFMT.base': No such file or directory *** done
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 03/11] block/drive-mirror: Check for NULL backing_hd
In reply to Kevin WolfFrom: Max Reitz <[email protected]>
It should be possible to execute the QMP "drive-mirror" command in "none" sync mode and "absolute-paths" mode even for block devices lacking a backing file.
"absolute-paths" does in fact not require a backing file to be present, as can be seen from the "top" sync mode code path. "top" basically states that the device should indeed have a backing file - however, the current code catches the case if it doesn't and then simply treats it as "full" sync mode, creating a target image without a backing file (in "absolute-paths" mode). Thus, "absolute-paths" does not imply the target file must indeed have a backing file.
Therefore, the target file may be left unbacked in case of "none" sync mode as well, if the specified device is not backed either. Currently, qemu will crash trying to dereference the backing file pointer since it assumes that it will always be non-NULL in that case ("none" with "absolute-paths").
--- blockdev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
blockdev.c +3 -1
@@ -2029,7 +2029,9 @@ void qmp_drive_mirror(const char *device, const char *target,return ; } -if (sync ==MIRROR_SYNC_MODE_FULL && mode !=NEW_IMAGE_MODE_EXISTING ) { +if ((sync ==MIRROR_SYNC_MODE_FULL || !source) + && mode !=NEW_IMAGE_MODE_EXISTING ) + {/* create new image w/o backing file */ assert (format && drv); bdrv_img_create(target, format,
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 05/11] MAINTAINERS: add block tree repo URLs
In reply to Kevin WolfFrom: Stefan Hajnoczi <[email protected]>
--- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
@@ -639,6 +639,8 @@ S: Supported F: block* F: block/ F: hw/block/ +T: git git://repo.or.cz/qemu/kevin.git block +T: git git://github.com/stefanha/qemu.git block Character Devices M: Anthony Liguori <[email protected]>
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 04/11] qemu-iotests: Extend 041 for unbacked mirroring
In reply to Kevin WolfFrom: Max Reitz <[email protected]>
Add a new test case in file 041 for mirroring unbacked images in "absolute-paths" mode. This should work, if possible, but most importantly, qemu should never crash.
--- tests/qemu-iotests/041 | 25 +++++++++++++++++++++++++ tests/qemu-iotests/041.out | 4 ++-- 2 files changed, 27 insertions(+), 2 deletions(-)
tests/qemu-iotests/041 +25 -0
@@ -677,5 +677,30 @@ class TestSetSpeed(ImageMirroringTestCase): self.wait_ready_and_cancel() +class TestUnbackedSource(ImageMirroringTestCase): + image_len = 2 * 1024 * 1024 # MB + + def setUp(self): + qemu_img('create', '-f', iotests.imgfmt, test_img, + str(TestUnbackedSource.image_len)) + self.vm = iotests.VM().add_drive(test_img) + self.vm.launch() + + def tearDown(self): + self.vm.shutdown() + os.remove(test_img) + os.remove(target_img) + + def test_absolute_paths(self): + self.assert_no_active_block_jobs() + + for sync_mode in ['full', 'top', 'none']: + result = self.vm.qmp('drive-mirror', device='drive0', + sync=sync_mode, target=target_img, + mode='absolute-paths') + self.assert_qmp(result, 'return', {}) + self.complete_and_wait() + self.assert_no_active_block_jobs() + if __name__ == '__main__': iotests.main(supported_fmts=['qcow2', 'qed'])
tests/qemu-iotests/041.out +2 -2
@@ -1,5 +1,5 @@ -........................ +......................... ---------------------------------------------------------------------- -Ran 24 tests +Ran 25 tests OK
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 07/11] qcow2: fix possible corruption when reading multiple clusters
In reply to Kevin WolfFrom: Peter Lieven <[email protected]>
if multiple sectors spanning multiple clusters are read the function count_contiguous_clusters should ensure that the cluster type should not change between the clusters.
Especially the for-loop should break when we have one or more normal clusters followed by a compressed cluster.
Unfortunately the wrong macro was used in the mask to compare the flags.
This was discovered while debugging a data corruption issue when converting a compressed qcow2 image to raw. qemu-img reads 2MB chunks which span multiple clusters.
--- block/qcow2-cluster.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/qcow2-cluster.c +1 -1
@@ -290,7 +290,7 @@ static int count_contiguous_clusters(uint64_t nb_clusters, int cluster_size, uint64_t *l2_table, uint64_t stop_flags) { int i; -uint64_t mask = stop_flags |L2E_OFFSET_MASK |QCOW2_CLUSTER_COMPRESSED ; +uint64_t mask = stop_flags |L2E_OFFSET_MASK |QCOW_OFLAG_COMPRESSED ;uint64_t first_entry =be64_to_cpu (l2_table[0 ]);uint64_t offset = first_entry & mask;
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 06/11] qmp: access the local QemuOptsLists for drive option
In reply to Kevin WolfFrom: Amos Kong <[email protected]>
Currently we have three QemuOptsList (qemu_common_drive_opts, qemu_legacy_drive_opts, and qemu_drive_opts), only qemu_drive_opts is added to vm_config_groups[].
This patch changes query-command-line-options to access three local QemuOptsLists for drive option, and merge the description items together.
--- blockdev.c | 1 - include/qemu/config-file.h | 1 + include/sysemu/sysemu.h | 2 ++ util/qemu-config.c | 77 +++++++++++++++++++++++++++++++++++++++++++++- vl.c | 3 ++ 5 files changed, 82 insertions(+), 2 deletions(-)
blockdev.c +0 -1
@@ -47,7 +47,6 @@#include "sysemu/arch_init.h" static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives); -extern QemuOptsList qemu_common_drive_opts;static const char *const if_name[IF_COUNT ] = { [IF_NONE ] ="none" ,
include/qemu/config-file.h +1 -0
@@ -8,6 +8,7 @@QemuOptsList *qemu_find_opts (const char *group);QemuOptsList *qemu_find_opts_err (const char *group,Error **errp);void qemu_add_opts (QemuOptsList *list); +void qemu_add_drive_opts (QemuOptsList *list);int qemu_set_option (const char *str);int qemu_global_option (const char *str);void qemu_add_globals (void );
include/sysemu/sysemu.h +2 -0
@@ -193,6 +193,8 @@ QemuOpts *qemu_get_machine_opts(void);bool usb_enabled (bool default_usb); +extern QemuOptsList qemu_legacy_drive_opts; +extern QemuOptsList qemu_common_drive_opts;extern QemuOptsList qemu_drive_opts;extern QemuOptsList qemu_chardev_opts;extern QemuOptsList qemu_device_opts;
util/qemu-config.c +76 -1
101 lines not on this page · raw message
vl.c +3 -0
@@ -2867,6 +2867,9 @@ int main(int argc, char **argv, char **envp)module_call_init (MODULE_INIT_QOM );qemu_add_opts (&qemu_drive_opts); +qemu_add_drive_opts (&qemu_legacy_drive_opts); +qemu_add_drive_opts (&qemu_common_drive_opts); +qemu_add_drive_opts (&qemu_drive_opts);qemu_add_opts (&qemu_chardev_opts);qemu_add_opts (&qemu_device_opts);qemu_add_opts (&qemu_netdev_opts);
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 08/11] qemu-iotests: Test qcow2 count_contiguous_clusters()
In reply to Kevin Wolf--- tests/qemu-iotests/073 | 166 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/073.out | 118 ++++++++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 285 insertions(+) create mode 100755 tests/qemu-iotests/073 create mode 100644 tests/qemu-iotests/073.out
tests/qemu-iotests/073 new file +166 -0
@@ -0,0 +1,166 @@ +#!/bin/bash +# +# Test count_contiguous_clusters in qcow2 +# +# Copyright (C) 2013 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +# creator [email protected] + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt qcow2 +_supported_proto generic +_supported_os Linux + +CLUSTER_SIZE=64k +size=128M + +echo +echo "== creating backing file ==" + +TEST_IMG="$TEST_IMG.base" _make_test_img $size + +_make_test_img -b "$TEST_IMG.base" +$QEMU_IO -c "write -P 0xa5 0 $size" "$TEST_IMG.base" | _filter_qemu_io + +echo +echo "== normal -> unallocated ==" + +$QEMU_IO -c "write -P 0x11 0 0x10000" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -P 0x11 0x10000 0x10000" "$TEST_IMG.base" | _filter_qemu_io + +$QEMU_IO -c "read -P 0x11 0 0x20000" "$TEST_IMG" | _filter_qemu_io + +echo +echo "== normal -> compressed ==" + +$QEMU_IO -c "write -P 0x22 0x20000 0x10000" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -c -P 0x22 0x30000 0x10000" "$TEST_IMG" | _filter_qemu_io + +$QEMU_IO -c "read -P 0x22 0x20000 0x20000" "$TEST_IMG" | _filter_qemu_io + +echo +echo "== normal -> zero ==" + +$QEMU_IO -c "write -P 0x33 0x40000 0x20000" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -P 0x33 0x40000 0x20000" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c "write -P 0 0x40000 0x10000" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -z 0x50000 0x10000" "$TEST_IMG" | _filter_qemu_io + +$QEMU_IO -c "read -P 0 0x40000 0x20000" "$TEST_IMG" | _filter_qemu_io + +echo +echo +echo "== unallocated -> normal ==" + +$QEMU_IO -c "write -P 0x44 0x60000 0x10000" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c "write -P 0x44 0x70000 0x10000" "$TEST_IMG" | _filter_qemu_io + +$QEMU_IO -c "read -P 0x44 0x60000 0x20000" "$TEST_IMG" | _filter_qemu_io + +echo +echo "== unallocated -> compressed ==" + +$QEMU_IO -c "write -P 0x55 0x80000 0x10000" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c "write -c -P 0x55 0x90000 0x10000" "$TEST_IMG" | _filter_qemu_io + +$QEMU_IO -c "read -P 0x55 0x80000 0x20000" "$TEST_IMG" | _filter_qemu_io + +echo +echo "== unallocated -> zero ==" + +$QEMU_IO -c "write -P 0x66 0xa0000 0x20000" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c "write -P 0 0xa0000 0x10000" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c "write -z 0xb0000 0x10000" "$TEST_IMG" | _filter_qemu_io + +$QEMU_IO -c "read -P 0 0xa0000 0x20000" "$TEST_IMG" | _filter_qemu_io + +echo +echo +echo "== compressed -> normal ==" + +$QEMU_IO -c "write -c -P 0x77 0xc0000 0x10000" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -P 0x77 0xd0000 0x10000" "$TEST_IMG" | _filter_qemu_io + +$QEMU_IO -c "read -P 0x77 0xc0000 0x20000" "$TEST_IMG" | _filter_qemu_io + +echo +echo "== compressed -> unallocated ==" + +$QEMU_IO -c "write -c -P 0x88 0xe0000 0x10000" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -P 0x88 0xf0000 0x10000" "$TEST_IMG.base" | _filter_qemu_io + +$QEMU_IO -c "read -P 0x88 0xe0000 0x20000" "$TEST_IMG" | _filter_qemu_io + +echo +echo "== compressed -> zero ==" + +$QEMU_IO -c "write -c -P 0 0x100000 0x10000" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -c -P 0x99 0x110000 0x10000" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -z 0x110000 0x10000" "$TEST_IMG" | _filter_qemu_io + +$QEMU_IO -c "read -P 0 0x100000 0x20000" "$TEST_IMG" | _filter_qemu_io + +echo +echo +echo "== zero -> normal ==" + +$QEMU_IO -c "write -P 0xaa 0x120000 0x10000" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -P 0 0x130000 0x10000" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -z 0x120000 0x10000" "$TEST_IMG" | _filter_qemu_io + +$QEMU_IO -c "read -P 0 0x120000 0x20000" "$TEST_IMG" | _filter_qemu_io + +echo +echo "== zero -> unallocated ==" + +$QEMU_IO -c "write -z 0x140000 0x10000" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -P 0 0x150000 0x10000" "$TEST_IMG.base" | _filter_qemu_io + +$QEMU_IO -c "read -P 0 0x140000 0x20000" "$TEST_IMG" | _filter_qemu_io + +echo +echo "== zero -> compressed ==" + +$QEMU_IO -c "write -c -P 0 0x170000 0x10000" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -z 0x160000 0x10000" "$TEST_IMG" | _filter_qemu_io + +$QEMU_IO -c "read -P 0 0x160000 0x20000" "$TEST_IMG" | _filter_qemu_io + + +_check_test_img + +# success, all done +echo "*** done" +rm -f $seq.full +status=0
tests/qemu-iotests/073.out new file +118 -0
118 lines not on this page · raw message
tests/qemu-iotests/group +1 -0
@@ -76,3 +76,4 @@ 068 rw auto 069 rw auto 070 rw auto +073 rw auto
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 10/11] MAINTAINERS: add block driver sub-maintainers
In reply to Kevin WolfFrom: Stefan Hajnoczi <[email protected]>
There are a number of contributors who maintain block drivers (image formats and protocols). They should be listed in the MAINTAINERS file so that get_maintainer.pl lists them.
Note that commits are still merged through Kevin or Stefan's block tree but the block driver sub-maintainers are usually the ones to review patches.
--- MAINTAINERS | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
MAINTAINERS +40 -0
@@ -863,3 +863,43 @@ Stable 0.10 L: [email protected] T: git git://git.qemu-project.org/qemu-stable-0.10.git S: Orphan + +Block drivers +------------- +VMDK +M: Fam Zheng <[email protected]> +S: Supported +F: block/vmdk.c + +RBD +M: Josh Durgin <[email protected]> +S: Supported +F: block/rbd.c + +Sheepdog +M: MORITA Kazutaka <[email protected]> +M: Liu Yuan <[email protected]> +S: Supported +F: block/sheepdog.c + +VHDX +M: Jeff Cody <[email protected]> +S: Supported +F: block/vhdx* + +VDI +M: Stefan Weil <[email protected]> +S: Maintained +F: block/vdi.c + +iSCSI +M: Ronnie Sahlberg <[email protected]> +M: Paolo Bonzini <[email protected]> +M: Peter Lieven <[email protected]> +S: Supported +F: block/iscsi.c + +SSH +M: Richard W.M. Jones <[email protected]> +S: Supported +F: block/ssh.c
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 09/11] qemu-img: Fix overwriting 'ret' before using
In reply to Kevin WolfFrom: Fam Zheng <[email protected]>
This patch moves ret assignment after reporting original error.
We were lucky to pass qemu-iotests 048 (qemu-img compare case) but when I tried to run with TEST_DIR=/tmp (tmpfs), it fails with a "wrong" mismatch offset. This fixes two bugs.
In the first if branch, setting ret to 1 before using it makes dead code in the next line: pnum is never added to mismatch offset even if ret was 0.
In the other if branch, currently the output error is always -4:
strerror(-4) -> Unknown error -4
Added regression test in case 048.
--- qemu-img.c | 6 +++--- tests/qemu-iotests/048 | 34 ++++++++++++++++++++++++++++++++++ tests/qemu-iotests/048.out | 27 ++++++++++++++++++++++++++- 3 files changed, 63 insertions(+), 4 deletions(-)
qemu-img.c +3 -3
@@ -1020,10 +1020,10 @@ static int img_compare(int argc, char **argv) } ret =compare_sectors (buf1, buf2, nb_sectors, &pnum);if (ret || pnum != nb_sectors) { - ret =1 ;qprintf (quiet,"Content mismatch at offset %" PRId64"!\n" ,sectors_to_bytes ( ret ? sector_num : sector_num + pnum)); + ret =1 ; goto out; } }
@@ -1045,9 +1045,9 @@ static int img_compare(int argc, char **argv) }if (ret) {if (ret <0 ) { - ret =4 ;error_report ("Error while reading offset %" PRId64": %s" ,sectors_to_bytes (sector_num),strerror (-ret)); + ret =4 ; } goto out; }
@@ -1092,10 +1092,10 @@ static int img_compare(int argc, char **argv) filename_over, buf1, quiet);if (ret) {if (ret <0 ) { - ret =4 ;error_report ("Error while reading offset %" PRId64" of %s: %s" ,sectors_to_bytes (sector_num), filename_over,strerror (-ret)); + ret =4 ; } goto out; }
tests/qemu-iotests/048 +34 -0
@@ -74,5 +74,39 @@ _compare io_pattern write 0 $CLUSTER_SIZE 0 1 123 _compare +# Test unaligned case of mismatch offsets in allocated clusters +_make_test_img $size +io_pattern write 0 512 0 1 100 +cp "$TEST_IMG" "$TEST_IMG2" +io_pattern write 512 512 0 1 101 +_compare + +# Test cluster allocated in one, with IO error +cat > "$TEST_DIR/blkdebug.conf"<<EOF +[inject-error] +event = "read_aio" +errno = "5" +once ="off" +EOF +_make_test_img $size +cp "$TEST_IMG" "$TEST_IMG2" +io_pattern write 512 512 0 1 102 +TEST_IMG="blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG" _compare 2>&1 |\ + _filter_testdir | _filter_imgfmt + +# Test cluster allocated in one, with different sizes and IO error in the part +# that exists only in one image +cat > "$TEST_DIR/blkdebug.conf"<<EOF +[inject-error] +event = "read_aio" +errno = "5" +once ="off" +EOF +_make_test_img $size +TEST_IMG="$TEST_IMG2" _make_test_img 0 +io_pattern write 512 512 0 1 102 +TEST_IMG="blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG" _compare 2>&1 |\ + _filter_testdir | _filter_imgfmt + # Cleanup status=0
tests/qemu-iotests/048.out +26 -1
@@ -1,5 +1,5 @@ QA output created by 048 -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824 === IO: pattern 45 qemu-io> wrote 4096/4096 bytes at offset 524288 4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -28,4 +28,29 @@ qemu-io> wrote 4096/4096 bytes at offset 0 4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) qemu-io> Content mismatch at offset 0! 1 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824 +=== IO: pattern 100 +qemu-io> wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +qemu-io> === IO: pattern 101 +qemu-io> wrote 512/512 bytes at offset 512 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +qemu-io> Content mismatch at offset 512! +1 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824 +=== IO: pattern 102 +qemu-io> wrote 512/512 bytes at offset 512 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +qemu-io> qemu-img: Error while reading offset 0 of blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error +qemu-img: Error while reading offset 0: Input/output error +4 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824 +Formatting 'TEST_DIR/t.IMGFMT.2', fmt=IMGFMT size=0 +=== IO: pattern 102 +qemu-io> wrote 512/512 bytes at offset 512 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +qemu-io> qemu-img: Error while reading offset 0 of blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error +qemu-img: Error while reading offset 0 of blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error +Warning: Image size mismatch! +4 Cleanup
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 11/11] block: Fail if requested driver is not available
In reply to Kevin WolfIf an explicit driver option is present, but doesn't specify a valid driver, then bdrv_open() should fail instead of probing the format.
--- block.c | 5 +++++ tests/qemu-iotests/051 | 7 +++++++ tests/qemu-iotests/051.out | 9 +++++++++ 3 files changed, 21 insertions(+)
block.c +5 -0
@@ -1137,6 +1137,11 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,if (drvname) { drv =bdrv_find_format (drvname);qdict_del (options,"driver" ); +if (!drv) { +error_setg (errp,"Invalid driver: '%s'" , drvname); + ret = -EINVAL ; + goto unlink_and_fail; + } }if (!drv) {
tests/qemu-iotests/051 +7 -0
@@ -78,6 +78,13 @@ run_qemu -drive file="$TEST_IMG",format=qcow2,unknown_opt=1234 run_qemu -drive file="$TEST_IMG",format=qcow2,unknown_opt=foo echo +echo === Invalid format === +echo + +run_qemu -drive file="$TEST_IMG",format=foo +run_qemu -drive file="$TEST_IMG",driver=foo + +echo echo === Overriding backing file === echo
tests/qemu-iotests/051.out +9 -0
@@ -17,6 +17,15 @@ Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=foo QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=foo: could not open disk image TEST_DIR/t.qcow2: Block format 'qcow2' used by device 'ide0-hd0' doesn't support the option 'unknown_opt' +=== Invalid format === + +Testing: -drive file=TEST_DIR/t.qcow2,format=foo +QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=foo: 'foo' invalid format + +Testing: -drive file=TEST_DIR/t.qcow2,driver=foo +QEMU_PROG: -drive file=TEST_DIR/t.qcow2,driver=foo: could not open disk image TEST_DIR/t.qcow2: Invalid driver: 'foo' + + === Overriding backing file === Testing: -drive file=TEST_DIR/t.qcow2,driver=qcow2,backing.file.filename=TEST_DIR/t.qcow2.orig -nodefaults
Signature · 1 line
1.8.1.4