Changeset 99523 in vbox for trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
- Timestamp:
- Apr 24, 2023 2:44:16 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 157024
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
r98782 r99523 342 342 if ( vsysThis.pelmVBoxMachine 343 343 && pNewDesc->m->pConfig->hardwareMachine.ulMemorySizeMB) 344 ullMemSizeVBox = (uint64_t)pNewDesc->m->pConfig->hardwareMachine.ulMemorySizeMB * _1M;344 ullMemSizeVBox = (uint64_t)pNewDesc->m->pConfig->hardwareMachine.ulMemorySizeMB; 345 345 else 346 ullMemSizeVBox = vsysThis.ullMemorySize; /* already in bytes via OVFReader::HandleVirtualSystemContent() */346 ullMemSizeVBox = vsysThis.ullMemorySize; /* already in Megabytes via OVFReader::HandleVirtualSystemContent() */ 347 347 /* Check for the constraints */ 348 348 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 351 351 ) 352 352 ) … … 355 355 "however VirtualBox supports a minimum of %u MB and a maximum of %u MB " 356 356 "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); 359 359 } 360 360 if (vsysThis.ullMemorySize == 0) … … 369 369 else 370 370 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; 373 373 } 374 374 pNewDesc->i_addEntry(VirtualSystemDescriptionType_Memory, … … 1533 1533 // RAM 1534 1534 GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_Memory); 1535 if (aVBoxValues.size() == 0)//10 00MB by default1535 if (aVBoxValues.size() == 0)//1024MB by default, 1,073,741,824 in bytes 1536 1536 vsd->AddDescription(VirtualSystemDescriptionType_Memory, 1537 Bstr("10 00").raw(),1537 Bstr("1024").raw(), 1538 1538 NULL); 1539 1539 … … 1797 1797 } 1798 1798 1799 ULONG memory ;//Mb1799 ULONG memory = 1024;//1024MB by default, 1,073,741,824 in bytes 1800 1800 pGuestOSType->COMGETTER(RecommendedRAM)(&memory); 1801 1801 { 1802 //note! Memory must be stored in Megabytes on the earlier stages for the correct comparison here 1802 1803 GET_VSD_DESCRIPTION_BY_TYPE(VirtualSystemDescriptionType_Memory); //aVBoxValues is set in this #define 1803 1804 if (aVBoxValues.size() != 0) 1804 1805 { 1805 1806 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 1808 1809 } 1810 //and set in ovf::VirtualSystem in Megabytes 1809 1811 vsys.ullMemorySize = memory; 1810 1812 LogRel(("%s: Size of RAM is %d MB\n", __FUNCTION__, vsys.ullMemorySize)); … … 6114 6116 if (vsdeRAM.size() != 1) 6115 6117 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(); 6117 6120 stack.ulMemorySizeMB = (uint32_t)ullMemorySizeMB; 6118 6121
Note:
See TracChangeset
for help on using the changeset viewer.