private void migrateThroughHypervisorOrStorage(StoragePool destPool, VMInstanceVO vm) throws StorageUnavailableException, InsufficientCapacityException {
final VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
final Long srchostId = vm.getHostId() != null ? vm.getHostId() : vm.getLastHostId();
final HostVO srcHost = _hostDao.findById(srchostId);
final Long srcClusterId = srcHost.getClusterId();
Answer[] hypervisorMigrationResults = attemptHypervisorMigration(destPool, vm);
boolean migrationResult = false;
if (hypervisorMigrationResults == null) {
migrationResult = volumeMgr.storageMigration(profile, destPool);
if (migrationResult) {
afterStorageMigrationCleanup(destPool, vm, srcHost, srcClusterId);
} else {
s_logger.debug("Storage migration failed");
}
} else {
afterHypervisorMigrationCleanup(destPool, vm, srcHost, srcClusterId, hypervisorMigrationResults);
}
}