block: Propagate error in bdrv_img_create()
cover block: Propagate error in bdrv_img_create()
Currently, when trying to create a backed image without specifying its size, when the backing file does not exist or is not accessible, an appropriate error message will be generated which is then (in bdrv_img_create()) prefixed with the image file name and the strerror(). However, both are generally already part of the bdrv_open() error message, so we should not double this information. An example:
$ qemu-img create -f qcow2 -b /tmp/enoent /tmp/img.qcow2 qemu-img: /tmp/img.qcow2: Could not open '/tmp/enoent': Could not open '/tmp/enoent': No such file or directory: No such file or directory
Just propagating the error is sufficient:
$ qemu-img create -f qcow2 -b /tmp/enoent /tmp/img.qcow2 qemu-img /tmp/img.qcow2: Could not open '/tmp/enoent': No such file or directory
Max Reitz (2):
block: Propagate error in bdrv_img_create()
iotests: Add test for non-existing backing file
block.c | 5 ----- tests/qemu-iotests/111 | 53 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/111.out | 3 +++ tests/qemu-iotests/group | 1 + 4 files changed, 57 insertions(+), 5 deletions(-) create mode 100755 tests/qemu-iotests/111 create mode 100644 tests/qemu-iotests/111.out
Signature · 1 line
1.9.3
PATCH 1/2 block: Propagate error in bdrv_img_create()
If the specified backing file could not be opened, do not generate a new error message which contains the message which has been generated by bdrv_open(), but just propagate the latter.
--- block.c | 5 ----- 1 file changed, 5 deletions(-)
block.c +0 -5
@@ -5577,11 +5577,6 @@ void bdrv_img_create(const char *filename, const char *fmt, ret =bdrv_open (&bs, backing_file,NULL ,NULL , back_flags, backing_drv, &local_err);if (ret <0 ) { -error_setg_errno (errp, -ret,"Could not open '%s': %s" , - backing_file, -error_get_pretty (local_err)); -error_free (local_err); - local_err =NULL ; goto out; } size =bdrv_getlength (bs);
Signature · 1 line
1.9.3
PATCH 2/2 iotests: Add test for non-existing backing file
In reply to Max ReitzTest the error message when a COW file is about to be created which is supposed to inherit the size of its backing file, while the backing file given does not actually exist.
--- tests/qemu-iotests/111 | 53 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/111.out | 3 +++ tests/qemu-iotests/group | 1 + 3 files changed, 57 insertions(+) create mode 100755 tests/qemu-iotests/111 create mode 100644 tests/qemu-iotests/111.out
tests/qemu-iotests/111 new file +53 -0
@@ -0,0 +1,53 @@ +#!/bin/bash +# +# Test case for non-existing backing file when creating a qcow2 image +# and not specifying the size +# +# Copyright (C) 2014 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 qed qcow qcow2 vmdk +_supported_proto file +_supported_os Linux +_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" + +$QEMU_IMG create -f $IMGFMT -b "$TEST_IMG.inexistent" "$TEST_IMG" 2>&1 \ + | _filter_testdir | _filter_imgfmt + +# success, all done +echo '*** done' +rm -f $seq.full +status=0
tests/qemu-iotests/111.out new file +3 -0
@@ -0,0 +1,3 @@ +QA output created by 111 +qemu-img: TEST_DIR/t.IMGFMT: Could not open 'TEST_DIR/t.IMGFMT.inexistent': No such file or directory +*** done
tests/qemu-iotests/group +1 -0
@@ -109,3 +109,4 @@ 105 rw auto quick 107 rw auto quick 108 rw auto quick +111 rw auto quick
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH 2/2] iotests: Add test for non-existing backing file
tests/qemu-iotests/111 line 48
Quoted 10 lines · Max Reitz
Test the error message when a COW file is about to be created which is supposed to inherit the size of its backing file, while the backing file given does not actually exist.
Signed-off-by Max Reitz <[email protected]>---
tests/qemu-iotests/111 new file +3
-0+ +$QEMU_IMG create -f $IMGFMT -b "$TEST_IMG.inexistent" "$TEST_IMG" 2>&1 \ + | _filter_testdir | _filter_imgfmt
inexistent it a nonexistent word :) But it correctly tests the problem.
tests/qemu-iotests/111.out line 2
Quoted 4 lines
+++ b/tests/qemu-iotests/111.out
tests/qemu-iotests/111.out new file +2
-0@@ -0,0 +1,3 @@ +QA output created by 111 +qemu-img: TEST_DIR/t.IMGFMT: Could not open 'TEST_DIR/t.IMGFMT.inexistent': No such file or directory
I'm okay whether you leave the test as-is, or s/in/non/ in two places.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH 2/2] iotests: Add test for non-existing backing file
Quoted 11 lines · Eric Blake
tests/qemu-iotests/111 line 48
Quoted 9 lines · Max Reitz
Test the error message when a COW file is about to be created which is supposed to inherit the size of its backing file, while the backing file given does not actually exist.
Signed-off-by Max Reitz <[email protected]>---
tests/qemu-iotests/111 new file +3
-0+ +$QEMU_IMG create -f $IMGFMT -b "$TEST_IMG.inexistent" "$TEST_IMG" 2>&1 \ + | _filter_testdir | _filter_imgfmtinexistent it a nonexistent word :) But it correctly tests the problem.
I was tempted to use .nai, which would be "does not exist" in Japanese, but then I went for http://en.wiktionary.org/wiki/inexistent :-P
I'd be fine with whatever.
Max
Quoted 5 lines
tests/qemu-iotests/111.out line 2
Quoted 4 lines
+++ b/tests/qemu-iotests/111.out
tests/qemu-iotests/111.out new file +2
-0@@ -0,0 +1,3 @@ +QA output created by 111 +qemu-img: TEST_DIR/t.IMGFMT: Could not open 'TEST_DIR/t.IMGFMT.inexistent': No such file or directoryI'm okay whether you leave the test as-is, or s/in/non/ in two places.
Quoted 22 lines · Max Reitz
Currently, when trying to create a backed image without specifying its size, when the backing file does not exist or is not accessible, an appropriate error message will be generated which is then (in
bdrv_img_create()) prefixed with the image file name and thestrerror(). However, both are generally already part of thebdrv_open()error message, so we should not double this information. An example:$ qemu-img create -f qcow2 -b /tmp/enoent /tmp/img.qcow2 qemu-img: /tmp/img.qcow2: Could not open '/tmp/enoent': Could not open '/tmp/enoent': No such file or directory: No such file or directoryJust propagating the error is sufficient:
$ qemu-img create -f qcow2 -b /tmp/enoent /tmp/img.qcow2 qemu-img /tmp/img.qcow2: Could not open '/tmp/enoent': No such file or directoryMax Reitz (2):
block: Propagate error inbdrv_img_create()
iotests: Add test for non-existing backing file
Quoted 8 lines
block.c | 5 ----- tests/qemu-iotests/111 | 53 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/111.out | 3 +++ tests/qemu-iotests/group | 1 + 4 files changed, 57 insertions(+), 5 deletions(-)create mode 100755 tests/qemu-iotests/111
create mode 100644 tests/qemu-iotests/111.out
Both patches:
Am 27.10.2014 um 13:30 hat Max Reitz geschrieben:
Quoted 11 lines
Currently, when trying to create a backed image without specifying its size, when the backing file does not exist or is not accessible, an appropriate error message will be generated which is then (in
bdrv_img_create()) prefixed with the image file name and thestrerror(). However, both are generally already part of thebdrv_open()error message, so we should not double this information. An example:$ qemu-img create -f qcow2 -b /tmp/enoent /tmp/img.qcow2 qemu-img: /tmp/img.qcow2: Could not open '/tmp/enoent': Could not open '/tmp/enoent': No such file or directory: No such file or directory
Quoted 5 lines
Just propagating the error is sufficient:
$ qemu-img create -f qcow2 -b /tmp/enoent /tmp/img.qcow2 qemu-img /tmp/img.qcow2: Could not open '/tmp/enoent': No such file or directory
Stefan Hajnoczi
AppliedQuoted 22 lines · Max Reitz
Currently, when trying to create a backed image without specifying its size, when the backing file does not exist or is not accessible, an appropriate error message will be generated which is then (in
bdrv_img_create()) prefixed with the image file name and thestrerror(). However, both are generally already part of thebdrv_open()error message, so we should not double this information. An example:$ qemu-img create -f qcow2 -b /tmp/enoent /tmp/img.qcow2 qemu-img: /tmp/img.qcow2: Could not open '/tmp/enoent': Could not open '/tmp/enoent': No such file or directory: No such file or directoryJust propagating the error is sufficient:
$ qemu-img create -f qcow2 -b /tmp/enoent /tmp/img.qcow2 qemu-img /tmp/img.qcow2: Could not open '/tmp/enoent': No such file or directoryMax Reitz (2):
block: Propagate error inbdrv_img_create()
iotests: Add test for non-existing backing file
Quoted 7 lines
block.c | 5 ----- tests/qemu-iotests/111 | 53 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/111.out | 3 +++ tests/qemu-iotests/group | 1 + 4 files changed, 57 insertions(+), 5 deletions(-) create mode 100755 tests/qemu-iotests/111 create mode 100644 tests/qemu-iotests/111.out
Eric: Leaving "inexistent". It is in several dictionaries besides Wiktionary :).
Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block
Stefan
Quoted 30 lines · Stefan Hajnoczi
Quoted 22 lines · Max Reitz
Currently, when trying to create a backed image without specifying its size, when the backing file does not exist or is not accessible, an appropriate error message will be generated which is then (in
bdrv_img_create()) prefixed with the image file name and thestrerror(). However, both are generally already part of thebdrv_open()error message, so we should not double this information. An example:$ qemu-img create -f qcow2 -b /tmp/enoent /tmp/img.qcow2 qemu-img: /tmp/img.qcow2: Could not open '/tmp/enoent': Could not open '/tmp/enoent': No such file or directory: No such file or directoryJust propagating the error is sufficient:
$ qemu-img create -f qcow2 -b /tmp/enoent /tmp/img.qcow2 qemu-img /tmp/img.qcow2: Could not open '/tmp/enoent': No such file or directoryMax Reitz (2):
block: Propagate error inbdrv_img_create()
iotests: Add test for non-existing backing fileQuoted 7 lines
block.c | 5 ----- tests/qemu-iotests/111 | 53 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/111.out | 3 +++ tests/qemu-iotests/group | 1 + 4 files changed, 57 insertions(+), 5 deletions(-)create mode 100755 tests/qemu-iotests/111
create mode 100644 tests/qemu-iotests/111.out
Quoted 5 lines
Eric: Leaving "inexistent". It is in several dictionaries besides Wiktionary :).
Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block
Did you really? It appears neither there nor did it in your pull request...
Max
Am 03.11.2014 um 13:33 hat Max Reitz geschrieben:
Quoted 31 lines · Stefan Hajnoczi
Quoted 30 lines · Max Reitz
Quoted 29 lines
Currently, when trying to create a backed image without specifying its size, when the backing file does not exist or is not accessible, an appropriate error message will be generated which is then (in
bdrv_img_create()) prefixed with the image file name and thestrerror(). However, both are generally already part of thebdrv_open()error message, so we should not double this information. An example:$ qemu-img create -f qcow2 -b /tmp/enoent /tmp/img.qcow2 qemu-img: /tmp/img.qcow2: Could not open '/tmp/enoent': Could not open '/tmp/enoent': No such file or directory: No such file or directoryJust propagating the error is sufficient:
$ qemu-img create -f qcow2 -b /tmp/enoent /tmp/img.qcow2 qemu-img /tmp/img.qcow2: Could not open '/tmp/enoent': No such file or directoryMax Reitz (2):
block: Propagate error inbdrv_img_create()
iotests: Add test for non-existing backing fileblock.c | 5 ----- tests/qemu-iotests/111 | 53 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/111.out | 3 +++ tests/qemu-iotests/group | 1 + 4 files changed, 57 insertions(+), 5 deletions(-) create mode 100755 tests/qemu-iotests/111 create mode 100644 tests/qemu-iotests/111.out
Quoted 7 lines
Quoted 5 lines
Eric: Leaving "inexistent". It is in several dictionaries besides Wiktionary :).
Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/blockDid you really? It appears neither there nor did it in your pull request...
Looks like it's missing indeed. Applied to my tree then.
Kevin