Skip to content

Commit 7e5e1e7

Browse files
committed
fix creation of volume on destination host during migration to clvm/clvm-ng
1 parent 01aa259 commit 7e5e1e7

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy {
208208
private VolumeDataFactory _volFactory;
209209
@Inject
210210
ResourceManager resourceManager;
211+
@Inject
212+
private ClvmLockManager clvmLockManager;
211213

212214
@Override
213215
public StrategyPriority canHandle(DataObject srcData, DataObject destData) {
@@ -2073,6 +2075,13 @@ public void copyAsync(Map<VolumeInfo, DataStore> volumeDataStoreMap, VirtualMach
20732075

20742076
setVolumeMigrationOptions(srcVolumeInfo, destVolumeInfo, vmTO, srcHost, destStoragePool, migrationType);
20752077

2078+
if (ClvmLockManager.isClvmPoolType(destStoragePool.getPoolType())) {
2079+
destVolumeInfo.setDestinationHostId(destHost.getId());
2080+
clvmLockManager.setClvmLockHostId(destVolume.getId(), destHost.getId());
2081+
logger.info("Set CLVM lock host {} for volume {} during migration to ensure creation on destination host",
2082+
destHost.getId(), destVolumeInfo.getUuid());
2083+
}
2084+
20762085
// create a volume on the destination storage
20772086
destDataStore.getDriver().createAsync(destDataStore, destVolumeInfo, null);
20782087

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2652,10 +2652,11 @@ private KVMPhysicalDisk createClvmNgDiskWithBacking(String volumeUuid, int timeo
26522652
throw new CloudRuntimeException("Failed to create QCOW2 on CLVM_NG volume: " + result);
26532653
}
26542654

2655+
long actualSize = getClvmVolumeSize(volumePath);
26552656
KVMPhysicalDisk disk = new KVMPhysicalDisk(volumePath, volumeUuid, pool);
26562657
disk.setFormat(PhysicalDiskFormat.QCOW2);
2657-
disk.setSize(lvSize);
2658-
disk.setVirtualSize(virtualSize);
2658+
disk.setSize(actualSize);
2659+
disk.setVirtualSize(actualSize);
26592660

26602661
logger.info("Successfully created CLVM_NG volume {} with backing file (LV size: {}, virtual size: {}, provisioning: {}, preallocation: {})",
26612662
volumeUuid, lvSize, virtualSize, provisioningType, preallocation);

0 commit comments

Comments
 (0)