From patchwork Mon Oct 10 03:07:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tian xu X-Patchwork-Id: 680211 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ssmVh75nVz9rxv for ; Mon, 10 Oct 2016 14:55:24 +1100 (AEDT) Received: from localhost ([::1]:47233 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btRgP-0001kC-RW for incoming@patchwork.ozlabs.org; Sun, 09 Oct 2016 23:55:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btQwT-00035P-Fh for qemu-devel@nongnu.org; Sun, 09 Oct 2016 23:07:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btQwR-0007vl-BA for qemu-devel@nongnu.org; Sun, 09 Oct 2016 23:07:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39506) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btQwJ-0007pi-TP; Sun, 09 Oct 2016 23:07:44 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 62F838553C; Mon, 10 Oct 2016 03:07:43 +0000 (UTC) Received: from xutian-dev.nay.redhat.com (dhcp-8-157.nay.redhat.com [10.66.8.157]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9A37euX013546; Sun, 9 Oct 2016 23:07:41 -0400 From: Xu Tian To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 10 Oct 2016 11:07:09 +0800 Message-Id: <1476068829-17426-1-git-send-email-xutian@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 10 Oct 2016 03:07:43 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [Qemu-block][PATCH] qemu-img: fix failed qemu-img command return zero exit code defeat X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, Xu Tian , famz@redhat.com, mreitz@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" If backing file can not open when do image rebase, flag 'ret' not assign a non-zero value, then qemu-img process exit with code zero. Assign value '-1' to flag 'ret' after report error message to fix this defeat. BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1383012 Signed-off-by: Xu Tian Reviewed-by: Stefan Hajnoczi --- qemu-img.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qemu-img.c b/qemu-img.c index 46f2a6d..37dcade 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2918,6 +2918,7 @@ static int img_rebase(int argc, char **argv) error_reportf_err(local_err, "Could not open old backing file '%s': ", backing_name); + ret = -1; goto out; } @@ -2935,6 +2936,7 @@ static int img_rebase(int argc, char **argv) error_reportf_err(local_err, "Could not open new backing file '%s': ", out_baseimg); + ret = -1; goto out; } }