From nobody Wed May 8 08:57:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1596874846; cv=none; d=zohomail.com; s=zohoarc; b=GEe3d9YNMbpguU/WBT9Cw2+w9sFO4/K3fL0NN/6fk1jzu4jcQYWnz4tr7iPlF81s2NNDT1kt6y+aWxqJXikPbsyZeAzPOPPuk83HmxJVKifOJ+ML3i78MkX0R6Z7/DmfGzs4RNuh0mjnjyMJ4JFsBsiyYUu1z24j3trAs7H7qxU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596874846; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=MN7JtS2EDdHHm3ssXvXOgdvzkggY7msVMmsn9l6RXSU=; b=eeEmFsTtNA1OobOVv/2idXzt/hXxFXu4VAf0ZIYhviRafp8NdSxZhAF9JN/HpC7Hb7/zRjIbD+MMCbf9npIgyHO3An1HeFRuk+9Zbm2lk/3LTE2W8h/zgs0BBg1AYOg6+0JRIZ0wTlCoOeldvkCMuOSlCh/myb97RIw1Mu1Yy+s= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1596874846529474.72782223512434; Sat, 8 Aug 2020 01:20:46 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-172-G-ghJpWlNS-9C59kDpQH1Q-1; Sat, 08 Aug 2020 04:20:42 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 68FF818FF665; Sat, 8 Aug 2020 08:20:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5064A87A72; Sat, 8 Aug 2020 08:20:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 98777A5521; Sat, 8 Aug 2020 08:20:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0788KNZd008197 for ; Sat, 8 Aug 2020 04:20:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 43C61217B436; Sat, 8 Aug 2020 08:20:23 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3FBC3217B435 for ; Sat, 8 Aug 2020 08:20:21 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F297A80067A for ; Sat, 8 Aug 2020 08:20:20 +0000 (UTC) Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-343-XSADaeiuNQ2UWVbpCec7lg-1; Sat, 08 Aug 2020 04:20:18 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 43979D60252D4BD7F13F for ; Sat, 8 Aug 2020 16:20:07 +0800 (CST) Received: from [127.0.0.1] (10.174.187.164) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Sat, 8 Aug 2020 16:19:59 +0800 X-MC-Unique: G-ghJpWlNS-9C59kDpQH1Q-1 X-MC-Unique: XSADaeiuNQ2UWVbpCec7lg-1 To: From: Hao Wang Subject: [PATCH] doCoreDump: fix return value not expect as result Message-ID: <2d14812d-5f3c-f7e1-957a-cbb982e76c51@huawei.com> Date: Sat, 8 Aug 2020 16:19:58 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 X-Originating-IP: [10.174.187.164] X-CFilter-Loop: Reflected X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false; X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: "Chenzhendong \(alex\)" , zhengchuan , Zhanghailiang , yubihong X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Hao Wang Subject: [PATCH] doCoreDump: fix return value not expect as result In a case that qemuDumpToFd() return zero while VIR_CLOSE(fd) fails, codes will go to "cleanup" with "ret=3D0", resulting in unexpected return value. Fix that. Signed-off-by: Hao Wang Reviewed-by: Erik Skultety --- src/qemu/qemu_driver.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0f98243fe4..8dfb9a38bf 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3796,6 +3796,7 @@ doCoreDump(virQEMUDriverPtr driver, { int fd =3D -1; int ret =3D -1; + int rc =3D -1; virFileWrapperFdPtr wrapperFd =3D NULL; int directFlag =3D 0; unsigned int flags =3D VIR_FILE_WRAPPER_NON_BLOCKING; @@ -3843,8 +3844,8 @@ doCoreDump(virQEMUDriverPtr driver, if (STREQ(memory_dump_format, "elf")) memory_dump_format =3D NULL; - ret =3D qemuDumpToFd(driver, vm, fd, QEMU_ASYNC_JOB_DUMP, - memory_dump_format); + rc =3D qemuDumpToFd(driver, vm, fd, QEMU_ASYNC_JOB_DUMP, + memory_dump_format); } else { if (dumpformat !=3D VIR_DOMAIN_CORE_DUMP_FORMAT_RAW) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", @@ -3856,11 +3857,11 @@ doCoreDump(virQEMUDriverPtr driver, if (!qemuMigrationSrcIsAllowed(driver, vm, false, 0)) goto cleanup; - ret =3D qemuMigrationSrcToFile(driver, vm, fd, compressor, - QEMU_ASYNC_JOB_DUMP); + rc =3D qemuMigrationSrcToFile(driver, vm, fd, compressor, + QEMU_ASYNC_JOB_DUMP); } - if (ret < 0) + if (rc < 0) goto cleanup; if (VIR_CLOSE(fd) < 0) { -- 2.23.0