|
|
fbe740 |
From 14b1e4fc93ba1a87854aa1afaf519cc3accff4c6 Mon Sep 17 00:00:00 2001
|
|
|
fbe740 |
Message-Id: <14b1e4fc93ba1a87854aa1afaf519cc3accff4c6@dist-git>
|
|
|
fbe740 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
fbe740 |
Date: Tue, 23 Jun 2020 12:23:34 +0200
|
|
|
fbe740 |
Subject: [PATCH] qemu: backup: Fix handling of backing store for backup target
|
|
|
fbe740 |
images
|
|
|
fbe740 |
MIME-Version: 1.0
|
|
|
fbe740 |
Content-Type: text/plain; charset=UTF-8
|
|
|
fbe740 |
Content-Transfer-Encoding: 8bit
|
|
|
fbe740 |
|
|
|
fbe740 |
We always tried to install backing store for the image even if it didn't
|
|
|
fbe740 |
make sense, e.g. for a full backup into a raw image. Additionally we
|
|
|
fbe740 |
didn't record the backing file into the qcow2 metadata so the image
|
|
|
fbe740 |
itself contained the diff of data but reading from it would be
|
|
|
fbe740 |
incomplete as it depends on the backing image.
|
|
|
fbe740 |
|
|
|
fbe740 |
This patch fixes both issues by carefully installing the correct backing
|
|
|
fbe740 |
file when appropriate and also recording it into the metadata when
|
|
|
fbe740 |
creating the image.
|
|
|
fbe740 |
|
|
|
fbe740 |
https://bugzilla.redhat.com/show_bug.cgi?id=1813310
|
|
|
fbe740 |
|
|
|
fbe740 |
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
fbe740 |
(cherry picked from commit 4aea6f42fe32175ce0cb9015913db536097130e4)
|
|
|
fbe740 |
https://bugzilla.redhat.com/show_bug.cgi?id=1804593
|
|
|
fbe740 |
Message-Id: <8c4ebc06863aac1f75532b6633772944a6b0bd2a.1592906423.git.pkrempa@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
fbe740 |
---
|
|
|
fbe740 |
src/qemu/qemu_backup.c | 26 ++++++++++++++++++++++----
|
|
|
fbe740 |
1 file changed, 22 insertions(+), 4 deletions(-)
|
|
|
fbe740 |
|
|
|
fbe740 |
diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c
|
|
|
fbe740 |
index 9a056fa407..5d18720f53 100644
|
|
|
fbe740 |
--- a/src/qemu/qemu_backup.c
|
|
|
fbe740 |
+++ b/src/qemu/qemu_backup.c
|
|
|
fbe740 |
@@ -105,6 +105,8 @@ struct qemuBackupDiskData {
|
|
|
fbe740 |
virDomainDiskDefPtr domdisk;
|
|
|
fbe740 |
qemuBlockJobDataPtr blockjob;
|
|
|
fbe740 |
virStorageSourcePtr store;
|
|
|
fbe740 |
+ virStorageSourcePtr terminator;
|
|
|
fbe740 |
+ virStorageSourcePtr backingStore;
|
|
|
fbe740 |
char *incrementalBitmap;
|
|
|
fbe740 |
qemuBlockStorageSourceChainDataPtr crdata;
|
|
|
fbe740 |
bool labelled;
|
|
|
fbe740 |
@@ -146,6 +148,7 @@ qemuBackupDiskDataCleanupOne(virDomainObjPtr vm,
|
|
|
fbe740 |
qemuBlockJobStartupFinalize(vm, dd->blockjob);
|
|
|
fbe740 |
|
|
|
fbe740 |
qemuBlockStorageSourceChainDataFree(dd->crdata);
|
|
|
fbe740 |
+ virObjectUnref(dd->terminator);
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
|
|
|
fbe740 |
@@ -295,6 +298,7 @@ qemuBackupDiskPrepareDataOne(virDomainObjPtr vm,
|
|
|
fbe740 |
virDomainBackupDiskDefPtr backupdisk,
|
|
|
fbe740 |
struct qemuBackupDiskData *dd,
|
|
|
fbe740 |
virJSONValuePtr actions,
|
|
|
fbe740 |
+ bool pull,
|
|
|
fbe740 |
virDomainMomentDefPtr *incremental,
|
|
|
fbe740 |
virHashTablePtr blockNamedNodeData,
|
|
|
fbe740 |
virQEMUDriverConfigPtr cfg)
|
|
|
fbe740 |
@@ -314,6 +318,19 @@ qemuBackupDiskPrepareDataOne(virDomainObjPtr vm,
|
|
|
fbe740 |
if (!dd->store->format)
|
|
|
fbe740 |
dd->store->format = VIR_STORAGE_FILE_QCOW2;
|
|
|
fbe740 |
|
|
|
fbe740 |
+ /* calculate backing store to use:
|
|
|
fbe740 |
+ * push mode:
|
|
|
fbe740 |
+ * full backups: no backing store
|
|
|
fbe740 |
+ * incremental: original disk if format supports backing store
|
|
|
fbe740 |
+ * pull mode:
|
|
|
fbe740 |
+ * both: original disk
|
|
|
fbe740 |
+ */
|
|
|
fbe740 |
+ if (pull || (incremental && dd->store->format >= VIR_STORAGE_FILE_BACKING)) {
|
|
|
fbe740 |
+ dd->backingStore = dd->domdisk->src;
|
|
|
fbe740 |
+ } else {
|
|
|
fbe740 |
+ dd->backingStore = dd->terminator = virStorageSourceNew();
|
|
|
fbe740 |
+ }
|
|
|
fbe740 |
+
|
|
|
fbe740 |
if (qemuDomainStorageFileInit(priv->driver, vm, dd->store, dd->domdisk->src) < 0)
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
|
|
|
fbe740 |
@@ -337,7 +354,7 @@ qemuBackupDiskPrepareDataOne(virDomainObjPtr vm,
|
|
|
fbe740 |
|
|
|
fbe740 |
/* use original disk as backing to prevent opening the backing chain */
|
|
|
fbe740 |
if (!(dd->crdata = qemuBuildStorageSourceChainAttachPrepareBlockdevTop(dd->store,
|
|
|
fbe740 |
- dd->domdisk->src,
|
|
|
fbe740 |
+ dd->backingStore,
|
|
|
fbe740 |
priv->qemuCaps)))
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
|
|
|
fbe740 |
@@ -398,6 +415,7 @@ qemuBackupDiskPrepareData(virDomainObjPtr vm,
|
|
|
fbe740 |
struct qemuBackupDiskData *disks = NULL;
|
|
|
fbe740 |
ssize_t ndisks = 0;
|
|
|
fbe740 |
size_t i;
|
|
|
fbe740 |
+ bool pull = def->type == VIR_DOMAIN_BACKUP_TYPE_PULL;
|
|
|
fbe740 |
|
|
|
fbe740 |
disks = g_new0(struct qemuBackupDiskData, def->ndisks);
|
|
|
fbe740 |
|
|
|
fbe740 |
@@ -410,12 +428,12 @@ qemuBackupDiskPrepareData(virDomainObjPtr vm,
|
|
|
fbe740 |
|
|
|
fbe740 |
ndisks++;
|
|
|
fbe740 |
|
|
|
fbe740 |
- if (qemuBackupDiskPrepareDataOne(vm, backupdisk, dd, actions,
|
|
|
fbe740 |
+ if (qemuBackupDiskPrepareDataOne(vm, backupdisk, dd, actions, pull,
|
|
|
fbe740 |
incremental, blockNamedNodeData,
|
|
|
fbe740 |
cfg) < 0)
|
|
|
fbe740 |
goto error;
|
|
|
fbe740 |
|
|
|
fbe740 |
- if (def->type == VIR_DOMAIN_BACKUP_TYPE_PULL) {
|
|
|
fbe740 |
+ if (pull) {
|
|
|
fbe740 |
if (qemuBackupDiskPrepareDataOnePull(actions, dd) < 0)
|
|
|
fbe740 |
goto error;
|
|
|
fbe740 |
} else {
|
|
|
fbe740 |
@@ -480,7 +498,7 @@ qemuBackupDiskPrepareOneStorage(virDomainObjPtr vm,
|
|
|
fbe740 |
dd->store, dd->domdisk->src) < 0)
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
|
|
|
fbe740 |
- if (qemuBlockStorageSourceCreate(vm, dd->store, NULL, NULL,
|
|
|
fbe740 |
+ if (qemuBlockStorageSourceCreate(vm, dd->store, dd->backingStore, NULL,
|
|
|
fbe740 |
dd->crdata->srcdata[0],
|
|
|
fbe740 |
QEMU_ASYNC_JOB_BACKUP) < 0)
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
--
|
|
|
fbe740 |
2.27.0
|
|
|
fbe740 |
|