Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3543,7 +3543,8 @@ protected void createStoragePoolMappingsForVolumes(VirtualMachineProfile profile
protected boolean shouldMapVolume(VirtualMachineProfile profile, StoragePoolVO currentPool) {
boolean isManaged = currentPool.isManaged();
boolean isNotKvm = HypervisorType.KVM != profile.getHypervisorType();
return isNotKvm || isManaged;
boolean isClvm = ClvmPoolManager.isClvmPoolType(currentPool.getPoolType());
return isNotKvm || isManaged || isClvm;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,9 @@ protected Answer copyVolumeBetweenPools(DataObject srcData, DataObject destData)
answer = new Answer(cmd, false, errMsg);
} else {
answer = ep.sendMessage(cmd);
if (answer != null && answer.getResult()) {
setClvmLockHostIdIfApplicable(destData, ep);
}
}
return answer;
}
Expand Down Expand Up @@ -463,6 +466,7 @@ protected Answer copyVolumeBetweenPools(DataObject srcData, DataObject destData)
imageStore.delete(objOnImageStore);
return answer;
}
setClvmLockHostIdIfApplicable(destData, ep);
} catch (Exception e) {
if (imageStore.exists(objOnImageStore)) {
objOnImageStore.processEvent(Event.OperationFailed);
Expand All @@ -486,6 +490,9 @@ protected Answer copyVolumeBetweenPools(DataObject srcData, DataObject destData)
answer = new Answer(cmd, false, errMsg);
} else {
answer = ep.sendMessage(cmd);
if (answer != null && answer.getResult()) {
setClvmLockHostIdIfApplicable(destData, ep);
}
}
// delete volume on cache store
if (cacheData != null) {
Expand All @@ -495,6 +502,17 @@ protected Answer copyVolumeBetweenPools(DataObject srcData, DataObject destData)
}
}

private void setClvmLockHostIdIfApplicable(DataObject destData, EndPoint ep) {
if (ep == null || !(destData instanceof VolumeInfo)) {
return;
}
VolumeInfo destVolume = (VolumeInfo) destData;
if (ClvmPoolManager.isClvmPoolType(destVolume.getStoragePoolType())) {
clvmPoolManager.setClvmLockHostId(destVolume.getId(), ep.getId());
logger.debug("Set CLVM lock host {} for migrated volume {}", ep.getId(), destVolume.getUuid());
}
}

private boolean canBypassSecondaryStorage(DataObject srcData, DataObject destData) {
if (srcData instanceof VolumeInfo) {
if (((VolumeInfo)srcData).isDirectDownload()) {
Expand Down Expand Up @@ -613,6 +631,9 @@ protected Answer migrateVolumeToPool(DataObject srcData, DataObject destData) {
if (destPool.getPoolType() == StoragePoolType.CLVM) {
volumeVo.setFormat(ImageFormat.RAW);
}
if (ClvmPoolManager.isClvmPoolType(destPool.getPoolType())) {
clvmPoolManager.setClvmLockHostId(volume.getId(), ep.getId());
}
// For SMB, pool credentials are also stored in the uri query string. We trim the query string
// part here to make sure the credentials do not get stored in the db unencrypted.
String folder = destPool.getPath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3096,6 +3096,12 @@ public boolean isLockTransferRequired(VolumeInfo volumeToAttach, StoragePoolType
}

if (volumePoolId == null || !volumePoolId.equals(vmPoolId)) {
Long volumeLockHostId = findVolumeLockHost(volumeToAttach);
if (volumeLockHostId != null && vmHostId != null && !volumeLockHostId.equals(vmHostId)) {
logger.info("CLVM cross-pool lock transfer required: Volume {} on pool {} lock is on host {} but VM is on host {}",
volumeToAttach.getUuid(), volumePoolId, volumeLockHostId, vmHostId);
return true;
}
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7022,7 +7022,7 @@ private static boolean isClvmVolume(DiskDef disk, VirtualMachineTO vmSpec) {
continue;
}
VolumeObjectTO volumeTO = (VolumeObjectTO) diskTO.getData();
if (!diskPath.equals(volumeTO.getPath()) && !diskPath.equals(diskTO.getPath())) {
if (!diskPath.substring(diskPath.lastIndexOf(File.separator) + 1).equals(volumeTO.getPath())) {
continue;
Comment thread
Pearl1594 marked this conversation as resolved.
Comment thread
Pearl1594 marked this conversation as resolved.
}
Comment thread
Pearl1594 marked this conversation as resolved.
DataStoreTO dataStore = volumeTO.getDataStore();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,16 +437,10 @@ public void revertSnapshot(SnapshotInfo snapshot, SnapshotInfo snapshotOnPrimary
try {
EndPoint ep = null;
VolumeInfo volumeInfo = volFactory.getVolume(snapshot.getVolumeId(), DataStoreRole.Primary);

StoragePoolVO storagePool = primaryStoreDao.findById(volumeInfo.getPoolId());
if (storagePool != null && storagePool.getPoolType() == StoragePoolType.CLVM) {
ep = epSelector.select(volumeInfo);
if (snapshotOnPrimaryStore != null) {
ep = epSelector.select(snapshotOnPrimaryStore);
} else {
if (snapshotOnPrimaryStore != null) {
ep = epSelector.select(snapshotOnPrimaryStore);
} else {
ep = epSelector.select(volumeInfo);
}
ep = epSelector.select(volumeInfo);
}
Comment thread
Pearl1594 marked this conversation as resolved.

if ( ep == null ){
Expand Down
Loading