rp- commented on code in PR #13877:
URL: https://github.com/apache/cloudstack/pull/13877#discussion_r3965390920
##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRestoreBackupCommandWrapper.java:
##########
@@ -275,11 +284,28 @@ private boolean
replaceVolumeWithBackup(KVMStoragePoolManager storagePoolMgr, Pr
return replaceBlockDeviceWithBackup(storagePoolMgr, volumePool,
volumePath, backupPath, timeout, createTargetVolume, size);
}
+ // For NAS-backed incremental backups, the source qcow2 has a
backing-file
+ // reference to its parent (set by nasbackup.sh's qemu-img rebase). A
plain
+ // rsync would copy only the differential blocks, leaving a volume that
+ // depends on a backing file the primary storage doesn't have. Flatten
the
+ // chain via qemu-img convert, which follows the backing-file links and
+ // produces a single self-contained qcow2.
+ if (hasBackingChain(backupPath)) {
+ int flattenExit = Script.runSimpleBashScriptForExitValue(
+ String.format(QEMU_IMG_FLATTEN_COMMAND, backupPath,
volumePath), timeout, false);
Review Comment:
This ended up different from main. When 4.22 was forward-merged, cd486acc93
switched this flatten call to the argv form to match the rsync/mount/virsh
calls that 56ad044865 had already converted in this file:
```java
String[] qemuImgCmd = new String[] {
Script.getExecutableAbsolutePath("qemu-img"), "convert", "-O", "qcow2",
backupPath, volumePath };
int flattenExit = Script.executeCommandForExitValue(qemuImgCmd);
```
The backport keeps the runSimpleBashScriptForExitValue + String.format
version, so we now have the shell-string form right above an rsync call that
uses argv. It works, but paths with spaces or shell metacharacters would break.
We should use the change from cd486acc93 here and drop the
`QEMU_IMG_FLATTEN_COMMAND` constant? Then 4.22 and main are identical for this
file.
--
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]