From nobody Sun Apr 28 06:32:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587567926; cv=none; d=zohomail.com; s=zohoarc; b=hy2Z80XJEcVu5tRIIQngErqw+pcPaVOsCIi/qvBEm+UUmFMc+4KJG9aZV+wkj845gnbjusyhipNjtcrKcxjrpIUnO60MMAIeHezKc4rzxVSjwMDbirGJ9NDKkM/YU6oRss4uNLpAh9RGe7R/+yaLKTQJRFlBMQN5EpdTurmBl/4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587567926; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SvU8+3FucNz8bvsJ61tabugkYsKpKUHkcS7Cs5t0lLs=; b=Q9K/xDnhn1KePiba1MgMgKb+gd8sxhi2li9ZhgW43D0WpWawCS5KN3Bhnngqc5zK+cdZtMGG6D8MlaQ22oX7mMzW8u1/S0Wb5YprbqPc6KcFemD06K1himhIxYVQe5a8uA1acs+pqXApQ37iSzro9RN/1rTYzKXdhuZ5/5JGbak= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1587567926720977.0710018263421; Wed, 22 Apr 2020 08:05:26 -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-31-SrKODoyuOLijvz2ysqgjqQ-1; Wed, 22 Apr 2020 11:05:21 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 291267A412; Wed, 22 Apr 2020 15:05:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B8F7F19925; Wed, 22 Apr 2020 15:05:04 +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 64C171809541; Wed, 22 Apr 2020 15:05:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03MF52M8013775 for ; Wed, 22 Apr 2020 11:05:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id D6CC0600DB; Wed, 22 Apr 2020 15:05:02 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 543D6600D2 for ; Wed, 22 Apr 2020 15:05:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587567925; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=SvU8+3FucNz8bvsJ61tabugkYsKpKUHkcS7Cs5t0lLs=; b=HrHtHMXx5cWpq39Lx3n5s7MgEWipXwsrEa6ChKYgH2ivbGlIOd4UVDFuD4+v7NZljU23dG LX7WyGyntxg5bCQeeHzY4s1PA01HA3TFuh84LlQG8xMYaBIq2ICjmALkdaF9Fkk9TgofYK l9VKBdbPsvINSGzy+lrL79kczdfLxcw= X-MC-Unique: SrKODoyuOLijvz2ysqgjqQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/6] qemu: fix domain start with corrupted save file Date: Wed, 22 Apr 2020 17:04:54 +0200 Message-Id: <0c8dc98cae4404d91966793d498815f8ba5ed741.1587567222.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Commit 21ad56e932 introduced a regression where a VM with a corrupted save image file would fail to start on the first attempt. This was caused by returning a wrong return code as 'fd' was abused to also hold the return code. Since it's easy to miss this nuance introduce a 'ret' variable for the return code and return it's value in the error section. https://bugzilla.redhat.com/show_bug.cgi?id=3D1791522 Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Pavel Mores --- src/qemu/qemu_driver.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index dfe0adaad8..9a9361949d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6691,6 +6691,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, bool unlink_corrupt) { int fd =3D -1; + int ret =3D -1; virQEMUSaveDataPtr data =3D NULL; virQEMUSaveHeaderPtr header; virDomainDefPtr def =3D NULL; @@ -6726,7 +6727,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, _("cannot remove corrupt file: %s"), path); } else { - fd =3D -3; + ret =3D -3; } } else { virReportError(VIR_ERR_OPERATION_FAILED, @@ -6747,7 +6748,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, _("cannot remove corrupt file: %s= "), path); } else { - fd =3D -3; + ret =3D -3; } goto error; } @@ -6816,7 +6817,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, virDomainDefFree(def); virQEMUSaveDataFree(data); VIR_FORCE_CLOSE(fd); - return -1; + return ret; } static int ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5) ATTRIBUTE_NONNULL(6) --=20 2.26.0 From nobody Sun Apr 28 06:32:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587567932; cv=none; d=zohomail.com; s=zohoarc; b=bPKOWLUIKc4va/rQR85pYpji7bsZ/xT+2OE2VsJ/m80ioZMMQ5gQk9IMcj4kJEDdfgI6WQR8KHqjwfmvLdrvgaAFZTpYHWM26EdPnG0VbTjguVq+FLjtpu8wpbMhwcm4qoMQDGOvSIvRo8roJom6mpOFS15S6mRnkIov7A4biJA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587567932; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AeyZ6Z7QnNLj9JOwtCYok2Tyd5nk6QMNjNO6ume4FzU=; b=M8ODOtwdP4QTTKowE/zOgCjytvb1rttg8BwGO/oE9MIhd9/rEDc2P9lWXOuOwVKXxKlP0+NYqPB/YIMBwoYR49yUuL3ssyzbV1kG8pPSBvSdAEsZl/XZl8CKGEYqMk6zNlOgFyhwLthgzUK8jrinBYb4+zYE9gNULPKPKIY541k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1587567932075827.1164629774897; Wed, 22 Apr 2020 08:05:32 -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-53-ivlpurhENeGIugf_RZoGdg-1; Wed, 22 Apr 2020 11:05:28 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8EE231137855; Wed, 22 Apr 2020 15:05:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5C8185C541; Wed, 22 Apr 2020 15:05:16 +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 E87DB1809554; Wed, 22 Apr 2020 15:05:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03MF53i8013783 for ; Wed, 22 Apr 2020 11:05:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id C40BC600DB; Wed, 22 Apr 2020 15:05:03 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B11E600D2 for ; Wed, 22 Apr 2020 15:05:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587567930; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=AeyZ6Z7QnNLj9JOwtCYok2Tyd5nk6QMNjNO6ume4FzU=; b=YNIyjChP3moUjuPGOIHj90Ir2ifwqNYGM9Qmn0bQiUpquig7P3LRpUPJe7LW5xNaH8v6ln Z7aAdhD4QRA1TjwhBv4GsP5wd3IVGf9Nia0F+JFiJGtGQsNXzebWFGj4sgg6TpYNG9VUgO PD21RPBipCTv2hJyinfiiuV6Yxwb+Lc= X-MC-Unique: ivlpurhENeGIugf_RZoGdg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/6] virQEMUSaveData: Register autoclear function and use it in qemuDomainSaveImageOpen Date: Wed, 22 Apr 2020 17:04:55 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In an attempt to simplify qemuDomainSaveImageOpen we need to add automatic pointer clearing for virQEMUSaveData. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9a9361949d..5b87aaf9c2 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2856,6 +2856,7 @@ virQEMUSaveDataFree(virQEMUSaveDataPtr data) VIR_FREE(data); } +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virQEMUSaveData, virQEMUSaveDataFree); /** * This function steals @domXML on success. @@ -6692,7 +6693,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, { int fd =3D -1; int ret =3D -1; - virQEMUSaveDataPtr data =3D NULL; + g_autoptr(virQEMUSaveData) data =3D NULL; virQEMUSaveHeaderPtr header; virDomainDefPtr def =3D NULL; int oflags =3D open_write ? O_RDWR : O_RDONLY; @@ -6809,13 +6810,12 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, goto error; *ret_def =3D def; - *ret_data =3D data; + *ret_data =3D g_steal_pointer(&data); return fd; error: virDomainDefFree(def); - virQEMUSaveDataFree(data); VIR_FORCE_CLOSE(fd); return ret; } --=20 2.26.0 From nobody Sun Apr 28 06:32:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587567931; cv=none; d=zohomail.com; s=zohoarc; b=Uxw3OCfMvjdUk2iGeWFdSE5uF2DQGIfAogjmpCVa5vKriVeJkZDuDl2j08c4nLDpeEOgQFOKBJuCr5wgRTnaahtqznVHJgEJJFJSWVM8QKaHukc2XlxX0E4IZT0P1I3YWLgWYCI1qte2J0Xy2UIt5x0nnWVHhmblsSVyDs3tptw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587567931; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RY1WgXMeedgrFzMMuZsZpOuknQYXKcGN+K0Wz7rooAc=; b=RqLiST3kQee7Jbb3M+89u/uAPwW5a9VVEpe6+1l/a2Q6mNos4Q5+GYjoQTgncBC7d0kdR9TAsd0y3jOMJaNiyQVe6ToMuFiRe8ZfmZLcoa0uSfMiB4x3jTvgZdLXHLBo4TcXWE/DArqUz8PKh+u/vTLQi5EFNZul1G64hrKb6MY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1587567931615593.211106550235; Wed, 22 Apr 2020 08:05:31 -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-114-1zR6EzejNnKmdkniFnLNNQ-1; Wed, 22 Apr 2020 11:05:23 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0EA13803B3E; Wed, 22 Apr 2020 15:05:08 +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 C058019925; Wed, 22 Apr 2020 15:05:07 +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 51F8D938FB; Wed, 22 Apr 2020 15:05:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03MF54oe013794 for ; Wed, 22 Apr 2020 11:05:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id C887C600DB; Wed, 22 Apr 2020 15:05:04 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CED0600D2 for ; Wed, 22 Apr 2020 15:05:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587567929; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=RY1WgXMeedgrFzMMuZsZpOuknQYXKcGN+K0Wz7rooAc=; b=MqrWIgdbyBAlV0G9tVC+nuQJ/NMbGrZsAovg5vZhwFUOK9f2h/pUYjvVtz/RwH+zldHzAG 7C3qWfvMiUFswwdmWbEDYjSxBCLZsuUqpSRxW4q9W7zb4gBsZ3PoF/aehflsjaEab4GwEB Y7cakocbsQxHt5d2K3d2hDk3KCYSXvw= X-MC-Unique: 1zR6EzejNnKmdkniFnLNNQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/6] qemuDomainSaveImageOpen: Use g_autoptr for 'dom' Date: Wed, 22 Apr 2020 17:04:56 +0200 Message-Id: <67d21e4bdd4c80874eb85b1f98a380dcde0a7feb.1587567222.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa --- src/qemu/qemu_driver.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 5b87aaf9c2..57c66c3401 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6695,7 +6695,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, int ret =3D -1; g_autoptr(virQEMUSaveData) data =3D NULL; virQEMUSaveHeaderPtr header; - virDomainDefPtr def =3D NULL; + g_autoptr(virDomainDef) def =3D NULL; int oflags =3D open_write ? O_RDWR : O_RDONLY; size_t xml_len; size_t cookie_len; @@ -6809,13 +6809,12 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE= ))) goto error; - *ret_def =3D def; + *ret_def =3D g_steal_pointer(&def); *ret_data =3D g_steal_pointer(&data); return fd; error: - virDomainDefFree(def); VIR_FORCE_CLOSE(fd); return ret; } --=20 2.26.0 From nobody Sun Apr 28 06:32:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587567931; cv=none; d=zohomail.com; s=zohoarc; b=SmSjwKvqFj2qRQNMdfHP9qN4zfwMg8BtXsuVvAe2IOi1dg7YhU0pBiHWTdomT9E2veGgymQGvT8V2i00qaO8oJUUxXYIYW0EEv85PK56HXo5SnSSZb8qWicWEgJnopHtzSqLsk6ABNEQxXpi9bsfaxo+KKnbL/qmqe8Czlk5gWc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587567931; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y1UNLaZ1bgLwQIbRBAU5rXchj7E0qzTYMhzXsHADxCA=; b=IVuii1ye4SN7w1hK4ix95LqebJXsW4THgbKAKvfLgFGnAelbb6pTfVRQkbWuQ+lyqqAvosyTCgUjr0MEp5YPPwhrB3yPAcq8SCuGKiJjKdgcRcp20NyJG+7cMBvShlFMjosXLyvMV5JY9eBs76QxET0n2mKDl6fV24JQn5Fn08s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1587567931626825.6156087153066; Wed, 22 Apr 2020 08:05:31 -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-342-l9PWFrP1Oz2bUlaB3KZIVw-1; Wed, 22 Apr 2020 11:05:27 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 92B81100CC86; Wed, 22 Apr 2020 15:05:16 +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 644965DC18; Wed, 22 Apr 2020 15:05:16 +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 07158941BF; Wed, 22 Apr 2020 15:05:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03MF56oR013805 for ; Wed, 22 Apr 2020 11:05:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 86CDB600E8; Wed, 22 Apr 2020 15:05:06 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2910C600D2 for ; Wed, 22 Apr 2020 15:05:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587567929; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Y1UNLaZ1bgLwQIbRBAU5rXchj7E0qzTYMhzXsHADxCA=; b=GsnpvSa+FA/Jey3YRiuBSAd81lOSwm8J0+UMSMpYUv3b+gIP0ZSNADde0AbGBC/7c8TcT1 J2rKA79Z6z7t87kwbq7m1szr+clBd/4oKoe9yFIWKVRLnvpZlzpECU2+BAY5F91BA6eiFn IlNQ5sjVYl8zOi7itlzf66B2Rjt0SUs= X-MC-Unique: l9PWFrP1Oz2bUlaB3KZIVw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/6] qemuDomainSaveImageOpen: Automatically close 'fd' if unneeded Date: Wed, 22 Apr 2020 17:04:57 +0200 Message-Id: <5eb44d04db82970aed45bd7a05ea44e5b8fba4a0.1587567222.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use VIR_AUTOCLOSE to declare it and remove all internal closing of the filedescriptor. This will allow getting rid of 'error' completely. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 57c66c3401..c0ce1583b1 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6691,7 +6691,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, bool open_write, bool unlink_corrupt) { - int fd =3D -1; + VIR_AUTOCLOSE fd =3D -1; int ret =3D -1; g_autoptr(virQEMUSaveData) data =3D NULL; virQEMUSaveHeaderPtr header; @@ -6723,7 +6723,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, header =3D &data->header; if (saferead(fd, header, sizeof(*header)) !=3D sizeof(*header)) { if (unlink_corrupt) { - if (VIR_CLOSE(fd) < 0 || unlink(path) < 0) { + if (unlink(path) < 0) { virReportSystemError(errno, _("cannot remove corrupt file: %s"), path); @@ -6744,7 +6744,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, sizeof(header->magic)) =3D=3D 0) { msg =3D _("save image is incomplete"); if (unlink_corrupt) { - if (VIR_CLOSE(fd) < 0 || unlink(path) < 0) { + if (unlink(path) < 0) { virReportSystemError(errno, _("cannot remove corrupt file: %s= "), path); @@ -6812,10 +6812,12 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, *ret_def =3D g_steal_pointer(&def); *ret_data =3D g_steal_pointer(&data); - return fd; + ret =3D fd; + fd =3D -1; + + return ret; error: - VIR_FORCE_CLOSE(fd); return ret; } --=20 2.26.0 From nobody Sun Apr 28 06:32:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587567979; cv=none; d=zohomail.com; s=zohoarc; b=ZWTK8Rqn5ACLRzaPGpOD3pYiFJsUVPgD/tysJfQv6O35X0US0/wslumbpj1FaYqlv65zgLcFAQTxE8NpR/hj7sy+g4Jne+abz9cIAjGdI5cKOU2URLFSOoswdwCSpSYUljs6VdldSISNK7h/J7SjPpMGNSoWf+x//AryXervPc0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587567979; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ga2hIUXVRlXK5wCK+fwO3gHqWPUwMudsJkT+0OJYtwc=; b=keEyrIlQeZHJYBDUYI2AIksxc/28G9+iC+8siWQT+ayHtZj2gMS4175RZkTnZjbh4HRERg0+lOjgTt2IFBtERB7prav5jCdAAydezmi2/XUBYqC0l/Q2r2fcG9n1lzj1a8XvsfxPrKQMxU5dfYtOf905tdKnpsAn8UpIzfO9Clc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1587567979506890.4007799167978; Wed, 22 Apr 2020 08:06:19 -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-124-_wjG32rgMt6f6nJcpp2YDg-1; Wed, 22 Apr 2020 11:05:34 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EA02018FE877; Wed, 22 Apr 2020 15:05:21 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C18C65DD79; Wed, 22 Apr 2020 15:05:21 +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 4634D1809541; Wed, 22 Apr 2020 15:05:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03MF564w013810 for ; Wed, 22 Apr 2020 11:05:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id B5181600D2; Wed, 22 Apr 2020 15:05:06 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FD7D600DE for ; Wed, 22 Apr 2020 15:05:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587567978; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Ga2hIUXVRlXK5wCK+fwO3gHqWPUwMudsJkT+0OJYtwc=; b=CNlZhgKQeniCuZz1W39YDm4XrI2n94V8XzLZdRBZd0i3cIwadrsejUGfOUiCocpEhuqHmX U+pSf8rQaKqSjLatgJO4WL1v/Bu29w1AI52DY9dJeQVpEFymVZMiDXMgoSSjQP9hzSlvbh 2tKu2A4aTnSqSiFkomFj6MSbxpBspH4= X-MC-Unique: _wjG32rgMt6f6nJcpp2YDg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/6] qemuDomainSaveImageOpen: Use 'g_new0' instead of VIR_ALLOC(_N) Date: Wed, 22 Apr 2020 17:04:58 +0200 Message-Id: <923048b7aabe5206167f9c632870ca23856bda62.1587567222.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c0ce1583b1..70cdbe235a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6717,8 +6717,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, VIR_FILE_WRAPPER_BYPASS_CACHE))) goto error; - if (VIR_ALLOC(data) < 0) - goto error; + data =3D g_new0(virQEMUSaveData, 1); header =3D &data->header; if (saferead(fd, header, sizeof(*header)) !=3D sizeof(*header)) { @@ -6783,8 +6782,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, cookie_len =3D header->data_len - xml_len; - if (VIR_ALLOC_N(data->xml, xml_len) < 0) - goto error; + data->xml =3D g_new0(char, xml_len); if (saferead(fd, data->xml, xml_len) !=3D xml_len) { virReportError(VIR_ERR_OPERATION_FAILED, @@ -6793,8 +6791,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, } if (cookie_len > 0) { - if (VIR_ALLOC_N(data->cookie, cookie_len) < 0) - goto error; + data->cookie =3D g_new0(char, cookie_len); if (saferead(fd, data->cookie, cookie_len) !=3D cookie_len) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", --=20 2.26.0 From nobody Sun Apr 28 06:32:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587567931; cv=none; d=zohomail.com; s=zohoarc; b=FfJ53IgTVI0C6QvP8waM+J1QkhtZRocHjLSRi3Pr0w3zNGZcdamOGl7Y5i6ZFaasMDwB4il92dqFI4/cXpRZWoZt9iOIV8kKUjCew7Rpx/Rx+PrNJnYf15DouFE7Kx61N9VjNEy739DBCqljIxuWu9cwpx9hj6YUT1RFvqt0GJo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587567931; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=82atpauGlR5cGq8WvNLKPgBQMyYINWYhc9VdiZISEiY=; b=BA2eBV2rN+CQ1r4bOkxBexa80Hd64kQVOZdQhIkHPZ0usvnK+YwhsAY1PUeAopGHbIe9N5pfMiM90X+vgfZxpqKKsYmt7cmmA/2pw2fj6UqTGYqYL68emd2CaKIAM63LKdqhmbUJVZY7JC/yG+/eoyVXtJLY6ym98Jy0vXfRuyg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1587567931876805.0735925931976; Wed, 22 Apr 2020 08:05:31 -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-406-ir6ir76xPSSizNTrhJNTZg-1; Wed, 22 Apr 2020 11:05:27 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4A03718FE872; Wed, 22 Apr 2020 15:05:21 +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 1868660FF9; Wed, 22 Apr 2020 15:05:21 +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 B68E9941BF; Wed, 22 Apr 2020 15:05:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03MF57m5013820 for ; Wed, 22 Apr 2020 11:05:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id CDD02600DE; Wed, 22 Apr 2020 15:05:07 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 056E4600D2 for ; Wed, 22 Apr 2020 15:05:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587567930; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=82atpauGlR5cGq8WvNLKPgBQMyYINWYhc9VdiZISEiY=; b=I2wAnNV2g6UtRFuXNpeFmJJcMYgjPiXvqktgVYsI6oyFtmt5kgdl5gl2jRyxja+af/d9tq bfTeqlW3Vde9izngoWx31m99XBWs3nZalWNHPF4Ks/49FOWhTBF6RO4maIZhO0Pkdi0IUI YV5IJW58+OEKbjG/PEatWZ8w5dpUYD0= X-MC-Unique: ir6ir76xPSSizNTrhJNTZg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 6/6] qemuDomainSaveImageOpen: Refactor handling of errors Date: Wed, 22 Apr 2020 17:04:59 +0200 Message-Id: <25e72c5353d3cd4da18dc9082da3f1f5dfac3a18.1587567222.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Return error codes directly and fix weird reporting of errors via temporary variable. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 51 +++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 70cdbe235a..00d276061e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6705,17 +6705,18 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, if (directFlag < 0) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("bypass cache unsupported by this system")); - goto error; + return -1; } oflags |=3D directFlag; } if ((fd =3D qemuOpenFile(driver, NULL, path, oflags, NULL)) < 0) - goto error; + return -1; + if (bypass_cache && !(*wrapperFd =3D virFileWrapperFdNew(&fd, path, VIR_FILE_WRAPPER_BYPASS_CACHE))) - goto error; + return -1; data =3D g_new0(virQEMUSaveData, 1); @@ -6726,35 +6727,38 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, virReportSystemError(errno, _("cannot remove corrupt file: %s"), path); + return -1; } else { - ret =3D -3; + return -3; } - } else { - virReportError(VIR_ERR_OPERATION_FAILED, - "%s", _("failed to read qemu header")); } - goto error; + + virReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("failed to read qemu header")); + return -1; } if (memcmp(header->magic, QEMU_SAVE_MAGIC, sizeof(header->magic)) !=3D= 0) { - const char *msg =3D _("image magic is incorrect"); - - if (memcmp(header->magic, QEMU_SAVE_PARTIAL, - sizeof(header->magic)) =3D=3D 0) { - msg =3D _("save image is incomplete"); + if (memcmp(header->magic, QEMU_SAVE_PARTIAL, sizeof(header->magic)= ) =3D=3D 0) { if (unlink_corrupt) { if (unlink(path) < 0) { virReportSystemError(errno, _("cannot remove corrupt file: %s= "), path); + return -1; } else { - ret =3D -3; + return -3; } - goto error; } + + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("save image is incomplete")); + return -1; } - virReportError(VIR_ERR_OPERATION_FAILED, "%s", msg); - goto error; + + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("image magic is incorrect")); + return -1; } if (header->version > QEMU_SAVE_VERSION) { @@ -6766,13 +6770,13 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, virReportError(VIR_ERR_OPERATION_FAILED, _("image version is not supported (%d > %d)"), header->version, QEMU_SAVE_VERSION); - goto error; + return -1; } if (header->data_len <=3D 0) { virReportError(VIR_ERR_OPERATION_FAILED, _("invalid header data length: %d"), header->data_l= en); - goto error; + return -1; } if (header->cookieOffset) @@ -6787,7 +6791,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, if (saferead(fd, data->xml, xml_len) !=3D xml_len) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("failed to read domain XML")); - goto error; + return -1; } if (cookie_len > 0) { @@ -6796,7 +6800,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, if (saferead(fd, data->cookie, cookie_len) !=3D cookie_len) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("failed to read cookie")); - goto error; + return -1; } } @@ -6804,7 +6808,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, if (!(def =3D virDomainDefParseString(data->xml, driver->xmlopt, qemuC= aps, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE= ))) - goto error; + return -1; *ret_def =3D g_steal_pointer(&def); *ret_data =3D g_steal_pointer(&data); @@ -6813,9 +6817,6 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, fd =3D -1; return ret; - - error: - return ret; } static int ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5) ATTRIBUTE_NONNULL(6) --=20 2.26.0