From nobody Mon Sep 16 20:03:47 2024 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=1678722210; cv=none; d=zohomail.com; s=zohoarc; b=nkKMIMPDTmqRq33lLoWu8jP/bA06X+lSsMgFOd/GIZlVc13rEgUZYYhvebQ7yF9c5ccpmvb9YZWkqqkA2/7c4SvOjh7+4QsLxw1drZo/+1Tzd5kuP4r8OU4DPojjvnQEDbKiXVC5ZDqOZRHFBOGw2L0DSUfsRTfHHxKdAuwQkaM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678722210; 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=R5Fw4wKu73fJrY8EJIDJOvus8kNUL/8AyvRYMDkJdOI=; b=L5mYDVgWjOU2+h3Ns815afzpABtNkk2MsghTLB2khG5XSUxmmtc9m6HnDey3zvy/VlEcQil0L2Yrnt0Sn1Vwe6H9l1FzDdgtZVNixW2tGjZqd1aHhuQ/HO4Pg2mxZ9AS/YsDiZ4BVVJjDWrbBAlNdr2q7P8/9YhU5ZEGkpEyaxM= 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 16787222106851013.2364021628593; Mon, 13 Mar 2023 08:43:30 -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-270-oa1elAZGPSOis8jY8Cn_tg-1; Mon, 13 Mar 2023 11:43:01 -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 2740338123BB; Mon, 13 Mar 2023 15:42: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 12428C164E7; Mon, 13 Mar 2023 15:42: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 DED6119465B2; Mon, 13 Mar 2023 15:42:39 +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 A8E8B1946594 for ; Mon, 13 Mar 2023 15:42:36 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 890DC2166B30; Mon, 13 Mar 2023 15:42:36 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.226.242]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E4D92166B26 for ; Mon, 13 Mar 2023 15:42:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678722209; 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=R5Fw4wKu73fJrY8EJIDJOvus8kNUL/8AyvRYMDkJdOI=; b=gcgiXCBZqNcd3IuZpipLxeONn3l599w0L1kaf+HwkiBnkdbOldojy0Ir6oYJZOMPMk86Sy 9dd1AMLLmLws75NDOyEmv1dUKyq6qPGqXgKzu5VBcjklZI7fQ/twwUQGUuwL3XwLXMa/Wg zWMXL4QjLzSQXHh25SCHNWxOC3ovDak= X-MC-Unique: oa1elAZGPSOis8jY8Cn_tg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 14/20] qemu_snapshot: add support to delete external snapshot without block commit Date: Mon, 13 Mar 2023 16:42:15 +0100 Message-Id: <698e4183d7d6a879615e9cceea6ff47f5fff7cbc.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.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: 1678722211195100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When block commit is not needed we can just simply unlink the disk files. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 55 +++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index be2e5c8cc4..dbcdf56758 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2414,6 +2414,7 @@ typedef struct _qemuSnapshotDeleteExternalData { virStorageSource *prevDiskSrc; /* source of disk for which @diskSrc is backing disk */ qemuBlockJobData *job; + bool blockCommit; } qemuSnapshotDeleteExternalData; =20 =20 @@ -2517,8 +2518,9 @@ qemuSnapshotDeleteExternalPrepareData(virDomainObj *v= m, =20 data =3D g_new0(qemuSnapshotDeleteExternalData, 1); data->snapDisk =3D snapDisk; + data->blockCommit =3D blockCommit; =20 - if (blockCommit) { + if (data->blockCommit) { data->domDisk =3D qemuDomainDiskByName(vm->def, snapDisk->name= ); if (!data->domDisk) return -1; @@ -2949,31 +2951,41 @@ qemuSnapshotDiscardExternal(virDomainObj *vm, virTristateBool autofinalize =3D VIR_TRISTATE_BOOL_NO; unsigned int commitFlags =3D VIR_DOMAIN_BLOCK_COMMIT_DELETE; =20 - if (data->domDisk->src =3D=3D data->diskSrc) { - commitFlags |=3D VIR_DOMAIN_BLOCK_COMMIT_ACTIVE; - autofinalize =3D VIR_TRISTATE_BOOL_YES; + if (data->blockCommit) { + if (data->domDisk->src =3D=3D data->diskSrc) { + commitFlags |=3D VIR_DOMAIN_BLOCK_COMMIT_ACTIVE; + autofinalize =3D VIR_TRISTATE_BOOL_YES; + } + + if (qemuSnapshotSetInvalid(vm, data->parentSnap, data->snapDis= k, true) < 0) + goto error; + + data->job =3D qemuBlockCommit(vm, + data->domDisk, + data->parentDiskSrc, + data->diskSrc, + data->prevDiskSrc, + 0, + VIR_ASYNC_JOB_SNAPSHOT, + autofinalize, + commitFlags); + + if (!data->job) + goto error; + } else { + if (unlink(data->snapDisk->src->path) < 0) { + VIR_WARN("Failed to remove snapshot image '%s'", + data->snapDisk->name); + } } - - if (qemuSnapshotSetInvalid(vm, data->parentSnap, data->snapDisk, t= rue) < 0) - goto error; - - data->job =3D qemuBlockCommit(vm, - data->domDisk, - data->parentDiskSrc, - data->diskSrc, - data->prevDiskSrc, - 0, - VIR_ASYNC_JOB_SNAPSHOT, - autofinalize, - commitFlags); - - if (!data->job) - goto error; } =20 for (cur =3D externalData; cur; cur =3D g_slist_next(cur)) { qemuSnapshotDeleteExternalData *data =3D cur->data; =20 + if (!data->blockCommit) + continue; + if (qemuSnapshotDeleteBlockJobRunning(vm, data->job) < 0) goto error; =20 @@ -2988,6 +3000,9 @@ qemuSnapshotDiscardExternal(virDomainObj *vm, for (cur =3D externalData; cur; cur =3D g_slist_next(cur)) { qemuSnapshotDeleteExternalData *data =3D cur->data; =20 + if (!data->blockCommit) + continue; + if (data->job->state =3D=3D QEMU_BLOCKJOB_STATE_READY) { if (qemuBlockPivot(vm, data->job, VIR_ASYNC_JOB_SNAPSHOT, NULL= ) < 0) goto error; --=20 2.39.2