VirtualBox

Changeset 66941 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 17, 2017 5:54:01 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
115473
Message:

Main/Machine: Use the internal method for querying the guest OS type info, which also allows getting details more easily. Eliminate lots of redundant conversions from/to Bstr.

File:
1 edited

Legend:

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

    r66877 r66941  
    10851085{
    10861086    /* look up the object by Id to check it is valid */
    1087     ComPtr<IGuestOSType> guestOSType;
    1088     HRESULT rc = mParent->GetGuestOSType(Bstr(aOSTypeId).raw(), guestOSType.asOutParam());
     1087    ComObjPtr<GuestOSType> pGuestOSType;
     1088    HRESULT rc = mParent->i_findGuestOSType(aOSTypeId,
     1089                                            pGuestOSType);
    10891090    if (FAILED(rc)) return rc;
    10901091
    10911092    /* when setting, always use the "etalon" value for consistency -- lookup
    10921093     * by ID is case-insensitive and the input value may have different case */
    1093     Bstr osTypeId;
    1094     rc = guestOSType->COMGETTER(Id)(osTypeId.asOutParam());
    1095     if (FAILED(rc)) return rc;
     1094    Utf8Str osTypeId = pGuestOSType->i_id();
    10961095
    10971096    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    12851284        default:
    12861285        {
    1287             ComPtr<IGuestOSType> ptrGuestOSType;
    1288             HRESULT hrc2 = mParent->GetGuestOSType(Bstr(mUserData->s.strOsType).raw(), ptrGuestOSType.asOutParam());
     1286            ComObjPtr<GuestOSType> pGuestOSType;
     1287            HRESULT hrc2 = mParent->i_findGuestOSType(mUserData->s.strOsType,
     1288                                                      pGuestOSType);
    12891289            AssertMsgReturn(SUCCEEDED(hrc2), ("Failed to get guest OS type. hrc2=%Rhrc\n", hrc2), hrc2);
    12901290
    1291             Bstr guestTypeFamilyId;
    1292             hrc2 = ptrGuestOSType->COMGETTER(FamilyId)(guestTypeFamilyId.asOutParam());
    1293             AssertMsgReturn(SUCCEEDED(hrc2), ("Failed to get guest family. hrc2=%Rhrc\n", hrc2), hrc2);
    1294             BOOL fOsXGuest = guestTypeFamilyId == Bstr("MacOS");
     1291            Utf8Str guestTypeFamilyId = pGuestOSType->i_familyId();
     1292            bool fOsXGuest = guestTypeFamilyId == "MacOS";
    12951293
    12961294            switch (mHWData->mParavirtProvider)
     
    22262224                *aValue = FALSE;
    22272225
    2228                 ComPtr<IGuestOSType> ptrGuestOSType;
    2229                 HRESULT hrc2 = mParent->GetGuestOSType(Bstr(mUserData->s.strOsType).raw(), ptrGuestOSType.asOutParam());
     2226                ComObjPtr<GuestOSType> pGuestOSType;
     2227                HRESULT hrc2 = mParent->i_findGuestOSType(mUserData->s.strOsType,
     2228                                                          pGuestOSType);
    22302229                if (SUCCEEDED(hrc2))
    22312230                {
    2232                     BOOL fIs64Bit = FALSE;
    2233                     hrc2 = ptrGuestOSType->COMGETTER(Is64Bit)(&fIs64Bit); AssertComRC(hrc2);
    2234                     if (SUCCEEDED(hrc2) && fIs64Bit)
     2231                    if (pGuestOSType->i_is64Bit())
    22352232                    {
    2236                         ComObjPtr<Host> ptrHost = mParent->i_host();
     2233                        ComObjPtr<Host> pHost = mParent->i_host();
    22372234                        alock.release();
    22382235
    2239                         hrc2 = ptrHost->GetProcessorFeature(ProcessorFeature_LongMode, aValue); AssertComRC(hrc2);
     2236                        hrc2 = pHost->GetProcessorFeature(ProcessorFeature_LongMode, aValue); AssertComRC(hrc2);
    22402237                        if (FAILED(hrc2))
    22412238                            *aValue = FALSE;
     
    38593856    MediumAttachment *pAttachTemp;
    38603857    if ((pAttachTemp = i_findAttachment(*mMediumAttachments.data(),
    3861                                         Bstr(aName).raw(),
     3858                                        aName,
    38623859                                        aControllerPort,
    38633860                                        aDevice)))
     
    39463943
    39473944                /* see if it's the same bus/channel/device */
    3948                 if (pAttachTemp->i_matches(Bstr(aName).raw(), aControllerPort, aDevice))
     3945                if (pAttachTemp->i_matches(aName, aControllerPort, aDevice))
    39493946                {
    39503947                    /* the simplest case: restore the whole attachment
     
    40474044                         * descendant of medium will be used
    40484045                         */
    4049                         if (pAttach->i_matches(Bstr(aName).raw(), aControllerPort, aDevice))
     4046                        if (pAttach->i_matches(aName, aControllerPort, aDevice))
    40504047                        {
    40514048                            /* the simplest case: restore the whole attachment
     
    44214418
    44224419    MediumAttachment *pAttach = i_findAttachment(*mMediumAttachments.data(),
    4423                                                  Bstr(aName).raw(),
     4420                                                 aName,
    44244421                                                 aControllerPort,
    44254422                                                 aDevice);
     
    44784475
    44794476    MediumAttachment *pAttach = i_findAttachment(*mMediumAttachments.data(),
    4480                                                  Bstr(aName).raw(),
     4477                                                 aName,
    44814478                                                 aControllerPort,
    44824479                                                 aDevice);
     
    45144511
    45154512    MediumAttachment *pAttach = i_findAttachment(*mMediumAttachments.data(),
    4516                                                  Bstr(aName).raw(),
     4513                                                 aName,
    45174514                                                 aControllerPort,
    45184515                                                 aDevice);
     
    45574554
    45584555    MediumAttachment *pAttach = i_findAttachment(*mMediumAttachments.data(),
    4559                                                  Bstr(aName).raw(),
     4556                                                 aName,
    45604557                                                 aControllerPort,
    45614558                                                 aDevice);
     
    46004597
    46014598    MediumAttachment *pAttach = i_findAttachment(*mMediumAttachments.data(),
    4602                                                  Bstr(aName).raw(),
     4599                                                 aName,
    46034600                                                 aControllerPort,
    46044601                                                 aDevice);
     
    46424639
    46434640    MediumAttachment *pAttach = i_findAttachment(*mMediumAttachments.data(),
    4644                                                  Bstr(aName).raw(),
     4641                                                 aName,
    46454642                                                 aControllerPort,
    46464643                                                 aDevice);
     
    47104707
    47114708    MediumAttachment *pAttach = i_findAttachment(*mMediumAttachments.data(),
    4712                                                  Bstr(aName).raw(),
     4709                                                 aName,
    47134710                                                 aControllerPort,
    47144711                                                 aDevice);
     
    47604757                      aName.c_str(), aControllerPort, aDevice, aType));
    47614758
    4762      rc = AttachDevice(Bstr(aName).raw(), aControllerPort, aDevice, aType, NULL);
     4759     rc = attachDevice(aName, aControllerPort, aDevice, aType, NULL);
    47634760
    47644761     return rc;
     
    47974794
    47984795    ComObjPtr<MediumAttachment> pAttach = i_findAttachment(*mMediumAttachments.data(),
    4799                                                            Bstr(aName).raw(),
     4796                                                           aName,
    48004797                                                           aControllerPort,
    48014798                                                           aDevice);
     
    48444841        // old settings. Re-get the correct reference.
    48454842        pAttach = i_findAttachment(*mMediumAttachments.data(),
    4846                                    Bstr(aName).raw(),
     4843                                   aName,
    48474844                                   aControllerPort,
    48484845                                   aDevice);
     
    48784875            pMedium->i_removeBackReference(mData->mUuid);
    48794876        pAttach = i_findAttachment(*mMediumAttachments.data(),
    4880                                    Bstr(aName).raw(),
     4877                                   aName,
    48814878                                   aControllerPort,
    48824879                                   aDevice);
     
    49134910
    49144911    ComObjPtr<MediumAttachment> pAttach = i_findAttachment(*mMediumAttachments.data(),
    4915                                                            Bstr(aName).raw(),
     4912                                                           aName,
    49164913                                                           aControllerPort,
    49174914                                                           aDevice);
     
    55245521    rc = pProgress->init(i_getVirtualBox(),
    55255522                         static_cast<IMachine*>(this) /* aInitiator */,
    5526                          Bstr(tr("Deleting files")).raw(),
     5523                         tr("Deleting files"),
    55275524                         true /* fCancellable */,
    55285525                         (ULONG)(1 + llMediums.size() + llFilesToDelete.size() + 1),    // cOperations
    5529                          Bstr(tr("Collecting file inventory")).raw());
     5526                         tr("Collecting file inventory"));
    55305527    if (FAILED(rc))
    55315528        return rc;
     
    57255722        rc = E_ACCESSDENIED;
    57265723    else
    5727         rc = directControl->AccessGuestProperty(Bstr(aName).raw(), Bstr("").raw(), Bstr("").raw(),
     5724        rc = directControl->AccessGuestProperty(Bstr(aName).raw(), Bstr::Empty.raw(), Bstr::Empty.raw(),
    57285725                                                0 /* accessMode */,
    57295726                                                &bValue, aTimestamp, &bFlags);
     
    60896086
    60906087    ComObjPtr<MediumAttachment> pAttach = i_findAttachment(*mMediumAttachments.data(),
    6091                                                            Bstr(aName).raw(),
     6088                                                           aName,
    60926089                                                           aControllerPort,
    60936090                                                           aDevice);
     
    68076804        RTStrPrintf(name, sizeof(name), "host%02x:%02x.%x", (aHostAddress>>8) & 0xff,
    68086805                    (aHostAddress & 0xf8) >> 3, aHostAddress & 7);
    6809         Bstr bname(name);
    68106806        pda.createObject();
    6811         pda->init(this, bname, aHostAddress, aDesiredGuestAddress, TRUE);
     6807        pda->init(this, name, aHostAddress, aDesiredGuestAddress, TRUE);
    68126808        i_setModified(IsModified_MachineData);
    68136809        mHWData.backup();
     
    74087404            vrc = RTPathAbs(szTmp, szTmp2, sizeof(szTmp2));
    74097405            if (RT_SUCCESS(vrc))
    7410                 aLogFolder = BstrFmt("%s%c%s",
    7411                                      szTmp2,
    7412                                      RTPATH_DELIMITER,
    7413                                      mUserData->s.strName.c_str()); // path/to/logfolder/vmname
     7406                aLogFolder = Utf8StrFmt("%s%c%s",
     7407                                        szTmp2,
     7408                                        RTPATH_DELIMITER,
     7409                                        mUserData->s.strName.c_str()); // path/to/logfolder/vmname
    74147410        }
    74157411        else
     
    87378733
    87388734    // look up the object by Id to check it is valid
    8739     ComPtr<IGuestOSType> guestOSType;
    8740     HRESULT rc = mParent->GetGuestOSType(Bstr(mUserData->s.strOsType).raw(),
    8741                                          guestOSType.asOutParam());
     8735    ComObjPtr<GuestOSType> pGuestOSType;
     8736    HRESULT rc = mParent->i_findGuestOSType(mUserData->s.strOsType,
     8737                                            pGuestOSType);
    87428738    if (FAILED(rc)) return rc;
     8739    mUserData->s.strOsType = pGuestOSType->i_id();
    87438740
    87448741    // stateFile (optional)
     
    91079104            const settings::NetworkAdapter &nic = *it;
    91089105
    9109             /* slot unicity is guaranteed by XML Schema */
     9106            /* slot uniqueness is guaranteed by XML Schema */
    91109107            AssertBreak(nic.ulSlot < mNetworkAdapters.size());
    91119108            rc = mNetworkAdapters[nic.ulSlot]->i_loadSettings(mBandwidthControl, nic);
     
    92659262
    92669263/**
    9267  * Called from Machine::loadHardware() to load the debugging settings of the
     9264 * Called from i_loadHardware() to load the debugging settings of the
    92689265 * machine.
    92699266 *
     
    95269523        }
    95279524
    9528         const Bstr controllerName = aStorageController->i_getName();
     9525        const Utf8Str controllerName = aStorageController->i_getName();
    95299526        ComObjPtr<MediumAttachment> pAttachment;
    95309527        pAttachment.createObject();
     
    1283812835                {
    1283912836                    multilock.release();
    12840                     LogRel(("VM '%s' stops using NAT network '%ls'\n",
    12841                             mUserData->s.strName.c_str(), name.raw()));
    12842                     mParent->i_natNetworkRefDec(name.raw());
     12837                    Utf8Str strName(name);
     12838                    LogRel(("VM '%s' stops using NAT network '%s'\n",
     12839                            mUserData->s.strName.c_str(), strName.c_str()));
     12840                    mParent->i_natNetworkRefDec(strName);
    1284312841                    multilock.acquire();
    1284412842                }
     
    1312513123    rc = pProgress->init(i_getVirtualBox(),
    1312613124                         static_cast<IMachine *>(this) /* aInitiator */,
    13127                          Bstr(tr("Saving the execution state of the virtual machine")).raw(),
     13125                         tr("Saving the execution state of the virtual machine"),
    1312813126                         FALSE /* aCancelable */);
    1312913127    if (FAILED(rc))
     
    1325513253                if (SUCCEEDED(hrc))
    1325613254                {
    13257                     LogRel(("VM '%s' starts using NAT network '%ls'\n",
    13258                             mUserData->s.strName.c_str(), name.raw()));
     13255                    Utf8Str strName(name);
     13256                    LogRel(("VM '%s' starts using NAT network '%s'\n",
     13257                            mUserData->s.strName.c_str(), strName.c_str()));
    1325913258                    mPeer->lockHandle()->unlockWrite();
    13260                     mParent->i_natNetworkRefInc(name.raw());
     13259                    mParent->i_natNetworkRefInc(strName);
    1326113260#ifdef RT_LOCK_STRICT
    1326213261                    mPeer->lockHandle()->lockWrite(RT_SRC_POS);
     
    1332213321    pProgress->init(i_getVirtualBox(),
    1332313322                    static_cast<IMachine *>(this) /* aInitiator */,
    13324                     Bstr(tr("Stopping the virtual machine")).raw(),
     13323                    tr("Stopping the virtual machine"),
    1332513324                    FALSE /* aCancelable */);
    1332613325
     
    1375213751    ComObjPtr<MediumAttachment> pAttach = static_cast<MediumAttachment *>(iAttach);
    1375313752
    13754     Bstr ctrlName;
     13753    Utf8Str ctrlName;
    1375513754    LONG lPort;
    1375613755    LONG lDevice;
     
    1378013779        // old settings. Re-get the correct reference.
    1378113780        pAttach = i_findAttachment(*mMediumAttachments.data(),
    13782                                    ctrlName.raw(),
     13781                                   ctrlName,
    1378313782                                   lPort,
    1378413783                                   lDevice);
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