VirtualBox

Changeset 72919 in vbox


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
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp

    r70790 r72919  
    673673
    674674    SHOW_STRING_PROP(      machine, Name,                       "name",                 "Name:");
    675 
     675    SHOW_STRINGARRAY_PROP( machine, Groups,                     "groups",               "Groups:");
    676676    Bstr osTypeId;
    677677    CHECK_ERROR2I_RET(machine, COMGETTER(OSTypeId)(osTypeId.asOutParam()), hrcCheck);
    678678    ComPtr<IGuestOSType> osType;
    679     CHECK_ERROR2I_RET(pVirtualBox, GetGuestOSType(osTypeId.raw(), osType.asOutParam()), hrcCheck);
    680     SHOW_STRINGARRAY_PROP( machine, Groups,                     "groups",               "Groups:");
    681     SHOW_STRING_PROP(       osType, Description,                "ostype",               "Guest OS:");
     679    pVirtualBox->GetGuestOSType(osTypeId.raw(), osType.asOutParam());
     680    if (!osType.isNull())
     681        SHOW_STRING_PROP(       osType, Description,                "ostype",               "Guest OS:");
     682    else
     683        SHOW_STRING_PROP(      machine, OSTypeId,                   "ostype",               "Guest OS:");
    682684    SHOW_UUID_PROP(        machine, Id,                         "UUID",                 "UUID:");
    683685    SHOW_STRING_PROP(      machine, SettingsFilePath,           "CfgFile",              "Config file:");
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp

    r72143 r72919  
    564564            case MODIFYVM_OSTYPE:
    565565            {
    566                 ComPtr<IGuestOSType> guestOSType;
    567                 CHECK_ERROR(a->virtualBox, GetGuestOSType(Bstr(ValueUnion.psz).raw(),
    568                                                           guestOSType.asOutParam()));
    569                 if (SUCCEEDED(rc) && guestOSType)
    570                 {
    571                     CHECK_ERROR(sessionMachine, COMSETTER(OSTypeId)(Bstr(ValueUnion.psz).raw()));
    572                 }
    573                 else
    574                 {
    575                     errorArgument("Invalid guest OS type '%s'", ValueUnion.psz);
    576                     rc = E_FAIL;
    577                 }
     566                CHECK_ERROR(sessionMachine, COMSETTER(OSTypeId)(Bstr(ValueUnion.psz).raw()));
    578567                break;
    579568            }
  • trunk/src/VBox/Frontends/VBoxShell/vboxshell.py

    r71179 r72919  
    962962    if mach == None:
    963963        return 0
    964     vmos = ctx['vb'].getGuestOSType(mach.OSTypeId)
     964    try:
     965        vmos = ctx['vb'].getGuestOSType(mach.OSTypeId)
     966    except:
     967        vmos = None
    965968    print(" One can use setvar <mach> <var> <value> to change variable, using name in [].")
    966969    print("  Name [name]: %s" % (colVm(ctx, mach.name)))
    967970    print("  Description [description]: %s" % (mach.description))
    968971    print("  ID [n/a]: %s" % (mach.id))
    969     print("  OS Type [via OSTypeId]: %s" % (vmos.description))
     972    print("  OS Type [via OSTypeId]: %s" % (vmos.description if vmos is not None else mach.OSTypeId))
    970973    print("  Firmware [firmwareType]: %s (%s)" % (asEnumElem(ctx, "FirmwareType", mach.firmwareType), mach.firmwareType))
    971974    print()
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r72915 r72919  
    26402640        the guest OS this object describes.
    26412641
     2642        While this function returns an error for unknown guest OS types, they
     2643        can be still used without serious problems (if one accepts the fact
     2644        that there is no default VM config information).
     2645
    26422646        <result name="E_INVALIDARG">
    26432647          @a id is not a valid Guest OS type.
     
    50265030        You may use <link to="IVirtualBox::getGuestOSType"/> to obtain
    50275031        an IGuestOSType object representing details about the given
    5028         Guest OS type.
     5032        Guest OS type. All Guest OS types are considered valid, even those
     5033        which are not known to <link to="IVirtualBox::getGuestOSType"/>.
    50295034        <note>
    50305035          This value may differ from the value returned by
  • trunk/src/VBox/Main/include/MachineImpl.h

    r72476 r72919  
    351351                 const Utf8Str &strName,
    352352                 const StringsList &llGroups,
     353                 const Utf8Str &strOsTypeId,
    353354                 GuestOSType *aOsType,
    354355                 const Guid &aId,
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r72343 r72919  
    820820    }
    821821
    822     ComPtr<IGuestOSType> guestOSType;
    823     hrc = virtualBox->GetGuestOSType(osTypeId.raw(), guestOSType.asOutParam());             H();
    824 
    825     Bstr guestTypeFamilyId;
    826     hrc = guestOSType->COMGETTER(FamilyId)(guestTypeFamilyId.asOutParam());                 H();
    827     BOOL fOsXGuest = guestTypeFamilyId == Bstr("MacOS");
     822    ComPtr<IGuestOSType> pGuestOSType;
     823    virtualBox->GetGuestOSType(osTypeId.raw(), pGuestOSType.asOutParam());
     824
     825    BOOL fOsXGuest = FALSE;
     826    if (!pGuestOSType.isNull())
     827    {
     828        Bstr guestTypeFamilyId;
     829        hrc = pGuestOSType->COMGETTER(FamilyId)(guestTypeFamilyId.asOutParam());            H();
     830        fOsXGuest = guestTypeFamilyId == Bstr("MacOS");
     831    }
    828832
    829833    ULONG maxNetworkAdapters;
  • 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