VirtualBox

Changeset 93072 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Dec 24, 2021 12:34:26 AM (3 years ago)
Author:
vboxsync
Message:

Main/ApplianceImplImport.cpp: Added todo on GET_VSD_DESCRIPTION_BY_TYPE from r130666 and made it safe. bugref:9416

File:
1 edited

Legend:

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

    r92786 r93072  
    13571357 * uses only the previously locally declared variable names
    13581358 * set hrc as the result of operation
     1359 *
     1360 * What the above description fail to say is that this returns:
     1361 *      - retTypes
     1362 *      - aRefs
     1363 *      - aOvfValues
     1364 *      - aVBoxValues
     1365 *      - aExtraConfigValues
    13591366 */
    1360 #define GET_VSD_DESCRIPTION_BY_TYPE(aParamType) \
    1361     retTypes.setNull(); \
    1362     aRefs.setNull(); \
    1363     aOvfValues.setNull(); \
    1364     aVBoxValues.setNull(); \
    1365     aExtraConfigValues.setNull(); \
    1366     vsd->GetDescriptionByType(aParamType, \
    1367         ComSafeArrayAsOutParam(retTypes), \
    1368         ComSafeArrayAsOutParam(aRefs), \
    1369         ComSafeArrayAsOutParam(aOvfValues), \
    1370         ComSafeArrayAsOutParam(aVBoxValues), \
    1371         ComSafeArrayAsOutParam(aExtraConfigValues)); \
    1372 
    1373 
    1374     GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_CloudProfileName)
     1367/** @todo r=bird: The setNull calls here are implicit in ComSafeArraySasOutParam,
     1368 * so we're doing twice here for no good reason!  Btw. very untidy to not wrap
     1369 * this in do { } while (0) and require ';' when used.  */
     1370#define GET_VSD_DESCRIPTION_BY_TYPE(aParamType) do { \
     1371        retTypes.setNull(); \
     1372        aRefs.setNull(); \
     1373        aOvfValues.setNull(); \
     1374        aVBoxValues.setNull(); \
     1375        aExtraConfigValues.setNull(); \
     1376        vsd->GetDescriptionByType(aParamType, \
     1377                                  ComSafeArrayAsOutParam(retTypes), \
     1378                                  ComSafeArrayAsOutParam(aRefs), \
     1379                                  ComSafeArrayAsOutParam(aOvfValues), \
     1380                                  ComSafeArrayAsOutParam(aVBoxValues), \
     1381                                  ComSafeArrayAsOutParam(aExtraConfigValues)); \
     1382    } while (0)
     1383
     1384    GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_CloudProfileName);
    13751385    if (aVBoxValues.size() == 0)
    13761386        return setErrorVrc(VERR_NOT_FOUND, tr("%s: Cloud user profile name wasn't found"), __FUNCTION__);
     
    13981408    {
    13991409        VBOXOSTYPE guestOsType = VBOXOSTYPE_Unknown;
    1400         GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_OS)//aVBoxValues is set in this #define
     1410        GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_OS); //aVBoxValues is set in this #define
    14011411        if (aVBoxValues.size() != 0)
    14021412        {
     
    14431453
    14441454            {
    1445                 GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_Name)//aVBoxValues is set in this #define
     1455                GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_Name); //aVBoxValues is set in this #define
    14461456                if (aVBoxValues.size() != 0)//paranoia but anyway...
    14471457                    strVMName = aVBoxValues[0];
     
    15061516
    15071517                    if (counter > 0)
    1508                     {
    1509                         return setErrorVrc(VERR_ALREADY_EXISTS, tr("The target folder %s has already contained some"
    1510                                           " files (%d items). Clear the folder from the files or choose another folder"),
    1511                                           strMachineFolder.c_str(), counter);
    1512                     }
     1518                        return setErrorVrc(VERR_ALREADY_EXISTS,
     1519                                           tr("The target folder %s has already contained some files (%d items). Clear the folder from the files or choose another folder"),
     1520                                           strMachineFolder.c_str(), counter);
    15131521                }
    15141522            }
    15151523
    1516             Utf8Str strInsId;
    1517             GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_CloudInstanceId)//aVBoxValues is set in this #define
     1524            GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_CloudInstanceId); //aVBoxValues is set in this #define
    15181525            if (aVBoxValues.size() == 0)
    15191526                return setErrorVrc(VERR_NOT_FOUND, "%s: Cloud Instance Id wasn't found", __FUNCTION__);
    15201527
    1521             strInsId = aVBoxValues[0];
    1522 
    1523             LogRel(("%s: calling CloudClient::ImportInstance\n", __FUNCTION__));
     1528            Utf8Str strInsId = aVBoxValues[0];
     1529
     1530            LogRelFunc(("calling CloudClient::ImportInstance\n"));
    15241531
    15251532            /* Here it's strongly supposed that cloud import produces ONE object on the disk.
     
    15281535             * must be combined together into one object by cloud client.
    15291536             * The most simple way is to create a TAR archive. */
    1530             hrc = cloudClient->ImportInstance(m->virtualSystemDescriptions.front(),
    1531                                               pProgress);
     1537            hrc = cloudClient->ImportInstance(m->virtualSystemDescriptions.front(), pProgress);
    15321538            if (FAILED(hrc))
    15331539            {
    1534                 LogRel(("%s: Cloud import (cloud phase) failed. "
    1535                         "Used cloud instance is \'%s\'\n", __FUNCTION__, strInsId.c_str()));
    1536                 hrc = setError(hrc, tr("%s: Cloud import (cloud phase) failed. "
    1537                                "Used cloud instance is \'%s\'\n"), __FUNCTION__, strInsId.c_str());
     1540                LogRelFunc(("Cloud import (cloud phase) failed. Used cloud instance is \'%s\'\n", strInsId.c_str()));
     1541                hrc = setError(hrc, tr("%s: Cloud import (cloud phase) failed. Used cloud instance is \'%s\'\n"),
     1542                               __FUNCTION__, strInsId.c_str());
    15381543                break;
    15391544            }
     
    15551560        HRESULT const hrcSaved = hrc;
    15561561
    1557         GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_CloudInstanceId)//aVBoxValues is set in this #define
     1562        GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_CloudInstanceId); //aVBoxValues is set in this #define
    15581563        if (aVBoxValues.size() == 0)
    15591564            hrc = setErrorVrc(VERR_NOT_FOUND, tr("%s: Cloud cleanup action - the instance wasn't found"), __FUNCTION__);
     
    16141619                /* small explanation here, the image here points out to the whole downloaded object (not to the image only)
    16151620                 * filled during the first cloud import stage (in the ICloudClient::importInstance()) */
    1616                 GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_HardDiskImage)//aVBoxValues is set in this #define
     1621                GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_HardDiskImage); //aVBoxValues is set in this #define
    16171622                if (aVBoxValues.size() == 0)
    16181623                    hrc = setErrorVrc(VERR_NOT_FOUND, pszGeneralRollBackErrorMessage);
     
    16621667            /* Small explanation here, the image here points out to the whole downloaded object (not to the image only)
    16631668             * filled during the first cloud import stage (in the ICloudClient::importInstance()) */
    1664             GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_HardDiskImage)//aVBoxValues is set in this #define
     1669            GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_HardDiskImage); //aVBoxValues is set in this #define
    16651670            if (aVBoxValues.size() == 0)
    16661671                throw setErrorVrc(VERR_NOT_FOUND, "%s: The description of the downloaded object wasn't found", __FUNCTION__);
     
    16921697             * The downloaded images should be converted to VDI/VMDK if they have another format */
    16931698            Utf8Str strInstId("default cloud instance id");
    1694             {
    1695                 GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_CloudInstanceId)//aVBoxValues is set in this #define
    1696                 if (aVBoxValues.size() != 0)//paranoia but anyway...
    1697                     strInstId = aVBoxValues[0];
    1698                 LogRel(("%s: Importing cloud instance %s\n", __FUNCTION__, strInstId.c_str()));
    1699             }
     1699            GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_CloudInstanceId); //aVBoxValues is set in this #define
     1700            if (aVBoxValues.size() != 0)//paranoia but anyway...
     1701                strInstId = aVBoxValues[0];
     1702            LogRel(("%s: Importing cloud instance %s\n", __FUNCTION__, strInstId.c_str()));
    17001703
    17011704            /* Processing the downloaded object (prepare for the local import) */
     
    17191722                uint32_t cpus = 1;
    17201723                {
    1721                     GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_CPU)//aVBoxValues is set in this #define
     1724                    GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_CPU); //aVBoxValues is set in this #define
    17221725                    if (aVBoxValues.size() != 0)
    17231726                    {
     
    17321735                pGuestOSType->COMGETTER(RecommendedRAM)(&memory);
    17331736                {
    1734                     GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_Memory)//aVBoxValues is set in this #define
     1737                    GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_Memory); //aVBoxValues is set in this #define
    17351738                    if (aVBoxValues.size() != 0)
    17361739                    {
     
    17441747
    17451748                {
    1746                     GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_Description)//aVBoxValues is set in this #define
     1749                    GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_Description); //aVBoxValues is set in this #define
    17471750                    if (aVBoxValues.size() != 0)
    17481751                    {
     
    17541757
    17551758                {
    1756                     GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_OS)//aVBoxValues is set in this #define
     1759                    GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_OS); //aVBoxValues is set in this #define
    17571760                    if (aVBoxValues.size() != 0)
    17581761                        strOsType = aVBoxValues[0];
     
    17631766                ovf::EthernetAdapter ea;
    17641767                {
    1765                     GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_NetworkAdapter)//aVBoxValues is set in this #define
     1768                    GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_NetworkAdapter); //aVBoxValues is set in this #define
    17661769                    if (aVBoxValues.size() != 0)
    17671770                    {
     
    17881791                    hdc.strIdController = "0";
    17891792
    1790                     GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_HardDiskControllerSATA)//aVBoxValues is set in this #define
     1793                    GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_HardDiskControllerSATA); //aVBoxValues is set in this #define
    17911794                    if (aVBoxValues.size() != 0)
    17921795                        hdc.strControllerType = (Utf8Str)(aVBoxValues[0]);
     
    18071810
    18081811                {
    1809                     GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_SoundCard)//aVBoxValues is set in this #define
     1812                    GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_SoundCard); //aVBoxValues is set in this #define
    18101813                    if (aVBoxValues.size() != 0)
    18111814                        vsys.strSoundCardType  = (Utf8Str)(aVBoxValues[0]);
     
    20922095         * But it was the first record added into the list, so aVBoxValues[0] should be correct here.
    20932096         */
    2094         GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_HardDiskImage)//aVBoxValues is set in this #define
     2097        GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_HardDiskImage); //aVBoxValues is set in this #define
    20952098        if (!fKeepDownloadedObject)
    20962099        {
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