From nobody Fri Mar 14 06:43:54 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=1678722255; cv=none; d=zohomail.com; s=zohoarc; b=YBV6pMAnHc37egxbOkvZqMIKDXLGhI0H9B3kSL0BnCd8Z09MfRrw/uuCaZF/AyZChZHBap7NAi1fTOFVKIumpEanzZdOgRcLR7X7D9pt5FC/2eREB0TpoFxyy9DWWHnN4ikRpitGhRyYjhhpSc2ZU9A9gFDJTG6Bwt5CGwr4ut4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678722255; 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=gr+H8Gu/ti/ETCuzkYCzNgmQyKt6HNALlubnIe7AoAc=; b=fAMd/vidCRBzZ6KFVRQlFIiu6ZvXnndbKJ46YbdghES6qDqQg1depBIJyhmjytcx3LQSPYHEn5ahKVyyJ+oCNWO9zEXQv/mesrq2DxcM44Z6FatFyNZjHmiGj+6Dl4to6PH6TrrqOLREPAUhlCd0CsGVml+IVozcOsbXPvW5q94= 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 167872225556748.50125270447063; Mon, 13 Mar 2023 08:44:15 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-522-kw85ZQBdO9aSb-vFuEMFgA-1; Mon, 13 Mar 2023 11:43:02 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B030780A1CB; Mon, 13 Mar 2023 15:42:44 +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 9CA8F492C14; Mon, 13 Mar 2023 15:42:44 +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 8E79D1946594; Mon, 13 Mar 2023 15:42:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CFE8A19465A2 for ; Mon, 13 Mar 2023 15:42:39 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A62532166B26; Mon, 13 Mar 2023 15:42:39 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.226.242]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48D322166B2A for ; Mon, 13 Mar 2023 15:42:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678722254; 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=gr+H8Gu/ti/ETCuzkYCzNgmQyKt6HNALlubnIe7AoAc=; b=QVv2I0G2TEKv1H4RJ8533VQ2Oqty7vXex4sZ3V4G9iLipTxw4qZ5HTHgPXmYvncN0jylly nORFobaLMIGBMYAPs1g8KqxOoIJFaKjMbqx5pzgDUla8HG0GWPpYWPP4jF1PUHkLjY1/Hb oI5pQ/fHyN/i/Cgld0Z5xRFsKAAJ3z8= X-MC-Unique: kw85ZQBdO9aSb-vFuEMFgA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 19/20] qemu_snapshot: add checks for external snapshot deletion Date: Mon, 13 Mar 2023 16:42:20 +0100 Message-Id: <9ef8f2c2ca057ed1bccb12e6f655c1f888f0d805.1678718987.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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.9 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: 1678722257470100004 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. Signed-off-by: Pavel Hrdina --- src/qemu/qemu_snapshot.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 05386b11fe..c6c7b077dd 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -3427,6 +3427,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")); @@ -3438,6 +3440,19 @@ 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; + } } =20 return 0; --=20 2.39.2