From nobody Sun Feb 8 20:13:28 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=1661272458; cv=none; d=zohomail.com; s=zohoarc; b=fKOL99gEea3GPfP0xTP6c0+mGPssu2bofJ0UTnKKSJZ5oRUfBBeNhNm13ztVksxw7YFRSERZvLwxUrVSqdA7CLATAzBUQIpsJumE4qC0lKd+w0Aqms1iwKS473f70bCVitYNqaZRErdVnlJ2DKU52a62VBER1KrvnE5kCfvKt78= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661272458; 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=n0eAiAk6B+c4mfse9fq4IE6DFnM6nqWB9Z3+LZnvVdE=; b=YISLt9VuzX2/ok0RHUz6kh2iD9QthDvxFns50thIMfi+WJzCd/z91X6+9o+SflP/TtygZO2MQGR9CDz3TyoZx90McGSaetwMVZge66GbWtWtQ2aZxOjBr+mFzwPDcXwMGCWQtSYfp5h6u9xkI4F4cLmKFVp83aplM7sTeNRjon4= 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 1661272458949547.302468160994; Tue, 23 Aug 2022 09:34:18 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-492-Q1YlX0HSNXKJRVRAzzT_cw-1; Tue, 23 Aug 2022 12:33:08 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 54C0C1C00ACE; Tue, 23 Aug 2022 16:32:43 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3EF6640315A; Tue, 23 Aug 2022 16:32:43 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 237A91946A47; Tue, 23 Aug 2022 16:32:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 348281946A61 for ; Tue, 23 Aug 2022 16:32:40 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1824140334B; Tue, 23 Aug 2022 16:32:40 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.194]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD80F492C3B for ; Tue, 23 Aug 2022 16:32:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661272458; 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=n0eAiAk6B+c4mfse9fq4IE6DFnM6nqWB9Z3+LZnvVdE=; b=GQkbQVbjrWRvl8HaA5yMe7wsO2ZsY9n32HzYJeOsaXpxo3qubWjvYmVC5AhNRFF+tQ9Rf3 5uWJs8z/rmoCZE+RgF97KTjBENFF2mldBK5ZHoQXHY8oBzurVQnPPNE7bkuyW/oZrvIJHl 7Omsy9Mw4k3NAzfYQi2oLqcMkSpFCZI= X-MC-Unique: Q1YlX0HSNXKJRVRAzzT_cw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt RFC 10/24] qemu_snapshot: extract single snapshot deletion to separate function Date: Tue, 23 Aug 2022 18:32:13 +0200 Message-Id: <767e4c745c47e25136a592b230d27e0b8227297e.1661271812.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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: 1661272459939100003 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 46 ++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index c1c67ac445..b5e6a87566 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2281,6 +2281,35 @@ qemuSnapshotChildrenReparent(void *payload, } =20 =20 +static int +qemuSnapshotDeleteSingle(virDomainObj *vm, + virDomainMomentObj *snap, + virQEMUDriver *driver, + bool metadata_only) +{ + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + + if (snap->nchildren) { + virQEMUMomentReparent rep; + + rep.dir =3D cfg->snapshotDir; + rep.parent =3D snap->parent; + rep.vm =3D vm; + rep.err =3D 0; + rep.xmlopt =3D driver->xmlopt; + rep.writeMetadata =3D qemuDomainSnapshotWriteMetadata; + virDomainMomentForEachChild(snap, + qemuSnapshotChildrenReparent, + &rep); + if (rep.err < 0) + return -1; + virDomainMomentMoveChildren(snap, snap->parent); + } + + return qemuDomainSnapshotDiscard(driver, vm, snap, true, metadata_only= ); +} + + int qemuSnapshotDelete(virDomainObj *vm, virDomainSnapshotPtr snapshot, @@ -2290,7 +2319,6 @@ qemuSnapshotDelete(virDomainObj *vm, int ret =3D -1; virDomainMomentObj *snap =3D NULL; virQEMUMomentRemove rem; - virQEMUMomentReparent rep; bool metadata_only =3D !!(flags & VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_= ONLY); int external =3D 0; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); @@ -2358,21 +2386,7 @@ qemuSnapshotDelete(virDomainObj *vm, ret =3D qemuDomainSnapshotDiscard(driver, vm, snap, true, meta= data_only); } } else { - if (snap->nchildren) { - rep.dir =3D cfg->snapshotDir; - rep.parent =3D snap->parent; - rep.vm =3D vm; - rep.err =3D 0; - rep.xmlopt =3D driver->xmlopt; - rep.writeMetadata =3D qemuDomainSnapshotWriteMetadata; - virDomainMomentForEachChild(snap, - qemuSnapshotChildrenReparent, - &rep); - if (rep.err < 0) - goto endjob; - virDomainMomentMoveChildren(snap, snap->parent); - } - ret =3D qemuDomainSnapshotDiscard(driver, vm, snap, true, metadata= _only); + ret =3D qemuSnapshotDeleteSingle(vm, snap, driver, metadata_only); } =20 endjob: --=20 2.37.2