Source:
public static void updateVmDevices(VmManagementParametersBase params, VM oldVm) { VmBase oldVmBase = oldVm.getStaticData(); VmBase entity = params.getVmStaticData(); if (entity != null) { updateCdInVmDevice(oldVmBase, entity); if (oldVmBase.getDefaultBootSequence() != entity .getDefaultBootSequence()) { updateBootOrderInVmDeviceAndStoreToDB(entity); } boolean displayTypeChanged = oldVmBase.getDefaultDisplayType() != entity.getDefaultDisplayType(); boolean numOfMonitorsChanged = entity.getDefaultDisplayType() == DisplayType.qxl && oldVmBase.getNumOfMonitors() != entity.getNumOfMonitors(); boolean singleQxlChanged = oldVmBase.getSingleQxlPci() != entity.getSingleQxlPci(); if(displayTypeChanged || numOfMonitorsChanged || singleQxlChanged) { for (VmDevice device : dao.getVmDeviceByVmIdAndType(oldVmBase.getId(), VmDeviceGeneralType.VIDEO)) { dao.remove(device.getId()); } int monitors = entity.getSingleQxlPci() ? 1 : entity.getNumOfMonitors(); for (int i = 0; i<monitors; i++) { VmDeviceType vmDeviceType = osRepository.getVmDeviceType(entity.getOsId(), entity.getDefaultDisplayType()); addManagedDevice(new VmDeviceId(Guid.newGuid(), entity.getId()), VmDeviceGeneralType.VIDEO, vmDeviceType, getMemExpr(entity.getNumOfMonitors(), entity.getSingleQxlPci()), true, false, null); } } updateUSBSlots(oldVmBase, entity); updateMemoryBalloon(oldVmBase, entity, params.isBalloonEnabled()); updateAudioDevice(oldVm.getStaticData(), entity, oldVm.getVdsGroupCompatibilityVersion(), params.isSoundDeviceEnabled()); updateSmartcardDevice(oldVm, entity); updateConsoleDevice(entity, params.isConsoleEnabled()); } }

Target:
public static void updateVmDevices(VmManagementParametersBase params, VM oldVm) { VmBase oldVmBase = oldVm.getStaticData(); VmBase entity = params.getVmStaticData(); if (entity != null) { updateCdInVmDevice(oldVmBase, entity); if (oldVmBase.getDefaultBootSequence() != entity .getDefaultBootSequence()) { updateBootOrderInVmDeviceAndStoreToDB(entity); } boolean displayTypeChanged = oldVmBase.getDefaultDisplayType() != entity.getDefaultDisplayType(); boolean numOfMonitorsChanged = entity.getDefaultDisplayType() == DisplayType.qxl && oldVmBase.getNumOfMonitors() != entity.getNumOfMonitors(); boolean singleQxlChanged = oldVmBase.getSingleQxlPci() != entity.getSingleQxlPci(); if(displayTypeChanged || numOfMonitorsChanged || singleQxlChanged) { for (VmDevice device : dao.getVmDeviceByVmIdAndType(oldVmBase.getId(), VmDeviceGeneralType.VIDEO)) { dao.remove(device.getId()); } int monitors = entity.getSingleQxlPci() ? 1 : entity.getNumOfMonitors(); for (int i = 0; i<monitors; i++) { VmDeviceType vmDeviceType = osRepository.getDisplayDevice(entity.getOsId(), ClusterUtils.getCompatibilityVersion(entity), entity.getDefaultDisplayType()); addManagedDevice(new VmDeviceId(Guid.newGuid(), entity.getId()), VmDeviceGeneralType.VIDEO, vmDeviceType, getMemExpr(entity.getNumOfMonitors(), entity.getSingleQxlPci()), true, false, null); } } updateUSBSlots(oldVmBase, entity); updateMemoryBalloon(oldVmBase, entity, params.isBalloonEnabled()); updateAudioDevice(oldVm.getStaticData(), entity, oldVm.getVdsGroupCompatibilityVersion(), params.isSoundDeviceEnabled()); updateSmartcardDevice(oldVm, entity); updateConsoleDevice(entity, params.isConsoleEnabled()); } }