From nobody Wed May 8 23:48:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1571161061; cv=none; d=zoho.com; s=zohoarc; b=cSlbFs3xB3JXX5sAeKd7yJcuNJ/Pklabmk+QHhYExeTCd600SkeKIRzetyZo/Egrdg0zcVYtuRaNrb6wlBJsriLAlJUDjdd1XU996A5vgMXnZSezRJCKSg4dEsMsOdP//ZyGL5f86KLghcxJqNpuHrfaDNPs39vh1yLKXZIAJAs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571161061; 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=/aclG/HA1qQEAcILjTmHxL2PPFHeNaAh/eKSD7jaDpk=; b=V4+KeCgSEjBQSqwOKb9XuqsAVJSRKfKwNQP0Xd/h92O3FAv4Twd65gFcBHJNmR4UWgUCr2kfH5akwDo7MXKRTyjqi8FoGMopCwYP0dJ2ynmqOzVMkYWhPfZWNgtkdtqpqKgYs54fUtFNd1LutI80Oo+XL957ywQmLCEbzGDeQ7I= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1571161061309552.5004974376319; Tue, 15 Oct 2019 10:37:41 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8F5E6302246D; Tue, 15 Oct 2019 17:37:39 +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 A836A1001DF0; Tue, 15 Oct 2019 17:37:38 +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 9A2184EDA7; Tue, 15 Oct 2019 17:37:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9FHbZv3001206 for ; Tue, 15 Oct 2019 13:37:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id D6F565D9E2; Tue, 15 Oct 2019 17:37:35 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.com (ovpn-116-31.phx2.redhat.com [10.3.116.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 967385D9CD for ; Tue, 15 Oct 2019 17:37:35 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Oct 2019 13:37:19 -0400 Message-Id: <20191015173728.1633-2-jferlan@redhat.com> In-Reply-To: <20191015173728.1633-1-jferlan@redhat.com> References: <20191015173728.1633-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/10] conf: Use consistent error preservation and restoration calls 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 15 Oct 2019 17:37:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Provide some consistency over error message variable name and usage when saving error messages across possible other errors or possibility of resetting of the last error. Instead of virSaveLastError paired up with virSetError and virFreeError, we should use the newer virErrorPreserveLast and virRestoreError. Signed-off-by: John Ferlan Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 10d6bf0eea..188ea80c3d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -23624,17 +23624,14 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPt= r src, return true; =20 error: - err =3D virSaveLastError(); + virErrorPreserveLast(&err); =20 strSrc =3D virDomainDefFormat(src, NULL, 0); strDst =3D virDomainDefFormat(dst, NULL, 0); VIR_DEBUG("XMLs that failed stability check were: src=3D\"%s\", dst=3D= \"%s\"", NULLSTR(strSrc), NULLSTR(strDst)); =20 - if (err) { - virSetError(err); - virFreeError(err); - } + virErrorRestore(&err); return false; } =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 23:48:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1571161061; cv=none; d=zoho.com; s=zohoarc; b=fBdrTGt82Rlz07ksG9ont4fo3YW0IvwxqGjp6BJeO/cxhi/x32dvEvqT+/H8ZRPjHtLvuRmHa1T6gycC+nF0bwWruMv2nICYBvFo9Lcq/nDar9cMI5G/hrX0j7iWgOJ8cBW1PwKrQEAdI4LkbEoNtvK4HRc8WkIct0YR0NPaISw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571161061; 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=31Km+shQ7xmQ6iAYEe7mTaywqhDP1I/bfLAt8ViKWWE=; b=DDXL+QbII3hHj42xFx4Nt6KO+OvtVSHf9ZgwTCzu76H2xgNN6eirnCvt2o1YUBrfrt/YvVQbFNSdwuB7FqhRl/T2e9+8v9eqK/tJfMEvq3iHxJrFXblwev61p1tUbITkNMew44hEv2VqgMjol9EPRYXRJf9xCVmxNtVTSPQcnIg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1571161061503271.97496282140946; Tue, 15 Oct 2019 10:37:41 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id CBA4110DCC81; Tue, 15 Oct 2019 17:37:39 +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 A64F25D9CD; Tue, 15 Oct 2019 17:37:38 +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 DE7284EDA6; Tue, 15 Oct 2019 17:37:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9FHbabN001211 for ; Tue, 15 Oct 2019 13:37:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4D5B95D9E2; Tue, 15 Oct 2019 17:37:36 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.com (ovpn-116-31.phx2.redhat.com [10.3.116.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C8E65D9CD for ; Tue, 15 Oct 2019 17:37:35 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Oct 2019 13:37:20 -0400 Message-Id: <20191015173728.1633-3-jferlan@redhat.com> In-Reply-To: <20191015173728.1633-1-jferlan@redhat.com> References: <20191015173728.1633-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 02/10] src: Use consistent error preservation and restoration calls 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.64]); Tue, 15 Oct 2019 17:37:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Provide some consistency over error message variable name and usage when saving error messages across possible other errors or possibility of resetting of the last error. Instead of virSaveLastError paired up with virSetError and virFreeError, we should use the newer virErrorPreserveLast and virRestoreError. Signed-off-by: John Ferlan Reviewed-by: Michal Privoznik --- src/libvirt-stream.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/libvirt-stream.c b/src/libvirt-stream.c index ef83696bcd..fb646d0aef 100644 --- a/src/libvirt-stream.c +++ b/src/libvirt-stream.c @@ -622,12 +622,11 @@ virStreamSendAll(virStreamPtr stream, VIR_FREE(bytes); =20 if (ret !=3D 0) { - virErrorPtr orig_err =3D virSaveLastError(); + virErrorPtr orig_err; + + virErrorPreserveLast(&orig_err); virStreamAbort(stream); - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } + virErrorRestore(&orig_err); virDispatchError(stream->conn); } =20 @@ -794,12 +793,11 @@ int virStreamSparseSendAll(virStreamPtr stream, VIR_FREE(bytes); =20 if (ret !=3D 0) { - virErrorPtr orig_err =3D virSaveLastError(); + virErrorPtr orig_err; + + virErrorPreserveLast(&orig_err); virStreamAbort(stream); - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } + virErrorRestore(&orig_err); virDispatchError(stream->conn); } =20 @@ -900,12 +898,11 @@ virStreamRecvAll(virStreamPtr stream, VIR_FREE(bytes); =20 if (ret !=3D 0) { - virErrorPtr orig_err =3D virSaveLastError(); + virErrorPtr orig_err; + + virErrorPreserveLast(&orig_err); virStreamAbort(stream); - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } + virErrorRestore(&orig_err); virDispatchError(stream->conn); } =20 @@ -1034,12 +1031,11 @@ virStreamSparseRecvAll(virStreamPtr stream, VIR_FREE(bytes); =20 if (ret !=3D 0) { - virErrorPtr orig_err =3D virSaveLastError(); + virErrorPtr orig_err; + + virErrorPreserveLast(&orig_err); virStreamAbort(stream); - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } + virErrorRestore(&orig_err); virDispatchError(stream->conn); } =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 23:48:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1571161068; cv=none; d=zoho.com; s=zohoarc; b=iLRK5JLPFsbvR+WdfNbGDbedhxPR8vTn4teuc8UxZDeWiLbUfQc463WoV8QBxlWhbD+n4fM9AFfCcs/lBUADIgh7Cvucg0ZLiiuv4Y9XEBkGp8AbUMxGVlbP/1DOCm9EK/wgxniImaMi/s2+QWhfZYZ24ETGHOnbeZZ506Urtgo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571161068; 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=7addJqWXJxEE6y9s2ApZDh3AIeErQWPJJP0MSjY5jJE=; b=YnfAYY8AkaMgCyftCiBICu8W5FrVPC1le3P5kwpDDR2yS3POdwZJ8Zkr+1JvdwlRuF4k3icVUSNa/XoAPBZ5qe1638q6MPdi2oWoAShaSaz7DgaxpXAwkwA6LnjXd46knMKCrWGGqkbT8PrEcFXFiM4I+/cVMxn3RinBVJLEzWY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1571161068647807.289825079313; Tue, 15 Oct 2019 10:37:48 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 26D237BDA7; Tue, 15 Oct 2019 17:37:47 +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 00DA03CC8; Tue, 15 Oct 2019 17:37:46 +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 686964EE6F; Tue, 15 Oct 2019 17:37:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9FHbaKA001216 for ; Tue, 15 Oct 2019 13:37:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id B73115D9E2; Tue, 15 Oct 2019 17:37:36 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.com (ovpn-116-31.phx2.redhat.com [10.3.116.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75D765D9CD for ; Tue, 15 Oct 2019 17:37:36 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Oct 2019 13:37:21 -0400 Message-Id: <20191015173728.1633-4-jferlan@redhat.com> In-Reply-To: <20191015173728.1633-1-jferlan@redhat.com> References: <20191015173728.1633-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/10] libxl: Use consistent error preservation and restoration calls 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 15 Oct 2019 17:37:47 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Provide some consistency over error message variable name and usage when saving error messages across possible other errors or possibility of resetting of the last error. Instead of virSaveLastError paired up with virSetError and virFreeError, we should use the newer virErrorPreserveLast and virRestoreError. Signed-off-by: John Ferlan Reviewed-by: Michal Privoznik --- src/libxl/libxl_migration.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index 8a41e9374d..770a300316 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -1049,7 +1049,7 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver, if (uri_out) { if (virTypedParamsReplaceString(¶ms, &nparams, VIR_MIGRATE_PARAM_URI, uri_out= ) < 0) { - orig_err =3D virSaveLastError(); + virErrorPreserveLast(&orig_err); goto finish; } } else { @@ -1067,7 +1067,7 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver, uri_out, NULL, flags); if (ret < 0) { notify_source =3D false; - orig_err =3D virSaveLastError(); + virErrorPreserveLast(&orig_err); } =20 cancelled =3D (ret < 0); @@ -1094,7 +1094,7 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver, * one we need to preserve it in case confirm3 overwrites */ if (!orig_err) - orig_err =3D virSaveLastError(); + virErrorPreserveLast(&orig_err); =20 confirm: if (notify_source) { @@ -1119,10 +1119,7 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver, ret =3D -1; } =20 - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } + virErrorRestore(&orig_err); =20 VIR_FREE(cookieout); VIR_FREE(dom_xml); @@ -1200,15 +1197,12 @@ libxlDomainMigrationSrcPerformP2P(libxlDriverPrivat= ePtr driver, } =20 cleanup: - orig_err =3D virSaveLastError(); + virErrorPreserveLast(&orig_err); virObjectUnlock(vm); virObjectUnref(dconn); virObjectUnref(cfg); virObjectLock(vm); - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } + virErrorRestore(&orig_err); return ret; } =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 23:48:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1571161071; cv=none; d=zoho.com; s=zohoarc; b=gO2p9L0BBNhH7jqdQUjq36f0s0gKO6NPz5n7/Fq8ijiTtAKn5f+/lGEMu5ekBqwwbwbJlxHg/WRUFazY6eZGrQ5CduCAD4j0ZOxZTScHaJp5zKj72JGA9pwrARxIcjKLBxkRTYvjaXA+D5tAQuqwAzKQbBZQ4Ax7cpTHbjD1jMw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571161071; 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=rX2FEZjcUqW5ehOEcULfikvkVzjc7cB8NHRi3ZFHCWI=; b=AdnS2VxrYbcbuAVVqTiGrnnM13vUu2PSq2dEJ7AkbYxnqLR5cFohbSp7OLEDvDC2lBtTqxxLARqDLGwGaAtu/NXgy7Gy1HWqw6KpgD4bKYQJYpujz18kuFAMRdGTygdNPsaPSA9ohSmqAxhg30fW0GW1xFWv5pGx21nUk4G41CE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1571161071779883.8565177811472; Tue, 15 Oct 2019 10:37:51 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 2F1F9305FD51; Tue, 15 Oct 2019 17:37:50 +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 022855C548; Tue, 15 Oct 2019 17:37:50 +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 B587418037CA; Tue, 15 Oct 2019 17:37:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9FHbb3S001221 for ; Tue, 15 Oct 2019 13:37:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2C3555D9E2; Tue, 15 Oct 2019 17:37:37 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.com (ovpn-116-31.phx2.redhat.com [10.3.116.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF1B95D9CD for ; Tue, 15 Oct 2019 17:37:36 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Oct 2019 13:37:22 -0400 Message-Id: <20191015173728.1633-5-jferlan@redhat.com> In-Reply-To: <20191015173728.1633-1-jferlan@redhat.com> References: <20191015173728.1633-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/10] lxc: Use consistent error preservation and restoration calls 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 15 Oct 2019 17:37:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Provide some consistency over error message variable name and usage when saving error messages across possible other errors or possibility of resetting of the last error. Instead of virSaveLastError paired up with virSetError and virFreeError, we should use the newer virErrorPreserveLast and virRestoreError. Signed-off-by: John Ferlan Reviewed-by: Michal Privoznik --- src/lxc/lxc_driver.c | 9 ++++----- src/lxc/lxc_process.c | 7 ++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 5c7a9140b2..204a3ed522 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1857,12 +1857,11 @@ static int lxcSetVcpuBWLive(virCgroupPtr cgroup, un= signed long long period, =20 error: if (period) { - virErrorPtr saved =3D virSaveLastError(); + virErrorPtr saved; + + virErrorPreserveLast(&saved); virCgroupSetCpuCfsPeriod(cgroup, old_period); - if (saved) { - virSetError(saved); - virFreeError(saved); - } + virErrorRestore(&saved); } =20 return -1; diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index da0b055b85..d9939f102d 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -1568,7 +1568,7 @@ int virLXCProcessStart(virConnectPtr conn, rc =3D -1; } if (rc !=3D 0) { - err =3D virSaveLastError(); + virErrorPreserveLast(&err); virLXCProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED); } virCommandFree(cmd); @@ -1582,10 +1582,7 @@ int virLXCProcessStart(virConnectPtr conn, virObjectUnref(cfg); virObjectUnref(caps); =20 - if (err) { - virSetError(err); - virFreeError(err); - } + virErrorRestore(&err); =20 return rc; } --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 23:48:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1571161738; cv=none; d=zoho.com; s=zohoarc; b=XSeZiWO/EDBvndTSa7mB4H6ZS6yK/0SRRkFkXzPaeF1hkH30oB21oPvQKX8sfqsR3YO5Upew1zEGejCb1q/aY2kHRmTMGCRTf7Hcx9fxsOHDPFD/s4jwFruB142cya+q38VPBfk/anKxF950QzmwGxAII/H3/VDzYWcxhbXS//E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571161738; 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=uzFj0qebLiKb4IWogPrMnEkssTz8NyUo4de/fL4UAQA=; b=QpiZS66h8CXI41tyYIt+uVpeWjIQnOULC/QzSe59M+/Dg1W3kqWM+f7DSV5YlRknRu/YeMFikyxwavl8SdPeT41BQFMNnpvcKZAai/frHL4yASV9teNu1BvDo3honEEPL0mAPUUHwe+nkvQ9VmDnThibcG+6NXyjC/mIxBbIAg8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1571161738291433.38611680543863; Tue, 15 Oct 2019 10:48:58 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id B154720FF; Tue, 15 Oct 2019 17:48:56 +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 8268960BE2; Tue, 15 Oct 2019 17:48:56 +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 39E3D18005A0; Tue, 15 Oct 2019 17:48:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9FHbbNk001229 for ; Tue, 15 Oct 2019 13:37:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id AA4CD5D9E2; Tue, 15 Oct 2019 17:37:37 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.com (ovpn-116-31.phx2.redhat.com [10.3.116.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 553065D9CD for ; Tue, 15 Oct 2019 17:37:37 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Oct 2019 13:37:23 -0400 Message-Id: <20191015173728.1633-6-jferlan@redhat.com> In-Reply-To: <20191015173728.1633-1-jferlan@redhat.com> References: <20191015173728.1633-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/10] qemu: Use consistent error preservation and restoration calls 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.71]); Tue, 15 Oct 2019 17:48:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Provide some consistency over error message variable name and usage when saving error messages across possible other errors or possibility of resetting of the last error. Instead of virSaveLastError paired up with virSetError and virFreeError, we should use the newer virErrorPreserveLast and virRestoreError. Signed-off-by: John Ferlan Reviewed-by: Michal Privoznik --- src/qemu/qemu_cgroup.c | 14 +++--- src/qemu/qemu_command.c | 12 ++--- src/qemu/qemu_domain.c | 7 +-- src/qemu/qemu_driver.c | 36 ++++++-------- src/qemu/qemu_migration.c | 85 +++++++++++--------------------- src/qemu/qemu_migration_params.c | 9 ++-- src/qemu/qemu_monitor.c | 19 +++---- src/qemu/qemu_process.c | 7 +-- 8 files changed, 72 insertions(+), 117 deletions(-) diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index f1776a7c0b..8b915d124c 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -1149,12 +1149,11 @@ qemuSetupCgroupVcpuBW(virCgroupPtr cgroup, =20 error: if (period) { - virErrorPtr saved =3D virSaveLastError(); + virErrorPtr saved; + + virErrorPreserveLast(&saved); ignore_value(virCgroupSetCpuCfsPeriod(cgroup, old_period)); - if (saved) { - virSetError(saved); - virFreeError(saved); - } + virErrorRestore(&saved); } =20 return -1; @@ -1362,10 +1361,9 @@ qemuCgroupEmulatorAllNodesRestore(qemuCgroupEmulator= AllNodesDataPtr data) if (!data) return; =20 - err =3D virSaveLastError(); + virErrorPreserveLast(&err); virCgroupSetCpusetMems(data->emulatorCgroup, data->emulatorMemMask); - virSetError(err); - virFreeError(err); + virErrorRestore(&err); =20 qemuCgroupEmulatorAllNodesDataFree(data); } diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c2a19689c5..2e5e2a75bf 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8644,10 +8644,11 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driv= er, ret =3D 0; cleanup: if (ret < 0) { - virErrorPtr saved_err =3D virSaveLastError(); + virErrorPtr saved_err; + + virErrorPreserveLast(&saved_err); virDomainConfNWFilterTeardown(net); - virSetError(saved_err); - virFreeError(saved_err); + virErrorRestore(&saved_err); } for (i =3D 0; vhostfd && i < vhostfdSize; i++) { if (ret < 0) @@ -8730,11 +8731,10 @@ qemuBuildNetCommandLine(virQEMUDriverPtr driver, error: /* free up any resources in the network driver * but don't overwrite the original error */ - originalError =3D virSaveLastError(); + virErrorPreserveLast(&originalError); for (i =3D 0; last_good_net !=3D -1 && i <=3D last_good_net; i++) virDomainConfNWFilterTeardown(def->nets[i]); - virSetError(originalError); - virFreeError(originalError); + virErrorRestore(&originalError); return -1; } =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c638077aa8..43aec2e3d7 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9174,7 +9174,7 @@ void qemuDomainObjTaint(virQEMUDriverPtr driver, /* We don't care about errors logging taint info, so * preserve original error, and clear any error that * is raised */ - orig_err =3D virSaveLastError(); + virErrorPreserveLast(&orig_err); =20 if (!(timestamp =3D virTimeStringNow())) goto cleanup; @@ -9198,10 +9198,7 @@ void qemuDomainObjTaint(virQEMUDriverPtr driver, =20 cleanup: VIR_FREE(timestamp); - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } + virErrorRestore(&orig_err); } =20 =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6ce6348593..c662676be3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3436,7 +3436,8 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, endjob: if (ret < 0) { if (was_running && virDomainObjIsActive(vm)) { - virErrorPtr save_err =3D virSaveLastError(); + virErrorPtr save_err; + virErrorPreserveLast(&save_err); if (qemuProcessStartCPUs(driver, vm, VIR_DOMAIN_RUNNING_SAVE_CANCELED, QEMU_ASYNC_JOB_SAVE) < 0) { @@ -3446,8 +3447,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, VIR_DOMAIN_EVENT_SUSPENDED, VIR_DOMAIN_EVENT_SUSPENDED_API_ER= ROR)); } - virSetError(save_err); - virFreeError(save_err); + virErrorRestore(&save_err); } } qemuDomainObjEndAsyncJob(driver, vm); @@ -6729,7 +6729,9 @@ qemuDomainSaveImageUpdateDef(virQEMUDriverPtr driver, goto cleanup; =20 if (!virDomainDefCheckABIStability(def, newdef_migr, driver->xmlopt)) { - virErrorPtr err =3D virSaveLastError(); + virErrorPtr save_err; + + virErrorPreserveLast(&save_err); =20 /* Due to a bug in older version of external snapshot creation * code, the XML saved in the save image was not a migratable @@ -6738,11 +6740,10 @@ qemuDomainSaveImageUpdateDef(virQEMUDriverPtr drive= r, * the user provided XML if the check against the migratable XML * fails. Snapshots created prior to v1.1.3 have this issue. */ if (!virDomainDefCheckABIStability(def, newdef, driver->xmlopt)) { - virSetError(err); - virFreeError(err); + virErrorRestore(&save_err); goto cleanup; } - virFreeError(err); + virFreeError(save_err); =20 /* use the user provided XML */ VIR_STEAL_PTR(ret, newdef); @@ -6991,7 +6992,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, * must manually kill it and ignore any error related to * the process */ - orig_err =3D virSaveLastError(); + virErrorPreserveLast(&orig_err); VIR_FORCE_CLOSE(intermediatefd); VIR_FORCE_CLOSE(*fd); } @@ -7002,10 +7003,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, } VIR_DEBUG("Decompression binary stderr: %s", NULLSTR(errbuf)); =20 - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } + virErrorRestore(&orig_err); } VIR_FORCE_CLOSE(intermediatefd); =20 @@ -14739,13 +14737,11 @@ qemuDomainSnapshotFSThaw(virQEMUDriverPtr driver = G_GNUC_UNUSED, =20 agent =3D qemuDomainObjEnterAgent(vm); if (!report) - err =3D virSaveLastError(); + virErrorPreserveLast(&err); thawed =3D qemuAgentFSThaw(agent); - if (!report) - virSetError(err); qemuDomainObjExitAgent(vm, agent); =20 - virFreeError(err); + virErrorRestore(&err); =20 return thawed; } @@ -18897,16 +18893,14 @@ qemuDomainBlockCommit(virDomainPtr dom, =20 endjob: if (ret < 0 && clean_access) { - virErrorPtr orig_err =3D virSaveLastError(); + virErrorPtr orig_err; + virErrorPreserveLast(&orig_err); /* Revert access to read-only, if possible. */ qemuDomainStorageSourceAccessAllow(driver, vm, baseSource, true, f= alse); if (top_parent && top_parent !=3D disk->src) qemuDomainStorageSourceAccessAllow(driver, vm, top_parent, tru= e, false); =20 - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } + virErrorRestore(&orig_err); } qemuBlockJobStartupFinalize(vm, job); qemuDomainObjEndJob(driver, vm); diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 52ef1874aa..8ad1e6fcaf 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -728,7 +728,7 @@ qemuMigrationSrcNBDCopyCancel(virQEMUDriverPtr driver, if (rv !=3D 0) { if (rv < 0) { if (!err) - err =3D virSaveLastError(); + virErrorPreserveLast(&err); failed =3D true; } qemuBlockJobSyncEnd(vm, job, asyncJob); @@ -753,7 +753,7 @@ qemuMigrationSrcNBDCopyCancel(virQEMUDriverPtr driver, } =20 if (failed && !err) - err =3D virSaveLastError(); + virErrorPreserveLast(&err); =20 if (virDomainObjWait(vm) < 0) goto cleanup; @@ -775,10 +775,7 @@ qemuMigrationSrcNBDCopyCancel(virQEMUDriverPtr driver, ret =3D failed ? -1 : 0; =20 cleanup: - if (err) { - virSetError(err); - virFreeError(err); - } + virErrorRestore(&err); return ret; } =20 @@ -3001,15 +2998,16 @@ qemuMigrationSrcConfirmPhase(virQEMUDriverPtr drive= r, virObjectEventStateQueue(driver->domainEventState, event); qemuDomainEventEmitJobCompleted(driver, vm); } else { - virErrorPtr orig_err =3D virSaveLastError(); + virErrorPtr orig_err; int reason; =20 + virErrorPreserveLast(&orig_err); + /* cancel any outstanding NBD jobs */ qemuMigrationSrcNBDCopyCancel(driver, vm, false, QEMU_ASYNC_JOB_MIGRATION_OUT, NULL); =20 - virSetError(orig_err); - virFreeError(orig_err); + virErrorRestore(&orig_err); =20 if (virDomainObjGetState(vm, &reason) =3D=3D VIR_DOMAIN_PAUSED && reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY) @@ -3213,16 +3211,13 @@ static void qemuMigrationSrcIOFunc(void *arg) return; =20 abrt: - err =3D virSaveLastError(); + virErrorPreserveLast(&err); if (err && err->code =3D=3D VIR_ERR_OK) { virFreeError(err); err =3D NULL; } virStreamAbort(data->st); - if (err) { - virSetError(err); - virFreeError(err); - } + virErrorRestore(&err); =20 error: /* Let the source qemu know that the transfer cant continue anymore. @@ -3704,15 +3699,12 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver, if (events) priv->signalIOError =3D false; =20 - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } + virErrorRestore(&orig_err); =20 return ret; =20 error: - orig_err =3D virSaveLastError(); + virErrorPreserveLast(&orig_err); =20 if (virDomainObjIsActive(vm)) { if (cancel && @@ -3967,7 +3959,7 @@ qemuMigrationSrcPerformPeer2Peer2(virQEMUDriverPtr dr= iver, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("domainMigratePrepare2 did not set uri")); cancelled =3D true; - orig_err =3D virSaveLastError(); + virErrorPreserveLast(&orig_err); goto finish; } =20 @@ -3990,7 +3982,7 @@ qemuMigrationSrcPerformPeer2Peer2(virQEMUDriverPtr dr= iver, =20 /* Perform failed. Make sure Finish doesn't overwrite the error */ if (ret < 0) - orig_err =3D virSaveLastError(); + virErrorPreserveLast(&orig_err); =20 /* If Perform returns < 0, then we need to cancel the VM * startup on the destination @@ -4023,10 +4015,7 @@ qemuMigrationSrcPerformPeer2Peer2(virQEMUDriverPtr d= river, =20 virObjectUnref(st); =20 - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } + virErrorRestore(&orig_err); VIR_FREE(uri_out); VIR_FREE(cookie); =20 @@ -4200,13 +4189,13 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriverPtr = driver, if (useParams && virTypedParamsReplaceString(¶ms, &nparams, VIR_MIGRATE_PARAM_URI, uri_out) < = 0) { - orig_err =3D virSaveLastError(); + virErrorPreserveLast(&orig_err); goto finish; } } else if (!uri && !(flags & VIR_MIGRATE_TUNNELLED)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("domainMigratePrepare3 did not set uri")); - orig_err =3D virSaveLastError(); + virErrorPreserveLast(&orig_err); goto finish; } =20 @@ -4239,7 +4228,7 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriverPtr dr= iver, =20 /* Perform failed. Make sure Finish doesn't overwrite the error */ if (ret < 0) { - orig_err =3D virSaveLastError(); + virErrorPreserveLast(&orig_err); } else { qemuMigrationJobSetPhase(driver, vm, QEMU_MIGRATION_PHASE_PERFORM3_DONE); @@ -4331,7 +4320,7 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriverPtr dr= iver, * one we need to preserve it in case confirm3 overwrites */ if (!orig_err) - orig_err =3D virSaveLastError(); + virErrorPreserveLast(&orig_err); =20 /* * If cancelled, then src VM will be restarted, else @@ -4363,10 +4352,7 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriverPtr d= river, =20 virObjectUnref(st); =20 - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } + virErrorRestore(&orig_err); VIR_FREE(uri_out); VIR_FREE(cookiein); VIR_FREE(cookieout); @@ -4542,15 +4528,12 @@ qemuMigrationSrcPerformPeer2Peer(virQEMUDriverPtr d= river, } =20 cleanup: - orig_err =3D virSaveLastError(); + virErrorPreserveLast(&orig_err); qemuDomainObjEnterRemote(vm); virConnectUnregisterCloseCallback(dconn, qemuMigrationSrcConnectionClo= sed); virObjectUnref(dconn); ignore_value(qemuDomainObjExitRemote(vm, false)); - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } + virErrorRestore(&orig_err); virObjectUnref(cfg); return ret; } @@ -4639,7 +4622,7 @@ qemuMigrationSrcPerformJob(virQEMUDriverPtr driver, =20 endjob: if (ret < 0) - orig_err =3D virSaveLastError(); + virErrorPreserveLast(&orig_err); =20 /* v2 proto has no confirm phase so we need to reset migration paramet= ers * here @@ -4659,10 +4642,7 @@ qemuMigrationSrcPerformJob(virQEMUDriverPtr driver, qemuDomainRemoveInactiveJob(driver, vm); } =20 - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } + virErrorRestore(&orig_err); =20 cleanup: virObjectEventStateQueue(driver->domainEventState, event); @@ -5074,7 +5054,7 @@ qemuMigrationDstFinish(virQEMUDriverPtr driver, /* Need to save the current error, in case shutting * down the process overwrites it */ - orig_err =3D virSaveLastError(); + virErrorPreserveLast(&orig_err); =20 /* * In v3 protocol, the source VM is still available to @@ -5203,10 +5183,7 @@ qemuMigrationDstFinish(virQEMUDriverPtr driver, VIR_FREE(priv->origname); virDomainObjEndAPI(&vm); qemuMigrationCookieFree(mig); - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } + virErrorRestore(&orig_err); virObjectUnref(cfg); =20 /* Set a special error if Finish is expected to return NULL as a resul= t of @@ -5311,7 +5288,7 @@ qemuMigrationSrcToFile(virQEMUDriverPtr driver, virDo= mainObjPtr vm, =20 if (rc < 0) { if (rc =3D=3D -2) { - orig_err =3D virSaveLastError(); + virErrorPreserveLast(&orig_err); virCommandAbort(cmd); if (virDomainObjIsActive(vm) && qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) =3D= =3D 0) { @@ -5330,7 +5307,7 @@ qemuMigrationSrcToFile(virQEMUDriverPtr driver, virDo= mainObjPtr vm, =20 cleanup: if (ret < 0 && !orig_err) - orig_err =3D virSaveLastError(); + virErrorPreserveLast(&orig_err); =20 /* Restore max migration bandwidth */ if (virDomainObjIsActive(vm) && @@ -5348,10 +5325,7 @@ qemuMigrationSrcToFile(virQEMUDriverPtr driver, virD= omainObjPtr vm, virCommandFree(cmd); } =20 - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } + virErrorRestore(&orig_err); =20 return ret; } @@ -5539,8 +5513,7 @@ qemuMigrationDstErrorReport(virQEMUDriverPtr driver, =20 VIR_DEBUG("Restoring saved incoming migration error for domain %s: %s", name, err->message); - virSetError(err); - virFreeError(err); + virErrorRestore(&err); } =20 =20 diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 85fa8f8de5..1acaebcfd0 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -1197,7 +1197,9 @@ qemuMigrationParamsReset(virQEMUDriverPtr driver, qemuMigrationParamsPtr origParams, unsigned long apiFlags) { - virErrorPtr err =3D virSaveLastError(); + virErrorPtr err; + + virErrorPreserveLast(&err); =20 VIR_DEBUG("Resetting migration parameters %p, flags 0x%lx", origParams, apiFlags); @@ -1211,10 +1213,7 @@ qemuMigrationParamsReset(virQEMUDriverPtr driver, qemuMigrationParamsResetTLS(driver, vm, asyncJob, origParams, apiFlags= ); =20 cleanup: - if (err) { - virSetError(err); - virFreeError(err); - } + virErrorRestore(&err); } =20 =20 diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 49f9159315..68a7cfc453 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -929,17 +929,17 @@ qemuMonitorClose(qemuMonitorPtr mon) */ if (mon->msg) { if (mon->lastError.code =3D=3D VIR_ERR_OK) { - virErrorPtr err =3D virSaveLastError(); + virErrorPtr err; + + virErrorPreserveLast(&err); =20 virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("QEMU monitor was closed")); virCopyLastError(&mon->lastError); - if (err) { - virSetError(err); - virFreeError(err); - } else { + if (err) + virErrorRestore(&err); + else virResetLastError(); - } } mon->msg->finished =3D 1; virCondSignal(&mon->notify); @@ -2671,17 +2671,14 @@ qemuMonitorCloseFileHandle(qemuMonitorPtr mon, =20 VIR_DEBUG("fdname=3D%s", fdname); =20 - error =3D virSaveLastError(); + virErrorPreserveLast(&error); =20 QEMU_CHECK_MONITOR_GOTO(mon, cleanup); =20 ret =3D qemuMonitorJSONCloseFileHandle(mon, fdname); =20 cleanup: - if (error) { - virSetError(error); - virFreeError(error); - } + virErrorRestore(&error); return ret; } =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 9c50c4a1d8..d82d5eb202 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7412,7 +7412,7 @@ void qemuProcessStop(virQEMUDriverPtr driver, =20 /* This method is routinely used in clean up paths. Disable error * reporting so we don't squash a legit error. */ - orig_err =3D virSaveLastError(); + virErrorPreserveLast(&orig_err); =20 if (asyncJob !=3D QEMU_ASYNC_JOB_NONE) { if (qemuDomainObjBeginNestedJob(driver, vm, asyncJob) < 0) @@ -7705,10 +7705,7 @@ void qemuProcessStop(virQEMUDriverPtr driver, qemuDomainObjEndJob(driver, vm); =20 cleanup: - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } + virErrorRestore(&orig_err); virObjectUnref(conn); virObjectUnref(cfg); } --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 23:48:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1571161068; cv=none; d=zoho.com; s=zohoarc; b=S7xgv0sl5R1jqrmCJ5f8O9k1zrjm79qhvQ2k6F7ARWzxwlQwTYdZTssbKPm5Qrs0IKqJuRKytjdmJqP7TUyDpHSDUh61lstmgHE4fXRSy5p0kgxu4INy+PBm05NaDHePZ0f6VpnoAK9dKTfhlZQ4qgjsh3ERGaVyDLttUBk9XqA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571161068; 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=YicmFsDAzE0TH5qbtgDzJJvEmpyCXhCnWsqbQXh/GBA=; b=XlyypQv2MXtn3YhMktip0XWWI58S/CCFQd3f4qibQ3PYFI2UYmWVCiYRYNMUCntBxtk4RP1KSeG01+QFOpH4JNvD67fB+YTnNo5g6Lb0Vv4MbkqHdSQig6NwGYI6RY0hYqiAiYRjdqgPiDHB5ZFit/8ifGTjvGPScha9Phq5TQ0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15711610683609.860694631065599; Tue, 15 Oct 2019 10:37:48 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D74FC3018ED0; Tue, 15 Oct 2019 17:37:46 +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 AE57D5D712; Tue, 15 Oct 2019 17:37:46 +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 6B5461803518; Tue, 15 Oct 2019 17:37:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9FHbcdO001238 for ; Tue, 15 Oct 2019 13:37:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1F5925D9CD; Tue, 15 Oct 2019 17:37:38 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.com (ovpn-116-31.phx2.redhat.com [10.3.116.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2D205D9E2 for ; Tue, 15 Oct 2019 17:37:37 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Oct 2019 13:37:24 -0400 Message-Id: <20191015173728.1633-7-jferlan@redhat.com> In-Reply-To: <20191015173728.1633-1-jferlan@redhat.com> References: <20191015173728.1633-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/10] remote: Use consistent error preservation and restoration calls 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Tue, 15 Oct 2019 17:37:47 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Provide some consistency over error message variable name and usage when saving error messages across possible other errors or possibility of resetting of the last error. Instead of virSaveLastError paired up with virSetError and virFreeError, we should use the newer virErrorPreserveLast and virRestoreError. Signed-off-by: John Ferlan Reviewed-by: Michal Privoznik --- src/remote/remote_daemon_stream.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/remote/remote_daemon_stream.c b/src/remote/remote_daemon_s= tream.c index d7fcb1bf42..c4f14a27ef 100644 --- a/src/remote/remote_daemon_stream.c +++ b/src/remote/remote_daemon_stream.c @@ -229,15 +229,18 @@ daemonStreamEvent(virStreamPtr st, int events, void *= opaque) int ret; virNetMessagePtr msg; virNetMessageError rerr; - virErrorPtr origErr =3D virSaveLastError(); + virErrorPtr origErr; + + virErrorPreserveLast(&origErr); =20 memset(&rerr, 0, sizeof(rerr)); stream->closed =3D true; virStreamEventRemoveCallback(stream->st); virStreamAbort(stream->st); if (origErr && origErr->code !=3D VIR_ERR_OK) { - virSetError(origErr); + virErrorRestore(&origErr); } else { + virFreeError(origErr); if (events & VIR_STREAM_EVENT_HANGUP) virReportError(VIR_ERR_RPC, "%s", _("stream had unexpected termination"= )); @@ -245,7 +248,6 @@ daemonStreamEvent(virStreamPtr st, int events, void *op= aque) virReportError(VIR_ERR_RPC, "%s", _("stream had I/O failure")); } - virFreeError(origErr); =20 msg =3D virNetMessageNew(false); if (!msg) { @@ -549,7 +551,9 @@ daemonStreamHandleWriteData(virNetServerClientPtr clien= t, return 1; } else if (ret < 0) { virNetMessageError rerr; - virErrorPtr err =3D virSaveLastError(); + virErrorPtr err; + + virErrorPreserveLast(&err); =20 memset(&rerr, 0, sizeof(rerr)); =20 @@ -558,10 +562,7 @@ daemonStreamHandleWriteData(virNetServerClientPtr clie= nt, virStreamEventRemoveCallback(stream->st); virStreamAbort(stream->st); =20 - if (err) { - virSetError(err); - virFreeError(err); - } + virErrorRestore(&err); =20 return virNetServerProgramSendReplyError(stream->prog, client, --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 23:48:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1571161076; cv=none; d=zoho.com; s=zohoarc; b=VDghKS4T3dApWlXfUOqNzybdEdyWDA0qswr1S0vuuwSISx+8zh0uPSyuvLkApeH0KOZlpT1PM8UExSNP/kS2cjOE4u+xgdg0TC2X4m2V5tLWo9Q/yiAfUJQSlt2NHLmuAT+eh54rvfM5RNMPvR1iP+tQBTjEOCXSO+UR2ol132s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571161076; 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=dXOV58xFj6w0y33vbZOD+P4MKv8Gz422vEryf/P8S9U=; b=D/6fdcncSGSH1Oe/Z/ROCmTxOPjr6BVmAn39iBK4yBDgT34Ja61QTzRYMBnqlRfGJR6Ao+dOsKaAjA0PcdPzW/Mx6NgcCh/I1c7IPo6vwlDRrVefiRi4uyog8skH/qjGtH84G6iNAYZoVAFGEC+G06jWkqwrGePVjUQnwTXi/u4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1571161076291805.8129725881926; Tue, 15 Oct 2019 10:37:56 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BECDA309BDBC; Tue, 15 Oct 2019 17:37:54 +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 98DB96092D; Tue, 15 Oct 2019 17:37:54 +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 5336B4EE6A; Tue, 15 Oct 2019 17:37:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9FHbcB0001247 for ; Tue, 15 Oct 2019 13:37:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 872F55D9E2; Tue, 15 Oct 2019 17:37:38 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.com (ovpn-116-31.phx2.redhat.com [10.3.116.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 469D65D9CD for ; Tue, 15 Oct 2019 17:37:38 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Oct 2019 13:37:25 -0400 Message-Id: <20191015173728.1633-8-jferlan@redhat.com> In-Reply-To: <20191015173728.1633-1-jferlan@redhat.com> References: <20191015173728.1633-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 07/10] storage: Use consistent error preservation and restoration calls 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 15 Oct 2019 17:37:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Provide some consistency over error message variable name and usage when saving error messages across possible other errors or possibility of resetting of the last error. Instead of virSaveLastError paired up with virSetError and virFreeError, we should use the newer virErrorPreserveLast and virRestoreError. Signed-off-by: John Ferlan Reviewed-by: Michal Privoznik --- src/storage/storage_backend_disk.c | 5 ++--- src/storage/storage_backend_logical.c | 5 ++--- src/storage/storage_driver.c | 8 +++----- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backe= nd_disk.c index 5bf704bcc8..d2f7b94224 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -918,10 +918,9 @@ virStorageBackendDiskCreateVol(virStoragePoolObjPtr po= ol, /* Best effort to remove the partition. Ignore any errors * since we could be calling this with vol->target.path =3D=3D NULL */ - save_err =3D virSaveLastError(); + virErrorPreserveLast(&save_err); ignore_value(virStorageBackendDiskDeleteVol(pool, vol, 0)); - virSetError(save_err); - virFreeError(save_err); + virErrorRestore(&save_err); return -1; } =20 diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index 6e468b3579..bfedb06a91 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -969,10 +969,9 @@ virStorageBackendLogicalCreateVol(virStoragePoolObjPtr= pool, return 0; =20 error: - err =3D virSaveLastError(); + virErrorPreserveLast(&err); virStorageBackendLogicalDeleteVol(pool, vol, 0); - virSetError(err); - virFreeError(err); + virErrorRestore(&err); return -1; } =20 diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 6516b0943d..e8551ba57e 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -81,18 +81,16 @@ storagePoolRefreshFailCleanup(virStorageBackendPtr back= end, virStoragePoolObjPtr obj, const char *stateFile) { - virErrorPtr orig_err =3D virSaveLastError(); + virErrorPtr orig_err; =20 + virErrorPreserveLast(&orig_err); virStoragePoolObjClearVols(obj); =20 if (stateFile) unlink(stateFile); if (backend->stopPool) backend->stopPool(obj); - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } + virErrorRestore(&orig_err); } =20 =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 23:48:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1571161080; cv=none; d=zoho.com; s=zohoarc; b=eAntl1WwZyNJiP+jT6AxsgjcJa4y6fbhAC8JMu+QvJ5VZR33+xyo2bYsA9omXdn426inoTUvqcMlhxwVt0lJKHmH6u60zJR34o0juyd8BY1nVPCjGlKnEpGGtaeQSwU4KlCVfKQk3Aw5VJOJPKmXa+EkDM2E5WMUDK4JYwzM590= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571161080; 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=AmIgd3PEpDSZt7IyItiunp1wf1RsGA95nfzrg9hu3vY=; b=EzvjQoSLNeK46tHNNHf0/iCqaKdaDIQea1+0rJHG369RcGZR3ZSM4cLwK7wc2l1BuEwUS+DJwc6Uv1wf+si2vwJP4pAevQvES5ErxJAf2v2jiso0yN5pYExX6jDbL8n0wxGrujtfVZNfzpocNn7fTVE/Ff7PqCbZENTIai6CRv4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1571161080174390.817165613253; Tue, 15 Oct 2019 10:38:00 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 130663175281; Tue, 15 Oct 2019 17:37:58 +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 E3EB5100EBD5; Tue, 15 Oct 2019 17:37:57 +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 AD3054EE71; Tue, 15 Oct 2019 17:37:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9FHbc29001260 for ; Tue, 15 Oct 2019 13:37:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id F037B5DA8C; Tue, 15 Oct 2019 17:37:38 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.com (ovpn-116-31.phx2.redhat.com [10.3.116.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id AFF6E5D9E2 for ; Tue, 15 Oct 2019 17:37:38 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Oct 2019 13:37:26 -0400 Message-Id: <20191015173728.1633-9-jferlan@redhat.com> In-Reply-To: <20191015173728.1633-1-jferlan@redhat.com> References: <20191015173728.1633-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/10] util: Use consistent error preservation and restoration calls 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 15 Oct 2019 17:37:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Provide some consistency over error message variable name and usage when saving error messages across possible other errors or possibility of resetting of the last error. Instead of virSaveLastError paired up with virSetError and virFreeError, we should use the newer virErrorPreserveLast and virRestoreError. Signed-off-by: John Ferlan Reviewed-by: Michal Privoznik --- src/util/vircgroup.c | 18 ++++++++---------- src/util/virfirewall.c | 6 ++++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index c6e4cf2dde..4c83e37ec4 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1168,13 +1168,12 @@ virCgroupNewMachineSystemd(const char *name, } =20 if (virCgroupAddProcess(*group, pidleader) < 0) { - virErrorPtr saved =3D virSaveLastError(); + virErrorPtr saved; + + virErrorPreserveLast(&saved); virCgroupRemove(*group); virCgroupFree(group); - if (saved) { - virSetError(saved); - virFreeError(saved); - } + virErrorRestore(&saved); } =20 return 0; @@ -1220,13 +1219,12 @@ virCgroupNewMachineManual(const char *name, goto cleanup; =20 if (virCgroupAddProcess(*group, pidleader) < 0) { - virErrorPtr saved =3D virSaveLastError(); + virErrorPtr saved; + + virErrorPreserveLast(&saved); virCgroupRemove(*group); virCgroupFree(group); - if (saved) { - virSetError(saved); - virFreeError(saved); - } + virErrorRestore(&saved); } =20 done: diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index 0d4bfae8f8..62f404afd6 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -838,7 +838,9 @@ virFirewallApply(virFirewallPtr firewall) if (virFirewallApplyGroup(firewall, i) < 0) { VIR_DEBUG("Rolling back groups up to %zu for %p", i, firewall); size_t first =3D i; - VIR_AUTOPTR(virError) saved_error =3D virSaveLastError(); + virErrorPtr saved_error; + + virErrorPreserveLast(&saved_error); =20 /* * Look at any inheritance markers to figure out @@ -858,7 +860,7 @@ virFirewallApply(virFirewallPtr firewall) virFirewallRollbackGroup(firewall, j); } =20 - virSetError(saved_error); + virErrorRestore(&saved_error); VIR_DEBUG("Done rolling back groups for %p", firewall); goto cleanup; } --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 23:48:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1571161083; cv=none; d=zoho.com; s=zohoarc; b=a7qF5CDTrrt4oWTlvNbz+rmRt93GwbP8XY1k24h4rY9i88eCfBS9OJaF2nd2GsK4AGiZdH9/jh024lRn2AlVjCKjXLkuwCtSTWjs5/aXjR7UD5CcZ7cDTYI0+sw8qvnJqLm+QCy5DzzJYF7kSXC9u7C6pBSP7mDWewslNq4WgP4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571161083; 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=+DDqHPQBd+/zatTJ+y5FsaYDWc1fIarYXIcmUqL9NaU=; b=h3lNe/Huok3+z0iXmjep13HNF6zVHMcrJRWa7pLNFi7i+Kl1EA/j+S6qVO3W+cGCp3i+ey4HGHkod+HxH/SH9MZ4rfJEI5DyV7+zV6O+aGlL2bei373ybazAj7DLC2MTW5xb3VoqvVNtQdYA1qHyq0SbsWj81/9cCKdEe8WA8ck= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1571161083083263.9342254340751; Tue, 15 Oct 2019 10:38:03 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 62A32307D974; Tue, 15 Oct 2019 17:38:01 +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 3EE29601B3; Tue, 15 Oct 2019 17:38:01 +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 03D39180B536; Tue, 15 Oct 2019 17:38:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9FHbdvR001265 for ; Tue, 15 Oct 2019 13:37:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 639825DA8C; Tue, 15 Oct 2019 17:37:39 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.com (ovpn-116-31.phx2.redhat.com [10.3.116.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23D2D5D9E2 for ; Tue, 15 Oct 2019 17:37:39 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Oct 2019 13:37:27 -0400 Message-Id: <20191015173728.1633-10-jferlan@redhat.com> In-Reply-To: <20191015173728.1633-1-jferlan@redhat.com> References: <20191015173728.1633-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/10] vz: Use consistent error preservation and restoration calls 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 15 Oct 2019 17:38:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Provide some consistency over error message variable name and usage when saving error messages across possible other errors or possibility of resetting of the last error. Instead of virSaveLastError paired up with virSetError and virFreeError, we should use the newer virErrorPreserveLast and virRestoreError. Signed-off-by: John Ferlan Reviewed-by: Michal Privoznik --- src/vz/vz_driver.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 917acdae57..b4049261ae 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -3206,7 +3206,7 @@ vzDomainMigratePerformP2P(virDomainObjPtr dom, */ if (uri && virTypedParamsReplaceString(¶ms, &nparams, VIR_MIGRATE_PARAM_URI, uri) < 0= ) { - orig_err =3D virSaveLastError(); + virErrorPreserveLast(&orig_err); goto finish; } =20 @@ -3216,7 +3216,7 @@ vzDomainMigratePerformP2P(virDomainObjPtr dom, cookieoutlen =3D 0; if (vzDomainMigratePerformStep(dom, driver, params, nparams, cookiein, cookieinlen, flags) < 0) { - orig_err =3D virSaveLastError(); + virErrorPreserveLast(&orig_err); goto finish; } =20 @@ -3242,10 +3242,7 @@ vzDomainMigratePerformP2P(virDomainObjPtr dom, /* confirm step is NOOP thus no need to call it */ =20 done: - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } + virErrorRestore(&orig_err); VIR_FREE(dom_xml); VIR_FREE(uri); VIR_FREE(cookiein); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 23:48:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1571161743; cv=none; d=zoho.com; s=zohoarc; b=HYHJd8/+WndO8O5hH4jbPxBWfVMv4WwBhPb7xVAHUwu+2QXWfIUCNvGl8REVNbJP9aqJhchvz5i5mpKa1TkaI8Jk2KtVJpaH0KT1DO3sJEx8mGE6jB9sEvX2zDSTT1SytSEDrAlL7O0FwzIY28OYxeSva8PKV50/OZH+TgqFfsw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571161743; 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=WhYaOWGJcZyEEUjfYw5BTSbmnsFg9M2tglaAE/wEMvA=; b=UZwTaucNpjdhuoq8cuW3/DGQVQXlFqUq94c+yHtM+swqIG+7OFODRl8C4+/g2tdqf93HhIQc0HpNsmk9nORR4VzKFkOnCqaXlGFggH1GT2LZQp8uNq2Z6Lmmv80NFEbS38uUASOPTW0X/XGw8Q50RIWXgXUSFqKE2f1Tu+3f8Dw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1571161743895457.4486988829706; Tue, 15 Oct 2019 10:49:03 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 33CB818C427D; Tue, 15 Oct 2019 17:49:02 +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 0DDA160852; Tue, 15 Oct 2019 17:49:02 +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 C05804EE69; Tue, 15 Oct 2019 17:49:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9FHbd4k001272 for ; Tue, 15 Oct 2019 13:37:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id CBEE05DA8C; Tue, 15 Oct 2019 17:37:39 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.com (ovpn-116-31.phx2.redhat.com [10.3.116.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BF455D9E2 for ; Tue, 15 Oct 2019 17:37:39 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Oct 2019 13:37:28 -0400 Message-Id: <20191015173728.1633-11-jferlan@redhat.com> In-Reply-To: <20191015173728.1633-1-jferlan@redhat.com> References: <20191015173728.1633-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/10] tools: Use consistent error preservation and restoration calls 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.62]); Tue, 15 Oct 2019 17:49:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Provide some consistency over error message variable name and usage when saving error messages across possible other errors or possibility of resetting of the last error. Instead of virSaveLastError paired up with virSetError and virFreeError, we should use the newer virErrorPreserveLast and virRestoreError. Signed-off-by: John Ferlan Reviewed-by: Michal Privoznik --- tools/virsh.c | 7 ++----- tools/virt-admin.c | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index 4aae877160..a3553ddd36 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -93,7 +93,7 @@ virshCatchDisconnect(virConnectPtr conn, virErrorPtr error; char *uri; =20 - error =3D virSaveLastError(); + virErrorPreserveLast(&error); uri =3D virConnectGetURI(conn); =20 switch ((virConnectCloseReason) reason) { @@ -114,10 +114,7 @@ virshCatchDisconnect(virConnectPtr conn, vshError(ctl, _(str), NULLSTR(uri)); VIR_FREE(uri); =20 - if (error) { - virSetError(error); - virFreeError(error); - } + virErrorRestore(&error); disconnected++; vshEventDone(ctl); } diff --git a/tools/virt-admin.c b/tools/virt-admin.c index c0cc0999cb..a820e7241d 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -124,7 +124,7 @@ vshAdmCatchDisconnect(virAdmConnectPtr conn G_GNUC_UNUS= ED, if (reason =3D=3D VIR_CONNECT_CLOSE_REASON_CLIENT) return; =20 - error =3D virSaveLastError(); + virErrorPreserveLast(&error); uri =3D virAdmConnectGetURI(conn); =20 switch ((virConnectCloseReason) reason) { @@ -146,10 +146,7 @@ vshAdmCatchDisconnect(virAdmConnectPtr conn G_GNUC_UNU= SED, vshError(ctl, _(str), NULLSTR(uri)); VIR_FREE(uri); =20 - if (error) { - virSetError(error); - virFreeError(error); - } + virErrorRestore(&error); } =20 static int --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list