From d871e9e001c8e1973214e7646862ac1b642a6624 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: <07146f8b79923c529fd93fa528e6fcbd6f571a02.1369658547.git.minovotn@redhat.com> References: <07146f8b79923c529fd93fa528e6fcbd6f571a02.1369658547.git.minovotn@redhat.com> From: Fam Zheng Date: Mon, 20 May 2013 03:36:41 +0200 Subject: [PATCH 26/47] vmdk: fix return values of vmdk_parent_open RH-Author: Fam Zheng Message-id: <1369021022-22728-27-git-send-email-famz@redhat.com> Patchwork-id: 51462 O-Subject: [PATCH RHEL-6.5 qemu-kvm v3 26/47] vmdk: fix return values of vmdk_parent_open Bugzilla: 960685 RH-Acked-by: Stefan Hajnoczi RH-Acked-by: Jeffrey Cody RH-Acked-by: Kevin Wolf From: Paolo Bonzini While vmdk_open_desc_file (touched by the patch) correctly changed -1 to -EINVAL, vmdk_open did not. Fix it directly in vmdk_parent_open. Signed-off-by: Paolo Bonzini Signed-off-by: Kevin Wolf (cherry picked from commit 588b65a37abf7bbe47c3a7243a871d83fa1aa66b) Signed-off-by: Fam Zheng --- block/vmdk.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) Signed-off-by: Michal Novotny --- block/vmdk.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index 4fbcd0b..e9e4345 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -284,10 +284,12 @@ static int vmdk_parent_open(BlockDriverState *bs) char *p_name; char desc[DESC_SIZE + 1]; BDRVVmdkState *s = bs->opaque; + int ret; desc[DESC_SIZE] = '\0'; - if (bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE) != DESC_SIZE) { - return -1; + ret = bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE); + if (ret < 0) { + return ret; } p_name = strstr(desc, "parentFileNameHint"); @@ -297,10 +299,10 @@ static int vmdk_parent_open(BlockDriverState *bs) p_name += sizeof("parentFileNameHint") + 1; end_name = strchr(p_name, '\"'); if (end_name == NULL) { - return -1; + return -EINVAL; } if ((end_name - p_name) > sizeof(bs->backing_file) - 1) { - return -1; + return -EINVAL; } pstrcpy(bs->backing_file, end_name - p_name + 1, p_name); @@ -630,9 +632,10 @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags, } /* try to open parent images, if exist */ - if (vmdk_parent_open(bs)) { + ret = vmdk_parent_open(bs); + if (ret) { vmdk_free_extents(bs); - return -EINVAL; + return ret; } s->parent_cid = vmdk_read_cid(bs, 1); return 0; -- 1.7.11.7