VirtualBox

Changeset 99523 in vbox for trunk/src/VBox/Main


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.

Location:
trunk/src/VBox/Main
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/ovfreader.h

    r98103 r99523  
    635635    HardwareItemVector  vecHardwareItems;       //< vector containing all virtual hardware items in parsing order.
    636636
    637     uint64_t            ullMemorySize;          // always in bytes, copied from llHardwareItems; default = 0 (unspecified)
     637    uint64_t            ullMemorySize;          // always in Megabytes, copied from llHardwareItems; default = 0 (unspecified)
    638638    uint16_t            cCPUs;                  // no. of CPUs, copied from llHardwareItems; default = 1
    639639
  • trunk/src/VBox/Main/src-server/ApplianceImplExport.cpp

    r98322 r99523  
    188188
    189189        /* Memory */
    190         Utf8Str strMemory = Utf8StrFmt("%RI64", (uint64_t)ulMemSizeMB * _1M);
     190        Utf8Str strMemory = Utf8StrFmt("%RI64", (uint64_t)ulMemSizeMB);
    191191        pNewDesc->i_addEntry(VirtualSystemDescriptionType_Memory,
    192192                             "",
     
    16171617                        type = ovf::ResourceType_Memory; // 4
    16181618                        desc.strVBoxCurrent.toInt(uTemp);
    1619                         lVirtualQuantity = (int32_t)(uTemp / _1M);
     1619                        lVirtualQuantity = (int32_t)(uTemp);
    16201620                        strAllocationUnits = "MegaBytes";
    16211621                        strCaption = Utf8StrFmt("%d MB of memory", lVirtualQuantity);     // without this ovftool
     
    18151815                                           tr("Missing or bad extra config string in hard disk image: \"%s\""),
    18161816                                           desc.strExtraConfigCurrent.c_str());
    1817 
    18181817                        stack.mapDisks[strDiskID] = &desc;
    18191818
  • 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
  • trunk/src/VBox/Main/xml/ovfreader.cpp

    r98103 r99523  
    525525                             || i.strAllocationUnits == "byte * 2^20"         // suggested by OVF spec DSP0243 page 21
    526526                           )
    527                             vsys.ullMemorySize = i.ullVirtualQuantity * _1M;
     527                            vsys.ullMemorySize = i.ullVirtualQuantity;
     528                        else if ( i.strAllocationUnits == "GigaBytes"
     529                                  || i.strAllocationUnits == "GB"
     530                                  || i.strAllocationUnits == "byte * 2^30"
     531                           )
     532                            vsys.ullMemorySize = i.ullVirtualQuantity/_1K;//back to MB
    528533                        else
    529534                            throw OVFLogicError(N_("Error reading \"%s\": Invalid allocation unit \"%s\" specified with memory size item, line %d"),
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