sureshanaparti commented on code in PR #12796:
URL: https://github.com/apache/cloudstack/pull/12796#discussion_r2930402213
##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRestoreBackupCommandWrapper.java:
##########
@@ -247,28 +262,38 @@ private boolean checkBackupPathExists(String backupPath) {
}
private boolean replaceVolumeWithBackup(KVMStoragePoolManager
storagePoolMgr, PrimaryDataStoreTO volumePool, String volumePath, String
backupPath, int timeout) {
- return replaceVolumeWithBackup(storagePoolMgr, volumePool, volumePath,
backupPath, timeout, false);
+ return replaceVolumeWithBackup(storagePoolMgr, volumePool, volumePath,
backupPath, timeout, false, null);
}
- 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;
+ private boolean replaceVolumeWithBackup(KVMStoragePoolManager
storagePoolMgr, PrimaryDataStoreTO volumePool, String volumePath, String
backupPath, int timeout, boolean createTargetVolume, Long size) {
+ if (List.of(Storage.StoragePoolType.RBD,
Storage.StoragePoolType.Linstor).contains(volumePool.getPoolType())) {
+ return replaceBlockDeviceWithBackup(storagePoolMgr, volumePool,
volumePath, backupPath, timeout, createTargetVolume, size);
}
- return replaceRbdVolumeWithBackup(storagePoolMgr, volumePool,
volumePath, backupPath, timeout, createTargetVolume);
+ int exitValue =
Script.runSimpleBashScriptForExitValue(String.format(RSYNC_COMMAND, backupPath,
volumePath));
+ return exitValue == 0;
}
- private boolean replaceRbdVolumeWithBackup(KVMStoragePoolManager
storagePoolMgr, PrimaryDataStoreTO volumePool, String volumePath, String
backupPath, int timeout, boolean createTargetVolume) {
+ private boolean replaceBlockDeviceWithBackup(KVMStoragePoolManager
storagePoolMgr, PrimaryDataStoreTO volumePool, String volumePath, String
backupPath, int timeout, boolean createTargetVolume, Long size) {
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("Restoring RBD volume: {}", rdbDisk.toString());
+ String volumeUuid = getVolumeUuidFromPath(volumePath, volumePool);
+ KVMPhysicalDisk disk = null;
+ if (createTargetVolume) {
+ if
(Storage.StoragePoolType.Linstor.equals(volumePool.getPoolType())) {
+ disk = volumeStoragePool.createPhysicalDisk(volumeUuid,
QemuImg.PhysicalDiskFormat.RAW, Storage.ProvisioningType.THIN, size, null);
+ }
+ } else {
+ if
(Storage.StoragePoolType.Linstor.equals(volumePool.getPoolType())) {
+
storagePoolMgr.connectPhysicalDisk(volumePool.getPoolType(),
volumePool.getUuid(), volumeUuid, null);
+ } else {
+ disk =
volumeStoragePool.getPhysicalDisk(getVolumeUuidFromPath(volumePath,
volumePool));
Review Comment:
@abh1sar usually, better to lookup by volume path, not the uuid. I checked
in my earlier testing, the uuid and path are the same for volumes on ceph,
we've to check after migrate volume, any other operation which can changes the
path and not uuid. to avoid any issue, can you check for StoragePoolType.RBD
and get disk by volume path?
--
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]