@Override
  public boolean stopvirtualmachine(VMEntityVO vmEntityVO, String caller)
      throws ResourceUnavailableException {

    VMInstanceVO vm = _vmDao.findByUuid(vmEntityVO.getUuid());
    return _itMgr.stop(
        vm, _userDao.findById(new Long(caller)), _accountDao.findById(vm.getAccountId()));
  }
  @Override
  public boolean stopSecStorageVm(long secStorageVmId) {
    SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findById(secStorageVmId);
    if (secStorageVm == null) {
      String msg =
          "Stopping secondary storage vm failed: secondary storage vm "
              + secStorageVmId
              + " no longer exists";
      if (s_logger.isDebugEnabled()) {
        s_logger.debug(msg);
      }
      return false;
    }
    try {
      if (secStorageVm.getHostId() != null) {
        GlobalLock secStorageVmLock =
            GlobalLock.getInternLock(getSecStorageVmLockName(secStorageVm.getId()));
        try {
          if (secStorageVmLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
            try {
              boolean result =
                  _itMgr.stop(
                      secStorageVm, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
              if (result) {}

              return result;
            } finally {
              secStorageVmLock.unlock();
            }
          } else {
            String msg = "Unable to acquire secondary storage vm lock : " + secStorageVm.toString();
            s_logger.debug(msg);
            return false;
          }
        } finally {
          secStorageVmLock.releaseRef();
        }
      }

      // vm was already stopped, return true
      return true;
    } catch (ResourceUnavailableException e) {
      if (s_logger.isDebugEnabled()) {
        s_logger.debug(
            "Stopping secondary storage vm "
                + secStorageVm.getHostName()
                + " faled : exception "
                + e.toString());
      }
      return false;
    }
  }