Skip to content

Commit 40c22e2

Browse files
authored
kvm: execute "qemu-img convert" by Script.executeCommandForExitValue
1 parent f513c2a commit 40c22e2

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRestoreBackupCommandWrapper.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ public class LibvirtRestoreBackupCommandWrapper extends CommandWrapper<RestoreBa
5959
// Flattens the backing-file chain into a single self-contained qcow2 written to the
6060
// destination volume path. Used when the source backup is an incremental whose qcow2
6161
// has a backing reference to its parent (chain set up by nasbackup.sh's qemu-img rebase).
62-
private static final String QEMU_IMG_FLATTEN_COMMAND = "qemu-img convert -O qcow2 %s %s";
63-
// Detects whether a qcow2 file references a parent in its backing-file metadata.
64-
// Returns 0 (true) when a backing file is present, 1 when not. Uses --output=json
65-
// so the test is robust to qemu-img version differences in human-readable output.
6662
private static final String QEMU_IMG_HAS_BACKING_COMMAND =
6763
"qemu-img info --output=json %s 2>/dev/null | grep -q '\"backing-filename\"'";
6864

@@ -291,9 +287,8 @@ private boolean replaceVolumeWithBackup(KVMStoragePoolManager storagePoolMgr, Pr
291287
// chain via qemu-img convert, which follows the backing-file links and
292288
// produces a single self-contained qcow2.
293289
if (hasBackingChain(backupPath)) {
294-
int flattenExit = Script.runSimpleBashScriptForExitValue(
295-
String.format(QEMU_IMG_FLATTEN_COMMAND, backupPath, volumePath), timeout, false);
296-
return flattenExit == 0;
290+
String[] qemuImgCmd = new String[] { Script.getExecutableAbsolutePath("qemu-img"), "convert", "-O", "qcow2", backupPath, volumePath };
291+
int flattenExit = Script.executeCommandForExitValue(qemuImgCmd);
297292
}
298293

299294
String[] rsyncCmd = new String[] { Script.getExecutableAbsolutePath("rsync"), "-az", backupPath, volumePath };

0 commit comments

Comments
 (0)