private void setDeviceByResource(XmlNode node, VmDevice vmDevice) { int resourceType = getResourceType(node, OvfProperties.VMD_RESOURCE_TYPE); int resourceSubType = getResourceType(node, OvfProperties.VMD_SUB_RESOURCE_TYPE); if (resourceSubType == -1) { // we need special handling for Monitor to define it as vnc or spice if (Integer.parseInt(OvfHardware.Monitor) == resourceType) { // if default display type is defined in the ovf, set the video device that is suitable for // it if (defaultDisplayType != null) { vmDevice.setDevice(defaultDisplayType.getDefaultVmDeviceType().getName()); } else { // get number of monitors from VirtualQuantity in OVF if (selectSingleNode(node, OvfProperties.VMD_VIRTUAL_QUANTITY, _xmlNS) != null && !StringUtils.isEmpty( selectSingleNode(node, OvfProperties.VMD_VIRTUAL_QUANTITY, _xmlNS).innerText)) { int virtualQuantity = Integer.parseInt( selectSingleNode(node, OvfProperties.VMD_VIRTUAL_QUANTITY, _xmlNS).innerText); if (virtualQuantity > 1) { vmDevice.setDevice(VmDeviceType.QXL.getName()); } else { // get first supported display device List<Pair<GraphicsType, DisplayType>> supportedGraphicsAndDisplays = osRepository.getGraphicsAndDisplays(vmBase.getOsId(), new Version(getVersion())); if (!supportedGraphicsAndDisplays.isEmpty()) { DisplayType firstDisplayType = supportedGraphicsAndDisplays.get(0).getSecond(); vmDevice.setDevice(firstDisplayType.getDefaultVmDeviceType().getName()); } else { vmDevice.setDevice(VmDeviceType.QXL.getName()); } } } else { // default to spice if quantity not found vmDevice.setDevice(VmDeviceType.QXL.getName()); } } } else { vmDevice.setDevice(VmDeviceType.getoVirtDevice(resourceType).getName()); } } else if (Integer.parseInt(OvfHardware.Network) == resourceType) { // handle interfaces with different sub types : we have 0-5 as the VmInterfaceType enum VmInterfaceType nicType = VmInterfaceType.forValue(resourceSubType); if (nicType != null) { if (nicType == VmInterfaceType.pciPassthrough) { vmDevice.setDevice(VmDeviceType.HOST_DEVICE.getName()); } else { vmDevice.setDevice(VmDeviceType.BRIDGE.getName()); } } else { vmDevice.setDevice(VmDeviceType.getoVirtDevice(resourceType).getName()); } } }