From nobody Sun Feb 8 09:27:00 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1642011073; cv=none; d=zohomail.com; s=zohoarc; b=fFIIOgNEGU+p3i8whIjRNOjSX59UYuktGF+aN7T4iHDswy3TjOUH4fBCAH7HCKBpBxez2vAcYmTd5cl2wq3+cR9hg4MswMoJHCY93xG7ekvDhHbkHVW7wOD4BZwcTCs1U8fVwI1FW1D1P/5Zm3kdPuwbM+1mK+KHFbUyW564me8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642011073; 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=VMVHTJjmExJkak2/87RrbMZPKSvadRsQ2gCNWfX99Hw=; b=hCqEeUjUo1SAtKPYeWveXUQd0hB8IAhYwKJNMBTmFesskyhvgtMUZ4RmhGTH6e4E5HLjwd+/vLtr04OqjtACRywdM/M/asPOZ46yO8orBJHCkGa8+okdlmqBgWjcYV+7V+I9SEcezpRVYQFTHYEWdHp1Um/tD0MhmTodMwvE4I4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1642011073432864.8688921630079; Wed, 12 Jan 2022 10:11:13 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-633-7M_yw_JTPBenhRoaSh7CBg-1; Wed, 12 Jan 2022 13:10:59 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 75DF29251F; Wed, 12 Jan 2022 18:10:53 +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 50C7E7E64F; Wed, 12 Jan 2022 18:10:53 +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 16FDA4BB7C; Wed, 12 Jan 2022 18:10:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20CIAoU3003166 for ; Wed, 12 Jan 2022 13:10:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id EE6B08AC23; Wed, 12 Jan 2022 18:10:50 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5CD3D8AC21 for ; Wed, 12 Jan 2022 18:10:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642011069; 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=VMVHTJjmExJkak2/87RrbMZPKSvadRsQ2gCNWfX99Hw=; b=Mz0UtA+Saa1mRnZ40TnhMlDfVKs+sGMGtaWhHUw1K4gwIhBJ/qTYxulFHJYqhddcKeerHl J5LoM9N5l+CbmasL5+ZHtNPW18oMkaEfJNqh+KbcoRbLh3UF4M2pN8fHDSmchQGvv8rabl Cuy0sI37VMcrHIpRGcr5P8svgbcEUi0= X-MC-Unique: 7M_yw_JTPBenhRoaSh7CBg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 15/17] qemuDomainSnapshotLoad: Refactor handling of snapshot definition object Date: Wed, 12 Jan 2022 19:10:15 +0100 Message-Id: <9cfd151e312feffcbf3e13f9e3309587747b7b82.1642010887.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642011075385100001 Content-Type: text/plain; charset="utf-8" Move the variable holding the snapshot definition into the loop and use automatic clearing for it. Adjust the code for parity. Note that the clearing of 'snapdef' on success of 'virDomainSnapshotAssignDef' will be refactored in upcoming patches. Signed-off-by: Peter Krempa --- src/qemu/qemu_driver.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 65ac5ef367..b3588f9478 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -343,7 +343,6 @@ qemuDomainSnapshotLoad(virDomainObj *vm, g_autofree char *snapDir =3D NULL; g_autoptr(DIR) dir =3D NULL; struct dirent *entry; - virDomainSnapshotDef *def =3D NULL; virDomainMomentObj *snap =3D NULL; virDomainMomentObj *current =3D NULL; bool cur; @@ -367,6 +366,7 @@ qemuDomainSnapshotLoad(virDomainObj *vm, goto cleanup; while ((direrr =3D virDirRead(dir, &entry, NULL)) > 0) { + g_autoptr(virDomainSnapshotDef) snapdef =3D NULL; g_autofree char *xmlStr =3D NULL; g_autofree char *fullpath =3D NULL; @@ -384,11 +384,11 @@ qemuDomainSnapshotLoad(virDomainObj *vm, continue; } - def =3D virDomainSnapshotDefParseString(xmlStr, - qemu_driver->xmlopt, - priv->qemuCaps, &cur, - flags); - if (def =3D=3D NULL) { + snapdef =3D virDomainSnapshotDefParseString(xmlStr, + qemu_driver->xmlopt, + priv->qemuCaps, &cur, + flags); + if (snapdef =3D=3D NULL) { /* Nothing we can do here, skip this one */ virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to parse snapshot XML from file '%s'"= ), @@ -396,10 +396,10 @@ qemuDomainSnapshotLoad(virDomainObj *vm, continue; } - snap =3D virDomainSnapshotAssignDef(vm->snapshots, def); - if (snap =3D=3D NULL) { - virObjectUnref(def); - } else if (cur) { + snap =3D virDomainSnapshotAssignDef(vm->snapshots, snapdef); + if (snap) + snapdef =3D NULL; + if (cur && snap) { if (current) virReportError(VIR_ERR_INTERNAL_ERROR, _("Too many snapshots claiming to be curren= t for domain %s"), --=20 2.31.1