VirtualBox

Changeset 72919 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Jul 5, 2018 2:44:31 PM (7 years ago)
Author:
vboxsync
Message:

Main/*: From now on any valid UTF8 string is considered a valid guest OS type. Of course not all of them are known, so the API clients must be prepared to deal with not having a matching IGuestOSType object.
Frontends/VBoxManage+VBoxShell: adjust to deal with the change

Location:
trunk/src/VBox/Main/src-server
Files:
7 edited

Legend:

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

    r72525 r72919  
    289289                                     vsysThis.strLicenseText);
    290290
    291             /* Now that we know the OS type, get our internal defaults based on that. */
     291            /* Now that we know the OS type, get our internal defaults based on
     292             * that, if it is known (otherwise pGuestOSType will be NULL). */
    292293            ComPtr<IGuestOSType> pGuestOSType;
    293             rc = mVirtualBox->GetGuestOSType(Bstr(strOsTypeVBox).raw(), pGuestOSType.asOutParam());
    294             if (FAILED(rc)) throw rc;
     294            mVirtualBox->GetGuestOSType(Bstr(strOsTypeVBox).raw(), pGuestOSType.asOutParam());
    295295
    296296            /* CPU count */
     
    341341                /* If the RAM of the OVF is zero, use our predefined values */
    342342                ULONG memSizeVBox2;
    343                 rc = pGuestOSType->COMGETTER(RecommendedRAM)(&memSizeVBox2);
    344                 if (FAILED(rc)) throw rc;
     343                if (!pGuestOSType.isNull())
     344                {
     345                    rc = pGuestOSType->COMGETTER(RecommendedRAM)(&memSizeVBox2);
     346                    if (FAILED(rc)) throw rc;
     347                }
     348                else
     349                    memSizeVBox2 = 1024;
    345350                /* VBox stores that in MByte */
    346351                ullMemSizeVBox = (uint64_t)memSizeVBox2;
     
    428433                /* Get the default network adapter type for the selected guest OS */
    429434                NetworkAdapterType_T defaultAdapterVBox = NetworkAdapterType_Am79C970A;
    430                 rc = pGuestOSType->COMGETTER(AdapterType)(&defaultAdapterVBox);
    431                 if (FAILED(rc)) throw rc;
     435                if (!pGuestOSType.isNull())
     436                {
     437                    rc = pGuestOSType->COMGETTER(AdapterType)(&defaultAdapterVBox);
     438                    if (FAILED(rc)) throw rc;
     439                }
     440                else
     441                {
     442#ifdef VBOX_WITH_E1000
     443                    defaultAdapterVBox = NetworkAdapterType_I82540EM;
     444#else
     445                    defaultAdapterVBox = NetworkAdapterType_Am79C973A;
     446#endif
     447                }
    432448
    433449                ovf::EthernetAdaptersList::const_iterator itEA;
  • trunk/src/VBox/Main/src-server/BIOSSettingsImpl.cpp

    r69500 r72919  
    5959void BIOSSettings::FinalRelease()
    6060{
    61     uninit ();
     61    uninit();
    6262    BaseFinalRelease();
    6363}
     
    562562}
    563563
    564 void BIOSSettings::i_copyFrom (BIOSSettings *aThat)
    565 {
    566     AssertReturnVoid (aThat != NULL);
     564void BIOSSettings::i_copyFrom(BIOSSettings *aThat)
     565{
     566    AssertReturnVoid(aThat != NULL);
    567567
    568568    /* sanity */
    569569    AutoCaller autoCaller(this);
    570     AssertComRCReturnVoid (autoCaller.rc());
     570    AssertComRCReturnVoid(autoCaller.rc());
    571571
    572572    /* sanity too */
    573     AutoCaller thatCaller (aThat);
    574     AssertComRCReturnVoid (thatCaller.rc());
     573    AutoCaller thatCaller(aThat);
     574    AssertComRCReturnVoid(thatCaller.rc());
    575575
    576576    /* peer is not modified, lock it for reading (aThat is "master" so locked
     
    583583}
    584584
    585 void BIOSSettings::i_applyDefaults (GuestOSType *aOsType)
    586 {
    587     AssertReturnVoid (aOsType != NULL);
    588 
     585void BIOSSettings::i_applyDefaults(GuestOSType *aOsType)
     586{
    589587    /* sanity */
    590588    AutoCaller autoCaller(this);
    591     AssertComRCReturnVoid (autoCaller.rc());
     589    AssertComRCReturnVoid(autoCaller.rc());
    592590
    593591    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    594592
    595593    /* Initialize default BIOS settings here */
    596     m->bd->fIOAPICEnabled = aOsType->i_recommendedIOAPIC();
     594    if (aOsType)
     595        m->bd->fIOAPICEnabled = aOsType->i_recommendedIOAPIC();
     596    else
     597        m->bd->fIOAPICEnabled = true;
    597598}
    598599
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r72700 r72919  
    278278 *  @param strName      name for the machine
    279279 *  @param llGroups     list of groups for the machine
     280 *  @param strOsType    OS Type string (stored as is if aOsType is NULL).
    280281 *  @param aOsType      OS Type of this machine or NULL.
    281282 *  @param aId          UUID for the new machine.
     
    290291                      const Utf8Str &strName,
    291292                      const StringsList &llGroups,
     293                      const Utf8Str &strOsType,
    292294                      GuestOSType *aOsType,
    293295                      const Guid &aId,
     
    343345            mUserData->s.strOsType = aOsType->i_id();
    344346
    345             /* Apply BIOS defaults */
    346             mBIOSSettings->i_applyDefaults(aOsType);
    347 
    348347            /* Let the OS type select 64-bit ness. */
    349348            mHWData->mLongMode = aOsType->i_is64Bit()
     
    353352            mHWData->mX2APIC = aOsType->i_recommendedX2APIC();
    354353        }
     354        else if (!strOsType.isEmpty())
     355        {
     356            /* Store OS type */
     357            mUserData->s.strOsType = strOsType;
     358
     359            /* No guest OS type object. Pick some plausible defaults which the
     360             * host can handle. There's no way to know or validate anything. */
     361            mHWData->mLongMode = HC_ARCH_BITS == 64 ? settings::Hardware::LongMode_Enabled : settings::Hardware::LongMode_Disabled;
     362            mHWData->mX2APIC = false;
     363        }
     364
     365        /* Apply BIOS defaults */
     366        mBIOSSettings->i_applyDefaults(aOsType);
    355367
    356368        /* Apply network adapters defaults */
     
    10871099    /* look up the object by Id to check it is valid */
    10881100    ComObjPtr<GuestOSType> pGuestOSType;
    1089     HRESULT rc = mParent->i_findGuestOSType(aOSTypeId,
    1090                                             pGuestOSType);
    1091     if (FAILED(rc)) return rc;
     1101    mParent->i_findGuestOSType(aOSTypeId, pGuestOSType);
    10921102
    10931103    /* when setting, always use the "etalon" value for consistency -- lookup
    10941104     * by ID is case-insensitive and the input value may have different case */
    1095     Utf8Str osTypeId = pGuestOSType->i_id();
     1105    Utf8Str osTypeId = !pGuestOSType.isNull() ? pGuestOSType->i_id() : aOSTypeId;
    10961106
    10971107    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    10981108
    1099     rc = i_checkStateDependency(MutableStateDep);
     1109    HRESULT rc = i_checkStateDependency(MutableStateDep);
    11001110    if (FAILED(rc)) return rc;
    11011111
     
    12881298            HRESULT hrc2 = mParent->i_findGuestOSType(mUserData->s.strOsType,
    12891299                                                      pGuestOSType);
    1290             AssertMsgReturn(SUCCEEDED(hrc2), ("Failed to get guest OS type. hrc2=%Rhrc\n", hrc2), hrc2);
     1300            if (FAILED(hrc2) || pGuestOSType.isNull())
     1301            {
     1302                *aParavirtProvider = ParavirtProvider_None;
     1303                break;
     1304            }
    12911305
    12921306            Utf8Str guestTypeFamilyId = pGuestOSType->i_familyId();
     
    22282242                HRESULT hrc2 = mParent->i_findGuestOSType(mUserData->s.strOsType,
    22292243                                                          pGuestOSType);
    2230                 if (SUCCEEDED(hrc2))
     2244                if (SUCCEEDED(hrc2) && !pGuestOSType.isNull())
    22312245                {
    22322246                    if (pGuestOSType->i_is64Bit())
     
    88308844    // look up the object by Id to check it is valid
    88318845    ComObjPtr<GuestOSType> pGuestOSType;
    8832     HRESULT rc = mParent->i_findGuestOSType(mUserData->s.strOsType,
    8833                                             pGuestOSType);
    8834     if (FAILED(rc)) return rc;
    8835     mUserData->s.strOsType = pGuestOSType->i_id();
     8846    mParent->i_findGuestOSType(mUserData->s.strOsType, pGuestOSType);
     8847    if (!pGuestOSType.isNull())
     8848        mUserData->s.strOsType = pGuestOSType->i_id();
    88368849
    88378850    // stateFile (optional)
     
    88518864
    88528865    // snapshot folder needs special processing so set it again
    8853     rc = COMSETTER(SnapshotFolder)(Bstr(config.machineUserData.strSnapshotFolder).raw());
     8866    HRESULT rc = COMSETTER(SnapshotFolder)(Bstr(config.machineUserData.strSnapshotFolder).raw());
    88548867    if (FAILED(rc)) return rc;
    88558868
     
    90329045    {
    90339046        ComObjPtr<GuestOSType> pGuestOSType;
    9034         rc = mParent->i_findGuestOSType(Bstr(mUserData->s.strOsType).raw(),
    9035                                         pGuestOSType);
    9036         if (FAILED(rc))
    9037             return rc;
     9047        mParent->i_findGuestOSType(mUserData->s.strOsType, pGuestOSType);
    90389048
    90399049        /* The hardware version attribute (optional). */
  • trunk/src/VBox/Main/src-server/NATEngineImpl.cpp

    r69500 r72919  
    2020#include "Logging.h"
    2121#include "MachineImpl.h"
    22 #include "GuestOSTypeImpl.h"
    2322
    2423#include <iprt/string.h>
  • trunk/src/VBox/Main/src-server/NetworkAdapterImpl.cpp

    r72482 r72919  
    12331233#endif // VBOX_WITH_E1000
    12341234
    1235     NetworkAdapterType_T defaultType = NetworkAdapterType_Am79C973;
     1235    NetworkAdapterType_T defaultType;
    12361236    if (aOsType)
    12371237        defaultType = aOsType->i_networkAdapterType();
     1238    else
     1239    {
     1240#ifdef VBOX_WITH_E1000
     1241        defaultType = NetworkAdapterType_I82540EM;
     1242#else
     1243        defaultType = NetworkAdapterType_Am79C973A;
     1244#endif
     1245    }
     1246
    12381247
    12391248    /* Set default network adapter for this OS type */
  • trunk/src/VBox/Main/src-server/UnattendedImpl.cpp

    r71012 r72919  
    10371037        HRESULT hrc = mParent->GetGuestOSType(bstrGuestOsTypeId.raw(), ptrGuestOSType.asOutParam());
    10381038        if (SUCCEEDED(hrc))
    1039             hrc = ptrGuestOSType->COMGETTER(RecommendedDVDStorageBus)(&enmRecommendedStorageBus);
     1039        {
     1040            if (!ptrGuestOSType.isNull())
     1041                hrc = ptrGuestOSType->COMGETTER(RecommendedDVDStorageBus)(&enmRecommendedStorageBus);
     1042        }
    10401043        if (FAILED(hrc))
    10411044            return hrc;
     
    23372340    {
    23382341        BOOL fIs64Bit = FALSE;
    2339         hrc = pGuestOSType->COMGETTER(Is64Bit)(&fIs64Bit);
     2342        if (!pGuestOSType.isNull())
     2343            hrc = pGuestOSType->COMGETTER(Is64Bit)(&fIs64Bit);
    23402344        if (SUCCEEDED(hrc))
    23412345            return fIs64Bit != FALSE;
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r72205 r72919  
    15171517    LogFlowThisFunc(("aSettingsFile=\"%s\", aName=\"%s\", aOsTypeId =\"%s\", aCreateFlags=\"%s\"\n",
    15181518                     aSettingsFile.c_str(), aName.c_str(), aOsTypeId.c_str(), aFlags.c_str()));
    1519     /** @todo tighten checks on aId? */
    15201519
    15211520    StringsList llGroups;
     
    15961595    ComObjPtr<GuestOSType> osType;
    15971596    if (!aOsTypeId.isEmpty())
    1598     {
    1599         rc = i_findGuestOSType(aOsTypeId, osType);
    1600         if (FAILED(rc)) return rc;
    1601     }
     1597        i_findGuestOSType(aOsTypeId, osType);
    16021598
    16031599    /* initialize the machine object */
    16041600    rc = machine->init(this,
    16051601                       strSettingsFile,
    1606                        Utf8Str(aName),
     1602                       aName,
    16071603                       llGroups,
     1604                       aOsTypeId,
    16081605                       osType,
    16091606                       id,
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