From nobody Sun Feb 8 18:48:48 2026 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1543335830363612.1744270394734; Tue, 27 Nov 2018 08:23:50 -0800 (PST) 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 330B1F81C; Tue, 27 Nov 2018 16:23:48 +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 F1ED25D738; Tue, 27 Nov 2018 16:23:47 +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 A6D8A181B9E4; Tue, 27 Nov 2018 16:23:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wARGNRdT017238 for ; Tue, 27 Nov 2018 11:23:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id D31551A90A; Tue, 27 Nov 2018 16:23:27 +0000 (UTC) Received: from unknown4CEB42C824F4.redhat.com (ovpn-117-184.phx2.redhat.com [10.3.117.184]) by smtp.corp.redhat.com (Postfix) with ESMTP id 932222633D for ; Tue, 27 Nov 2018 16:23:27 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 27 Nov 2018 11:23:22 -0500 Message-Id: <20181127162323.948-2-jferlan@redhat.com> In-Reply-To: <20181127162323.948-1-jferlan@redhat.com> References: <20181127162323.948-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] qemu: Save qemuDomainGetStats error 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: , MIME-Version: 1.0 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.28]); Tue, 27 Nov 2018 16:23:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" During qemuConnectGetAllDomainStats if qemuDomainGetStats causes a failure, then when collecting more than one domain's worth of statistics the loop in virDomainStatsRecordListFree would call virDomainFree which would call virResetLastError effectively wiping out the reason we failed leaving the caller with no idea why the collection failed. To fix this, let's save the error and restore it prior to return so that a caller such as 'virsh domstats' doesn't get the generic "error: An error occurred, but the cause is unknown". Signed-off-by: John Ferlan Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 7d9e17e72c..2fb8eef609 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -21092,6 +21092,7 @@ qemuConnectGetAllDomainStats(virConnectPtr conn, unsigned int flags) { virQEMUDriverPtr driver =3D conn->privateData; + virErrorPtr save_err =3D NULL; virDomainObjPtr *vms =3D NULL; virDomainObjPtr vm; size_t nvms; @@ -21160,6 +21161,7 @@ qemuConnectGetAllDomainStats(virConnectPtr conn, if (flags & VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING) domflags |=3D QEMU_DOMAIN_STATS_BACKING; if (qemuDomainGetStats(conn, vm, stats, &tmp, domflags) < 0) { + save_err =3D virSaveLastError(); if (HAVE_JOB(domflags) && vm) qemuDomainObjEndJob(driver, vm); =20 @@ -21184,6 +21186,10 @@ qemuConnectGetAllDomainStats(virConnectPtr conn, cleanup: virDomainStatsRecordListFree(tmpstats); virObjectListFreeCount(vms, nvms); + if (save_err) { + virSetError(save_err); + virFreeError(save_err); + } =20 return ret; } --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list