From nobody Mon Feb 9 12:25:15 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 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=1574243747; cv=none; d=zoho.com; s=zohoarc; b=HmFkfIt4+uy+2dBJrbB5zTOdEr5pW2MmedSmGhVO8o+vFwvObkU1lG6I11bNZY5JJJi/NshzZVZGcgij+IPjctjp8gfUsZL0QZSMST2GHGm81rqJNNed53wPPy5A5kLGDSzX0EpO4/BofcUMgdEbYjq5PkUS4uSjepctDmTnO7w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574243747; h=Content-Type:Content-Transfer-Encoding:Cc: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=CyCrZxVAgtcBUGR0jBXUoVjO9zXi145g7Xa69pi16K8=; b=E7Fndu6Jpjy+Sbo8/RtDaIt/Aa+fTCzOTmuzaDB4c5Yp039TDimdbvgID5j82BNOqFK6RpfmhpAbdTTnaaABgTuJbdqJ3ztIchdzzFs3+uJVOiFH8/dcMWk3dzZofqFci4KukPgH1mr4ce0+9fNp2fvxgCddj2d1ovMyCjdDh68= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1574243747916831.9454447485527; Wed, 20 Nov 2019 01:55:47 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-171-ZIUTzgmgNLKr3lOoZpU1RQ-1; Wed, 20 Nov 2019 04:55:44 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1A423802689; Wed, 20 Nov 2019 09:55:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DF85267E60; Wed, 20 Nov 2019 09:55:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 997CF4E562; Wed, 20 Nov 2019 09:55:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xAK9tYwx025741 for ; Wed, 20 Nov 2019 04:55:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id 76E334DA73; Wed, 20 Nov 2019 09:55:34 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE2664D9F7; Wed, 20 Nov 2019 09:55:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574243746; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=CyCrZxVAgtcBUGR0jBXUoVjO9zXi145g7Xa69pi16K8=; b=bQzAfIv9qmrwSjg6Kt2P/1GEkEC95zJlkelm9hSutVXdWu0iteJhkqxEG140opFadhyCSo 8ZoJym0WW/HEI5pujeu4+Ijce3zU0w8lXeYykcLrTGDYxTihJHc4bMuc7y/pv69xEAIIAl 2olhNNxDVFgTuowYRi5MiLZd0nWNqU4= From: Pavel Mores To: libvir-list@redhat.com Date: Wed, 20 Nov 2019 10:55:25 +0100 Message-Id: <20191120095527.18158-3-pmores@redhat.com> In-Reply-To: <20191120095527.18158-1-pmores@redhat.com> References: <20191120095527.18158-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Pavel Mores Subject: [libvirt] [PATCH 2/4] qemu: block: use the delete flag to delete snapshot images if requested X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: ZIUTzgmgNLKr3lOoZpU1RQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" When blockcommit finishes successfully, one of the qemuBlockJobProcessEventCompletedCommit() and qemuBlockJobProcessEventCompletedActiveCommit() event handlers is called. This is where the delete flag (stored in qemuBlockJobCommitData since the previous commit) can actually be used to delete the committed snapshot images if requested. Signed-off-by: Pavel Mores --- src/qemu/qemu_blockjob.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 7d94a6ce38..dae1fa44c8 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -965,6 +965,31 @@ qemuBlockJobProcessEventCompletedPull(virQEMUDriverPtr= driver, } =20 =20 +/** + * Helper for qemuBlockJobProcessEventCompletedCommit() and + * qemuBlockJobProcessEventCompletedActiveCommit(). Relies on adjustments + * these functions perform on the 'backingStore' chain to function correct= ly. + * + * TODO look into removing backing store for non-local snapshots too + */ +static void +qemuBlockJobUnlinkCommittedStorage(virStorageSourcePtr top) +{ + virStorageSourcePtr p =3D top; + const size_t errmsg_len =3D 128; + char errmsg[errmsg_len]; + + for (; p !=3D NULL; p =3D p->backingStore) { + if (virStorageSourceIsLocalStorage(p)) + if (unlink(p->path) < 0) { + char *dummy =3D strerror_r(errno, errmsg, errmsg_len); + (void)dummy; + VIR_WARN("Unable to remove snapshot image file %s (%s)", + p->path, errmsg); + } + } +} + /** * qemuBlockJobProcessEventCompletedCommit: * @driver: qemu driver object @@ -1031,6 +1056,9 @@ qemuBlockJobProcessEventCompletedCommit(virQEMUDriver= Ptr driver, job->data.commit.topparent->backingStore =3D job->data.commit.base; =20 qemuBlockJobEventProcessConcludedRemoveChain(driver, vm, asyncJob, job= ->data.commit.top); + + if (job->data.commit.deleteCommittedImages) + qemuBlockJobUnlinkCommittedStorage(job->data.commit.top); virObjectUnref(job->data.commit.top); job->data.commit.top =3D NULL; =20 @@ -1121,6 +1149,9 @@ qemuBlockJobProcessEventCompletedActiveCommit(virQEMU= DriverPtr driver, job->disk->src->readonly =3D job->data.commit.top->readonly; =20 qemuBlockJobEventProcessConcludedRemoveChain(driver, vm, asyncJob, job= ->data.commit.top); + + if (job->data.commit.deleteCommittedImages) + qemuBlockJobUnlinkCommittedStorage(job->data.commit.top); virObjectUnref(job->data.commit.top); job->data.commit.top =3D NULL; /* the mirror element does not serve functional purpose for the commit= job */ --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list