Program: 106105
Project: 106105
Buggy source:
@Override public void advanceStart(String vmUuid,Map<VirtualMachineProfile.Param,Object> params,DeploymentPlan planToDeploy) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
  CallContext cctxt=CallContext.current();
  Account account=cctxt.getCallingAccount();
  User caller=cctxt.getCallingUser();
  VMInstanceVO vm=_vmDao.findByUuid(vmUuid);
  VirtualMachineGuru vmGuru=getVmGuru(vm);
  Ternary<VMInstanceVO,ReservationContext,ItWorkVO> start=changeToStartState(vmGuru,vm,caller,account);
  if (start == null) {
    return;
  }
  vm=start.first();
  ReservationContext ctx=start.second();
  ItWorkVO work=start.third();
  VMInstanceVO startedVm=null;
  ServiceOfferingVO offering=_offeringDao.findById(vm.getId(),vm.getServiceOfferingId());
  VirtualMachineTemplate template=_entityMgr.findById(VirtualMachineTemplate.class,vm.getTemplateId());
  if (s_logger.isDebugEnabled()) {
    s_logger.debug("String_Node_Str" + vm.getDataCenterId() + "String_Node_Str"+ vm.getPodIdToDeployIn());
  }
  DataCenterDeployment plan=new DataCenterDeployment(vm.getDataCenterId(),vm.getPodIdToDeployIn(),null,null,null,null,ctx);
  if (planToDeploy != null && planToDeploy.getDataCenterId() != 0) {
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str" + planToDeploy.getDataCenterId() + "String_Node_Str"+ planToDeploy.getPodId()+ "String_Node_Str"+ planToDeploy.getClusterId()+ "String_Node_Str"+ planToDeploy.getHostId()+ "String_Node_Str"+ planToDeploy.getPoolId());
    }
    plan=new DataCenterDeployment(planToDeploy.getDataCenterId(),planToDeploy.getPodId(),planToDeploy.getClusterId(),planToDeploy.getHostId(),planToDeploy.getPoolId(),planToDeploy.getPhysicalNetworkId(),ctx);
  }
  HypervisorGuru hvGuru=_hvGuruMgr.getGuru(vm.getHypervisorType());
  boolean canRetry=true;
  ExcludeList avoids=null;
  try {
    Journal journal=start.second().getJournal();
    if (planToDeploy != null) {
      avoids=planToDeploy.getAvoids();
    }
    if (avoids == null) {
      avoids=new ExcludeList();
    }
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str" + avoids.getPodsToAvoid() + "String_Node_Str"+ avoids.getClustersToAvoid()+ "String_Node_Str"+ avoids.getHostsToAvoid());
    }
    boolean planChangedByVolume=false;
    boolean reuseVolume=true;
    DataCenterDeployment originalPlan=plan;
    int retry=StartRetry.value();
    while (retry-- != 0) {
      if (reuseVolume) {
        List<VolumeVO> vols=_volsDao.findReadyRootVolumesByInstance(vm.getId());
        for (        VolumeVO vol : vols) {
          Long volTemplateId=vol.getTemplateId();
          if (volTemplateId != null && volTemplateId.longValue() != template.getId()) {
            if (s_logger.isDebugEnabled()) {
              s_logger.debug(vol + "String_Node_Str" + vm+ "String_Node_Str");
            }
            continue;
          }
          StoragePool pool=(StoragePool)dataStoreMgr.getPrimaryDataStore(vol.getPoolId());
          if (!pool.isInMaintenance()) {
            if (s_logger.isDebugEnabled()) {
              s_logger.debug("String_Node_Str");
            }
            long rootVolDcId=pool.getDataCenterId();
            Long rootVolPodId=pool.getPodId();
            Long rootVolClusterId=pool.getClusterId();
            if (planToDeploy != null && planToDeploy.getDataCenterId() != 0) {
              Long clusterIdSpecified=planToDeploy.getClusterId();
              if (clusterIdSpecified != null && rootVolClusterId != null) {
                if (rootVolClusterId.longValue() != clusterIdSpecified.longValue()) {
                  if (s_logger.isDebugEnabled()) {
                    s_logger.debug("String_Node_Str" + rootVolClusterId + "String_Node_Str"+ clusterIdSpecified);
                  }
                  throw new ResourceUnavailableException("String_Node_Str" + vm,Cluster.class,clusterIdSpecified);
                }
              }
              plan=new DataCenterDeployment(planToDeploy.getDataCenterId(),planToDeploy.getPodId(),planToDeploy.getClusterId(),planToDeploy.getHostId(),vol.getPoolId(),null,ctx);
            }
 else {
              plan=new DataCenterDeployment(rootVolDcId,rootVolPodId,rootVolClusterId,null,vol.getPoolId(),null,ctx);
              if (s_logger.isDebugEnabled()) {
                s_logger.debug(vol + "String_Node_Str" + rootVolDcId+ "String_Node_Str"+ rootVolPodId+ "String_Node_Str"+ rootVolClusterId);
              }
              planChangedByVolume=true;
            }
          }
        }
      }
      VirtualMachineProfileImpl vmProfile=new VirtualMachineProfileImpl(vm,template,offering,account,params);
      DeployDestination dest=null;
      try {
        dest=_dpMgr.planDeployment(vmProfile,plan,avoids);
      }
 catch (      AffinityConflictException e2) {
        s_logger.warn("String_Node_Str",e2);
        throw new CloudRuntimeException("String_Node_Str");
      }
      if (dest == null) {
        if (planChangedByVolume) {
          plan=originalPlan;
          planChangedByVolume=false;
          reuseVolume=false;
          continue;
        }
        throw new InsufficientServerCapacityException("String_Node_Str" + vmProfile,DataCenter.class,plan.getDataCenterId(),areAffinityGroupsAssociated(vmProfile));
      }
      if (dest != null) {
        avoids.addHost(dest.getHost().getId());
        journal.record("String_Node_Str",vmProfile,dest);
      }
      long destHostId=dest.getHost().getId();
      vm.setPodId(dest.getPod().getId());
      Long cluster_id=dest.getCluster().getId();
      ClusterDetailsVO cluster_detail_cpu=_clusterDetailsDao.findDetail(cluster_id,"String_Node_Str");
      ClusterDetailsVO cluster_detail_ram=_clusterDetailsDao.findDetail(cluster_id,"String_Node_Str");
      if (_uservmDetailsDao.findDetail(vm.getId(),"String_Node_Str") == null && ((Float.parseFloat(cluster_detail_cpu.getValue()) > 1f || Float.parseFloat(cluster_detail_ram.getValue()) > 1f))) {
        _uservmDetailsDao.addDetail(vm.getId(),"String_Node_Str",cluster_detail_cpu.getValue());
        _uservmDetailsDao.addDetail(vm.getId(),"String_Node_Str",cluster_detail_ram.getValue());
      }
 else       if (_uservmDetailsDao.findDetail(vm.getId(),"String_Node_Str") != null) {
        _uservmDetailsDao.addDetail(vm.getId(),"String_Node_Str",cluster_detail_cpu.getValue());
        _uservmDetailsDao.addDetail(vm.getId(),"String_Node_Str",cluster_detail_ram.getValue());
      }
      vmProfile.setCpuOvercommitRatio(Float.parseFloat(cluster_detail_cpu.getValue()));
      vmProfile.setMemoryOvercommitRatio(Float.parseFloat(cluster_detail_ram.getValue()));
      StartAnswer startAnswer=null;
      try {
        if (!changeState(vm,Event.OperationRetry,destHostId,work,Step.Prepare)) {
          throw new ConcurrentOperationException("String_Node_Str");
        }
      }
 catch (      NoTransitionException e1) {
        throw new ConcurrentOperationException(e1.getMessage());
      }
      try {
        if (s_logger.isDebugEnabled()) {
          s_logger.debug("String_Node_Str" + vm.getPodIdToDeployIn());
        }
        _networkMgr.prepare(vmProfile,dest,ctx);
        if (vm.getHypervisorType() != HypervisorType.BareMetal) {
          volumeMgr.prepare(vmProfile,dest);
        }
        if (!reuseVolume) {
          reuseVolume=true;
        }
        Commands cmds=null;
        vmGuru.finalizeVirtualMachineProfile(vmProfile,dest,ctx);
        VirtualMachineTO vmTO=hvGuru.implement(vmProfile);
        handlePath(vmTO.getDisks(),vm.getHypervisorType());
        cmds=new Commands(Command.OnError.Stop);
        cmds.addCommand(new StartCommand(vmTO,dest.getHost(),getExecuteInSequence()));
        vmGuru.finalizeDeployment(cmds,vmProfile,dest,ctx);
        work=_workDao.findById(work.getId());
        if (work == null || work.getStep() != Step.Prepare) {
          throw new ConcurrentOperationException("String_Node_Str" + work);
        }
        _workDao.updateStep(work,Step.Starting);
        _agentMgr.send(destHostId,cmds);
        _workDao.updateStep(work,Step.Started);
        startAnswer=cmds.getAnswer(StartAnswer.class);
        if (startAnswer != null && startAnswer.getResult()) {
          handlePath(vmTO.getDisks(),startAnswer.getIqnToPath());
          String host_guid=startAnswer.getHost_guid();
          if (host_guid != null) {
            HostVO finalHost=_resourceMgr.findHostByGuid(host_guid);
            if (finalHost == null) {
              throw new CloudRuntimeException("String_Node_Str" + host_guid + "String_Node_Str");
            }
            destHostId=finalHost.getId();
          }
          if (vmGuru.finalizeStart(vmProfile,destHostId,cmds,ctx)) {
            syncDiskChainChange(startAnswer);
            if (!changeState(vm,Event.OperationSucceeded,destHostId,work,Step.Done)) {
              throw new ConcurrentOperationException("String_Node_Str");
            }
            startedVm=vm;
            if (s_logger.isDebugEnabled()) {
              s_logger.debug("String_Node_Str" + vm);
            }
            return;
          }
 else {
            if (s_logger.isDebugEnabled()) {
              s_logger.info("String_Node_Str" + vm);
            }
            StopCommand cmd=new StopCommand(vm,getExecuteInSequence());
            StopAnswer answer=(StopAnswer)_agentMgr.easySend(destHostId,cmd);
            if (answer != null) {
              String hypervisortoolsversion=answer.getHypervisorToolsVersion();
              if (hypervisortoolsversion != null) {
                if (vm.getType() == VirtualMachine.Type.User) {
                  UserVmVO userVm=_userVmDao.findById(vm.getId());
                  _userVmDao.loadDetails(userVm);
                  userVm.setDetail("String_Node_Str",hypervisortoolsversion);
                  _userVmDao.saveDetails(userVm);
                }
              }
            }
            if (answer == null || !answer.getResult()) {
              s_logger.warn("String_Node_Str" + vm + "String_Node_Str"+ (answer != null ? answer.getDetails() : "String_Node_Str"));
              _haMgr.scheduleStop(vm,destHostId,WorkType.ForceStop);
              throw new ExecutionException("String_Node_Str" + vm + "String_Node_Str");
            }
            throw new ExecutionException("String_Node_Str" + vm + "String_Node_Str");
          }
        }
        s_logger.info("String_Node_Str" + dest.getHost() + "String_Node_Str"+ (startAnswer == null ? "String_Node_Str" : startAnswer.getDetails()));
      }
 catch (      OperationTimedoutException e) {
        s_logger.debug("String_Node_Str" + dest.getHost());
        if (e.isActive()) {
          _haMgr.scheduleStop(vm,destHostId,WorkType.CheckStop);
        }
        canRetry=false;
        throw new AgentUnavailableException("String_Node_Str" + vm.getHostName(),destHostId,e);
      }
catch (      ResourceUnavailableException e) {
        s_logger.info("String_Node_Str",e);
        if (!avoids.add(e)) {
          if (e.getScope() == Volume.class || e.getScope() == Nic.class) {
            throw e;
          }
 else {
            s_logger.warn("String_Node_Str" + e.getScope().getName(),e);
            throw e;
          }
        }
      }
catch (      InsufficientCapacityException e) {
        s_logger.info("String_Node_Str",e);
        if (!avoids.add(e)) {
          if (e.getScope() == Volume.class || e.getScope() == Nic.class) {
            throw e;
          }
 else {
            s_logger.warn("String_Node_Str" + e.getScope().getName(),e);
          }
        }
      }
catch (      Exception e) {
        s_logger.error("String_Node_Str" + vm,e);
        throw new AgentUnavailableException("String_Node_Str" + e.getMessage(),destHostId,e);
      }
 finally {
        if (startedVm == null && canRetry) {
          Step prevStep=work.getStep();
          _workDao.updateStep(work,Step.Release);
          if ((prevStep == Step.Started || prevStep == Step.Starting) && (startAnswer != null && startAnswer.getResult())) {
            cleanup(vmGuru,vmProfile,work,Event.OperationFailed,false);
          }
 else {
            cleanup(vmGuru,vmProfile,work,Event.OperationFailed,true);
          }
        }
      }
    }
  }
  finally {
    if (startedVm == null) {
      if (canRetry) {
        try {
          changeState(vm,Event.OperationFailed,null,work,Step.Done);
        }
 catch (        NoTransitionException e) {
          throw new ConcurrentOperationException(e.getMessage());
        }
      }
    }
    if (planToDeploy != null) {
      planToDeploy.setAvoids(avoids);
    }
  }
  if (startedVm == null) {
    throw new CloudRuntimeException("String_Node_Str" + vm.getHostName() + "String_Node_Str"+ vm.getUuid()+ "String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public void advanceStart(String vmUuid,Map<VirtualMachineProfile.Param,Object> params,DeploymentPlan planToDeploy) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
  CallContext cctxt=CallContext.current();
  Account account=cctxt.getCallingAccount();
  User caller=cctxt.getCallingUser();
  VMInstanceVO vm=_vmDao.findByUuid(vmUuid);
  VirtualMachineGuru vmGuru=getVmGuru(vm);
  Ternary<VMInstanceVO,ReservationContext,ItWorkVO> start=changeToStartState(vmGuru,vm,caller,account);
  if (start == null) {
    return;
  }
  vm=start.first();
  ReservationContext ctx=start.second();
  ItWorkVO work=start.third();
  VMInstanceVO startedVm=null;
  ServiceOfferingVO offering=_offeringDao.findById(vm.getId(),vm.getServiceOfferingId());
  VirtualMachineTemplate template=_entityMgr.findById(VirtualMachineTemplate.class,vm.getTemplateId());
  if (s_logger.isDebugEnabled()) {
    s_logger.debug("String_Node_Str" + vm.getDataCenterId() + "String_Node_Str"+ vm.getPodIdToDeployIn());
  }
  DataCenterDeployment plan=new DataCenterDeployment(vm.getDataCenterId(),vm.getPodIdToDeployIn(),null,null,null,null,ctx);
  if (planToDeploy != null && planToDeploy.getDataCenterId() != 0) {
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str" + planToDeploy.getDataCenterId() + "String_Node_Str"+ planToDeploy.getPodId()+ "String_Node_Str"+ planToDeploy.getClusterId()+ "String_Node_Str"+ planToDeploy.getHostId()+ "String_Node_Str"+ planToDeploy.getPoolId());
    }
    plan=new DataCenterDeployment(planToDeploy.getDataCenterId(),planToDeploy.getPodId(),planToDeploy.getClusterId(),planToDeploy.getHostId(),planToDeploy.getPoolId(),planToDeploy.getPhysicalNetworkId(),ctx);
  }
  HypervisorGuru hvGuru=_hvGuruMgr.getGuru(vm.getHypervisorType());
  boolean canRetry=true;
  ExcludeList avoids=null;
  try {
    Journal journal=start.second().getJournal();
    if (planToDeploy != null) {
      avoids=planToDeploy.getAvoids();
    }
    if (avoids == null) {
      avoids=new ExcludeList();
    }
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str" + avoids.getPodsToAvoid() + "String_Node_Str"+ avoids.getClustersToAvoid()+ "String_Node_Str"+ avoids.getHostsToAvoid());
    }
    boolean planChangedByVolume=false;
    boolean reuseVolume=true;
    DataCenterDeployment originalPlan=plan;
    int retry=StartRetry.value();
    while (retry-- != 0) {
      if (reuseVolume) {
        List<VolumeVO> vols=_volsDao.findReadyRootVolumesByInstance(vm.getId());
        for (        VolumeVO vol : vols) {
          Long volTemplateId=vol.getTemplateId();
          if (volTemplateId != null && volTemplateId.longValue() != template.getId()) {
            if (s_logger.isDebugEnabled()) {
              s_logger.debug(vol + "String_Node_Str" + vm+ "String_Node_Str");
            }
            continue;
          }
          StoragePool pool=(StoragePool)dataStoreMgr.getPrimaryDataStore(vol.getPoolId());
          if (!pool.isInMaintenance()) {
            if (s_logger.isDebugEnabled()) {
              s_logger.debug("String_Node_Str");
            }
            long rootVolDcId=pool.getDataCenterId();
            Long rootVolPodId=pool.getPodId();
            Long rootVolClusterId=pool.getClusterId();
            if (planToDeploy != null && planToDeploy.getDataCenterId() != 0) {
              Long clusterIdSpecified=planToDeploy.getClusterId();
              if (clusterIdSpecified != null && rootVolClusterId != null) {
                if (rootVolClusterId.longValue() != clusterIdSpecified.longValue()) {
                  if (s_logger.isDebugEnabled()) {
                    s_logger.debug("String_Node_Str" + rootVolClusterId + "String_Node_Str"+ clusterIdSpecified);
                  }
                  throw new ResourceUnavailableException("String_Node_Str" + vm,Cluster.class,clusterIdSpecified);
                }
              }
              plan=new DataCenterDeployment(planToDeploy.getDataCenterId(),planToDeploy.getPodId(),planToDeploy.getClusterId(),planToDeploy.getHostId(),vol.getPoolId(),null,ctx);
            }
 else {
              plan=new DataCenterDeployment(rootVolDcId,rootVolPodId,rootVolClusterId,null,vol.getPoolId(),null,ctx);
              if (s_logger.isDebugEnabled()) {
                s_logger.debug(vol + "String_Node_Str" + rootVolDcId+ "String_Node_Str"+ rootVolPodId+ "String_Node_Str"+ rootVolClusterId);
              }
              planChangedByVolume=true;
            }
          }
        }
      }
      VirtualMachineProfileImpl vmProfile=new VirtualMachineProfileImpl(vm,template,offering,account,params);
      DeployDestination dest=null;
      try {
        dest=_dpMgr.planDeployment(vmProfile,plan,avoids);
      }
 catch (      AffinityConflictException e2) {
        s_logger.warn("String_Node_Str",e2);
        throw new CloudRuntimeException("String_Node_Str");
      }
      if (dest == null) {
        if (planChangedByVolume) {
          plan=originalPlan;
          planChangedByVolume=false;
          reuseVolume=false;
          continue;
        }
        throw new InsufficientServerCapacityException("String_Node_Str" + vmProfile,DataCenter.class,plan.getDataCenterId(),areAffinityGroupsAssociated(vmProfile));
      }
      if (dest != null) {
        avoids.addHost(dest.getHost().getId());
        journal.record("String_Node_Str",vmProfile,dest);
      }
      long destHostId=dest.getHost().getId();
      vm.setPodId(dest.getPod().getId());
      Long cluster_id=dest.getCluster().getId();
      ClusterDetailsVO cluster_detail_cpu=_clusterDetailsDao.findDetail(cluster_id,"String_Node_Str");
      ClusterDetailsVO cluster_detail_ram=_clusterDetailsDao.findDetail(cluster_id,"String_Node_Str");
      if (_uservmDetailsDao.findDetail(vm.getId(),"String_Node_Str") == null && ((Float.parseFloat(cluster_detail_cpu.getValue()) > 1f || Float.parseFloat(cluster_detail_ram.getValue()) > 1f))) {
        _uservmDetailsDao.addDetail(vm.getId(),"String_Node_Str",cluster_detail_cpu.getValue());
        _uservmDetailsDao.addDetail(vm.getId(),"String_Node_Str",cluster_detail_ram.getValue());
      }
 else       if (_uservmDetailsDao.findDetail(vm.getId(),"String_Node_Str") != null) {
        _uservmDetailsDao.addDetail(vm.getId(),"String_Node_Str",cluster_detail_cpu.getValue());
        _uservmDetailsDao.addDetail(vm.getId(),"String_Node_Str",cluster_detail_ram.getValue());
      }
      vmProfile.setCpuOvercommitRatio(Float.parseFloat(cluster_detail_cpu.getValue()));
      vmProfile.setMemoryOvercommitRatio(Float.parseFloat(cluster_detail_ram.getValue()));
      StartAnswer startAnswer=null;
      try {
        if (!changeState(vm,Event.OperationRetry,destHostId,work,Step.Prepare)) {
          throw new ConcurrentOperationException("String_Node_Str");
        }
      }
 catch (      NoTransitionException e1) {
        throw new ConcurrentOperationException(e1.getMessage());
      }
      try {
        if (s_logger.isDebugEnabled()) {
          s_logger.debug("String_Node_Str" + vm.getPodIdToDeployIn());
        }
        _networkMgr.prepare(vmProfile,dest,ctx);
        if (vm.getHypervisorType() != HypervisorType.BareMetal) {
          volumeMgr.prepare(vmProfile,dest);
        }
        if (!reuseVolume) {
          reuseVolume=true;
        }
        Commands cmds=null;
        vmGuru.finalizeVirtualMachineProfile(vmProfile,dest,ctx);
        VirtualMachineTO vmTO=hvGuru.implement(vmProfile);
        handlePath(vmTO.getDisks(),vm.getHypervisorType());
        cmds=new Commands(Command.OnError.Stop);
        cmds.addCommand(new StartCommand(vmTO,dest.getHost(),ExecuteInSequence.value()));
        vmGuru.finalizeDeployment(cmds,vmProfile,dest,ctx);
        work=_workDao.findById(work.getId());
        if (work == null || work.getStep() != Step.Prepare) {
          throw new ConcurrentOperationException("String_Node_Str" + work);
        }
        _workDao.updateStep(work,Step.Starting);
        _agentMgr.send(destHostId,cmds);
        _workDao.updateStep(work,Step.Started);
        startAnswer=cmds.getAnswer(StartAnswer.class);
        if (startAnswer != null && startAnswer.getResult()) {
          handlePath(vmTO.getDisks(),startAnswer.getIqnToPath());
          String host_guid=startAnswer.getHost_guid();
          if (host_guid != null) {
            HostVO finalHost=_resourceMgr.findHostByGuid(host_guid);
            if (finalHost == null) {
              throw new CloudRuntimeException("String_Node_Str" + host_guid + "String_Node_Str");
            }
            destHostId=finalHost.getId();
          }
          if (vmGuru.finalizeStart(vmProfile,destHostId,cmds,ctx)) {
            syncDiskChainChange(startAnswer);
            if (!changeState(vm,Event.OperationSucceeded,destHostId,work,Step.Done)) {
              throw new ConcurrentOperationException("String_Node_Str");
            }
            startedVm=vm;
            if (s_logger.isDebugEnabled()) {
              s_logger.debug("String_Node_Str" + vm);
            }
            return;
          }
 else {
            if (s_logger.isDebugEnabled()) {
              s_logger.info("String_Node_Str" + vm);
            }
            StopCommand cmd=new StopCommand(vm,ExecuteInSequence.value());
            StopAnswer answer=(StopAnswer)_agentMgr.easySend(destHostId,cmd);
            if (answer != null) {
              String hypervisortoolsversion=answer.getHypervisorToolsVersion();
              if (hypervisortoolsversion != null) {
                if (vm.getType() == VirtualMachine.Type.User) {
                  UserVmVO userVm=_userVmDao.findById(vm.getId());
                  _userVmDao.loadDetails(userVm);
                  userVm.setDetail("String_Node_Str",hypervisortoolsversion);
                  _userVmDao.saveDetails(userVm);
                }
              }
            }
            if (answer == null || !answer.getResult()) {
              s_logger.warn("String_Node_Str" + vm + "String_Node_Str"+ (answer != null ? answer.getDetails() : "String_Node_Str"));
              _haMgr.scheduleStop(vm,destHostId,WorkType.ForceStop);
              throw new ExecutionException("String_Node_Str" + vm + "String_Node_Str");
            }
            throw new ExecutionException("String_Node_Str" + vm + "String_Node_Str");
          }
        }
        s_logger.info("String_Node_Str" + dest.getHost() + "String_Node_Str"+ (startAnswer == null ? "String_Node_Str" : startAnswer.getDetails()));
      }
 catch (      OperationTimedoutException e) {
        s_logger.debug("String_Node_Str" + dest.getHost());
        if (e.isActive()) {
          _haMgr.scheduleStop(vm,destHostId,WorkType.CheckStop);
        }
        canRetry=false;
        throw new AgentUnavailableException("String_Node_Str" + vm.getHostName(),destHostId,e);
      }
catch (      ResourceUnavailableException e) {
        s_logger.info("String_Node_Str",e);
        if (!avoids.add(e)) {
          if (e.getScope() == Volume.class || e.getScope() == Nic.class) {
            throw e;
          }
 else {
            s_logger.warn("String_Node_Str" + e.getScope().getName(),e);
            throw e;
          }
        }
      }
catch (      InsufficientCapacityException e) {
        s_logger.info("String_Node_Str",e);
        if (!avoids.add(e)) {
          if (e.getScope() == Volume.class || e.getScope() == Nic.class) {
            throw e;
          }
 else {
            s_logger.warn("String_Node_Str" + e.getScope().getName(),e);
          }
        }
      }
catch (      Exception e) {
        s_logger.error("String_Node_Str" + vm,e);
        throw new AgentUnavailableException("String_Node_Str" + e.getMessage(),destHostId,e);
      }
 finally {
        if (startedVm == null && canRetry) {
          Step prevStep=work.getStep();
          _workDao.updateStep(work,Step.Release);
          if ((prevStep == Step.Started || prevStep == Step.Starting) && (startAnswer != null && startAnswer.getResult())) {
            cleanup(vmGuru,vmProfile,work,Event.OperationFailed,false);
          }
 else {
            cleanup(vmGuru,vmProfile,work,Event.OperationFailed,true);
          }
        }
      }
    }
  }
  finally {
    if (startedVm == null) {
      if (canRetry) {
        try {
          changeState(vm,Event.OperationFailed,null,work,Step.Done);
        }
 catch (        NoTransitionException e) {
          throw new ConcurrentOperationException(e.getMessage());
        }
      }
    }
    if (planToDeploy != null) {
      planToDeploy.setAvoids(avoids);
    }
  }
  if (startedVm == null) {
    throw new CloudRuntimeException("String_Node_Str" + vm.getHostName() + "String_Node_Str"+ vm.getUuid()+ "String_Node_Str");
  }
}