Source:
<code>protected void executeVmCommand() { oldVm = getVm(); if (isUpdateVmTemplateVersion) { updateVmTemplateVersion(); return; } if (isRunningConfigurationNeeded()) { createNextRunSnapshot(); } VmHandler.warnMemorySizeLegal(getParameters().getVm().getStaticData(), getEffectiveCompatibilityVersion()); getVmStaticDao().incrementDbGeneration(getVm().getId()); newVmStatic = getParameters().getVmStaticData(); newVmStatic.setCreationDate(oldVm.getStaticData().getCreationDate()); int cpuPerSocket = newVmStatic.getCpuPerSocket(); int numOfSockets = newVmStatic.getNumOfSockets(); int threadsPerCpu = newVmStatic.getThreadsPerCpu(); int memSizeMb = newVmStatic.getMemSizeMb(); if (newVmStatic.getCreationDate().equals(DateTime.getMinValue())) { newVmStatic.setCreationDate(new Date()); } if (getVm().isRunningOrPaused()) { if (!VmHandler.copyNonEditableFieldsToDestination(oldVm.getStaticData(), newVmStatic, isHotSetEnabled())) { throw new EngineException(EngineError.FAILED_UPDATE_RUNNING_VM); } } updateVmNetworks(); updateVmNumaNodes(); if (isHotSetEnabled()) { hotSetCpus(cpuPerSocket, numOfSockets, threadsPerCpu); hotSetMemory(memSizeMb); } final List<Guid> oldIconIds = IconUtils.updateVmIcon( oldVm.getStaticData(), newVmStatic, getParameters().getVmLargeIcon()); getVmStaticDao().update(newVmStatic); if (getVm().isNotRunning()) { updateVmPayload(); VmDeviceUtils.updateVmDevices(getParameters(), oldVm); updateWatchdog(); updateRngDevice(); updateGraphicsDevices(); updateVmHostDevices(); } IconUtils.removeUnusedIcons(oldIconIds); VmHandler.updateVmInitToDB(getParameters().getVmStaticData()); if (newVmStatic.getOrigin() == OriginType.MANAGED_HOSTED_ENGINE) { OvfDataUpdater.getInstance().triggerNow(); <START> } <END> checkTrustedService(); setSucceeded(true); }</code><technical_language>note chance of race condition here, UpdateVmCommand code is execute in a transaction, means ovf update triggered is commited updated data uploaded ovf stores</technical_language>

Target:
protected void executeVmCommand() { oldVm = getVm(); if (isUpdateVmTemplateVersion) { updateVmTemplateVersion(); return; } if (isRunningConfigurationNeeded()) { createNextRunSnapshot(); } VmHandler.warnMemorySizeLegal(getParameters().getVm().getStaticData(), getEffectiveCompatibilityVersion()); getVmStaticDao().incrementDbGeneration(getVm().getId()); newVmStatic = getParameters().getVmStaticData(); newVmStatic.setCreationDate(oldVm.getStaticData().getCreationDate()); registerRollbackHandler(new HostedEngineEditNotifier(newVmStatic)); int cpuPerSocket = newVmStatic.getCpuPerSocket(); int numOfSockets = newVmStatic.getNumOfSockets(); int threadsPerCpu = newVmStatic.getThreadsPerCpu(); int memSizeMb = newVmStatic.getMemSizeMb(); if (newVmStatic.getCreationDate().equals(DateTime.getMinValue())) { newVmStatic.setCreationDate(new Date()); } if (getVm().isRunningOrPaused() && !getVm().isHostedEngine()) { if (!VmHandler.copyNonEditableFieldsToDestination(oldVm.getStaticData(), newVmStatic, isHotSetEnabled())) { throw new EngineException(EngineError.FAILED_UPDATE_RUNNING_VM); } } updateVmNetworks(); updateVmNumaNodes(); if (isHotSetEnabled()) { hotSetCpus(cpuPerSocket, numOfSockets, threadsPerCpu); hotSetMemory(memSizeMb); } final List<Guid> oldIconIds = IconUtils.updateVmIcon( oldVm.getStaticData(), newVmStatic, getParameters().getVmLargeIcon()); getVmStaticDao().update(newVmStatic); if (getVm().isNotRunning()) { updateVmPayload(); VmDeviceUtils.updateVmDevices(getParameters(), oldVm); updateWatchdog(); updateRngDevice(); updateGraphicsDevices(); updateVmHostDevices(); } IconUtils.removeUnusedIcons(oldIconIds); VmHandler.updateVmInitToDB(getParameters().getVmStaticData()); checkTrustedService(); setSucceeded(true); }