From 20ba086d99dc7ed75b771ff81f653aeead42e68f Mon Sep 17 00:00:00 2001 From: Koushik Das Date: Thu, 9 Aug 2012 19:32:39 +0530 Subject: [PATCH] Fix CS-15910 In case of volume creation from snapshot there is no associated VM so put a check for that. Reviewed-by: Nitin --- .../storage/allocator/FirstFitStoragePoolAllocator.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/src/com/cloud/storage/allocator/FirstFitStoragePoolAllocator.java b/server/src/com/cloud/storage/allocator/FirstFitStoragePoolAllocator.java index 365fb6a7007..73783bb32e8 100644 --- a/server/src/com/cloud/storage/allocator/FirstFitStoragePoolAllocator.java +++ b/server/src/com/cloud/storage/allocator/FirstFitStoragePoolAllocator.java @@ -74,9 +74,10 @@ public class FirstFitStoragePoolAllocator extends AbstractStoragePoolAllocator { } List pools = null; - if (!dskCh.useLocalStorage() || vmProfile.getVirtualMachine().getHostId() == null) { + // volume is shared "or" vm is not known "or" no host associated then go here + if (!dskCh.useLocalStorage() || vmProfile.getVirtualMachine() == null || vmProfile.getVirtualMachine().getHostId() == null) { pools = _storagePoolDao.findPoolsByTags(dcId, podId, clusterId, dskCh.getTags(), !dskCh.useLocalStorage()); - } else { + } else { // volume is local and vm host id is known pools = new ArrayList(); List hostPools = _poolHostDao.listByHostId(vmProfile.getVirtualMachine().getHostId()); for (StoragePoolHostVO hostPool: hostPools) {