VirtualBox

Changeset 18530 in vbox for trunk/src


Ignore:
Timestamp:
Mar 30, 2009 11:55:27 AM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
45395
Message:

OVF: Try to guess the guest operation system in the case of the other types.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ApplianceImpl.cpp

    r18483 r18530  
    159159
    160160    CIMOSType_T         cimos;
     161    Utf8Str             strCimosDesc;           // readable description of the cimos type in the case of cimos = 0/1/102
    161162    Utf8Str             strVirtualSystemType;   // generic hardware description; OVF says this can be something like "vmx-4" or "xen";
    162163                                                // VMware Workstation 6.5 is "vmx-07"
     
    299300};
    300301
     302/* Pattern structure for matching the os type description field */
     303struct osTypePattern
     304{
     305    const char *pcszPattern;
     306    const char *pcszVbox;
     307};
     308
     309/* This are the 32-Bit ones. They are sorted by priority. */
     310static const osTypePattern g_osTypesPattern[] =
     311{
     312    {"Windows*NT",    SchemaDefs_OSTypeId_WindowsNT4},
     313    {"Windows*XP",    SchemaDefs_OSTypeId_WindowsXP},
     314    {"Windows*2000",  SchemaDefs_OSTypeId_Windows2000},
     315    {"Windows*2003",  SchemaDefs_OSTypeId_Windows2003},
     316    {"Windows*Vista", SchemaDefs_OSTypeId_WindowsVista},
     317    {"Windows*2008",  SchemaDefs_OSTypeId_Windows2008},
     318    {"SUSE",          SchemaDefs_OSTypeId_OpenSUSE},
     319    {"Novell",        SchemaDefs_OSTypeId_OpenSUSE},
     320    {"Red*Hat",       SchemaDefs_OSTypeId_RedHat},
     321    {"Mandriva",      SchemaDefs_OSTypeId_Mandriva},
     322    {"Ubuntu",        SchemaDefs_OSTypeId_Ubuntu},
     323    {"Debian",        SchemaDefs_OSTypeId_Debian},
     324    {"QNX",           SchemaDefs_OSTypeId_QNX},
     325    {"Linux*2.4",     SchemaDefs_OSTypeId_Linux24},
     326    {"Linux*2.6",     SchemaDefs_OSTypeId_Linux26},
     327    {"Linux",         SchemaDefs_OSTypeId_Linux},
     328    {"OpenSolaris",   SchemaDefs_OSTypeId_OpenSolaris},
     329    {"Solaris",       SchemaDefs_OSTypeId_OpenSolaris},
     330    {"FreeBSD",       SchemaDefs_OSTypeId_FreeBSD},
     331    {"NetBSD",        SchemaDefs_OSTypeId_NetBSD},
     332    {"Windows*95",    SchemaDefs_OSTypeId_Windows95},
     333    {"Windows*98",    SchemaDefs_OSTypeId_Windows98},
     334    {"Windows*Me",    SchemaDefs_OSTypeId_WindowsMe},
     335    {"Windows*3.",    SchemaDefs_OSTypeId_Windows31},
     336    {"DOS",           SchemaDefs_OSTypeId_DOS},
     337    {"OS2",           SchemaDefs_OSTypeId_OS2}
     338};
     339
     340/* This are the 64-Bit ones. They are sorted by priority. */
     341static const osTypePattern g_osTypesPattern64[] =
     342{
     343    {"Windows*XP",    SchemaDefs_OSTypeId_WindowsXP_64},
     344    {"Windows*2003",  SchemaDefs_OSTypeId_Windows2003_64},
     345    {"Windows*Vista", SchemaDefs_OSTypeId_WindowsVista_64},
     346    {"Windows*2008",  SchemaDefs_OSTypeId_Windows2008_64},
     347    {"SUSE",          SchemaDefs_OSTypeId_OpenSUSE_64},
     348    {"Novell",        SchemaDefs_OSTypeId_OpenSUSE_64},
     349    {"Red*Hat",       SchemaDefs_OSTypeId_RedHat_64},
     350    {"Mandriva",      SchemaDefs_OSTypeId_Mandriva_64},
     351    {"Ubuntu",        SchemaDefs_OSTypeId_Ubuntu_64},
     352    {"Debian",        SchemaDefs_OSTypeId_Debian_64},
     353    {"Linux*2.4",     SchemaDefs_OSTypeId_Linux24_64},
     354    {"Linux*2.6",     SchemaDefs_OSTypeId_Linux26_64},
     355    {"Linux",         SchemaDefs_OSTypeId_Linux26_64},
     356    {"OpenSolaris",   SchemaDefs_OSTypeId_OpenSolaris_64},
     357    {"Solaris",       SchemaDefs_OSTypeId_OpenSolaris_64},
     358    {"FreeBSD",       SchemaDefs_OSTypeId_FreeBSD_64},
     359};
     360
    301361/**
    302362 * Private helper func that suggests a VirtualBox guest OS type
     
    304364 * @param osTypeVBox
    305365 * @param c
     366 * @param cStr
    306367 */
    307 static void convertCIMOSType2VBoxOSType(Utf8Str &strType, CIMOSType_T c)
    308 {
     368static void convertCIMOSType2VBoxOSType(Utf8Str &strType, CIMOSType_T c, const Utf8Str &cStr)
     369{
     370    /* First */
     371    if (c == CIMOSType_CIMOS_Other)
     372    {
     373        for (size_t i=0; i < RT_ELEMENTS(g_osTypesPattern); ++i)
     374            if (cStr.contains (g_osTypesPattern[i].pcszPattern))
     375            {
     376                strType = g_osTypesPattern[i].pcszVbox;
     377                return;
     378            }
     379    }
     380    else if (c == CIMOSType_CIMOS_Other_64)
     381    {
     382        for (size_t i=0; i < RT_ELEMENTS(g_osTypesPattern64); ++i)
     383            if (cStr.contains (g_osTypesPattern64[i].pcszPattern))
     384            {
     385                strType = g_osTypesPattern64[i].pcszVbox;
     386                return;
     387            }
     388    }
     389
    309390    for (size_t i = 0; i < RT_ELEMENTS(g_osTypes); ++i)
    310391    {
     
    10421123
    10431124            vsys.cimos = (CIMOSType_T)cimos64;
     1125            const xml::ElementNode *pelmCIMOSDescription;
     1126            if ((pelmCIMOSDescription = pelmThis->findChildElement("Description")))
     1127                vsys.strCimosDesc = pelmCIMOSDescription->getValue();
    10441128        }
    10451129        else if (    (!strcmp(pcszElemName, "AnnotationSection"))
     
    12711355            Utf8Str strOsTypeVBox,
    12721356                    strCIMOSType = Utf8StrFmt("%RI32", (uint32_t)vsysThis.cimos);
    1273             convertCIMOSType2VBoxOSType(strOsTypeVBox, vsysThis.cimos);
     1357            convertCIMOSType2VBoxOSType(strOsTypeVBox, vsysThis.cimos, vsysThis.strCimosDesc);
    12741358            pNewDesc->addEntry(VirtualSystemDescriptionType_OS,
    12751359                               "",
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette