VirtualBox

Changeset 105922 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 2, 2024 6:08:46 PM (3 months ago)
Author:
vboxsync
Message:

Unattended: bugref:10511, bugref:10384. Simplify check if the detected guest OS type is supported by the host system.

File:
1 edited

Legend:

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

    r105917 r105922  
    341341{
    342342    HRESULT       hrc;
    343     HRESULT       getSupportedGuestOSTypesRC;
     343
    344344    /* Get a list of guest OS Type Ids supported by the host. */
    345345    ComPtr<ISystemProperties> pSystemProperties;
     
    353353        if (SUCCEEDED(hrc))
    354354        {
    355             getSupportedGuestOSTypesRC = pPlatformProperties->COMGETTER(SupportedGuestOSTypes)(ComSafeArrayAsOutParam(supportedGuestOSTypes));
     355            hrc = pPlatformProperties->COMGETTER(SupportedGuestOSTypes)(ComSafeArrayAsOutParam(supportedGuestOSTypes));
     356            if (!SUCCEEDED(hrc))
     357                supportedGuestOSTypes.resize(0);
    356358        }
    357359    }
     
    506508    }
    507509
    508     if (SUCCEEDED(getSupportedGuestOSTypesRC))
    509     {
    510         bool fSupported = false;
    511         for (size_t i = 0; i < supportedGuestOSTypes.size() && !fSupported; ++i)
    512         {
    513             ComPtr<IGuestOSType> guestOSType = supportedGuestOSTypes[i];
    514 
    515             Bstr guestId;
    516             guestOSType->COMGETTER(Id)(guestId.asOutParam());
    517             if (guestId == mStrDetectedOSTypeId)
    518                 fSupported = true;
    519         }
    520         if (!fSupported)
    521         {
    522             mStrDetectedOSTypeId.setNull();
    523             mStrDetectedOSVersion.setNull();
    524             mStrDetectedOSFlavor.setNull();
    525             mDetectedOSLanguages.clear();
    526             mStrDetectedOSHints.setNull();
    527             mDetectedImages.clear();
    528         }
    529     }
     510    /* Check if detected OS type is supported (covers platform architecture). */
     511    bool fSupported = false;
     512    for (size_t i = 0; i < supportedGuestOSTypes.size() && !fSupported; ++i)
     513    {
     514        ComPtr<IGuestOSType> guestOSType = supportedGuestOSTypes[i];
     515
     516        Bstr guestId;
     517        guestOSType->COMGETTER(Id)(guestId.asOutParam());
     518        if (guestId == mStrDetectedOSTypeId)
     519            fSupported = true;
     520    }
     521    if (!fSupported)
     522    {
     523        mStrDetectedOSTypeId.setNull();
     524        mStrDetectedOSVersion.setNull();
     525        mStrDetectedOSFlavor.setNull();
     526        mDetectedOSLanguages.clear();
     527        mStrDetectedOSHints.setNull();
     528        mDetectedImages.clear();
     529        hrc = E_FAIL;
     530    }
     531
    530532    /** @todo implement actual detection logic. */
    531533    return hrc;
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