Skip to content

Commit 2143559

Browse files
authored
server: fix volume migration check for local volume attach on a stopped (#9578)
vm Fixes #8645 When a local storage volume is being attached to a stopped VM, volume migration is only needed when it is not present on the last host as the current host ID will be null in the database. Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent b78aede commit 2143559

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4312,7 +4312,11 @@ private boolean needMoveVolume(VolumeVO existingVolume, VolumeInfo newVolume) {
43124312
}
43134313
} else if (storeForNewStoreScope.getScopeType() == ScopeType.HOST
43144314
&& (storeForExistingStoreScope.getScopeType() == ScopeType.CLUSTER || storeForExistingStoreScope.getScopeType() == ScopeType.ZONE)) {
4315-
Long hostId = _vmInstanceDao.findById(existingVolume.getInstanceId()).getHostId();
4315+
VMInstanceVO vm = _vmInstanceDao.findById(existingVolume.getInstanceId());
4316+
Long hostId = vm.getHostId();
4317+
if (hostId == null) {
4318+
hostId = vm.getLastHostId();
4319+
}
43164320
if (storeForNewStoreScope.getScopeId().equals(hostId)) {
43174321
return false;
43184322
}

0 commit comments

Comments
 (0)