From nobody Fri Dec 19 19:20:16 2025 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=1687878999; cv=none; d=zohomail.com; s=zohoarc; b=m/8mVCelhS4VXcir82n5mE5/KwbeNZDR04kOR2B6tSV38P4q0l3Pneq/ZEhrQ/XOyv4QQ1k4iJP9VJZ2jSemtjfukpECcyHrx/YXgAvmN+x21o4Aj+3nIxtkzcgLgUjFiI+ZZZc/ZFgf3dAYc6n1xvOwwJNWthD/V8Q4HaIC+os= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687878999; 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=+b6K0ibHqikSXtjdakwAkGnjJ4KGxmI+C9JJPkoGZyY=; b=nHDf9m8Swr0rp/aA+7hDlLx/vndr5/jva2aN01dsa183yJVxtmaN5UL22JYO7uTy8E+4MKDWrEtUTKXj9LFBPwXm0E7zSfFy7ZWkuaQt+zyFnP0X64EgOfoI+3Y0/WoDO+F0ntl5YpFVBw6cDbux/ytLOKpg9kw2g3IDbY/Ao0A= 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 168787899928716.13001974942142; Tue, 27 Jun 2023 08:16:39 -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-465-REkINKBdNdy4JKUJwaehUA-1; Tue, 27 Jun 2023 11:15:26 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CCD14299E76D; Tue, 27 Jun 2023 15:08:06 +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 B69C0C478C6; Tue, 27 Jun 2023 15:08:06 +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 A0E1419451E5; Tue, 27 Jun 2023 15:07:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D20151946588 for ; Tue, 27 Jun 2023 15:07:42 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C2C7E48FB01; Tue, 27 Jun 2023 15:07:42 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 66ADE48FB02 for ; Tue, 27 Jun 2023 15:07:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687878998; 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=+b6K0ibHqikSXtjdakwAkGnjJ4KGxmI+C9JJPkoGZyY=; b=PFkSqAbfbwLCXLeyRPBxUbb5Z86zydmJYC1VH1km7xkq0B/VVnf75X+eG+uryNa5du18Fl UEbBvTGPa2Thia2tWe2upOfILzAaa+4IxXa78FqYMsUolPZL+jh8QYGVaF2AZ/Ms2OAn38 uqQqWTSYceUlvk0FkiTP4ydb59ylMTQ= X-MC-Unique: REkINKBdNdy4JKUJwaehUA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 23/24] qemu_snapshot: add checks for external snapshot deletion Date: Tue, 27 Jun 2023 17:07:26 +0200 Message-ID: <9d095626099da72faaf0a2337db06497575530d1.1687877087.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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 3.1 on 10.11.54.8 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: 1687878999874100001 Content-Type: text/plain; charset="utf-8"; x-default="true" With the introduction of external snapshot revert support we need to error out in some cases when trying to delete some snapshots. If users reverts to non-leaf snapshots and would try to delete it after the revert is done it would not work currently as this operation would require using block-stream which is not implemented for now as in this case the snapshot has two children so the disk files have multiple overlays. Similarly if user reverts to non-leaf snapshot and would try to delete snapshot that is non-leaf but not in currently active snapshot chain we would still need to use block-commit operation. The issue here is that in order to do that we would have to start new qemu process with different domain definition than what is currently used by the domain. If the current domain would be running it would complicate things even more so this operation is not yet supported. If user creates new snapshot after reverting to non-leaf snapshot it creates a new branch. Deleting snapshot with multiple children will require block-stream which is not implemented for now. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 9246c02f12..9e8a7f2f9f 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -3636,6 +3636,8 @@ qemuSnapshotDeleteValidate(virDomainObj *vm, } =20 if (virDomainSnapshotIsExternal(snap)) { + virDomainMomentObj *current =3D virDomainSnapshotGetCurrent(vm->sn= apshots); + if (qemuDomainHasBlockjob(vm, false)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("cannot delete external snapshots when there = is another active block job")); @@ -3647,6 +3649,25 @@ qemuSnapshotDeleteValidate(virDomainObj *vm, _("deletion of external disk snapshots with chi= ldren not supported")); return -1; } + + if (snap =3D=3D current && snap->nchildren !=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("deletion of active external snapshot that is= not a leaf snapshot is not supported")); + return -1; + } + + if (snap !=3D current && snap->nchildren !=3D 0 && + virDomainMomentIsAncestor(snap, current)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("deletion of non-leaf external snapshot that = is not in active chain is not supported")); + return -1; + } + + if (snap->nchildren > 1) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("deletion of external disk snapshot with mult= iple children snapshots not supported")); + return -1; + } } =20 return 0; --=20 2.41.0