From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37344) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VeOSE-0006dQ-BG for qemu-devel@nongnu.org; Thu, 07 Nov 2013 07:12:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VeOS8-0002v7-7H for qemu-devel@nongnu.org; Thu, 07 Nov 2013 07:12:54 -0500 Received: from nodalink.pck.nerim.net ([62.212.105.220]:41854 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VeOS7-0002ul-NA for qemu-devel@nongnu.org; Thu, 07 Nov 2013 07:12:48 -0500 Date: Thu, 7 Nov 2013 13:12:40 +0100 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20131107121240.GA2921@irqsave.net> References: <1383809692-11158-1-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1383809692-11158-1-git-send-email-famz@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] block: Print its file name if backing file opening failed List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com Le Thursday 07 Nov 2013 =E0 15:34:52 (+0800), Fam Zheng a =E9crit : > If backing file doesn't exist, the error message is confusing and > misleading: >=20 > $ qemu /tmp/a.qcow2 > qemu: could not open disk image /tmp/a.qcow2: Could not open file: = No > such file or directory >=20 > But... >=20 > $ ls /tmp/a.qcow2 > /tmp/a.qcow2 >=20 > $ 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.qcow2 >=20 > Because... >=20 > $ ls /tmp/b.qcow2 > ls: cannot access /tmp/b.qcow2: No such file or directory >=20 > This is not intuitive. It's better to have the missing file's name in > the error message. With this patch: >=20 > $ 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' >=20 > Which is a little bit better. >=20 > Signed-off-by: Fam Zheng > --- > block.c | 3 ++- > 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, 4 insertions(+), 5 deletions(-) >=20 > diff --git a/block.c b/block.c > index f706634..a8dbcfc 100644 > --- a/block.c > +++ b/block.c > @@ -1009,7 +1009,8 @@ int bdrv_open_backing_file(BlockDriverState *bs, = QDict *options, Error **errp) > bdrv_unref(bs->backing_hd); > bs->backing_hd =3D NULL; > bs->open_flags |=3D BDRV_O_NO_BACKING; > - error_propagate(errp, local_err); > + error_setg(errp, "Could not open backing file: %s", > + error_get_pretty(local_err)); > return ret; > } > pstrcpy(bs->backing_file, sizeof(bs->backing_file), > diff --git a/block/raw-posix.c b/block/raw-posix.c > index f6d48bb..e1b1ba2 100644 > --- a/block/raw-posix.c > +++ b/block/raw-posix.c > @@ -310,7 +310,6 @@ static int raw_open_common(BlockDriverState *bs, QD= ict *options, > if (ret =3D=3D -EROFS) { > ret =3D -EACCES; > } > - error_setg_errno(errp, -ret, "Could not open file"); > goto fail; > } > s->fd =3D fd; > diff --git a/block/raw-win32.c b/block/raw-win32.c > index 2741e4d..2bad5a3 100644 > --- a/block/raw-win32.c > +++ b/block/raw-win32.c > @@ -280,7 +280,6 @@ static int raw_open(BlockDriverState *bs, QDict *op= tions, int flags, > } else { > ret =3D -EINVAL; > } > - error_setg_errno(errp, -ret, "Could not open file"); > goto fail; > } > =20 > diff --git a/tests/qemu-iotests/051.out b/tests/qemu-iotests/051.out > index 15deef6..d351935 100644 > --- a/tests/qemu-iotests/051.out > +++ b/tests/qemu-iotests/051.out > @@ -226,6 +226,6 @@ Testing: -drive file=3Dfoo:bar > QEMU_PROG: -drive file=3Dfoo:bar: could not open disk image foo:bar: U= nknown protocol > =20 > Testing: -drive file.filename=3Dfoo:bar > -QEMU_PROG: -drive file.filename=3Dfoo:bar: could not open disk image i= de0-hd0: Could not open file: No such file or directory > +QEMU_PROG: -drive file.filename=3Dfoo:bar: could not open disk image i= de0-hd0: Could not open 'foo:bar': No such file or directory > =20 > *** done > diff --git a/tests/qemu-iotests/069.out b/tests/qemu-iotests/069.out > index 3648814..b48306d 100644 > --- a/tests/qemu-iotests/069.out > +++ b/tests/qemu-iotests/069.out > @@ -4,5 +4,5 @@ QA output created by 069 > =20 > Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D131072=20 > Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D131072 backing_fil= e=3D'TEST_DIR/t.IMGFMT.base'=20 > -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 f= ile: Could not open 'TEST_DIR/t.IMGFMT.base': No such file or directory > *** done > --=20 > 1.8.3.1 >=20 >=20 Reviewed-by: Benoit Canet