VirtualBox

Changeset 34501 in vbox for trunk/src


Ignore:
Timestamp:
Nov 30, 2010 12:30:30 PM (14 years ago)
Author:
vboxsync
Message:

Main/OVF: use ostype from ovf:/OperatingSystemSection/vbox:OSType element if present (reading only so far)

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

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

    r34101 r34501  
    163163                pNewDesc->importVboxMachineXML(*vsysThis.pelmVboxMachine);
    164164
    165             /* Guest OS type */
     165            // Guest OS type
     166            // This is taken from one of three places, in this order:
    166167            Utf8Str strOsTypeVBox;
    167             Utf8Str strCIMOSType = Utf8StrFmt("%RU32", (uint32_t)vsysThis.cimos);
    168             /* If there is a vbox.xml, we always prefer the ostype settings
    169              * from there, cause OVF doesn't know all types VBox know. */
     168            Utf8StrFmt strCIMOSType("%RU32", (uint32_t)vsysThis.cimos);
     169            // 1) If there is a <vbox:Machine>, then use the type from there.
    170170            if (   vsysThis.pelmVboxMachine
    171                 && pNewDesc->m->pConfig->machineUserData.strOsType.isNotEmpty())
     171                && pNewDesc->m->pConfig->machineUserData.strOsType.isNotEmpty()
     172               )
    172173                strOsTypeVBox = pNewDesc->m->pConfig->machineUserData.strOsType;
     174            // 2) Otherwise, if there is OperatingSystemSection/vbox:OSType, use that one.
     175            else if (vsysThis.strTypeVbox.isNotEmpty())      // OVFReader has found vbox:OSType
     176                strOsTypeVBox = vsysThis.strTypeVbox;
     177            // 3) Otherwise, make a best guess what the vbox type is from the OVF (CIM) OS type.
    173178            else
    174179                convertCIMOSType2VBoxOSType(strOsTypeVBox, vsysThis.cimos, vsysThis.strCimosDesc);
     
    180185            /* VM name */
    181186            Utf8Str nameVBox;
    182             /* If there is a vbox.xml, we always prefer the setting from there. */
     187            /* If there is a <vbox:Machine>, we always prefer the setting from there. */
    183188            if (   vsysThis.pelmVboxMachine
    184189                && pNewDesc->m->pConfig->machineUserData.strName.isNotEmpty())
     
    261266            /* CPU count */
    262267            ULONG cpuCountVBox;
    263             /* If there is a vbox.xml, we always prefer the setting from there. */
     268            /* If there is a <vbox:Machine>, we always prefer the setting from there. */
    264269            if (   vsysThis.pelmVboxMachine
    265270                && pNewDesc->m->pConfig->hardwareMachine.cCPUs)
     
    283288            /* RAM */
    284289            uint64_t ullMemSizeVBox;
    285             /* If there is a vbox.xml, we always prefer the setting from there. */
     290            /* If there is a <vbox:Machine>, we always prefer the setting from there. */
    286291            if (   vsysThis.pelmVboxMachine
    287292                && pNewDesc->m->pConfig->hardwareMachine.ulMemorySizeMB)
     
    317322            Utf8Str strSoundCard;
    318323            Utf8Str strSoundCardOrig;
    319             /* If there is a vbox.xml, we always prefer the setting from there. */
     324            /* If there is a <vbox:Machine>, we always prefer the setting from there. */
    320325            if (   vsysThis.pelmVboxMachine
    321326                && pNewDesc->m->pConfig->hardwareMachine.audioAdapter.fEnabled)
     
    336341#ifdef VBOX_WITH_USB
    337342            /* USB Controller */
    338             /* If there is a vbox.xml, we always prefer the setting from there. */
     343            /* If there is a <vbox:Machine>, we always prefer the setting from there. */
    339344            if (   (   vsysThis.pelmVboxMachine
    340345                    && pNewDesc->m->pConfig->hardwareMachine.usbController.fEnabled)
     
    344349
    345350            /* Network Controller */
    346             /* If there is a vbox.xml, we always prefer the setting from there. */
     351            /* If there is a <vbox:Machine>, we always prefer the setting from there. */
    347352            if (vsysThis.pelmVboxMachine)
    348353            {
     
    448453            }
    449454
    450             /* If there is a vbox.xml, we always prefer the setting from there. */
     455            /* If there is a <vbox:Machine>, we always prefer the setting from there. */
    451456            bool fFloppy = false;
    452457            bool fDVD = false;
  • trunk/src/VBox/Main/include/ovfreader.h

    r33700 r34501  
    325325    CIMOSType_T         cimos;
    326326    iprt::MiniString    strCimosDesc;           // readable description of the cimos type in the case of cimos = 0/1/102
     327    iprt::MiniString    strTypeVbox;            // optional type from @vbox:ostype attribute (VirtualBox 4.0 or higher)
     328
    327329    iprt::MiniString    strVirtualSystemType;   // generic hardware description; OVF says this can be something like "vmx-4" or "xen";
    328330                                                // VMware Workstation 6.5 is "vmx-07"
     
    361363
    362364    VirtualSystem()
    363         : ullMemorySize(0),
     365        : cimos(CIMOSType_CIMOS_Unknown),
     366          ullMemorySize(0),
    364367          cCPUs(1),
    365368          fHasFloppyDrive(false),
  • trunk/src/VBox/Main/xml/ovfreader.cpp

    r33700 r34501  
    775775            if ((pelmCIMOSDescription = pelmThis->findChildElement("Description")))
    776776                vsys.strCimosDesc = pelmCIMOSDescription->getValue();
     777
     778            const xml::ElementNode *pelmVBoxOSType;
     779            if ((pelmVBoxOSType = pelmThis->findChildElement("vbox",            // namespace
     780                                                             "OSType")))        // element name
     781                vsys.strTypeVbox = pelmVBoxOSType->getValue();
    777782        }
    778783        else if (    (!strcmp(pcszElemName, "AnnotationSection"))
Note: See TracChangeset for help on using the changeset viewer.

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