From patchwork Wed Jun 14 06:22:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sochin jiang X-Patchwork-Id: 9785509 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 784A5602C9 for ; Wed, 14 Jun 2017 06:27:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5751C1FF8F for ; Wed, 14 Jun 2017 06:27:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4BA622853F; Wed, 14 Jun 2017 06:27:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C500C1FF8F for ; Wed, 14 Jun 2017 06:27:13 +0000 (UTC) Received: from localhost ([::1]:46652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dL1lo-0006pm-By for patchwork-qemu-devel@patchwork.kernel.org; Wed, 14 Jun 2017 02:27:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55144) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dL1lG-0006o6-Qp for qemu-devel@nongnu.org; Wed, 14 Jun 2017 02:26:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dL1lG-000827-1F for qemu-devel@nongnu.org; Wed, 14 Jun 2017 02:26:38 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:3946) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1dL1lB-0007xG-GV; Wed, 14 Jun 2017 02:26:33 -0400 Received: from 172.30.72.55 (EHLO dggeml405-hub.china.huawei.com) ([172.30.72.55]) by dggrg02-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id APH92223; Wed, 14 Jun 2017 14:26:24 +0800 (CST) Received: from linux-AEqqun.localdomain (10.175.104.153) by dggeml405-hub.china.huawei.com (10.3.17.49) with Microsoft SMTP Server id 14.3.301.0; Wed, 14 Jun 2017 14:26:14 +0800 From: "sochin.jiang" To: , Date: Wed, 14 Jun 2017 14:22:39 +0800 Message-ID: <1497421359-32660-1-git-send-email-sochin.jiang@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.175.104.153] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.5940D712.005B, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 2702061c192f7f7e37404c6caebe46e5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 45.249.212.188 Subject: [Qemu-devel] [PATCH] fix: avoid infinite loop when blockjob encountering failure 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: xieyingtai@huawei.com, lina.lulina@huawei.com, lizhengui@huawei.com, qemu-block@nongnu.org, subo7@huawei.com, eric.fangyi@huawei.com, zhangshuai13@huawei.com, qemu-devel@nongnu.org, sochin.jiang@huawei.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: "sochin.jiang" img_commit could fall into infinite loop if it's blockjob fail encountering any I/O error. Try to fix it. Signed-off-by: sochin.jiang --- qemu-img.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qemu-img.c b/qemu-img.c index 0ad698d..6ba565d 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -895,8 +895,11 @@ static void run_block_job(BlockJob *job, Error **errp) aio_poll(aio_context, true); qemu_progress_print(job->len ? ((float)job->offset / job->len * 100.f) : 0.0f, 0); - } while (!job->ready); + } while (!job->ready && !job->ret); + if (job->ret) { + return; + } block_job_complete_sync(job, errp); aio_context_release(aio_context);