host affinity: fix vm cannot be started if a vm is stopped in the affinity group (#6936)

This commit is contained in:
Wei Zhou 2022-12-06 10:05:49 +01:00 committed by GitHub
parent cf32f77e3d
commit d182eacf86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -81,7 +81,9 @@ public class HostAffinityProcessor extends AffinityProcessorBase implements Affi
Set<Long> hostIds = new HashSet<>();
for (Long groupVMId : vmIds) {
VMInstanceVO groupVM = _vmInstanceDao.findById(groupVMId);
hostIds.add(groupVM.getHostId());
if (groupVM != null && groupVM.getHostId() != null) {
hostIds.add(groupVM.getHostId());
}
}
return hostIds;
}