Source:
public static void autoSelectDefaultDisplayType(Guid srcEntityId, VmBase parametersStaticData, Cluster cluster, Map<GraphicsType, GraphicsDevice> graphicsDevices) { if (parametersStaticData.getOsId() == OsRepository.AUTO_SELECT_OS) { return; } List<Pair<GraphicsType, DisplayType>> graphicsAndDisplays = osRepository.getGraphicsAndDisplays( parametersStaticData.getOsId(), CompatibilityVersionUtils.getEffective(parametersStaticData, cluster)); if (parametersStaticData.getDefaultDisplayType() != null && isDisplayTypeSupported(parametersStaticData.getDefaultDisplayType(), graphicsAndDisplays)) { return; } DisplayType defaultDisplayType = null; Map<DisplayType, Set<GraphicsType>> displayGraphicsSupport = new LinkedHashMap<>(); for (Pair<GraphicsType, DisplayType> graphicsAndDisplay : graphicsAndDisplays) { DisplayType display = graphicsAndDisplay.getSecond(); if (!displayGraphicsSupport.containsKey(display)) { displayGraphicsSupport.put(display, new HashSet<>()); } displayGraphicsSupport.get(display).add(graphicsAndDisplay.getFirst()); } for (Map.Entry<DisplayType, Set<GraphicsType>> entry : displayGraphicsSupport.entrySet()) { if (entry.getValue().containsAll(VmHandler.getResultingVmGraphics(vmDeviceUtils.getGraphicsTypesOfEntity(srcEntityId), graphicsDevices))) { defaultDisplayType = entry.getKey(); break; } } if (defaultDisplayType == null) { if (!displayGraphicsSupport.isEmpty()) { Map.Entry<DisplayType, Set<GraphicsType>> entry = displayGraphicsSupport.entrySet().iterator().next(); defaultDisplayType = entry.getKey(); } else { defaultDisplayType = DisplayType.qxl; } } parametersStaticData.setDefaultDisplayType(defaultDisplayType); }

Target:
public static void autoSelectDefaultDisplayType(Guid srcEntityId, VmBase parametersStaticData, Cluster cluster, Map<GraphicsType, GraphicsDevice> graphicsDevices) { if (parametersStaticData.getOsId() == OsRepository.AUTO_SELECT_OS) { return; } List<Pair<GraphicsType, DisplayType>> graphicsAndDisplays = osRepository.getGraphicsAndDisplays( parametersStaticData.getOsId(), CompatibilityVersionUtils.getEffective(parametersStaticData, cluster)); if (parametersStaticData.getDefaultDisplayType() != null && isDisplayTypeSupported(parametersStaticData.getDefaultDisplayType(), graphicsAndDisplays)) { return; } DisplayType defaultDisplayType = null; Map<DisplayType, Set<GraphicsType>> displayGraphicsSupport = new LinkedHashMap<>(); for (Pair<GraphicsType, DisplayType> graphicsAndDisplay : graphicsAndDisplays) { DisplayType display = graphicsAndDisplay.getSecond(); if (!displayGraphicsSupport.containsKey(display)) { displayGraphicsSupport.put(display, new HashSet<>()); } displayGraphicsSupport.get(display).add(graphicsAndDisplay.getFirst()); } for (Map.Entry<DisplayType, Set<GraphicsType>> entry : displayGraphicsSupport.entrySet()) { final List<GraphicsType> graphicsTypes = vmDeviceUtils.getGraphicsTypesOfEntity(srcEntityId); final Set<GraphicsType> resultingVmGraphics = getResultingVmGraphics(graphicsTypes, graphicsDevices); if (entry.getValue().containsAll(resultingVmGraphics)) { defaultDisplayType = entry.getKey(); break; } } if (defaultDisplayType == null) { if (!displayGraphicsSupport.isEmpty()) { Map.Entry<DisplayType, Set<GraphicsType>> entry = displayGraphicsSupport.entrySet().iterator().next(); defaultDisplayType = entry.getKey(); } else { defaultDisplayType = DisplayType.qxl; } } parametersStaticData.setDefaultDisplayType(defaultDisplayType); }