From nobody Mon Feb 9 01:47:27 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=1642011135; cv=none; d=zohomail.com; s=zohoarc; b=fsZ4edqSfqq3Xk3Wu0xUILfsKqBIX4xUz4GQOfT6RfYtZItVFcZDEy8hyWPvOxxfTNmLTTMH19FKyjflWkyxdPpTR9JT1EjD390RaL8nawVrGUNsRnb0Z2F12LfeA42YnZPDX92EBNqjSMYxfPtMgRBZh4/LGBJiLA2ESkiJNTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642011135; 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=PkKpzomalVkKcOQX2PEyjb7PgEFAOzg9VIBty6RVz7c=; b=POlMlUYa9lsa5EHiLrhZx2o50W5DMdtXioSW5PG9L2Fj4HJfS1qw6fsLL6RXIU1gk6nnhR2a6N9y5VmgrDdqMbEGRvbz5THGWn6jWMV1UehpUBqkrtj0pQ+PFYvZK7JBRtINSs6f1l29SpWfqONSbv6TAR4j0ZT1gdV1reh/TUQ= 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 164201113569257.978624826018745; Wed, 12 Jan 2022 10:12:15 -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-208-xkTMSIHANPGdJbTMW9XJoA-1; Wed, 12 Jan 2022 13:11:36 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B9EC687499B; Wed, 12 Jan 2022 18:11:30 +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 8CD7D1091EDC; Wed, 12 Jan 2022 18:11:30 +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 4DB831806D2D; Wed, 12 Jan 2022 18:11:30 +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 20CIAnDi003156 for ; Wed, 12 Jan 2022 13:10:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id E62378AC21; Wed, 12 Jan 2022 18:10:49 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43F658AD18 for ; Wed, 12 Jan 2022 18:10:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642011134; 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=PkKpzomalVkKcOQX2PEyjb7PgEFAOzg9VIBty6RVz7c=; b=S8NpCK5m8UBv0piHyB7S3os4UhXdvWtlHT3UlUcNpw7oANnuXXaP+k2htenKLY45i5eT2t p+39csO9niR59n0Zn5uTwuXbgexjAtoT8qBhLyq/QTlZwNRru9V6apr15hr9z6fPUEf76V YHmNZ8afW1hD8FSH3Qig7gwd3+nGtoU= X-MC-Unique: xkTMSIHANPGdJbTMW9XJoA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/17] qemuSnapshotCreate: Standardize handling of the reference on @snapdef Date: Wed, 12 Jan 2022 19:10:14 +0100 Message-Id: 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.84 on 10.5.11.22 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: 1642011136238100001 Content-Type: text/plain; charset="utf-8" As with qemuSnapshotRedefine, make an extra reference in a temporary autocleaned variable and use that instead of refing the definition after it's stolen. Signed-off-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 5f256a77df..c5379d583e 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1750,11 +1750,12 @@ qemuSnapshotRedefine(virDomainObj *vm, static virDomainSnapshotPtr qemuSnapshotCreate(virDomainObj *vm, virDomainPtr domain, - virDomainSnapshotDef *snapdef, + virDomainSnapshotDef *snapdeftmp, virQEMUDriver *driver, virQEMUDriverConfig *cfg, unsigned int flags) { + g_autoptr(virDomainSnapshotDef) snapdef =3D virObjectRef(snapdeftmp); g_autoptr(virDomainMomentObj) tmpsnap =3D NULL; virDomainMomentObj *snap =3D NULL; virDomainMomentObj *current =3D NULL; @@ -1769,17 +1770,17 @@ qemuSnapshotCreate(virDomainObj *vm, if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA) { snap =3D tmpsnap =3D virDomainMomentObjNew(); snap->def =3D &snapdef->parent; + snapdef =3D NULL; } else { if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, snapdef))) return NULL; + snapdef =3D NULL; if ((current =3D virDomainSnapshotGetCurrent(vm->snapshots))) { snap->def->parent_name =3D g_strdup(current->def->name); } } - virObjectRef(snapdef); - /* actually do the snapshot */ if (virDomainObjIsActive(vm)) { if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY || --=20 2.31.1