VirtualBox

Ignore:
Timestamp:
Apr 24, 2023 2:44:16 PM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
157024
Message:

bugref:10314. Reverted back r154561 partially. RAM unit is MB.

File:
1 edited

Legend:

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

    r98782 r99523  
    342342            if (   vsysThis.pelmVBoxMachine
    343343                && pNewDesc->m->pConfig->hardwareMachine.ulMemorySizeMB)
    344                 ullMemSizeVBox = (uint64_t)pNewDesc->m->pConfig->hardwareMachine.ulMemorySizeMB * _1M;
     344                ullMemSizeVBox = (uint64_t)pNewDesc->m->pConfig->hardwareMachine.ulMemorySizeMB;
    345345            else
    346                 ullMemSizeVBox = vsysThis.ullMemorySize;  /* already in bytes via OVFReader::HandleVirtualSystemContent() */
     346                ullMemSizeVBox = vsysThis.ullMemorySize;  /* already in Megabytes via OVFReader::HandleVirtualSystemContent() */
    347347            /* Check for the constraints */
    348348            if (    ullMemSizeVBox != 0
    349                  && (    ullMemSizeVBox < MM_RAM_MIN
    350                       || ullMemSizeVBox > MM_RAM_MAX
     349                 && (    ullMemSizeVBox < MM_RAM_MIN_IN_MB
     350                      || ullMemSizeVBox > MM_RAM_MAX_IN_MB
    351351                    )
    352352               )
     
    355355                                "however VirtualBox supports a minimum of %u MB and a maximum of %u MB "
    356356                                "of memory."),
    357                                 vsysThis.strName.c_str(), ullMemSizeVBox / _1M, MM_RAM_MIN_IN_MB, MM_RAM_MAX_IN_MB);
    358                 ullMemSizeVBox = RT_MIN(RT_MAX(ullMemSizeVBox, MM_RAM_MIN), MM_RAM_MAX);
     357                                vsysThis.strName.c_str(), ullMemSizeVBox, MM_RAM_MIN_IN_MB, MM_RAM_MAX_IN_MB);
     358                ullMemSizeVBox = RT_MIN(RT_MAX(ullMemSizeVBox, MM_RAM_MIN_IN_MB), MM_RAM_MAX_IN_MB);
    359359            }
    360360            if (vsysThis.ullMemorySize == 0)
     
    369369                else
    370370                    memSizeVBox2 = 1024;
    371                 /* IGuestOSType::recommendedRAM() returns the size in MB so convert to bytes */
    372                 ullMemSizeVBox = (uint64_t)memSizeVBox2 * _1M;
     371                /* IGuestOSType::recommendedRAM() returns the size in MB */
     372                ullMemSizeVBox = (uint64_t)memSizeVBox2;
    373373            }
    374374            pNewDesc->i_addEntry(VirtualSystemDescriptionType_Memory,
     
    15331533                // RAM
    15341534                GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_Memory);
    1535                 if (aVBoxValues.size() == 0)//1000MB by default
     1535                if (aVBoxValues.size() == 0)//1024MB by default, 1,073,741,824 in bytes
    15361536                    vsd->AddDescription(VirtualSystemDescriptionType_Memory,
    1537                                         Bstr("1000").raw(),
     1537                                        Bstr("1024").raw(),
    15381538                                        NULL);
    15391539
     
    17971797                }
    17981798
    1799                 ULONG memory;//Mb
     1799                ULONG memory = 1024;//1024MB by default, 1,073,741,824 in bytes
    18001800                pGuestOSType->COMGETTER(RecommendedRAM)(&memory);
    18011801                {
     1802                    //note! Memory must be stored in Megabytes on the earlier stages for the correct comparison here
    18021803                    GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_Memory); //aVBoxValues is set in this #define
    18031804                    if (aVBoxValues.size() != 0)
    18041805                    {
    18051806                        vsdData = aVBoxValues[0];
    1806                         if (memory > vsdData.toUInt32())
    1807                             memory = vsdData.toUInt32();
     1807                        memory = RT_MIN(RT_MAX(vsdData.toUInt32(), MM_RAM_MIN_IN_MB), MM_RAM_MAX_IN_MB);
     1808
    18081809                    }
     1810                    //and set in ovf::VirtualSystem in Megabytes
    18091811                    vsys.ullMemorySize = memory;
    18101812                    LogRel(("%s: Size of RAM is %d MB\n", __FUNCTION__, vsys.ullMemorySize));
     
    61146116        if (vsdeRAM.size() != 1)
    61156117            throw setError(VBOX_E_FILE_ERROR, tr("RAM size missing"));
    6116         uint64_t ullMemorySizeMB = vsdeRAM.front()->strVBoxCurrent.toUInt64() / _1M;
     6118        //Returned value must be in MB
     6119        uint64_t ullMemorySizeMB = vsdeRAM.front()->strVBoxCurrent.toUInt64();
    61176120        stack.ulMemorySizeMB = (uint32_t)ullMemorySizeMB;
    61186121
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