abh1sar commented on code in PR #11684:
URL: https://github.com/apache/cloudstack/pull/11684#discussion_r2371519920


##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRestoreBackupCommandWrapper.java:
##########
@@ -197,14 +213,63 @@ private Pair<String, String> getBackupPath(String 
mountDirectory, String volumeP
         return new Pair<>(bkpPath, volUuid);
     }
 
-    private boolean replaceVolumeWithBackup(String volumePath, String 
backupPath) {
-        int exitValue = 
Script.runSimpleBashScriptForExitValue(String.format(RSYNC_COMMAND, backupPath, 
volumePath));
-        return exitValue == 0;
+    private boolean replaceVolumeWithBackup(KVMStoragePoolManager 
storagePoolMgr, PrimaryDataStoreTO volumePool, String volumePath, String 
backupPath, int timeout) {
+        return replaceVolumeWithBackup(storagePoolMgr, volumePool, volumePath, 
backupPath, timeout, false);
+    }
+
+    private boolean replaceVolumeWithBackup(KVMStoragePoolManager 
storagePoolMgr, PrimaryDataStoreTO volumePool, String volumePath, String 
backupPath, int timeout, boolean createTargetVolume) {
+        if (volumePool.getPoolType() != Storage.StoragePoolType.RBD) {
+            int exitValue = 
Script.runSimpleBashScriptForExitValue(String.format(RSYNC_COMMAND, backupPath, 
volumePath));
+            return exitValue == 0;
+        }
+
+        return replaceRbdVolumeWithBackup(storagePoolMgr, volumePool, 
volumePath, backupPath, timeout, createTargetVolume);
+    }
+
+    private boolean replaceRbdVolumeWithBackup(KVMStoragePoolManager 
storagePoolMgr, PrimaryDataStoreTO volumePool, String volumePath, String 
backupPath, int timeout, boolean createTargetVolume) {
+        KVMStoragePool volumeStoragePool = 
storagePoolMgr.getStoragePool(volumePool.getPoolType(), volumePool.getUuid());
+        QemuImg qemu;
+        try {
+            qemu = new QemuImg(timeout * 1000, true, false);
+            if (!createTargetVolume) {
+                KVMPhysicalDisk rdbDisk = 
volumeStoragePool.getPhysicalDisk(volumePath);
+                logger.debug("RBD volume: {}", rdbDisk.toString());

Review Comment:
   just some context that the volume was accessed for restore.



-- 
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]

Reply via email to