rp- commented on code in PR #13746:
URL: https://github.com/apache/cloudstack/pull/13746#discussion_r3729726792
##########
plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LinstorBackupSnapshotCommandWrapper.java:
##########
@@ -121,6 +121,49 @@ private String convertImageToQCow2(
return dstPath;
}
+ /**
+ * Writes an incremental backup: a qcow2 on secondary storage containing
only the blocks of the
+ * snapshot device that differ from the parent snapshot qcow2, with the
parent as backing file.
+ * The overlay starts out backed by the raw snapshot device itself; the
safe-mode rebase onto the
+ * parent then copies every cluster in which the two backing files differ
into the overlay. The
+ * explicit virtual size clips the DRBD metadata trailing the storage
snapshot device.
+ */
+ private String createIncrementalQCow2(
+ final String srcPath,
+ final SnapshotObjectTO dst,
+ final KVMStoragePool secondaryPool,
+ final File parentFile,
+ final long netSize,
+ int waitMilliSeconds)
+ throws LibvirtException, QemuImgException, IOException
+ {
+ final String dstDir = secondaryPool.getLocalPath() + File.separator +
dst.getPath();
+ FileUtils.forceMkdir(new File(dstDir));
+ final String dstPath = dstDir + File.separator + dst.getName();
+
+ final Script createOverlay = new Script("qemu-img",
Duration.millis(waitMilliSeconds));
+ createOverlay.add("create", "-f", "qcow2", "-F", "raw", "-b", srcPath,
dstPath, String.valueOf(netSize));
+ final String createResult = createOverlay.execute();
+ if (createResult != null) {
+ throw new QemuImgException("Unable to create qcow2 overlay of " +
srcPath + ": " + createResult);
+ }
+
+ try {
+ final QemuImg qemu = new QemuImg(waitMilliSeconds);
+ final QemuImgFile dstFile = new QemuImgFile(dstPath,
QemuImg.PhysicalDiskFormat.QCOW2);
Review Comment:
The source of the rebase is not the live volume — it's the LINSTOR
storage-level snapshot block device (a thin-LVM snapshot / ZFS zvol snapshot
taken on primary). The VM keeps writing to the live DRBD device, never to the
snapshot device, so: (1) consistency is exactly the same crash-consistency as
the existing full-backup path (which qemu-img converts the very same snapshot
device) — this PR only changes how the data gets copied to secondary, not when
or how the snapshot is taken; quiescing, if requested, happens at snapshot
creation as before; (2) the rebase reads two static inputs (the snapshot device
and the parent qcow2 on secondary), so it copies a fixed set of clusters and
always terminates.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]