From nobody Sun Feb 8 12:51:38 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=1661272452; cv=none; d=zohomail.com; s=zohoarc; b=Q4eGw3sTn7pESZ5UF53rrt/kPICWZK15EzuvTcfuAjbBU8HoCBr8ou5cFD8dPzfPuIp2asDI0Ard9MEEmfuPIGEo8emRIag7YPIV2fJWBRBQWTEKXfAI1gUp69HlR/jC6kixaWPa3xywTHfoyOYqGNjxTjA7+5y8EvcJWBxyXFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661272452; 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=A/X91Dx0VgMsC2KlgWRWwOy3ry0ug0SYlZbwyLUcn/k=; b=C9iRZuMB9yyam3xhbFREvpAC9gD06eTxMO6upwb+B5v7BWHsCD84tVyPIECwLLMZeJJl0EyZWSQ4Y37w2kAcAwIGFralwuwJ8e8cHXEXWXH/xO+vMN3GOzgN7Zvf+m/mlT+xp2FZOxCkQjlOh2GRQVm7NAmabUzVlBgRkj/xC0s= 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 1661272452811512.018396071981; Tue, 23 Aug 2022 09:34:12 -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-661-cjdeZfluNs23uaiBJJMfVA-1; Tue, 23 Aug 2022 12:33:05 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A03E83C10686; Tue, 23 Aug 2022 16:32:40 +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 89852945D2; Tue, 23 Aug 2022 16:32:40 +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 6675A1946A61; Tue, 23 Aug 2022 16:32:40 +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 EF3641946A40 for ; Tue, 23 Aug 2022 16:32:38 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E3A3540334C; Tue, 23 Aug 2022 16:32:38 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.194]) by smtp.corp.redhat.com (Postfix) with ESMTP id 855D9492C3B for ; Tue, 23 Aug 2022 16:32:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661272451; 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=A/X91Dx0VgMsC2KlgWRWwOy3ry0ug0SYlZbwyLUcn/k=; b=OAGR08FSfM6KIlJJN5b6vI5pLULNRO5ZxyPaxuWHmUZ5EBOWIwX01k0Irf08jmsrBbaa63 NKgJszLa409YN2K154jWs8E3r2E4iN6A6lcHN4d0/t+Kat6JY9ezME+FKSizfC0sAYI/h8 fkhdFrZY4rDIz+UiVbjhqAZR3GV7df8= X-MC-Unique: cjdeZfluNs23uaiBJJMfVA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt RFC 09/24] qemu_snapshot: refactor qemuSnapshotDelete Date: Tue, 23 Aug 2022 18:32:12 +0200 Message-Id: <0c04e2d42d58454a2541b2cc762a63821804da0d.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.79 on 10.11.54.5 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: 1661272453808100008 Content-Type: text/plain; charset="utf-8"; x-default="true" Move code around to make it clear what is called when deleting single snapshot or children snapshots. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 6033deafed..c1c67ac445 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2350,25 +2350,28 @@ qemuSnapshotDelete(virDomainObj *vm, } } } - } 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); - } =20 - if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) { - virDomainMomentDropChildren(snap); - ret =3D 0; + if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) { + virDomainMomentDropChildren(snap); + ret =3D 0; + } else { + 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); } =20 --=20 2.37.2