Changeset 101237 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Sep 22, 2023 11:16:42 AM (16 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp
r101158 r101237 172 172 CFirmwareSettings comFirmwareSettings = m_machine.GetFirmwareSettings(); 173 173 174 #if 0175 /* Configure the newly created vm here in GUI by several calls to API: */176 configureVM(strTypeId, m_comGuestOSType);177 #else178 174 /* The newer and less tested way of configuring vms: */ 179 175 m_machine.ApplyDefaults(QString()); … … 191 187 /* Set recommended firmware type: */ 192 188 comFirmwareSettings.SetFirmwareType(m_fEFIEnabled ? KFirmwareType_EFI : KFirmwareType_BIOS); 193 #endif194 189 195 190 /* Register the VM prior to attaching hard disks: */ … … 277 272 /* Detach virtual-disk finally: */ 278 273 m_virtualDisk.detach(); 279 }280 281 void UIWizardNewVM::configureVM(const QString &strGuestTypeId, const CGuestOSType &comGuestType)282 {283 /* Acquire platform stuff: */284 CPlatform comPlatform = m_machine.GetPlatform();285 CFirmwareSettings comFirmwareSettings = m_machine.GetFirmwareSettings();286 287 /* Get graphics adapter: */288 CGraphicsAdapter comGraphics = m_machine.GetGraphicsAdapter();289 290 /* RAM size: */291 m_machine.SetMemorySize(m_iMemorySize);292 293 /* VCPU count: */294 int iVPUCount = qMax(1, m_iCPUCount);295 m_machine.SetCPUCount(iVPUCount);296 297 /* Enabled I/O APIC explicitly in we have more than 1 VCPU: */298 if (iVPUCount > 1)299 comFirmwareSettings.SetIOAPICEnabled(true);300 301 /* Graphics Controller type: */302 comGraphics.SetGraphicsControllerType(comGuestType.GetRecommendedGraphicsController());303 304 /* VRAM size - select maximum between recommended and minimum for fullscreen: */305 comGraphics.SetVRAMSize(qMax(comGuestType.GetRecommendedVRAM(), (ULONG)(UICommon::requiredVideoMemory(strGuestTypeId) / _1M)));306 307 /* Selecting recommended chipset type: */308 comPlatform.SetChipsetType(comGuestType.GetRecommendedChipset());309 310 /* Selecting recommended Audio Controller: */311 CAudioSettings const comAudioSettings = m_machine.GetAudioSettings();312 CAudioAdapter comAdapter = comAudioSettings.GetAdapter();313 comAdapter.SetAudioController(comGuestType.GetRecommendedAudioController());314 /* And the Audio Codec: */315 comAdapter.SetAudioCodec(comGuestType.GetRecommendedAudioCodec());316 /* Enabling audio by default: */317 comAdapter.SetEnabled(true);318 comAdapter.SetEnabledOut(true);319 320 /* Enable the OHCI and EHCI controller by default for new VMs. (new in 2.2): */321 CUSBDeviceFilters usbDeviceFilters = m_machine.GetUSBDeviceFilters();322 bool fOhciEnabled = false;323 if (!usbDeviceFilters.isNull() && comGuestType.GetRecommendedUSB3() && m_machine.GetUSBProxyAvailable())324 {325 m_machine.AddUSBController("XHCI", KUSBControllerType_XHCI);326 /* xHCI includes OHCI */327 fOhciEnabled = true;328 }329 if ( !fOhciEnabled330 && !usbDeviceFilters.isNull() && comGuestType.GetRecommendedUSB() && m_machine.GetUSBProxyAvailable())331 {332 m_machine.AddUSBController("OHCI", KUSBControllerType_OHCI);333 fOhciEnabled = true;334 m_machine.AddUSBController("EHCI", KUSBControllerType_EHCI);335 }336 337 /* Create a floppy controller if recommended: */338 QString strFloppyName = getNextControllerName(KStorageBus_Floppy);339 if (comGuestType.GetRecommendedFloppy())340 {341 m_machine.AddStorageController(strFloppyName, KStorageBus_Floppy);342 CStorageController flpCtr = m_machine.GetStorageControllerByName(strFloppyName);343 flpCtr.SetControllerType(KStorageControllerType_I82078);344 }345 346 /* Create recommended DVD storage controller: */347 KStorageBus strDVDBus = comGuestType.GetRecommendedDVDStorageBus();348 QString strDVDName = getNextControllerName(strDVDBus);349 m_machine.AddStorageController(strDVDName, strDVDBus);350 351 /* Set recommended DVD storage controller type: */352 CStorageController dvdCtr = m_machine.GetStorageControllerByName(strDVDName);353 KStorageControllerType dvdStorageControllerType = comGuestType.GetRecommendedDVDStorageController();354 dvdCtr.SetControllerType(dvdStorageControllerType);355 356 /* Create recommended HD storage controller if it's not the same as the DVD controller: */357 KStorageBus ctrHDBus = comGuestType.GetRecommendedHDStorageBus();358 KStorageControllerType hdStorageControllerType = comGuestType.GetRecommendedHDStorageController();359 CStorageController hdCtr;360 QString strHDName;361 if (ctrHDBus != strDVDBus || hdStorageControllerType != dvdStorageControllerType)362 {363 strHDName = getNextControllerName(ctrHDBus);364 m_machine.AddStorageController(strHDName, ctrHDBus);365 hdCtr = m_machine.GetStorageControllerByName(strHDName);366 hdCtr.SetControllerType(hdStorageControllerType);367 }368 else369 {370 /* The HD controller is the same as DVD: */371 hdCtr = dvdCtr;372 strHDName = strDVDName;373 }374 375 KPlatformArchitecture const platformArch = comPlatform.GetArchitecture();376 switch (platformArch)377 {378 case KPlatformArchitecture_x86:379 {380 /* Limit the AHCI port count if it's used because windows has trouble with381 too many ports and other guest (OS X in particular) may take extra long382 to boot: */383 if (hdStorageControllerType == KStorageControllerType_IntelAhci)384 hdCtr.SetPortCount(1 + (dvdStorageControllerType == KStorageControllerType_IntelAhci));385 else if (dvdStorageControllerType == KStorageControllerType_IntelAhci)386 dvdCtr.SetPortCount(1);387 388 CPlatformX86 comPlatformX86 = comPlatform.GetX86();389 390 /* Turn on PAE, if recommended: */391 comPlatformX86.SetCPUProperty(KCPUPropertyTypeX86_PAE, comGuestType.GetRecommendedPAE());392 393 /* Set the recommended triple fault behavior: */394 comPlatformX86.SetCPUProperty(KCPUPropertyTypeX86_TripleFaultReset, comGuestType.GetRecommendedTFReset());395 396 /* Set HPET flag: */397 comPlatformX86.SetHPETEnabled(comGuestType.GetRecommendedHPET());398 break;399 }400 401 #ifdef VBOX_WITH_VIRT_ARMV8402 case KPlatformArchitecture_ARM:403 {404 /* When using VirtioSCSI as the HDD storage controller and the DVD Drive is on that same controller,405 * we have to raise the port count, as VirtioSCSI only configures one port per default. */406 if ( hdCtr == dvdCtr407 && hdStorageControllerType == KStorageControllerType_VirtioSCSI)408 hdCtr.SetPortCount(2);409 break;410 }411 #endif412 default:413 break;414 }415 416 /* Set recommended firmware type: */417 comFirmwareSettings.SetFirmwareType(m_fEFIEnabled ? KFirmwareType_EFI : KFirmwareType_BIOS);418 419 /* Set recommended human interface device types: */420 if (comGuestType.GetRecommendedUSBHID())421 {422 m_machine.SetKeyboardHIDType(KKeyboardHIDType_USBKeyboard);423 m_machine.SetPointingHIDType(KPointingHIDType_USBMouse);424 if (!fOhciEnabled && !usbDeviceFilters.isNull())425 m_machine.AddUSBController("OHCI", KUSBControllerType_OHCI);426 }427 428 if (comGuestType.GetRecommendedUSBTablet())429 {430 m_machine.SetPointingHIDType(KPointingHIDType_USBTablet);431 if (!fOhciEnabled && !usbDeviceFilters.isNull())432 m_machine.AddUSBController("OHCI", KUSBControllerType_OHCI);433 }434 435 /* Set UTC flags: */436 comPlatform.SetRTCUseUTC(comGuestType.GetRecommendedRTCUseUTC());437 438 /* Set graphic bits: */439 if (comGuestType.GetRecommended2DVideoAcceleration())440 comGraphics.SetAccelerate2DVideoEnabled(comGuestType.GetRecommended2DVideoAcceleration());441 442 if (comGuestType.GetRecommended3DAcceleration())443 comGraphics.SetAccelerate3DEnabled(comGuestType.GetRecommended3DAcceleration());444 274 } 445 275 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.h
r99207 r101237 176 176 virtual void populatePages() /* final override */; 177 177 virtual void cleanWizard() /* final override */; 178 void configureVM(const QString &strGuestTypeId, const CGuestOSType &comGuestType);179 178 bool attachDefaultDevices(); 180 179
Note:
See TracChangeset
for help on using the changeset viewer.