From nobody Mon May 6 12:16:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1575995160; cv=none; d=zohomail.com; s=zohoarc; b=NKVacpTf+WIJr65Oa4f8QWCgGVljgmBqY4l7SRuSrJbU5LAWEqK0/7/8ohm+y9T15Hhef1CBIKoqq9RW0j0o6wXSjYsw7m8JBnB29/AfYu8jFmUQwqQZ4sLAuC/cOixWV3Q6MVMWwb6G2X150ImaIMgwJfAgIvN4cvrKJc/N1i4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575995160; 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=PhZWK4icNejjEcfAQPtjQ2hqxXYU94I2MLjuFsFLMK4=; b=WJ5/oCDQltTuXFs7+GhpX+SFSXcdwSqbOFODucxjZ2CHDjmq188qdizwBOS6Dimpc5LCBPOC/dAsPyq61R4NlDs6o7TPOfoQl5DN4iq9wxcIMHS0EK8nVbtypPsMFa6S1QKBa5IC+1xcUhoYKDrtVd+DylmF4+Qdwq/rwOU/NJ4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1575995160229260.7135996854088; Tue, 10 Dec 2019 08:26:00 -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-300-sWM9YxIVPxC6uIlVajHBmg-1; Tue, 10 Dec 2019 11:25:56 -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 A2718801E74; Tue, 10 Dec 2019 16:25:50 +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 F087B77BE0; Tue, 10 Dec 2019 16:25:49 +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 F01A583568; Tue, 10 Dec 2019 16:25:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xBAGPlti006206 for ; Tue, 10 Dec 2019 11:25:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3C23819486; Tue, 10 Dec 2019 16:25:47 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9125019C6A; Tue, 10 Dec 2019 16:25:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575995159; 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=PhZWK4icNejjEcfAQPtjQ2hqxXYU94I2MLjuFsFLMK4=; b=iFLxEnC9Nnjxhpw6P1ulZshs6x1L3Dbc9nvpxjbITQEhS66s+VO4a++Uvw8TXY1R+/g2jE F+yPjJ5O2wVyKEus6qVOL+UArDkdKCSNr6PT6a0gXMt1o1xwUhUGERTLMhoL9Nd0zZO8E0 0GTmuiAMGcaHDiPnOAVlXjF9Gj8TE/8= From: Pavel Mores To: libvir-list@redhat.com Date: Tue, 10 Dec 2019 17:25:38 +0100 Message-Id: <20191210162541.15432-2-pmores@redhat.com> In-Reply-To: <20191210162541.15432-1-pmores@redhat.com> References: <20191210162541.15432-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Pavel Mores Subject: [libvirt] [PATCH v4 1/4] qemu: block: propagate the delete flag to where it can actually be used 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: sWM9YxIVPxC6uIlVajHBmg-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" Propagate the delete flag from qemuDomainBlockCommit() (which was just ignoring it until now) to qemuBlockJobDiskNewCommit() where it can be stored in the qemuBlockJobCommitData structure which holds information necessary to finish the job asynchronously. In the actual qemuBlockJobDiskNewCommit() in this commit, we temporarily pass a literal 'false' to preserve the current behaviour until the whole implementation of the feature is in place. Signed-off-by: Pavel Mores Reviewed-by: Peter Krempa --- src/qemu/qemu_blockjob.c | 4 +++- src/qemu/qemu_blockjob.h | 4 +++- src/qemu/qemu_driver.c | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 81aa46c2fb..718e311213 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -282,7 +282,8 @@ qemuBlockJobDiskNewCommit(virDomainObjPtr vm, virDomainDiskDefPtr disk, virStorageSourcePtr topparent, virStorageSourcePtr top, - virStorageSourcePtr base) + virStorageSourcePtr base, + bool delete_imgs) { qemuDomainObjPrivatePtr priv =3D vm->privateData; g_autoptr(qemuBlockJobData) job =3D NULL; @@ -305,6 +306,7 @@ qemuBlockJobDiskNewCommit(virDomainObjPtr vm, job->data.commit.topparent =3D topparent; job->data.commit.top =3D top; job->data.commit.base =3D base; + job->data.commit.deleteCommittedImages =3D delete_imgs; =20 if (qemuBlockJobRegister(job, vm, disk, true) < 0) return NULL; diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h index 52b03aaf9e..42b973fe96 100644 --- a/src/qemu/qemu_blockjob.h +++ b/src/qemu/qemu_blockjob.h @@ -87,6 +87,7 @@ struct _qemuBlockJobCommitData { virStorageSourcePtr topparent; virStorageSourcePtr top; virStorageSourcePtr base; + bool deleteCommittedImages; }; =20 =20 @@ -180,7 +181,8 @@ qemuBlockJobDiskNewCommit(virDomainObjPtr vm, virDomainDiskDefPtr disk, virStorageSourcePtr topparent, virStorageSourcePtr top, - virStorageSourcePtr base); + virStorageSourcePtr base, + bool delete_imgs); =20 qemuBlockJobDataPtr qemuBlockJobNewCreate(virDomainObjPtr vm, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9197dffadd..9c07b6b393 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18686,7 +18686,7 @@ qemuDomainBlockCommit(virDomainPtr dom, goto endjob; =20 if (!(job =3D qemuBlockJobDiskNewCommit(vm, disk, top_parent, topSourc= e, - baseSource))) + baseSource, false))) goto endjob; =20 disk->mirrorState =3D VIR_DOMAIN_DISK_MIRROR_STATE_NONE; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 12:16:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1575995162; cv=none; d=zohomail.com; s=zohoarc; b=KueCAOhBmcE9OiZQ35nXJjJ1z8V7GBI7e10cOKgMK+eu6N3mqyoB3feAqJnZAn4KM+q8Aa7r8rZBSEWTiRdEV4qBQynQvaufg5/CTyZOBjsBkUp3X1nkmliaTPWexZ1TxkMV1zwfSBNMhsJDJaMVmGQLQvHc2qqBnj0LvRTasT4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575995162; 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=OR5jijFjP61naTHUrkpQIGk9YhodlcrvVu/nO444Xjs=; b=IJmaz4eivb1dvDKGwi4QV807ohbgwLNa/Fjs0tXU1A+/AqnP5ZtANLrgfcssM8i0N22CCr5tg1SoAljcHyTrdqD7qq8jt2MRhsW3EIunGoLkJoCt56Ik0IfQtEz8EcXXLDFztPo2GfXcRqcX7cnHx8x2/R1RxuCRNV5wNmme48I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1575995162107939.3868879319659; Tue, 10 Dec 2019 08:26:02 -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-79-bADXsOTENLWXdd5jxZ_iVw-1; Tue, 10 Dec 2019 11:25:56 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 97466189DF47; Tue, 10 Dec 2019 16:25:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 628B35C219; Tue, 10 Dec 2019 16:25:50 +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 131CA18034E9; Tue, 10 Dec 2019 16:25:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xBAGPm1Y006214 for ; Tue, 10 Dec 2019 11:25:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3BFAC19486; Tue, 10 Dec 2019 16:25:48 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E6A819C6A; Tue, 10 Dec 2019 16:25:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575995158; 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=OR5jijFjP61naTHUrkpQIGk9YhodlcrvVu/nO444Xjs=; b=edrzFATb4f8xyArn/2hLoxlWD0iJ2rei/UDN6yS3dmd1YNglc+RF4EidqNpINT/Zr8gn7L ypCMR1RxE/KXql4wCIHfqnEWrUcktsF2ggphRi3/t4lekQT18tT/yXu474SzuQEXPrkHTU LPsF/VPIHu4gyBvqXxF1D+5mgNW9Fg8= From: Pavel Mores To: libvir-list@redhat.com Date: Tue, 10 Dec 2019 17:25:39 +0100 Message-Id: <20191210162541.15432-3-pmores@redhat.com> In-Reply-To: <20191210162541.15432-1-pmores@redhat.com> References: <20191210162541.15432-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Pavel Mores Subject: [libvirt] [PATCH v4 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.16 X-MC-Unique: bADXsOTENLWXdd5jxZ_iVw-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. We use virFileRemove() instead of a simple unlink() to cover the case where the image to be removed is on an NFS volume. Signed-off-by: Pavel Mores Reviewed-by: Peter Krempa --- src/qemu/qemu_blockjob.c | 46 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 718e311213..498e2a716f 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -1004,6 +1004,44 @@ qemuBlockJobProcessEventCompletedPull(virQEMUDriverP= tr driver, } =20 =20 +/** + * qemuBlockJobDeleteImages: + * @driver: qemu driver object + * @vm: domain object + * @disk: disk object that the chain to be deleted is associated with + * @top: top snapshot of the chain to be deleted + * + * Helper for removing snapshot images. Intended for callers like + * qemuBlockJobProcessEventCompletedCommit() and + * qemuBlockJobProcessEventCompletedActiveCommit() as it relies on adjustm= ents + * these functions perform on the 'backingStore' chain to function correct= ly. + * + * TODO look into removing backing store for non-local snapshots too + */ +static void +qemuBlockJobDeleteImages(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainDiskDefPtr disk, + virStorageSourcePtr top) +{ + virStorageSourcePtr p =3D top; + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + uid_t uid; + gid_t gid; + + for (; p !=3D NULL; p =3D p->backingStore) { + if (virStorageSourceGetActualType(p) =3D=3D VIR_STORAGE_TYPE_FILE)= { + + qemuDomainGetImageIds(cfg, vm, p, disk->src, &uid, &gid); + + if (virFileRemove(p->path, uid, gid) < 0) { + VIR_WARN("Unable to remove snapshot image file '%s' (%s)", + p->path, g_strerror(errno)); + } + } + } +} + /** * qemuBlockJobProcessEventCompletedCommit: * @driver: qemu driver object @@ -1070,6 +1108,10 @@ qemuBlockJobProcessEventCompletedCommit(virQEMUDrive= rPtr 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) + qemuBlockJobDeleteImages(driver, vm, job->disk, job->data.commit.t= op); + virObjectUnref(job->data.commit.top); job->data.commit.top =3D NULL; =20 @@ -1160,6 +1202,10 @@ qemuBlockJobProcessEventCompletedActiveCommit(virQEM= UDriverPtr 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) + qemuBlockJobDeleteImages(driver, vm, job->disk, job->data.commit.t= op); + 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 From nobody Mon May 6 12:16:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1575995171; cv=none; d=zohomail.com; s=zohoarc; b=gT3aZGN8Ky1aL4DT5iF5wI+NoZ+fLkx979p7niEoEvus7KNla+rcUxdtAtr++iCiT35Vw74/3RQj9hQeb4SRXibtKRP3qloxoP+4Vqz9AiZhsTazlaHiRaeET9FzVFUuu05+ickJ1Q+h3Yqkm/ICGP7YEz9VZAa10d0a68Ap2LE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575995171; 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=YeGa1o83RI2euCyeV4NWueLedO862qrEJlWF3ogZdCM=; b=IqFTZvtmXYKl2qfT4/ByIFr6r7yiTPgf1/h80urBZaEqqRyEvQzTjsQUk0B4TgRaXtO3+/ef07SrYWpzk43DfsHqFbPMjBL6QL/3EhX1/QnrzCFYeb/UhrS3nLl1hcmKLC3X952xlEgNzu05aWWY/9Q6iiKYoVABYuz09kOQYPg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1575995171462952.1319774724709; Tue, 10 Dec 2019 08:26:11 -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-343-VqVu03P3PJ28-rkTy4MYWQ-1; Tue, 10 Dec 2019 11:26:08 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 62DDC477; Tue, 10 Dec 2019 16:25:58 +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 33B025D9C5; Tue, 10 Dec 2019 16:25:58 +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 C01BB8356C; Tue, 10 Dec 2019 16:25:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xBAGPn1x006221 for ; Tue, 10 Dec 2019 11:25:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3537819486; Tue, 10 Dec 2019 16:25:49 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A9D419C6A; Tue, 10 Dec 2019 16:25:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575995170; 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=YeGa1o83RI2euCyeV4NWueLedO862qrEJlWF3ogZdCM=; b=JYTI3kCI1ME5E4vZTlRMs4xI7bFKWzjKlKmZwBi2GdxYbBSmbU3aEz95Uv5ywC1GkHEDVZ JWiyjhjZnNyLY3w0M36EiFLw/l8ijHfngIpIH+rUC2An5J+P+C7qtJcy7kFIZ+VUmAwg9d iFLlaDNaebTjiAr8UkOpaiH3CL/ubGU= From: Pavel Mores To: libvir-list@redhat.com Date: Tue, 10 Dec 2019 17:25:40 +0100 Message-Id: <20191210162541.15432-4-pmores@redhat.com> In-Reply-To: <20191210162541.15432-1-pmores@redhat.com> References: <20191210162541.15432-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Pavel Mores Subject: [libvirt] [PATCH v4 3/4] qemu: block: store the delete flag in libvirtd's status XML 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.14 X-MC-Unique: VqVu03P3PJ28-rkTy4MYWQ-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" Since blockcommit is asynchronous, libvirtd can be restarted while the operation runs. To ensure the information necessary to finish up the job is not lost, serialisation to and deserialisation from the status XML is added. To unittest this, the new element was only added to the active commit test, the non-active commit test doesn't have the new element so as to test its absence. Signed-off-by: Pavel Mores Reviewed-by: Peter Krempa --- src/qemu/qemu_domain.c | 4 ++++ tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml | 1 + 2 files changed, 5 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 767790bfc0..27926c7670 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2586,6 +2586,8 @@ qemuDomainObjPrivateXMLFormatBlockjobIterator(void *p= ayload, virBufferAsprintf(&childBuf, "\n", job->= data.commit.top->nodeformat); if (job->data.commit.topparent) virBufferAsprintf(&childBuf, "\n",= job->data.commit.topparent->nodeformat); + if (job->data.commit.deleteCommittedImages) + virBufferAddLit(&childBuf, "\n"); break; =20 case QEMU_BLOCKJOB_TYPE_CREATE: @@ -3185,6 +3187,8 @@ qemuDomainObjPrivateXMLParseBlockjobDataSpecific(qemu= BlockJobDataPtr job, "string(./base/@n= ode)", &job->data.commit= .base, ctxt); + if (virXPathNode("./deleteCommittedImages", ctxt)) + job->data.commit.deleteCommittedImages =3D true; if (!job->data.commit.top || !job->data.commit.base) goto broken; diff --git a/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml b/tests/q= emustatusxml2xmldata/blockjob-blockdev-in.xml index 67ab099bd9..b5d62fd4ab 100644 --- a/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml +++ b/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml @@ -242,6 +242,7 @@ + --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 12:16:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1575995204; cv=none; d=zohomail.com; s=zohoarc; b=PoJs2Mcebq7fnboslDo+xvCRHwXbYA3qMR4QTo6BohmMe3EFGf6mpGfAVjH8eSKfhO6Al/2z3jmcBtIlXDC+5h1Gou8T7axg2HO7KQe/b/LYbR4rTpFLV1PDRFm+bP2r7yGHUVm3plBk+aNn4AVQjXVY2Ev2ZzTcnmlRdqxyMcI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575995204; 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=IhhJXivSQwfOLKbVxXPqJ6V89pU99isHS1KIB6/VpXQ=; b=AVif+5ej8Jin37d84EBswe3x61RLJJqjNT/+B904QO6wmss028JU2Bq8mUzNg9PuiMBjXe35jUF642lm0N7XvTU86dChrhP5YdzERHkqLTzwbX342pxpw17ymtU0+iiy+YILXr/0WBi0uZpvz0y5l6IjNpR9DkHZD5Wzwsb2X6o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1575995204902205.2483948391299; Tue, 10 Dec 2019 08:26:44 -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-412-D6M6Nt7QN7is47zpY8f4lg-1; Tue, 10 Dec 2019 11:26:40 -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 6D154800C75; Tue, 10 Dec 2019 16:26:35 +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 39D546FF0F; Tue, 10 Dec 2019 16:26:35 +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 CD59783568; Tue, 10 Dec 2019 16:26:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xBAGPoF6006234 for ; Tue, 10 Dec 2019 11:25:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2FF3C19486; Tue, 10 Dec 2019 16:25:50 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83AD819C6A; Tue, 10 Dec 2019 16:25:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575995203; 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=IhhJXivSQwfOLKbVxXPqJ6V89pU99isHS1KIB6/VpXQ=; b=OIpx4bdbNij1TF8p09SBakiBj5sGYsE7Sgz6TMPtZ6H+w6PBE3XUmf4qcVILM9Tc5uCq05 KMBaV/ldR+SXsB9hdmoe0/1jP4Q0Eb8x3I8lefGt7tNULHTfkjis/L0m8aww9KC8CV9vPG a2c8kiDFgxTZ3fPJdbqTghSdzKBGJMs= From: Pavel Mores To: libvir-list@redhat.com Date: Tue, 10 Dec 2019 17:25:41 +0100 Message-Id: <20191210162541.15432-5-pmores@redhat.com> In-Reply-To: <20191210162541.15432-1-pmores@redhat.com> References: <20191210162541.15432-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Pavel Mores Subject: [libvirt] [PATCH v4 4/4] qemu: block: enable the snapshot image deletion feature 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: D6M6Nt7QN7is47zpY8f4lg-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" With all plumbing in place, we can now enable the new functionality. Signed-off-by: Pavel Mores Reviewed-by: Peter Krempa --- src/qemu/qemu_driver.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9c07b6b393..0cbc746c22 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18544,10 +18544,10 @@ qemuDomainBlockCommit(virDomainPtr dom, bool persistjob =3D false; bool blockdev =3D false; =20 - /* XXX Add support for COMMIT_DELETE */ virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW | VIR_DOMAIN_BLOCK_COMMIT_ACTIVE | VIR_DOMAIN_BLOCK_COMMIT_RELATIVE | + VIR_DOMAIN_BLOCK_COMMIT_DELETE | VIR_DOMAIN_BLOCK_COMMIT_BANDWIDTH_BYTES, -1); =20 if (!(vm =3D qemuDomainObjFromDomain(dom))) @@ -18568,6 +18568,13 @@ qemuDomainBlockCommit(virDomainPtr dom, =20 blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); =20 + if (!blockdev && (flags & VIR_DOMAIN_BLOCK_COMMIT_DELETE)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("deleting committed images is only supported for = VMs " + "with blockdev enabled")); + goto endjob; + } + /* Convert bandwidth MiB to bytes, if necessary */ if (!(flags & VIR_DOMAIN_BLOCK_COMMIT_BANDWIDTH_BYTES)) { if (speed > LLONG_MAX >> 20) { @@ -18686,7 +18693,8 @@ qemuDomainBlockCommit(virDomainPtr dom, goto endjob; =20 if (!(job =3D qemuBlockJobDiskNewCommit(vm, disk, top_parent, topSourc= e, - baseSource, false))) + baseSource, + flags & VIR_DOMAIN_BLOCK_COMMIT_= DELETE))) goto endjob; =20 disk->mirrorState =3D VIR_DOMAIN_DISK_MIRROR_STATE_NONE; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list