mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-24 12:22:20 +00:00
qemu: backup: Install bitmap for incremental backup to appropriate node only
Libvirt's backup code has two modes: 1) push - where qemu actively writes the difference since the checkpoint into the output file 2) pull - where we instruct qemu to expose a frozen disk state along with a bitmap of blocks which changed since the checkpoint For push mode qemu needs the temporary bitmap we use where we calculate the actual changes to be present on the block node backing the disk. For pull mode where we expose the bitmap via NBD qemu actually wants the bitmap to be present for the exported block node which is the scratch file. Until now we've calculated the bitmap twice and installed it both to the scratch file and to the disk node, but we don't need to since we know when it's needed. Pass in the 'pull' flag and decide where to install the bitmap according to it and also when to register the bitmap name with the blockjob. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
6f30d7003a
commit
0316c28a45
@ -109,6 +109,7 @@ struct qemuBackupDiskData {
|
|||||||
virStorageSourcePtr terminator;
|
virStorageSourcePtr terminator;
|
||||||
virStorageSourcePtr backingStore;
|
virStorageSourcePtr backingStore;
|
||||||
char *incrementalBitmap;
|
char *incrementalBitmap;
|
||||||
|
const char *domdiskIncrementalBitmap; /* name of temporary bitmap installed on disk source */
|
||||||
qemuBlockStorageSourceChainDataPtr crdata;
|
qemuBlockStorageSourceChainDataPtr crdata;
|
||||||
bool labelled;
|
bool labelled;
|
||||||
bool initialized;
|
bool initialized;
|
||||||
@ -201,6 +202,7 @@ qemuBackupDiskPrepareOneBitmapsChain(virStorageSourcePtr backingChain,
|
|||||||
static int
|
static int
|
||||||
qemuBackupDiskPrepareOneBitmaps(struct qemuBackupDiskData *dd,
|
qemuBackupDiskPrepareOneBitmaps(struct qemuBackupDiskData *dd,
|
||||||
virJSONValuePtr actions,
|
virJSONValuePtr actions,
|
||||||
|
bool pull,
|
||||||
GHashTable *blockNamedNodeData)
|
GHashTable *blockNamedNodeData)
|
||||||
{
|
{
|
||||||
if (!qemuBlockBitmapChainIsValid(dd->domdisk->src,
|
if (!qemuBlockBitmapChainIsValid(dd->domdisk->src,
|
||||||
@ -212,21 +214,29 @@ qemuBackupDiskPrepareOneBitmaps(struct qemuBackupDiskData *dd,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuBackupDiskPrepareOneBitmapsChain(dd->domdisk->src,
|
/* For pull-mode backup, we need the bitmap to be present in the scratch
|
||||||
dd->domdisk->src,
|
* file as that will be exported. For push-mode backup the bitmap is
|
||||||
dd->incrementalBitmap,
|
* actually required on top of the image backing the disk */
|
||||||
dd->backupdisk->incremental,
|
|
||||||
actions,
|
|
||||||
blockNamedNodeData) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (qemuBackupDiskPrepareOneBitmapsChain(dd->domdisk->src,
|
if (pull) {
|
||||||
dd->store,
|
if (qemuBackupDiskPrepareOneBitmapsChain(dd->domdisk->src,
|
||||||
dd->incrementalBitmap,
|
dd->store,
|
||||||
dd->backupdisk->incremental,
|
dd->incrementalBitmap,
|
||||||
actions,
|
dd->backupdisk->incremental,
|
||||||
blockNamedNodeData) < 0)
|
actions,
|
||||||
return -1;
|
blockNamedNodeData) < 0)
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
if (qemuBackupDiskPrepareOneBitmapsChain(dd->domdisk->src,
|
||||||
|
dd->domdisk->src,
|
||||||
|
dd->incrementalBitmap,
|
||||||
|
dd->backupdisk->incremental,
|
||||||
|
actions,
|
||||||
|
blockNamedNodeData) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
dd->domdiskIncrementalBitmap = dd->backupdisk->incremental;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -293,12 +303,12 @@ qemuBackupDiskPrepareDataOne(virDomainObjPtr vm,
|
|||||||
else
|
else
|
||||||
dd->incrementalBitmap = g_strdup_printf("backup-%s", dd->domdisk->dst);
|
dd->incrementalBitmap = g_strdup_printf("backup-%s", dd->domdisk->dst);
|
||||||
|
|
||||||
if (qemuBackupDiskPrepareOneBitmaps(dd, actions, blockNamedNodeData) < 0)
|
if (qemuBackupDiskPrepareOneBitmaps(dd, actions, pull, blockNamedNodeData) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(dd->blockjob = qemuBlockJobDiskNewBackup(vm, dd->domdisk, dd->store,
|
if (!(dd->blockjob = qemuBlockJobDiskNewBackup(vm, dd->domdisk, dd->store,
|
||||||
dd->incrementalBitmap)))
|
dd->domdiskIncrementalBitmap)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* use original disk as backing to prevent opening the backing chain */
|
/* use original disk as backing to prevent opening the backing chain */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user