From nobody Mon Feb 9 03:52:01 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1641894842; cv=none; d=zohomail.com; s=zohoarc; b=dm+xr4Shd6iHDXYj5+WRVecLxeXXPnLhYSnNetxoUx65j9i4uzUM2WHtCibo7jqtYG3QWBk9Lfo/s+fiTMlA9WkSubOEFa2nyYVrUDo+8QJG6aX9CrkiIUir1yDnJFY18Zf33NnnYuOR11DOJdI7WjOv9/K+M/mw5/6aw7qOE+8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641894842; 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=EETsKaZYo4uIuFkK+u1l6LFFvp5RaARTEybZfBOEbt4=; b=lfnarRrfBlWO4lkoBHbAfpShJmYdM62LLy72NRbN3iNjDlkjYadnMvUKkTOXC7YvF5BMeOX+G1nrGUUCn6eq/A7ffmNA/FqrQ0Vj3Hj3JJUv2VBKWsTejt1VzdsfS+1vscyQVjbS3iV8fPZfNUtOCUgz9ethMah0PVHFA1kZsyQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1641894842460849.6068237018693; Tue, 11 Jan 2022 01:54:02 -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-564-zu7OmJZCPyeWTht71nDfPw-1; Tue, 11 Jan 2022 04:53:35 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 25FF1871801; Tue, 11 Jan 2022 09:53:31 +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 03D1A6F11C; Tue, 11 Jan 2022 09:53:31 +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 C38C14CA9B; Tue, 11 Jan 2022 09:53:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20B9rS1Q002602 for ; Tue, 11 Jan 2022 04:53:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1A8E81059154; Tue, 11 Jan 2022 09:53:28 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 781241059155 for ; Tue, 11 Jan 2022 09:53:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641894841; 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=EETsKaZYo4uIuFkK+u1l6LFFvp5RaARTEybZfBOEbt4=; b=NauzAuBFkZF1j+xIuweX8bQ8Zv938i5CBtIX5SF8IykOjAOmxKsLa4+8ewMbS3RFs83luu 2DhOe8oper3tAnrLCqLoTZF4dg+HF9D9Cgw7Zr6T+OuxxF0iO1rPpY0ipMpZZ/otqnGb6i IHRukVYjJT1byh8Do/8TjKwoChO3xBs= X-MC-Unique: zu7OmJZCPyeWTht71nDfPw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/3] qemuSnapshotCreate: Don't insert snapshot into list with VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA Date: Tue, 11 Jan 2022 10:53:22 +0100 Message-Id: <68fed3242164f50582b9fca4a31ded7a903ad92a.1641894644.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.15 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: 1641894846329100001 Content-Type: text/plain; charset="utf-8" Our approach to snapshots without metadata was to insert them to the snapshot list and then later remove them from the list when the flag is present. This quirky logic was broken in a recent refactor of the snapshot code causing that the snapshot stayed inserted in the snapshot list. Recent refactor of the snapshot code didn't faithfully relocate this logic to the new function. Rather than attempting to restore the quirky logic of adding and then removing the object, don't add the snapshot into the list at all when the user doesn't want metadata. We achieve this by creating a temporary 'virDomainMomentObj' wrapper which is not inserted into the list and using that instead of calling virDomainSnapshotAssignDef. Fixes: 9bad0fb809b Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2039131 Signed-off-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 9a5d3e60aa..e9fc9051c1 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1756,7 +1756,7 @@ qemuSnapshotCreate(virDomainObj *vm, virQEMUDriverConfig *cfg, unsigned int flags) { - + g_autoptr(virDomainMomentObj) noMetadataSnap =3D NULL; virDomainMomentObj *snap =3D NULL; virDomainMomentObj *current =3D NULL; virDomainSnapshotPtr ret =3D NULL; @@ -1767,16 +1767,20 @@ qemuSnapshotCreate(virDomainObj *vm, if (qemuSnapshotPrepare(vm, def, &flags) < 0) return NULL; - if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, def))) - return NULL; - - virObjectRef(def); + if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA) { + snap =3D noMetadataSnap =3D virDomainMomentObjNew(); + snap->def =3D &def->parent; + } else { + if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, def))) + return NULL; - current =3D virDomainSnapshotGetCurrent(vm->snapshots); - if (current) { - snap->def->parent_name =3D g_strdup(current->def->name); + if ((current =3D virDomainSnapshotGetCurrent(vm->snapshots))) { + snap->def->parent_name =3D g_strdup(current->def->name); + } } + virObjectRef(def); + /* actually do the snapshot */ if (virDomainObjIsActive(vm)) { if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY || @@ -1804,7 +1808,7 @@ qemuSnapshotCreate(virDomainObj *vm, } } - if (!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) { + if (!noMetadataSnap) { qemuSnapshotSetCurrent(vm, snap); if (qemuSnapshotCreateWriteMetadata(vm, snap, driver, cfg) < 0) @@ -1818,7 +1822,8 @@ qemuSnapshotCreate(virDomainObj *vm, return ret; error: - virDomainSnapshotObjListRemove(vm->snapshots, snap); + if (!noMetadataSnap) + virDomainSnapshotObjListRemove(vm->snapshots, snap); return NULL; } --=20 2.31.1