From nobody Mon Feb 9 04:03:20 2026 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=1578594130; cv=none; d=zohomail.com; s=zohoarc; b=eBbKrl+hEOUvdX0FXk52RiowROqQqOivdVWHgDxLGzkmppeMoss2GGfGHgNgJDJ3/Zt39gVKgfO1pppJITvMGh61BnAeqcKlpIrsETidago6KJWG3VGReb3wBZw4CulNcc2p8CLJfr7Fkj/yrvyNg2d8Mcfg2prFXlQ+YN/nMSk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578594130; 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=11+4tBRLoBLEgs0UaZbnB0hnUJbbLY+yoAjR4DGsvdU=; b=R0i8+cOrifPo5ZEwo2y++tqObSddbmCK9U/slmsuIT0YLPZJwaAiJF2GX7xJgnGlSG44EVUnJdTpKPcoHLgT+pcn3NOw9k4qoNosb20xbhg1TbQTiQly7J/wjE9LOfpY4kt/DyGrBhwjxN69FYjCuEHT/KaeGb9DPnbpcurE2dM= 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-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1578594130539216.70898976842636; Thu, 9 Jan 2020 10:22:10 -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-101-QrToXC2bPGSzPFkzOYV1ZA-1; Thu, 09 Jan 2020 13:22:06 -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 8B706DBC7; Thu, 9 Jan 2020 18:21: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 65FEE5C57C; Thu, 9 Jan 2020 18:21: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 192C1503D4; Thu, 9 Jan 2020 18:21:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 009ILuX1018403 for ; Thu, 9 Jan 2020 13:21:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1FC507C3E8; Thu, 9 Jan 2020 18:21:56 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BDFF7C3E7; Thu, 9 Jan 2020 18:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578594129; 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=11+4tBRLoBLEgs0UaZbnB0hnUJbbLY+yoAjR4DGsvdU=; b=gGXurlM5WMuuLjdsH38ACOmusTZDCHPOYzJN8WeWTg4zUflR45N7pFSWq0/X74az5SIjdc CRqGQYK1t1CfcqO/8HVKfDtEYDBZaGREfjAuR1x1WgXO7GjddvxHScGaF8yGKIDV573t0L 1uyTPwWzC4CjbA2q5F9CjbIDDb/fJds= From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 9 Jan 2020 19:21:22 +0100 Message-Id: <663e82a9d222d966e6bc97f11b86ee8f54a74cce.1578593859.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 16/16] qemu: checkpoint: Track and relabel images for bitmap merging 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: QrToXC2bPGSzPFkzOYV1ZA-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" Allow qemu access to modify backing files in case when we want to delete a checkpoint. This patch adds tracking of which images need to be relabelled when calculating the transaction, the code to relabel them and rollback. To verify that stuff works we also output the list of images to relabel into the test case output files in qemublocktest. Signed-off-by: Peter Krempa --- src/qemu/qemu_checkpoint.c | 33 ++++++++++++++++--- src/qemu/qemu_checkpoint.h | 3 +- tests/qemublocktest.c | 19 +++++++++-- .../snapshots-intermediate1-out.json | 2 ++ .../snapshots-intermediate2-out.json | 3 ++ .../snapshots-intermediate3-out.json | 2 ++ .../snapshots-noparent-out.json | 4 +++ ...ynthetic-checkpoint-intermediate1-out.json | 2 ++ ...ynthetic-checkpoint-intermediate2-out.json | 2 ++ ...ynthetic-checkpoint-intermediate3-out.json | 2 ++ ...ots-synthetic-checkpoint-noparent-out.json | 4 +++ 11 files changed, 69 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c index 087a740cf8..13bd6653b7 100644 --- a/src/qemu/qemu_checkpoint.c +++ b/src/qemu/qemu_checkpoint.c @@ -155,7 +155,8 @@ qemuCheckpointDiscardDiskBitmaps(virStorageSourcePtr sr= c, const char *delbitmap, const char *parentbitmap, virJSONValuePtr actions, - const char *diskdst) + const char *diskdst, + GSList **reopenimages) { virStorageSourcePtr n =3D src; @@ -235,6 +236,9 @@ qemuCheckpointDiscardDiskBitmaps(virStorageSourcePtr sr= c, srcbitmap->name) < 0) return -1; + if (n !=3D src) + *reopenimages =3D g_slist_prepend(*reopenimages, n); + n =3D n->backingStore; } @@ -253,6 +257,9 @@ qemuCheckpointDiscardBitmaps(virDomainObjPtr vm, int rc; g_autoptr(virJSONValue) actions =3D NULL; size_t i; + g_autoptr(GSList) reopenimages =3D NULL; + g_autoptr(GSList) relabelimages =3D NULL; + GSList *next; if (!(actions =3D virJSONValueNewArray())) return -1; @@ -284,16 +291,34 @@ qemuCheckpointDiscardBitmaps(virDomainObjPtr vm, if (qemuCheckpointDiscardDiskBitmaps(domdisk->src, blockNamedNodeD= ata, chkdisk->bitmap, parentbitmap, - actions, domdisk->dst) < 0) + actions, domdisk->dst, + &reopenimages) < 0) return -1; } + /* label any non-top images for read-write access */ + for (next =3D reopenimages; next; next =3D next->next) { + virStorageSourcePtr src =3D next->data; + + if (qemuDomainStorageSourceAccessAllow(driver, vm, src, false, fal= se) < 0) + goto relabel; + + relabelimages =3D g_slist_prepend(relabelimages, src); + } + qemuDomainObjEnterMonitor(driver, vm); rc =3D qemuMonitorTransaction(priv->mon, &actions); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + if (qemuDomainObjExitMonitor(driver, vm) < 0) return -1; - return 0; + relabel: + for (next =3D relabelimages; next; next =3D next->next) { + virStorageSourcePtr src =3D next->data; + + ignore_value(qemuDomainStorageSourceAccessAllow(driver, vm, src, t= rue, false)); + } + + return rc; } diff --git a/src/qemu/qemu_checkpoint.h b/src/qemu/qemu_checkpoint.h index 976b1eed0f..cf1e9e46cb 100644 --- a/src/qemu/qemu_checkpoint.h +++ b/src/qemu/qemu_checkpoint.h @@ -78,4 +78,5 @@ qemuCheckpointDiscardDiskBitmaps(virStorageSourcePtr src, const char *delbitmap, const char *parentbitmap, virJSONValuePtr actions, - const char *diskdst); + const char *diskdst, + GSList **reopenimages); diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index c2c7507e20..a368e6a74f 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -717,6 +717,9 @@ testQemuCheckpointDeleteMerge(const void *opaque) g_autoptr(virJSONValue) actions =3D NULL; g_autoptr(virJSONValue) nodedatajson =3D NULL; g_autoptr(virHashTable) nodedata =3D NULL; + g_autoptr(GSList) reopenimages =3D NULL; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + GSList *tmp; expectpath =3D g_strdup_printf("%s/%s%s-out.json", abs_srcdir, checkpointDeletePrefix, data->name); @@ -738,14 +741,26 @@ testQemuCheckpointDeleteMerge(const void *opaque) data->deletebitmap, data->parentbitmap, actions, - "testdisk") < 0) { + "testdisk", + &reopenimages) < 0) { VIR_TEST_VERBOSE("failed to generate checkpoint delete transaction= \n"); return -1; } - if (!(actual =3D virJSONValueToString(actions, true))) + if (virJSONValueToBuffer(actions, &buf, true) < 0) return -1; + if (reopenimages) { + virBufferAddLit(&buf, "reopen nodes:\n"); + + for (tmp =3D reopenimages; tmp; tmp =3D tmp->next) { + virStorageSourcePtr src =3D tmp->data; + virBufferAsprintf(&buf, "%s\n", src->nodeformat); + } + } + + actual =3D virBufferContentAndReset(&buf); + return virTestCompareToFile(actual, expectpath); } diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-intermediat= e1-out.json b/tests/qemublocktestdata/checkpointdelete/snapshots-intermedia= te1-out.json index 29fefeea63..c9bda3a17a 100644 --- a/tests/qemublocktestdata/checkpointdelete/snapshots-intermediate1-out.= json +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-intermediate1-out.= json @@ -20,3 +20,5 @@ } } ] +reopen nodes: +libvirt-3-format diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-intermediat= e2-out.json b/tests/qemublocktestdata/checkpointdelete/snapshots-intermedia= te2-out.json index 4da21a9df7..8a0e3f2cff 100644 --- a/tests/qemublocktestdata/checkpointdelete/snapshots-intermediate2-out.= json +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-intermediate2-out.= json @@ -57,3 +57,6 @@ } } ] +reopen nodes: +libvirt-3-format +libvirt-2-format diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-intermediat= e3-out.json b/tests/qemublocktestdata/checkpointdelete/snapshots-intermedia= te3-out.json index dc87dd60b8..211bc40baf 100644 --- a/tests/qemublocktestdata/checkpointdelete/snapshots-intermediate3-out.= json +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-intermediate3-out.= json @@ -57,3 +57,5 @@ } } ] +reopen nodes: +libvirt-2-format diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-noparent-ou= t.json b/tests/qemublocktestdata/checkpointdelete/snapshots-noparent-out.js= on index 45a84b47c2..f750f44da2 100644 --- a/tests/qemublocktestdata/checkpointdelete/snapshots-noparent-out.json +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-noparent-out.json @@ -21,3 +21,7 @@ } } ] +reopen nodes: +libvirt-5-format +libvirt-4-format +libvirt-3-format diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-c= heckpoint-intermediate1-out.json b/tests/qemublocktestdata/checkpointdelete= /snapshots-synthetic-checkpoint-intermediate1-out.json index e979691e6f..d7e6d18637 100644 --- a/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-checkpoi= nt-intermediate1-out.json +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-checkpoi= nt-intermediate1-out.json @@ -27,3 +27,5 @@ } } ] +reopen nodes: +libvirt-3-format diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-c= heckpoint-intermediate2-out.json b/tests/qemublocktestdata/checkpointdelete= /snapshots-synthetic-checkpoint-intermediate2-out.json index e82098918a..cfbff010c2 100644 --- a/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-checkpoi= nt-intermediate2-out.json +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-checkpoi= nt-intermediate2-out.json @@ -30,3 +30,5 @@ } } ] +reopen nodes: +libvirt-2-format diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-c= heckpoint-intermediate3-out.json b/tests/qemublocktestdata/checkpointdelete= /snapshots-synthetic-checkpoint-intermediate3-out.json index dc87dd60b8..211bc40baf 100644 --- a/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-checkpoi= nt-intermediate3-out.json +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-checkpoi= nt-intermediate3-out.json @@ -57,3 +57,5 @@ } } ] +reopen nodes: +libvirt-2-format diff --git a/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-c= heckpoint-noparent-out.json b/tests/qemublocktestdata/checkpointdelete/snap= shots-synthetic-checkpoint-noparent-out.json index 45a84b47c2..f750f44da2 100644 --- a/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-checkpoi= nt-noparent-out.json +++ b/tests/qemublocktestdata/checkpointdelete/snapshots-synthetic-checkpoi= nt-noparent-out.json @@ -21,3 +21,7 @@ } } ] +reopen nodes: +libvirt-5-format +libvirt-4-format +libvirt-3-format --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list