VirtualBox

Changeset 99604 in vbox


Ignore:
Timestamp:
May 4, 2023 1:53:06 PM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
157124
Message:

bugref:10314. bugref:10278. Reverted VSD RAM unit to bytes and fixed other places where MB unit was used.

Location:
trunk/src/VBox
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageAppliance.cpp

    r99523 r99604  
    757757                                    RTPrintf(Appliance::tr("%2u: Guest memory specified with --memory: %RU32 MB\n"),
    758758                                             a, ulMemMB);
     759
     760                                   /* IVirtualSystemDescription guest memory size is in bytes.
     761                                      It's alway stored in bytes in VSD according to the old internal agreement within the team */
     762                                    uint64_t ullMemBytes = (uint64_t)ulMemMB * _1M;
     763                                    strOverride = Utf8StrFmt("%RU64", ullMemBytes);
    759764                                    bstrFinalValue = strOverride;
    760765                                }
     
    765770                            {
    766771                                strOverride = aVBoxValues[a];
    767                                 uint64_t ullMemMB = strOverride.toUInt64();
     772                                uint64_t ullMemMB = strOverride.toUInt64() / _1M;
    768773                                RTPrintf(Appliance::tr("%2u: Guest memory: %RU64 MB\n    (change with \"--vsys %u --memory <MB>\")\n"),
    769774                                         a, ullMemMB, i);
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceEditorWidget.cpp

    r99522 r99604  
    354354    , m_enmVSDType(enmVSDType)
    355355    , m_strRef(strRef)
    356     , m_strOrigValue(strOrigValue)
    357     , m_strConfigValue(strConfigValue)
     356    , m_strOrigValue(enmVSDType == KVirtualSystemDescriptionType_Memory ? UITranslator::byteStringToMegaByteString(strOrigValue) : strOrigValue)
     357    , m_strConfigValue(enmVSDType == KVirtualSystemDescriptionType_Memory ? UITranslator::byteStringToMegaByteString(strConfigValue) : strConfigValue)
    358358    , m_strConfigDefaultValue(strConfigValue)
    359     , m_strExtraConfigValue(strExtraConfigValue)
     359    , m_strExtraConfigValue(enmVSDType == KVirtualSystemDescriptionType_Memory ? UITranslator::byteStringToMegaByteString(strExtraConfigValue) : strExtraConfigValue)
    360360    , m_checkState(Qt::Checked)
    361361    , m_fModified(false)
     
    13031303{
    13041304    finalStates[m_iNumber] = m_checkState == Qt::Checked;
    1305     finalValues[m_iNumber] = m_strConfigValue;
    1306     finalExtraValues[m_iNumber] = m_strExtraConfigValue;
     1305    /* It's alway stored in bytes in VSD according to the old internal agreement within the team */
     1306    finalValues[m_iNumber] = m_enmVSDType == KVirtualSystemDescriptionType_Memory ? UITranslator::megabyteStringToByteString(m_strConfigValue) : m_strConfigValue;
     1307    finalExtraValues[m_iNumber] = m_enmVSDType == KVirtualSystemDescriptionType_Memory ? UITranslator::megabyteStringToByteString(m_strExtraConfigValue) : m_strExtraConfigValue;
    13071308
    13081309    UIApplianceModelItem::putBack(finalStates, finalValues, finalExtraValues);
  • trunk/src/VBox/Main/include/ovfreader.h

    r99523 r99604  
    635635    HardwareItemVector  vecHardwareItems;       //< vector containing all virtual hardware items in parsing order.
    636636
    637     uint64_t            ullMemorySize;          // always in Megabytes, copied from llHardwareItems; default = 0 (unspecified)
     637    uint64_t            ullMemorySize;          // always in bytes, 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

    r99523 r99604  
    187187                             strCpuCount);
    188188
    189         /* Memory */
    190         Utf8Str strMemory = Utf8StrFmt("%RI64", (uint64_t)ulMemSizeMB);
     189        /* Memory, it's alway stored in bytes in VSD according to the old internal agreement within the team */
     190        Utf8Str strMemory = Utf8StrFmt("%RI64", (uint64_t)ulMemSizeMB * _1M);
    191191        pNewDesc->i_addEntry(VirtualSystemDescriptionType_Memory,
    192192                             "",
     
    16171617                        type = ovf::ResourceType_Memory; // 4
    16181618                        desc.strVBoxCurrent.toInt(uTemp);
    1619                         lVirtualQuantity = (int32_t)(uTemp);
     1619                        /* It's alway stored in bytes in VSD according to the old internal agreement within the team */
     1620                        lVirtualQuantity = (int32_t)(uTemp / _1M);
    16201621                        strAllocationUnits = "MegaBytes";
    16211622                        strCaption = Utf8StrFmt("%d MB of memory", lVirtualQuantity);     // without this ovftool
  • trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp

    r99523 r99604  
    342342            if (   vsysThis.pelmVBoxMachine
    343343                && pNewDesc->m->pConfig->hardwareMachine.ulMemorySizeMB)
    344                 ullMemSizeVBox = (uint64_t)pNewDesc->m->pConfig->hardwareMachine.ulMemorySizeMB;
     344                ullMemSizeVBox = (uint64_t)pNewDesc->m->pConfig->hardwareMachine.ulMemorySizeMB * _1M;
    345345            else
    346                 ullMemSizeVBox = vsysThis.ullMemorySize;  /* already in Megabytes via OVFReader::HandleVirtualSystemContent() */
     346                /* already in bytes via OVFReader::HandleVirtualSystemContent() */
     347                ullMemSizeVBox = vsysThis.ullMemorySize;
    347348            /* Check for the constraints */
    348349            if (    ullMemSizeVBox != 0
    349                  && (    ullMemSizeVBox < MM_RAM_MIN_IN_MB
    350                       || ullMemSizeVBox > MM_RAM_MAX_IN_MB
     350                 && (    ullMemSizeVBox < MM_RAM_MIN
     351                      || ullMemSizeVBox > MM_RAM_MAX
    351352                    )
    352353               )
     
    355356                                "however VirtualBox supports a minimum of %u MB and a maximum of %u MB "
    356357                                "of memory."),
    357                                 vsysThis.strName.c_str(), ullMemSizeVBox, MM_RAM_MIN_IN_MB, MM_RAM_MAX_IN_MB);
     358                                vsysThis.strName.c_str(), ullMemSizeVBox / _1M, MM_RAM_MIN_IN_MB, MM_RAM_MAX_IN_MB);
    358359                ullMemSizeVBox = RT_MIN(RT_MAX(ullMemSizeVBox, MM_RAM_MIN_IN_MB), MM_RAM_MAX_IN_MB);
    359360            }
     
    369370                else
    370371                    memSizeVBox2 = 1024;
    371                 /* IGuestOSType::recommendedRAM() returns the size in MB */
    372                 ullMemSizeVBox = (uint64_t)memSizeVBox2;
    373             }
     372                /* IGuestOSType::recommendedRAM() returns the size in MB so convert to bytes */
     373                ullMemSizeVBox = (uint64_t)memSizeVBox2 * _1M;
     374            }
     375            /* It's alway stored in bytes in VSD according to the old internal agreement within the team */
    374376            pNewDesc->i_addEntry(VirtualSystemDescriptionType_Memory,
    375377                                 "",
     
    15321534
    15331535                // RAM
     1536                /* It's alway stored in bytes in VSD according to the old internal agreement within the team */
    15341537                GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_Memory);
    15351538                if (aVBoxValues.size() == 0)//1024MB by default, 1,073,741,824 in bytes
    15361539                    vsd->AddDescription(VirtualSystemDescriptionType_Memory,
    1537                                         Bstr("1024").raw(),
     1540                                        Bstr("1073741824").raw(),
    15381541                                        NULL);
    15391542
     
    17971800                }
    17981801
    1799                 ULONG memory = 1024;//1024MB by default, 1,073,741,824 in bytes
    1800                 pGuestOSType->COMGETTER(RecommendedRAM)(&memory);
     1802                ULONG memory;
     1803                pGuestOSType->COMGETTER(RecommendedRAM)(&memory);//returned in MB
     1804                memory *= _1M;//convert to bytes
    18011805                {
    1802                     //note! Memory must be stored in Megabytes on the earlier stages for the correct comparison here
     1806                    /* It's alway stored in bytes in VSD according to the old internal agreement within the team */
    18031807                    GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_Memory); //aVBoxValues is set in this #define
    18041808                    if (aVBoxValues.size() != 0)
    18051809                    {
    18061810                        vsdData = aVBoxValues[0];
    1807                         memory = RT_MIN(RT_MAX(vsdData.toUInt32(), MM_RAM_MIN_IN_MB), MM_RAM_MAX_IN_MB);
     1811                        memory = RT_MIN(RT_MAX(vsdData.toUInt64(), MM_RAM_MIN), MM_RAM_MAX);
    18081812
    18091813                    }
    1810                     //and set in ovf::VirtualSystem in Megabytes
     1814                    //and set in ovf::VirtualSystem in bytes
    18111815                    vsys.ullMemorySize = memory;
    1812                     LogRel(("%s: Size of RAM is %d MB\n", __FUNCTION__, vsys.ullMemorySize));
     1816                    LogRel(("%s: Size of RAM is %d MB\n", __FUNCTION__, vsys.ullMemorySize / _1M));
    18131817                }
    18141818
     
    61166120        if (vsdeRAM.size() != 1)
    61176121            throw setError(VBOX_E_FILE_ERROR, tr("RAM size missing"));
    6118         //Returned value must be in MB
    6119         uint64_t ullMemorySizeMB = vsdeRAM.front()->strVBoxCurrent.toUInt64();
     6122        /* It's alway stored in bytes in VSD according to the old internal agreement within the team */
     6123        uint64_t ullMemorySizeMB = vsdeRAM.front()->strVBoxCurrent.toUInt64() / _1M;
    61206124        stack.ulMemorySizeMB = (uint32_t)ullMemorySizeMB;
    61216125
  • trunk/src/VBox/Main/xml/ovfreader.cpp

    r99523 r99604  
    521521
    522522                    case ResourceType_Memory:        // 4
     523                        /* It's alway stored in bytes in VSD according to the old internal agreement within the team */
    523524                        if (    i.strAllocationUnits == "MegaBytes"           // found in OVF created by OVF toolkit
    524525                             || i.strAllocationUnits == "MB"                  // found in MS docs
    525526                             || i.strAllocationUnits == "byte * 2^20"         // suggested by OVF spec DSP0243 page 21
    526527                           )
    527                             vsys.ullMemorySize = i.ullVirtualQuantity;
     528                            vsys.ullMemorySize = i.ullVirtualQuantity * _1M;
    528529                        else if ( i.strAllocationUnits == "GigaBytes"
    529530                                  || i.strAllocationUnits == "GB"
    530531                                  || i.strAllocationUnits == "byte * 2^30"
    531532                           )
    532                             vsys.ullMemorySize = i.ullVirtualQuantity/_1K;//back to MB
     533                            vsys.ullMemorySize = i.ullVirtualQuantity * _1G;
    533534                        else
    534535                            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