|
|
fbe740 |
From ae0be0a7cbfb291c640b25d31013f938745e8c08 Mon Sep 17 00:00:00 2001
|
|
|
fbe740 |
Message-Id: <ae0be0a7cbfb291c640b25d31013f938745e8c08@dist-git>
|
|
|
fbe740 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
fbe740 |
Date: Tue, 23 Jun 2020 12:24:00 +0200
|
|
|
fbe740 |
Subject: [PATCH] qemu: Rewrite bitmap handling for block commit
|
|
|
fbe740 |
MIME-Version: 1.0
|
|
|
fbe740 |
Content-Type: text/plain; charset=UTF-8
|
|
|
fbe740 |
Content-Transfer-Encoding: 8bit
|
|
|
fbe740 |
|
|
|
fbe740 |
Reuse qemuBlockGetBitmapMergeActions which allows removing the ad-hoc
|
|
|
fbe740 |
implementation of bitmap merging for block commit. The new approach is
|
|
|
fbe740 |
way simpler and more robust and also allows us to get rid of the
|
|
|
fbe740 |
disabling of bitmaps done prior to the start as we actually do want to
|
|
|
fbe740 |
update the bitmaps in the base.
|
|
|
fbe740 |
|
|
|
fbe740 |
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
fbe740 |
(cherry picked from commit 20a7abc2d2d8a378103abf105fa0c617218ec023)
|
|
|
fbe740 |
https://bugzilla.redhat.com/show_bug.cgi?id=1804593
|
|
|
fbe740 |
Message-Id: <2b1054dbe576d3984c960a42d175edbafa92565a.1592906423.git.pkrempa@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
fbe740 |
---
|
|
|
fbe740 |
src/qemu/qemu_block.c | 203 +-----------------
|
|
|
fbe740 |
src/qemu/qemu_block.h | 11 +-
|
|
|
fbe740 |
src/qemu/qemu_blockjob.c | 25 ++-
|
|
|
fbe740 |
src/qemu/qemu_driver.c | 56 +----
|
|
|
fbe740 |
tests/qemublocktest.c | 18 +-
|
|
|
fbe740 |
.../qemublocktestdata/bitmapblockcommit/empty | 1 -
|
|
|
fbe740 |
6 files changed, 42 insertions(+), 272 deletions(-)
|
|
|
fbe740 |
|
|
|
fbe740 |
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
|
|
|
fbe740 |
index b2296c2b4c..ff9e000461 100644
|
|
|
fbe740 |
--- a/src/qemu/qemu_block.c
|
|
|
fbe740 |
+++ b/src/qemu/qemu_block.c
|
|
|
fbe740 |
@@ -3194,117 +3194,7 @@ qemuBlockBitmapsHandleBlockcopy(virStorageSourcePtr src,
|
|
|
fbe740 |
/**
|
|
|
fbe740 |
* @topsrc: virStorageSource representing 'top' of the job
|
|
|
fbe740 |
* @basesrc: virStorageSource representing 'base' of the job
|
|
|
fbe740 |
- * @blockNamedNodeData: hash table containing data about bitmaps
|
|
|
fbe740 |
- * @actions: filled with arguments for a 'transaction' command
|
|
|
fbe740 |
- * @disabledBitmapsBase: filled with a list of bitmap names which must be disabled
|
|
|
fbe740 |
- *
|
|
|
fbe740 |
- * Prepares data for correctly handling bitmaps during the start of a commit
|
|
|
fbe740 |
- * job. The bitmaps in the 'base' image must be disabled, so that the writes
|
|
|
fbe740 |
- * done by the blockjob don't dirty the enabled bitmaps.
|
|
|
fbe740 |
- *
|
|
|
fbe740 |
- * @actions and @disabledBitmapsBase are untouched if no bitmaps need
|
|
|
fbe740 |
- * to be disabled.
|
|
|
fbe740 |
- */
|
|
|
fbe740 |
-int
|
|
|
fbe740 |
-qemuBlockBitmapsHandleCommitStart(virStorageSourcePtr topsrc,
|
|
|
fbe740 |
- virStorageSourcePtr basesrc,
|
|
|
fbe740 |
- virHashTablePtr blockNamedNodeData,
|
|
|
fbe740 |
- virJSONValuePtr *actions,
|
|
|
fbe740 |
- char ***disabledBitmapsBase)
|
|
|
fbe740 |
-{
|
|
|
fbe740 |
- g_autoptr(virJSONValue) act = virJSONValueNewArray();
|
|
|
fbe740 |
- VIR_AUTOSTRINGLIST bitmaplist = NULL;
|
|
|
fbe740 |
- size_t curbitmapstr = 0;
|
|
|
fbe740 |
- qemuBlockNamedNodeDataPtr entry;
|
|
|
fbe740 |
- bool disable_bitmaps = false;
|
|
|
fbe740 |
- size_t i;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- if (!(entry = virHashLookup(blockNamedNodeData, basesrc->nodeformat)))
|
|
|
fbe740 |
- return 0;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- bitmaplist = g_new0(char *, entry->nbitmaps + 1);
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- for (i = 0; i < entry->nbitmaps; i++) {
|
|
|
fbe740 |
- qemuBlockNamedNodeDataBitmapPtr bitmap = entry->bitmaps[i];
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- if (!bitmap->recording || bitmap->inconsistent ||
|
|
|
fbe740 |
- !qemuBlockBitmapChainIsValid(topsrc, bitmap->name, blockNamedNodeData))
|
|
|
fbe740 |
- continue;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- disable_bitmaps = true;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- if (qemuMonitorTransactionBitmapDisable(act, basesrc->nodeformat,
|
|
|
fbe740 |
- bitmap->name) < 0)
|
|
|
fbe740 |
- return -1;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- bitmaplist[curbitmapstr++] = g_strdup(bitmap->name);
|
|
|
fbe740 |
- }
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- if (disable_bitmaps) {
|
|
|
fbe740 |
- *actions = g_steal_pointer(&act;;
|
|
|
fbe740 |
- *disabledBitmapsBase = g_steal_pointer(&bitmaplist);
|
|
|
fbe740 |
- }
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- return 0;
|
|
|
fbe740 |
-}
|
|
|
fbe740 |
-
|
|
|
fbe740 |
-
|
|
|
fbe740 |
-struct qemuBlockBitmapsHandleCommitData {
|
|
|
fbe740 |
- bool skip;
|
|
|
fbe740 |
- bool create;
|
|
|
fbe740 |
- bool enable;
|
|
|
fbe740 |
- const char *basenode;
|
|
|
fbe740 |
- virJSONValuePtr merge;
|
|
|
fbe740 |
- unsigned long long granularity;
|
|
|
fbe740 |
- bool persistent;
|
|
|
fbe740 |
-};
|
|
|
fbe740 |
-
|
|
|
fbe740 |
-
|
|
|
fbe740 |
-static void
|
|
|
fbe740 |
-qemuBlockBitmapsHandleCommitDataFree(void *opaque)
|
|
|
fbe740 |
-{
|
|
|
fbe740 |
- struct qemuBlockBitmapsHandleCommitData *data = opaque;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- virJSONValueFree(data->merge);
|
|
|
fbe740 |
- g_free(data);
|
|
|
fbe740 |
-}
|
|
|
fbe740 |
-
|
|
|
fbe740 |
-
|
|
|
fbe740 |
-static int
|
|
|
fbe740 |
-qemuBlockBitmapsHandleCommitFinishIterate(void *payload,
|
|
|
fbe740 |
- const void *entryname,
|
|
|
fbe740 |
- void *opaque)
|
|
|
fbe740 |
-{
|
|
|
fbe740 |
- struct qemuBlockBitmapsHandleCommitData *data = payload;
|
|
|
fbe740 |
- const char *bitmapname = entryname;
|
|
|
fbe740 |
- virJSONValuePtr actions = opaque;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- if (data->skip)
|
|
|
fbe740 |
- return 0;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- if (data->create) {
|
|
|
fbe740 |
- if (qemuMonitorTransactionBitmapAdd(actions, data->basenode, bitmapname,
|
|
|
fbe740 |
- data->persistent, !data->enable,
|
|
|
fbe740 |
- data->granularity) < 0)
|
|
|
fbe740 |
- return -1;
|
|
|
fbe740 |
- } else {
|
|
|
fbe740 |
- if (data->enable &&
|
|
|
fbe740 |
- qemuMonitorTransactionBitmapEnable(actions, data->basenode, bitmapname) < 0)
|
|
|
fbe740 |
- return -1;
|
|
|
fbe740 |
- }
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- if (data->merge &&
|
|
|
fbe740 |
- qemuMonitorTransactionBitmapMerge(actions, data->basenode, bitmapname,
|
|
|
fbe740 |
- &data->merge) < 0)
|
|
|
fbe740 |
- return -1;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- return 0;
|
|
|
fbe740 |
-}
|
|
|
fbe740 |
-
|
|
|
fbe740 |
-
|
|
|
fbe740 |
-/**
|
|
|
fbe740 |
- * @topsrc: virStorageSource representing 'top' of the job
|
|
|
fbe740 |
- * @basesrc: virStorageSource representing 'base' of the job
|
|
|
fbe740 |
+ * @active: commit job is an active layer block-commit
|
|
|
fbe740 |
* @blockNamedNodeData: hash table containing data about bitmaps
|
|
|
fbe740 |
* @actions: filled with arguments for a 'transaction' command
|
|
|
fbe740 |
* @disabledBitmapsBase: bitmap names which were disabled
|
|
|
fbe740 |
@@ -3317,95 +3207,20 @@ qemuBlockBitmapsHandleCommitFinishIterate(void *payload,
|
|
|
fbe740 |
int
|
|
|
fbe740 |
qemuBlockBitmapsHandleCommitFinish(virStorageSourcePtr topsrc,
|
|
|
fbe740 |
virStorageSourcePtr basesrc,
|
|
|
fbe740 |
+ bool active,
|
|
|
fbe740 |
virHashTablePtr blockNamedNodeData,
|
|
|
fbe740 |
- virJSONValuePtr *actions,
|
|
|
fbe740 |
- char **disabledBitmapsBase)
|
|
|
fbe740 |
+ virJSONValuePtr *actions)
|
|
|
fbe740 |
{
|
|
|
fbe740 |
- g_autoptr(virJSONValue) act = virJSONValueNewArray();
|
|
|
fbe740 |
- virStorageSourcePtr n;
|
|
|
fbe740 |
- qemuBlockNamedNodeDataPtr entry;
|
|
|
fbe740 |
- g_autoptr(virHashTable) commitdata = NULL;
|
|
|
fbe740 |
- struct qemuBlockBitmapsHandleCommitData *bitmapdata;
|
|
|
fbe740 |
- size_t i;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- commitdata = virHashNew(qemuBlockBitmapsHandleCommitDataFree);
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- for (n = topsrc; n != basesrc; n = n->backingStore) {
|
|
|
fbe740 |
- if (!(entry = virHashLookup(blockNamedNodeData, n->nodeformat)))
|
|
|
fbe740 |
- continue;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- for (i = 0; i < entry->nbitmaps; i++) {
|
|
|
fbe740 |
- qemuBlockNamedNodeDataBitmapPtr bitmap = entry->bitmaps[i];
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- if (!(bitmapdata = virHashLookup(commitdata, bitmap->name))) {
|
|
|
fbe740 |
- bitmapdata = g_new0(struct qemuBlockBitmapsHandleCommitData, 1);
|
|
|
fbe740 |
+ virStorageSourcePtr writebitmapsrc = NULL;
|
|
|
fbe740 |
|
|
|
fbe740 |
- /* we must mirror the state of the topmost bitmap and merge
|
|
|
fbe740 |
- * everything else */
|
|
|
fbe740 |
- bitmapdata->create = true;
|
|
|
fbe740 |
- bitmapdata->enable = bitmap->recording;
|
|
|
fbe740 |
- bitmapdata->basenode = basesrc->nodeformat;
|
|
|
fbe740 |
- bitmapdata->merge = virJSONValueNewArray();
|
|
|
fbe740 |
- bitmapdata->granularity = bitmap->granularity;
|
|
|
fbe740 |
- bitmapdata->persistent = bitmap->persistent;
|
|
|
fbe740 |
+ if (active)
|
|
|
fbe740 |
+ writebitmapsrc = basesrc;
|
|
|
fbe740 |
|
|
|
fbe740 |
- if (virHashAddEntry(commitdata, bitmap->name, bitmapdata) < 0) {
|
|
|
fbe740 |
- qemuBlockBitmapsHandleCommitDataFree(bitmapdata);
|
|
|
fbe740 |
- return -1;
|
|
|
fbe740 |
- }
|
|
|
fbe740 |
- }
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- if (bitmap->inconsistent ||
|
|
|
fbe740 |
- !qemuBlockBitmapChainIsValid(topsrc, bitmap->name, blockNamedNodeData))
|
|
|
fbe740 |
- bitmapdata->skip = true;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(bitmapdata->merge,
|
|
|
fbe740 |
- n->nodeformat,
|
|
|
fbe740 |
- bitmap->name) < 0)
|
|
|
fbe740 |
- return -1;
|
|
|
fbe740 |
- }
|
|
|
fbe740 |
- }
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- if ((entry = virHashLookup(blockNamedNodeData, basesrc->nodeformat))) {
|
|
|
fbe740 |
- /* note that all bitmaps in 'base' were disabled when commit was started */
|
|
|
fbe740 |
- for (i = 0; i < entry->nbitmaps; i++) {
|
|
|
fbe740 |
- qemuBlockNamedNodeDataBitmapPtr bitmap = entry->bitmaps[i];
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- if ((bitmapdata = virHashLookup(commitdata, bitmap->name))) {
|
|
|
fbe740 |
- bitmapdata->create = false;
|
|
|
fbe740 |
- } else {
|
|
|
fbe740 |
- if (disabledBitmapsBase) {
|
|
|
fbe740 |
- char **disabledbitmaps;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- for (disabledbitmaps = disabledBitmapsBase; *disabledbitmaps; disabledbitmaps++) {
|
|
|
fbe740 |
- if (STREQ(*disabledbitmaps, bitmap->name)) {
|
|
|
fbe740 |
- bitmapdata = g_new0(struct qemuBlockBitmapsHandleCommitData, 1);
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- bitmapdata->create = false;
|
|
|
fbe740 |
- bitmapdata->enable = true;
|
|
|
fbe740 |
- bitmapdata->basenode = basesrc->nodeformat;
|
|
|
fbe740 |
- bitmapdata->granularity = bitmap->granularity;
|
|
|
fbe740 |
- bitmapdata->persistent = bitmap->persistent;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- if (virHashAddEntry(commitdata, bitmap->name, bitmapdata) < 0) {
|
|
|
fbe740 |
- qemuBlockBitmapsHandleCommitDataFree(bitmapdata);
|
|
|
fbe740 |
- return -1;
|
|
|
fbe740 |
- }
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- break;
|
|
|
fbe740 |
- }
|
|
|
fbe740 |
- }
|
|
|
fbe740 |
- }
|
|
|
fbe740 |
- }
|
|
|
fbe740 |
- }
|
|
|
fbe740 |
- }
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- if (virHashForEach(commitdata, qemuBlockBitmapsHandleCommitFinishIterate, act) < 0)
|
|
|
fbe740 |
+ if (qemuBlockGetBitmapMergeActions(topsrc, basesrc, basesrc, NULL, NULL,
|
|
|
fbe740 |
+ writebitmapsrc, actions,
|
|
|
fbe740 |
+ blockNamedNodeData) < 0)
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
|
|
|
fbe740 |
- if (virJSONValueArraySize(act) > 0)
|
|
|
fbe740 |
- *actions = g_steal_pointer(&act;;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
return 0;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h
|
|
|
fbe740 |
index 2500390734..19d2fc32e0 100644
|
|
|
fbe740 |
--- a/src/qemu/qemu_block.h
|
|
|
fbe740 |
+++ b/src/qemu/qemu_block.h
|
|
|
fbe740 |
@@ -243,19 +243,12 @@ qemuBlockBitmapsHandleBlockcopy(virStorageSourcePtr src,
|
|
|
fbe740 |
bool shallow,
|
|
|
fbe740 |
virJSONValuePtr *actions);
|
|
|
fbe740 |
|
|
|
fbe740 |
-int
|
|
|
fbe740 |
-qemuBlockBitmapsHandleCommitStart(virStorageSourcePtr topsrc,
|
|
|
fbe740 |
- virStorageSourcePtr basesrc,
|
|
|
fbe740 |
- virHashTablePtr blockNamedNodeData,
|
|
|
fbe740 |
- virJSONValuePtr *actions,
|
|
|
fbe740 |
- char ***disabledBitmapsBase);
|
|
|
fbe740 |
-
|
|
|
fbe740 |
int
|
|
|
fbe740 |
qemuBlockBitmapsHandleCommitFinish(virStorageSourcePtr topsrc,
|
|
|
fbe740 |
virStorageSourcePtr basesrc,
|
|
|
fbe740 |
+ bool active,
|
|
|
fbe740 |
virHashTablePtr blockNamedNodeData,
|
|
|
fbe740 |
- virJSONValuePtr *actions,
|
|
|
fbe740 |
- char **disabledBitmapsBase);
|
|
|
fbe740 |
+ virJSONValuePtr *actions);
|
|
|
fbe740 |
|
|
|
fbe740 |
int
|
|
|
fbe740 |
qemuBlockReopenReadWrite(virDomainObjPtr vm,
|
|
|
fbe740 |
diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
|
|
|
fbe740 |
index c80c71295b..c63a691a0e 100644
|
|
|
fbe740 |
--- a/src/qemu/qemu_blockjob.c
|
|
|
fbe740 |
+++ b/src/qemu/qemu_blockjob.c
|
|
|
fbe740 |
@@ -1063,6 +1063,7 @@ qemuBlockJobProcessEventCompletedCommitBitmaps(virDomainObjPtr vm,
|
|
|
fbe740 |
qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
|
fbe740 |
g_autoptr(virHashTable) blockNamedNodeData = NULL;
|
|
|
fbe740 |
g_autoptr(virJSONValue) actions = NULL;
|
|
|
fbe740 |
+ bool active = job->type == QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT;
|
|
|
fbe740 |
|
|
|
fbe740 |
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN))
|
|
|
fbe740 |
return 0;
|
|
|
fbe740 |
@@ -1072,16 +1073,18 @@ qemuBlockJobProcessEventCompletedCommitBitmaps(virDomainObjPtr vm,
|
|
|
fbe740 |
|
|
|
fbe740 |
if (qemuBlockBitmapsHandleCommitFinish(job->data.commit.top,
|
|
|
fbe740 |
job->data.commit.base,
|
|
|
fbe740 |
+ active,
|
|
|
fbe740 |
blockNamedNodeData,
|
|
|
fbe740 |
- &actions,
|
|
|
fbe740 |
- job->data.commit.disabledBitmapsBase) < 0)
|
|
|
fbe740 |
+ &actions) < 0)
|
|
|
fbe740 |
return 0;
|
|
|
fbe740 |
|
|
|
fbe740 |
if (!actions)
|
|
|
fbe740 |
return 0;
|
|
|
fbe740 |
|
|
|
fbe740 |
- if (qemuBlockReopenReadWrite(vm, job->data.commit.base, asyncJob) < 0)
|
|
|
fbe740 |
- return -1;
|
|
|
fbe740 |
+ if (!active) {
|
|
|
fbe740 |
+ if (qemuBlockReopenReadWrite(vm, job->data.commit.base, asyncJob) < 0)
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
+ }
|
|
|
fbe740 |
|
|
|
fbe740 |
if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) < 0)
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
@@ -1091,8 +1094,10 @@ qemuBlockJobProcessEventCompletedCommitBitmaps(virDomainObjPtr vm,
|
|
|
fbe740 |
if (qemuDomainObjExitMonitor(priv->driver, vm) < 0)
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
|
|
|
fbe740 |
- if (qemuBlockReopenReadOnly(vm, job->data.commit.base, asyncJob) < 0)
|
|
|
fbe740 |
- return -1;
|
|
|
fbe740 |
+ if (!active) {
|
|
|
fbe740 |
+ if (qemuBlockReopenReadOnly(vm, job->data.commit.base, asyncJob) < 0)
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
+ }
|
|
|
fbe740 |
|
|
|
fbe740 |
return 0;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
@@ -1262,6 +1267,9 @@ qemuBlockJobProcessEventCompletedActiveCommit(virQEMUDriverPtr driver,
|
|
|
fbe740 |
job->disk->src = job->data.commit.base;
|
|
|
fbe740 |
job->disk->src->readonly = job->data.commit.top->readonly;
|
|
|
fbe740 |
|
|
|
fbe740 |
+ if (qemuBlockJobProcessEventCompletedCommitBitmaps(vm, job, asyncJob) < 0)
|
|
|
fbe740 |
+ return;
|
|
|
fbe740 |
+
|
|
|
fbe740 |
qemuBlockJobEventProcessConcludedRemoveChain(driver, vm, asyncJob, job->data.commit.top);
|
|
|
fbe740 |
|
|
|
fbe740 |
if (job->data.commit.deleteCommittedImages)
|
|
|
fbe740 |
@@ -1333,6 +1341,7 @@ qemuBlockJobProcessEventFailedActiveCommit(virQEMUDriverPtr driver,
|
|
|
fbe740 |
virDomainObjPtr vm,
|
|
|
fbe740 |
qemuBlockJobDataPtr job)
|
|
|
fbe740 |
{
|
|
|
fbe740 |
+ g_autoptr(virJSONValue) actions = virJSONValueNewArray();
|
|
|
fbe740 |
virDomainDiskDefPtr disk = job->disk;
|
|
|
fbe740 |
|
|
|
fbe740 |
VIR_DEBUG("active commit job '%s' on VM '%s' failed", job->name, vm->def->name);
|
|
|
fbe740 |
@@ -1340,6 +1349,10 @@ qemuBlockJobProcessEventFailedActiveCommit(virQEMUDriverPtr driver,
|
|
|
fbe740 |
if (!disk)
|
|
|
fbe740 |
return;
|
|
|
fbe740 |
|
|
|
fbe740 |
+ ignore_value(qemuMonitorTransactionBitmapRemove(actions, disk->mirror->nodeformat,
|
|
|
fbe740 |
+ "libvirt-tmp-activewrite"));
|
|
|
fbe740 |
+
|
|
|
fbe740 |
+
|
|
|
fbe740 |
/* Ideally, we would make the backing chain read only again (yes, SELinux
|
|
|
fbe740 |
* can do that using different labels). But that is not implemented yet and
|
|
|
fbe740 |
* not leaking security driver metadata is more important. */
|
|
|
fbe740 |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
fbe740 |
index 9f7d96c0b6..983d4a04a8 100644
|
|
|
fbe740 |
--- a/src/qemu/qemu_driver.c
|
|
|
fbe740 |
+++ b/src/qemu/qemu_driver.c
|
|
|
fbe740 |
@@ -17594,9 +17594,9 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
|
|
|
fbe740 |
|
|
|
fbe740 |
case QEMU_BLOCKJOB_TYPE_COPY:
|
|
|
fbe740 |
if (blockdev && !job->jobflagsmissing) {
|
|
|
fbe740 |
- g_autoptr(virHashTable) blockNamedNodeData = NULL;
|
|
|
fbe740 |
bool shallow = job->jobflags & VIR_DOMAIN_BLOCK_COPY_SHALLOW;
|
|
|
fbe740 |
bool reuse = job->jobflags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT;
|
|
|
fbe740 |
+ g_autoptr(virHashTable) blockNamedNodeData = NULL;
|
|
|
fbe740 |
|
|
|
fbe740 |
if (!(blockNamedNodeData = qemuBlockGetNamedNodeData(vm, QEMU_ASYNC_JOB_NONE)))
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
@@ -17634,16 +17634,15 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
|
|
|
fbe740 |
* the bitmaps if it wasn't present thus must skip this */
|
|
|
fbe740 |
if (blockdev &&
|
|
|
fbe740 |
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN)) {
|
|
|
fbe740 |
- g_autoptr(virHashTable) blockNamedNodeData = NULL;
|
|
|
fbe740 |
|
|
|
fbe740 |
- if (!(blockNamedNodeData = qemuBlockGetNamedNodeData(vm, QEMU_ASYNC_JOB_NONE)))
|
|
|
fbe740 |
- return -1;
|
|
|
fbe740 |
+ actions = virJSONValueNewArray();
|
|
|
fbe740 |
|
|
|
fbe740 |
- if (qemuBlockBitmapsHandleCommitFinish(job->data.commit.top,
|
|
|
fbe740 |
- job->data.commit.base,
|
|
|
fbe740 |
- blockNamedNodeData,
|
|
|
fbe740 |
- &actions,
|
|
|
fbe740 |
- job->data.commit.disabledBitmapsBase) < 0)
|
|
|
fbe740 |
+ if (qemuMonitorTransactionBitmapAdd(actions,
|
|
|
fbe740 |
+ job->data.commit.base->nodeformat,
|
|
|
fbe740 |
+ "libvirt-tmp-activewrite",
|
|
|
fbe740 |
+ false,
|
|
|
fbe740 |
+ false,
|
|
|
fbe740 |
+ 0) < 0)
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
@@ -18758,7 +18757,6 @@ qemuDomainBlockCommit(virDomainPtr dom,
|
|
|
fbe740 |
const char *nodebase = NULL;
|
|
|
fbe740 |
bool persistjob = false;
|
|
|
fbe740 |
bool blockdev = false;
|
|
|
fbe740 |
- g_autoptr(virJSONValue) bitmapDisableActions = NULL;
|
|
|
fbe740 |
VIR_AUTOSTRINGLIST bitmapDisableList = NULL;
|
|
|
fbe740 |
|
|
|
fbe740 |
virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW |
|
|
|
fbe740 |
@@ -18920,27 +18918,6 @@ qemuDomainBlockCommit(virDomainPtr dom,
|
|
|
fbe740 |
goto endjob;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
- if (blockdev &&
|
|
|
fbe740 |
- virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN)) {
|
|
|
fbe740 |
- g_autoptr(virHashTable) blockNamedNodeData = NULL;
|
|
|
fbe740 |
- if (!(blockNamedNodeData = qemuBlockGetNamedNodeData(vm, QEMU_ASYNC_JOB_NONE)))
|
|
|
fbe740 |
- goto endjob;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- if (qemuBlockBitmapsHandleCommitStart(topSource, baseSource,
|
|
|
fbe740 |
- blockNamedNodeData,
|
|
|
fbe740 |
- &bitmapDisableActions,
|
|
|
fbe740 |
- &bitmapDisableList) < 0)
|
|
|
fbe740 |
- goto endjob;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- /* if we don't have terminator on 'base' we can't reopen it */
|
|
|
fbe740 |
- if (bitmapDisableActions && !baseSource->backingStore) {
|
|
|
fbe740 |
- virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
|
|
|
fbe740 |
- _("can't handle bitmaps on unterminated backing image '%s'"),
|
|
|
fbe740 |
- base);
|
|
|
fbe740 |
- goto endjob;
|
|
|
fbe740 |
- }
|
|
|
fbe740 |
- }
|
|
|
fbe740 |
-
|
|
|
fbe740 |
if (!(job = qemuBlockJobDiskNewCommit(vm, disk, top_parent, topSource,
|
|
|
fbe740 |
baseSource, &bitmapDisableList,
|
|
|
fbe740 |
flags & VIR_DOMAIN_BLOCK_COMMIT_DELETE,
|
|
|
fbe740 |
@@ -18965,23 +18942,6 @@ qemuDomainBlockCommit(virDomainPtr dom,
|
|
|
fbe740 |
!(backingPath = qemuBlockGetBackingStoreString(baseSource, false)))
|
|
|
fbe740 |
goto endjob;
|
|
|
fbe740 |
|
|
|
fbe740 |
- if (bitmapDisableActions) {
|
|
|
fbe740 |
- int rc;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- if (qemuBlockReopenReadWrite(vm, baseSource, QEMU_ASYNC_JOB_NONE) < 0)
|
|
|
fbe740 |
- goto endjob;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- qemuDomainObjEnterMonitor(driver, vm);
|
|
|
fbe740 |
- rc = qemuMonitorTransaction(priv->mon, &bitmapDisableActions);
|
|
|
fbe740 |
- if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
|
|
fbe740 |
- goto endjob;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- if (qemuBlockReopenReadOnly(vm, baseSource, QEMU_ASYNC_JOB_NONE) < 0)
|
|
|
fbe740 |
- goto endjob;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- if (rc < 0)
|
|
|
fbe740 |
- goto endjob;
|
|
|
fbe740 |
- }
|
|
|
fbe740 |
} else {
|
|
|
fbe740 |
device = job->name;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
|
|
|
fbe740 |
index 8ce878f15b..f0e80a0738 100644
|
|
|
fbe740 |
--- a/tests/qemublocktest.c
|
|
|
fbe740 |
+++ b/tests/qemublocktest.c
|
|
|
fbe740 |
@@ -928,12 +928,11 @@ testQemuBlockBitmapBlockcommit(const void *opaque)
|
|
|
fbe740 |
|
|
|
fbe740 |
g_autofree char *actual = NULL;
|
|
|
fbe740 |
g_autofree char *expectpath = NULL;
|
|
|
fbe740 |
- g_autoptr(virJSONValue) actionsDisable = NULL;
|
|
|
fbe740 |
g_autoptr(virJSONValue) actionsMerge = NULL;
|
|
|
fbe740 |
g_autoptr(virJSONValue) nodedatajson = NULL;
|
|
|
fbe740 |
g_autoptr(virHashTable) nodedata = NULL;
|
|
|
fbe740 |
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
|
|
fbe740 |
- VIR_AUTOSTRINGLIST bitmapsDisable = NULL;
|
|
|
fbe740 |
+ bool active = data->top == data->chain;
|
|
|
fbe740 |
|
|
|
fbe740 |
expectpath = g_strdup_printf("%s/%s%s", abs_srcdir,
|
|
|
fbe740 |
blockcommitPrefix, data->name);
|
|
|
fbe740 |
@@ -947,20 +946,10 @@ testQemuBlockBitmapBlockcommit(const void *opaque)
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
- if (qemuBlockBitmapsHandleCommitStart(data->top, data->base, nodedata,
|
|
|
fbe740 |
- &actionsDisable, &bitmapsDisable) < 0)
|
|
|
fbe740 |
- return -1;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- virBufferAddLit(&buf, "pre job bitmap disable:\n");
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- if (actionsDisable &&
|
|
|
fbe740 |
- virJSONValueToBuffer(actionsDisable, &buf, true) < 0)
|
|
|
fbe740 |
- return -1;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
virBufferAddLit(&buf, "merge bitmpas:\n");
|
|
|
fbe740 |
|
|
|
fbe740 |
- if (qemuBlockBitmapsHandleCommitFinish(data->top, data->base, nodedata,
|
|
|
fbe740 |
- &actionsMerge, bitmapsDisable) < 0)
|
|
|
fbe740 |
+ if (qemuBlockBitmapsHandleCommitFinish(data->top, data->base, active, nodedata,
|
|
|
fbe740 |
+ &actionsMerge) < 0)
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
|
|
|
fbe740 |
if (actionsMerge &&
|
|
|
fbe740 |
@@ -1356,6 +1345,7 @@ mymain(void)
|
|
|
fbe740 |
#define TEST_BITMAP_BLOCKCOMMIT(testname, topimg, baseimg, ndf) \
|
|
|
fbe740 |
do {\
|
|
|
fbe740 |
blockbitmapblockcommitdata.name = testname; \
|
|
|
fbe740 |
+ blockbitmapblockcommitdata.chain = bitmapSourceChain; \
|
|
|
fbe740 |
blockbitmapblockcommitdata.top = testQemuBitmapGetFakeChainEntry(bitmapSourceChain, topimg); \
|
|
|
fbe740 |
blockbitmapblockcommitdata.base = testQemuBitmapGetFakeChainEntry(bitmapSourceChain, baseimg); \
|
|
|
fbe740 |
blockbitmapblockcommitdata.nodedatafile = ndf; \
|
|
|
fbe740 |
diff --git a/tests/qemublocktestdata/bitmapblockcommit/empty b/tests/qemublocktestdata/bitmapblockcommit/empty
|
|
|
fbe740 |
index bfc58f994e..9260011852 100644
|
|
|
fbe740 |
--- a/tests/qemublocktestdata/bitmapblockcommit/empty
|
|
|
fbe740 |
+++ b/tests/qemublocktestdata/bitmapblockcommit/empty
|
|
|
fbe740 |
@@ -1,2 +1 @@
|
|
|
fbe740 |
-pre job bitmap disable:
|
|
|
fbe740 |
merge bitmpas:
|
|
|
fbe740 |
--
|
|
|
fbe740 |
2.27.0
|
|
|
fbe740 |
|