private static VirtualNetworkAdapterType validateNicType ( GuestOsDescriptor [ ] guestOsDescriptorList , String guestId , VirtualNetworkAdapterType adapterType ) throws DeviceNotSupported { VirtualNetworkAdapterType result = adapterType ; GuestOsDescriptor guestOsInfo = null ; for ( GuestOsDescriptor desc : guestOsDescriptorList ) { if ( desc . getId ( ) . equalsIgnoreCase ( guestId ) ) { guestOsInfo = desc ; break ; } } if ( adapterType == VirtualNetworkAdapterType . Unknown ) { result = TryGetNetworkAdapterType ( guestOsInfo ) ; } else { if ( guestOsInfo . getSupportedEthernetCard ( ) != null ) { boolean supported = false ; List < String > supportedTypeList = new ArrayList < String > ( ) ; for ( String supportedAdapterName : guestOsInfo . getSupportedEthernetCard ( ) ) { VirtualNetworkAdapterType supportedAdapterType = GetNetworkAdapterTypeByApiType ( supportedAdapterName ) ; supportedTypeList . add ( supportedAdapterType . toString ( ) ) ; if ( supportedAdapterType == adapterType ) { supported = true ; break ; } } if ( ! supported ) { DeviceNotSupported dns = new DeviceNotSupported ( ) ; dns . setDevice ( "Virtual NIC" ) ; dns . setReason ( "The requested NIC is not supported in this OS." ) ; throw dns ; } } } return result ; }
Check network adapter type if it s supported by the guest OS