From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60166) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCmQq-0001LA-Oj for qemu-devel@nongnu.org; Mon, 10 Feb 2014 03:41:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WCmQk-0000kJ-LD for qemu-devel@nongnu.org; Mon, 10 Feb 2014 03:41:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45013) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCmQk-0000jK-EE for qemu-devel@nongnu.org; Mon, 10 Feb 2014 03:41:30 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1A8fTQu012356 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 10 Feb 2014 03:41:29 -0500 Date: Mon, 10 Feb 2014 16:41:36 +0800 From: Fam Zheng Message-ID: <20140210084136.GT15707@T430.nay.redhat.com> References: <1391939335-31580-1-git-send-email-pbonzini@redhat.com> <1391939335-31580-19-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1391939335-31580-19-git-send-email-pbonzini@redhat.com> Subject: Re: [Qemu-devel] [PATCH 18/20] vmdk: correctly propagate errors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, mreitz@redhat.com On Sun, 02/09 10:48, Paolo Bonzini wrote: > Now that we can return the "right" errors, use the Error** parameter > to pass them back instead of just printing them. > > Signed-off-by: Paolo Bonzini > --- > block/vmdk.c | 11 ++++++----- > tests/qemu-iotests/059.out | 6 ++---- > 2 files changed, 8 insertions(+), 9 deletions(-) > > diff --git a/block/vmdk.c b/block/vmdk.c > index 750e632..f148164 100644 > --- a/block/vmdk.c > +++ b/block/vmdk.c > @@ -571,6 +571,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs, > error_setg_errno(errp, -ret, > "Could not read header from file '%s'", > file->filename); > + return -EINVAL; > } > if (header.capacity == 0) { > uint64_t desc_offset = le64_to_cpu(header.desc_offset); > @@ -640,8 +641,8 @@ static int vmdk_open_vmdk4(BlockDriverState *bs, > char buf[64]; > snprintf(buf, sizeof(buf), "VMDK version %d", > le32_to_cpu(header.version)); > - qerror_report(QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, > - bs->device_name, "vmdk", buf); > + error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, > + bs->device_name, "vmdk", buf); > return -ENOTSUP; > } else if (le32_to_cpu(header.version) == 3 && (flags & BDRV_O_RDWR)) { > /* VMware KB 2064959 explains that version 3 added support for > @@ -653,7 +654,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs, > } > > if (le32_to_cpu(header.num_gtes_per_gt) > 512) { > - error_report("L2 table size too big"); > + error_setg(errp, "L2 table size too big"); > return -EINVAL; > } > > @@ -669,8 +670,8 @@ static int vmdk_open_vmdk4(BlockDriverState *bs, > } > if (bdrv_getlength(file) < > le64_to_cpu(header.grain_offset) * BDRV_SECTOR_SIZE) { > - error_report("File truncated, expecting at least %lld bytes", > - le64_to_cpu(header.grain_offset) * BDRV_SECTOR_SIZE); > + error_setg(errp, "File truncated, expecting at least %lld bytes", > + le64_to_cpu(header.grain_offset) * BDRV_SECTOR_SIZE); > return -EINVAL; > } > > diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out > index 4600670..3371c86 100644 > --- a/tests/qemu-iotests/059.out > +++ b/tests/qemu-iotests/059.out > @@ -7,8 +7,7 @@ no file open, try 'help open' > > === Testing too big L2 table size === > Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 > -L2 table size too big > -qemu-io: can't open device TEST_DIR/t.vmdk: Could not open 'TEST_DIR/t.vmdk': Invalid argument > +qemu-io: can't open device TEST_DIR/t.vmdk: L2 table size too big > no file open, try 'help open' > > === Testing too big L1 table size === > @@ -2045,8 +2044,7 @@ RW 12582912 VMFS "dummy.IMGFMT" 1 > > === Testing truncated sparse === > Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400 > -qemu-img: File truncated, expecting at least 13172736 bytes > -qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Could not open 'TEST_DIR/t.IMGFMT': Invalid argument > +qemu-img: Could not open 'TEST_DIR/t.IMGFMT': File truncated, expecting at least 13172736 bytes > > === Testing version 3 === > image: TEST_DIR/iotest-version3.IMGFMT > -- > 1.8.5.3 > > > Reviewed-by: Fam Zheng