|
|
fbe740 |
From 7322bb9f51c7c2c35d2e65734e03ff0056b5af22 Mon Sep 17 00:00:00 2001
|
|
|
fbe740 |
Message-Id: <7322bb9f51c7c2c35d2e65734e03ff0056b5af22@dist-git>
|
|
|
fbe740 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
fbe740 |
Date: Mon, 16 Mar 2020 22:12:22 +0100
|
|
|
fbe740 |
Subject: [PATCH] qemu: blockjob: Store list of bitmaps disabled prior to
|
|
|
fbe740 |
commit
|
|
|
fbe740 |
MIME-Version: 1.0
|
|
|
fbe740 |
Content-Type: text/plain; charset=UTF-8
|
|
|
fbe740 |
Content-Transfer-Encoding: 8bit
|
|
|
fbe740 |
|
|
|
fbe740 |
Starting a commit job will require disabling bitmaps in the base image
|
|
|
fbe740 |
so that they are not dirtied by the commit job. We need to store a list
|
|
|
fbe740 |
of the bitmaps so that we can later re-enable them.
|
|
|
fbe740 |
|
|
|
fbe740 |
Add a field and status XML handling code as well as a test.
|
|
|
fbe740 |
|
|
|
fbe740 |
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
fbe740 |
(cherry picked from commit 41de7230ab169e80237f3e3a29bfecd9baf1a578)
|
|
|
fbe740 |
https://bugzilla.redhat.com/show_bug.cgi?id=1799013
|
|
|
fbe740 |
Message-Id: <f009cdda8b29df504d19bddffea5638913f8c931.1584391727.git.pkrempa@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
fbe740 |
---
|
|
|
fbe740 |
src/qemu/qemu_blockjob.h | 2 ++
|
|
|
fbe740 |
src/qemu/qemu_domain.c | 26 +++++++++++++++++++
|
|
|
fbe740 |
.../blockjob-blockdev-in.xml | 4 +++
|
|
|
fbe740 |
3 files changed, 32 insertions(+)
|
|
|
fbe740 |
|
|
|
fbe740 |
diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h
|
|
|
fbe740 |
index 4045878568..c1d95ea3d8 100644
|
|
|
fbe740 |
--- a/src/qemu/qemu_blockjob.h
|
|
|
fbe740 |
+++ b/src/qemu/qemu_blockjob.h
|
|
|
fbe740 |
@@ -88,6 +88,8 @@ struct _qemuBlockJobCommitData {
|
|
|
fbe740 |
virStorageSourcePtr top;
|
|
|
fbe740 |
virStorageSourcePtr base;
|
|
|
fbe740 |
bool deleteCommittedImages;
|
|
|
fbe740 |
+ char **disabledBitmapsBase; /* a NULL-terminated list of bitmap names which
|
|
|
fbe740 |
+ were disabled in @base for the commit job */
|
|
|
fbe740 |
};
|
|
|
fbe740 |
|
|
|
fbe740 |
|
|
|
fbe740 |
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
|
|
fbe740 |
index 0faf042145..a273aefa6b 100644
|
|
|
fbe740 |
--- a/src/qemu/qemu_domain.c
|
|
|
fbe740 |
+++ b/src/qemu/qemu_domain.c
|
|
|
fbe740 |
@@ -2603,6 +2603,9 @@ static void
|
|
|
fbe740 |
qemuDomainPrivateBlockJobFormatCommit(qemuBlockJobDataPtr job,
|
|
|
fbe740 |
virBufferPtr buf)
|
|
|
fbe740 |
{
|
|
|
fbe740 |
+ g_auto(virBuffer) disabledBitmapsBuf = VIR_BUFFER_INIT_CHILD(buf);
|
|
|
fbe740 |
+ char **bitmaps = job->data.commit.disabledBitmapsBase;
|
|
|
fbe740 |
+
|
|
|
fbe740 |
if (job->data.commit.base)
|
|
|
fbe740 |
virBufferAsprintf(buf, "<base node='%s'/>\n", job->data.commit.base->nodeformat);
|
|
|
fbe740 |
|
|
|
fbe740 |
@@ -2614,6 +2617,11 @@ qemuDomainPrivateBlockJobFormatCommit(qemuBlockJobDataPtr job,
|
|
|
fbe740 |
|
|
|
fbe740 |
if (job->data.commit.deleteCommittedImages)
|
|
|
fbe740 |
virBufferAddLit(buf, "<deleteCommittedImages/>\n");
|
|
|
fbe740 |
+
|
|
|
fbe740 |
+ while (bitmaps && *bitmaps)
|
|
|
fbe740 |
+ virBufferEscapeString(&disabledBitmapsBuf, "<bitmap name='%s'/>\n", *(bitmaps++));
|
|
|
fbe740 |
+
|
|
|
fbe740 |
+ virXMLFormatElement(buf, "disabledBaseBitmaps", NULL, &disabledBitmapsBuf);
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
|
|
|
fbe740 |
@@ -3240,6 +3248,9 @@ static int
|
|
|
fbe740 |
qemuDomainObjPrivateXMLParseBlockjobDataCommit(qemuBlockJobDataPtr job,
|
|
|
fbe740 |
xmlXPathContextPtr ctxt)
|
|
|
fbe740 |
{
|
|
|
fbe740 |
+ g_autofree xmlNodePtr *nodes = NULL;
|
|
|
fbe740 |
+ ssize_t nnodes;
|
|
|
fbe740 |
+
|
|
|
fbe740 |
if (job->type == QEMU_BLOCKJOB_TYPE_COMMIT) {
|
|
|
fbe740 |
qemuDomainObjPrivateXMLParseBlockjobNodename(job,
|
|
|
fbe740 |
"string(./topparent/@node)",
|
|
|
fbe740 |
@@ -3266,6 +3277,21 @@ qemuDomainObjPrivateXMLParseBlockjobDataCommit(qemuBlockJobDataPtr job,
|
|
|
fbe740 |
!job->data.commit.base)
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
|
|
|
fbe740 |
+ if ((nnodes = virXPathNodeSet("./disabledBaseBitmaps/bitmap", ctxt, &nodes)) > 0) {
|
|
|
fbe740 |
+ size_t i;
|
|
|
fbe740 |
+
|
|
|
fbe740 |
+ job->data.commit.disabledBitmapsBase = g_new0(char *, nnodes + 1);
|
|
|
fbe740 |
+
|
|
|
fbe740 |
+ for (i = 0; i < nnodes; i++) {
|
|
|
fbe740 |
+ char *tmp;
|
|
|
fbe740 |
+
|
|
|
fbe740 |
+ if (!(tmp = virXMLPropString(nodes[i], "name")))
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
+
|
|
|
fbe740 |
+ job->data.commit.disabledBitmapsBase[i] = g_steal_pointer(&tmp);
|
|
|
fbe740 |
+ }
|
|
|
fbe740 |
+ }
|
|
|
fbe740 |
+
|
|
|
fbe740 |
return 0;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
diff --git a/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml b/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml
|
|
|
fbe740 |
index ca6d110179..cc17a17ff4 100644
|
|
|
fbe740 |
--- a/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml
|
|
|
fbe740 |
+++ b/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml
|
|
|
fbe740 |
@@ -243,6 +243,10 @@
|
|
|
fbe740 |
<base node='libvirt-19-format'/>
|
|
|
fbe740 |
<top node='libvirt-17-format'/>
|
|
|
fbe740 |
<deleteCommittedImages/>
|
|
|
fbe740 |
+ <disabledBaseBitmaps>
|
|
|
fbe740 |
+ <bitmap name='test'/>
|
|
|
fbe740 |
+ <bitmap name='test1'/>
|
|
|
fbe740 |
+ </disabledBaseBitmaps>
|
|
|
fbe740 |
</blockjob>
|
|
|
fbe740 |
<blockjob name='create-libvirt-1337-storage' type='create' state='running'>
|
|
|
fbe740 |
<create mode='storage'/>
|
|
|
fbe740 |
--
|
|
|
fbe740 |
2.25.1
|
|
|
fbe740 |
|