Source:
protected void executeVmCommand() { boolean isNicToBePlugged = getParameters().getAction() == PlugAction.PLUG; if (isNicToBePlugged){ clearAddressIfPciSlotIsDuplicated(vmDevice); } if (hotPlugVmNicRequired(getVm().getStatus())) { boolean externalNetworkIsPlugged = isNicToBePlugged && getNetwork() != null && getNetwork().isExternal(); if (externalNetworkIsPlugged) { plugToExternalNetwork(); } String vfToUse = null; try { boolean shouldAcquireVF = isNicToBePlugged && isPassthrough(); if (shouldAcquireVF) { vfToUse = acquireVF(); if (vfToUse == null) { failValidationCannotPlugPassthroughVnicNoSuitableVf(); return; } vmDevice.setHostDevice(vfToUse); } VDSReturnValue returnValue = runVdsCommand(getParameters().getAction().getCommandType(), new VmNicDeviceVDSParameters(getVdsId(), getVm(), getParameters().getNic(), vmDevice)); if (returnValue.getSucceeded()) { boolean passthroughHotPlug = vfToUse != null; boolean passthroughHotUnplug = isPassthrough() && getParameters().getAction() == PlugAction.UNPLUG; if (passthroughHotUnplug) { networkDeviceHelper.setVmIdOnVfs(getVdsId(), null, new HashSet<>(Arrays.asList(vmDevice.getHostDevice()))); } if (passthroughHotPlug || passthroughHotUnplug) { runInternalAction(VdcActionType.RefreshHost, new VdsActionParameters(getVdsId())); } } else { clearPassthroughData(vfToUse); } } catch (EngineException e) { if (externalNetworkIsPlugged && getParameters().isNewNic()) { unplugFromExternalNetwork(); } clearPassthroughData(vfToUse); throw e; } } TransactionSupport.executeInNewTransaction(updateDevice()); setSucceeded(true); }

Target:
protected void executeVmCommand() { boolean isNicToBePlugged = getParameters().getAction() == PlugAction.PLUG; if (isNicToBePlugged){ clearAddressIfPciSlotIsDuplicated(vmDevice); } if (hotPlugVmNicRequired(getVm().getStatus())) { boolean externalNetworkIsPlugged = isNicToBePlugged && getNetwork() != null && getNetwork().isExternal(); if (externalNetworkIsPlugged) { plugToExternalNetwork(); } String vfToUse = null; try { boolean shouldAcquireVF = isNicToBePlugged && isPassthrough(); if (shouldAcquireVF) { vfToUse = acquireVF(); if (vfToUse == null) { failValidationCannotPlugPassthroughVnicNoSuitableVf(); return; } networkDeviceHelper.setVmIdOnVfs(getVdsId(), getVmId(), Collections.singleton(vfToUse)); vmDevice.setHostDevice(vfToUse); } VDSReturnValue returnValue = runVdsCommand(getParameters().getAction().getCommandType(), new VmNicDeviceVDSParameters(getVdsId(), getVm(), getParameters().getNic(), vmDevice)); if (returnValue.getSucceeded()) { boolean passthroughHotPlug = vfToUse != null; boolean passthroughHotUnplug = isPassthrough() && getParameters().getAction() == PlugAction.UNPLUG; if (passthroughHotUnplug) { networkDeviceHelper.setVmIdOnVfs(getVdsId(), null, new HashSet<>(Arrays.asList(vmDevice.getHostDevice()))); } if (passthroughHotPlug || passthroughHotUnplug) { runInternalAction(VdcActionType.RefreshHost, new VdsActionParameters(getVdsId())); } } else { clearPassthroughData(vfToUse); } } catch (EngineException e) { if (externalNetworkIsPlugged && getParameters().isNewNic()) { unplugFromExternalNetwork(); } clearPassthroughData(vfToUse); throw e; } } TransactionSupport.executeInNewTransaction(updateDevice()); setSucceeded(true); }