Changeset 73740 in vbox
- Timestamp:
- Aug 17, 2018 4:52:08 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/manual/en_US/user_VBoxManage.xml
r73664 r73740 666 666 if it is assigned to a VM group membership. By default, a unique 667 667 uuid within the appropriate namespace is automatically generated. 668 </para> 669 670 <para> 671 If the <computeroutput>--default</computeroutput> option is used, 672 default hardware configuration for specified guest operation 673 system will be applied. By default, VM is created with minimal 674 hardware. 668 675 </para> 669 676 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r73716 r73740 478 478 " [--basefolder <path>]\n" 479 479 " [--uuid <uuid>]\n" 480 " [--default]\n" 480 481 "\n", SEP); 481 482 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
r73664 r73740 195 195 { "--register", 'r', RTGETOPT_REQ_NOTHING }, 196 196 { "-register", 'r', RTGETOPT_REQ_NOTHING }, 197 { "--default", 'd', RTGETOPT_REQ_NOTHING }, 198 { "-default", 'd', RTGETOPT_REQ_NOTHING }, 197 199 }; 198 200 … … 205 207 Bstr bstrUuid; 206 208 bool fRegister = false; 209 bool fDefault = false; 210 /* TBD. Now not used */ 211 Bstr bstrDefaultFlags; 207 212 com::SafeArray<BSTR> groups; 208 213 … … 239 244 case 'r': // --register 240 245 fRegister = true; 246 break; 247 248 case 'd': // --default 249 fDefault = true; 241 250 break; 242 251 … … 278 287 { 279 288 CHECK_ERROR_BREAK(a->virtualBox, RegisterMachine(machine)); 289 } 290 if (fDefault) 291 { 292 /* ApplyDefaults assumes the machine is already registered */ 293 CHECK_ERROR_BREAK(machine, ApplyDefaults(bstrDefaultFlags.raw())); 294 CHECK_ERROR_BREAK(machine, SaveSettings()); 280 295 } 281 296 Bstr uuid; -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r73589 r73740 46 46 #include "SystemPropertiesImpl.h" 47 47 #include "MachineImplMoveVM.h" 48 #include "ExtPackManagerImpl.h" 48 49 49 50 // generated header … … 15279 15280 HRESULT Machine::applyDefaults(const com::Utf8Str &aFlags) 15280 15281 { 15282 /* it's assumed the machine already registered. If not, it's a problem of the caller */ 15283 15284 AutoCaller autoCaller(this); 15285 AssertComRCReturn(autoCaller.rc(),autoCaller.rc()); 15286 15287 HRESULT rc = S_OK; 15288 15289 /* get usb device filters from host, before any writes occurred to avoid deadlock */ 15290 ComPtr<IUSBDeviceFilters> usbDeviceFilters; 15291 rc = getUSBDeviceFilters(usbDeviceFilters); 15292 if (FAILED(rc)) return rc; 15293 15281 15294 NOREF(aFlags); 15282 ReturnComNotImplemented(); 15295 com::Utf8Str osTypeId; 15296 ComObjPtr<GuestOSType> osType = NULL; 15297 15298 /* Get the guest os type as a string from the VB. */ 15299 rc = getOSTypeId(osTypeId); 15300 if (FAILED(rc)) return rc; 15301 15302 /* Get the os type obj that coresponds, can be used to get 15303 * the defaults for this guest OS. */ 15304 rc = mParent->i_findGuestOSType(Bstr(osTypeId), osType); 15305 if (FAILED(rc)) return rc; 15306 15307 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 15308 15309 /* Let the OS type select 64-bit ness. */ 15310 mHWData->mLongMode = osType->i_is64Bit() 15311 ? settings::Hardware::LongMode_Enabled : settings::Hardware::LongMode_Disabled; 15312 15313 /* Apply network adapters defaults */ 15314 for (ULONG slot = 0; slot < mNetworkAdapters.size(); ++slot) 15315 mNetworkAdapters[slot]->i_applyDefaults(osType); 15316 15317 /* Apply serial port defaults */ 15318 for (ULONG slot = 0; slot < RT_ELEMENTS(mSerialPorts); ++slot) 15319 mSerialPorts[slot]->i_applyDefaults(osType); 15320 15321 /* Apply parallel port defaults - not OS dependent*/ 15322 for (ULONG slot = 0; slot < RT_ELEMENTS(mParallelPorts); ++slot) 15323 mParallelPorts[slot]->i_applyDefaults(); 15324 15325 15326 /* Let the OS type enable the X2APIC */ 15327 mHWData->mX2APIC = osType->i_recommendedX2APIC(); 15328 15329 /* This one covers IOAPICEnabled. */ 15330 mBIOSSettings->i_applyDefaults(osType); 15331 15332 /* Initialize default BIOS settings here */ 15333 mHWData->mAPIC = osType->i_recommendedIOAPIC(); 15334 mHWData->mHWVirtExEnabled = osType->i_recommendedVirtEx(); 15335 15336 rc = osType->COMGETTER(RecommendedRAM)(&mHWData->mMemorySize); 15337 if (FAILED(rc)) return rc; 15338 15339 rc = osType->COMGETTER(RecommendedVRAM)(&mHWData->mVRAMSize); 15340 if (FAILED(rc)) return rc; 15341 15342 rc = osType->COMGETTER(Recommended2DVideoAcceleration)(&mHWData->mAccelerate2DVideoEnabled); 15343 if (FAILED(rc)) return rc; 15344 15345 rc = osType->COMGETTER(Recommended3DAcceleration)(&mHWData->mAccelerate3DEnabled); 15346 if (FAILED(rc)) return rc; 15347 15348 rc = osType->COMGETTER(RecommendedFirmware)(&mHWData->mFirmwareType); 15349 if (FAILED(rc)) return rc; 15350 15351 rc = osType->COMGETTER(RecommendedPAE)(&mHWData->mPAEEnabled); 15352 if (FAILED(rc)) return rc; 15353 15354 rc = osType->COMGETTER(RecommendedHPET)(&mHWData->mHPETEnabled); 15355 if (FAILED(rc)) return rc; 15356 15357 BOOL mRTCUseUTC; 15358 rc = osType->COMGETTER(RecommendedRTCUseUTC)(&mRTCUseUTC); 15359 if (FAILED(rc)) return rc; 15360 15361 setRTCUseUTC(mRTCUseUTC); 15362 if (FAILED(rc)) return rc; 15363 15364 rc = osType->COMGETTER(RecommendedChipset)(&mHWData->mChipsetType); 15365 if (FAILED(rc)) return rc; 15366 15367 rc = osType->COMGETTER(RecommendedTFReset)(&mHWData->mTripleFaultReset); 15368 if (FAILED(rc)) return rc; 15369 15370 /* Audio stuff. */ 15371 AudioCodecType_T audioCodec; 15372 rc = osType->COMGETTER(RecommendedAudioCodec)(&audioCodec); 15373 if (FAILED(rc)) return rc; 15374 15375 rc = mAudioAdapter->COMSETTER(AudioCodec)(audioCodec); 15376 if (FAILED(rc)) return rc; 15377 15378 AudioControllerType_T audioController; 15379 rc = osType->COMGETTER(RecommendedAudioController)(&audioController); 15380 if (FAILED(rc)) return rc; 15381 15382 rc = mAudioAdapter->COMSETTER(AudioController)(audioController); 15383 if (FAILED(rc)) return rc; 15384 15385 rc = mAudioAdapter->COMSETTER(Enabled)(true); 15386 if (FAILED(rc)) return rc; 15387 15388 rc = mAudioAdapter->COMSETTER(EnabledOut)(true); 15389 if (FAILED(rc)) return rc; 15390 15391 /* Storage Controllers */ 15392 StorageControllerType_T hdStorageControllerType; 15393 StorageBus_T hdStorageBusType; 15394 StorageControllerType_T dvdStorageControllerType; 15395 StorageBus_T dvdStorageBusType; 15396 BOOL recommendedFloppy; 15397 ComPtr<IStorageController> floppyController; 15398 ComPtr<IStorageController> hdController; 15399 ComPtr<IStorageController> dvdController; 15400 Utf8Str strFloppyName, strDVDName, strHDName; 15401 15402 /* GUI auto generates these - not accesible here - so hardware, at least for now. */ 15403 strFloppyName = Bstr("Floppy 1").raw(); 15404 strDVDName = Bstr("DVD 1").raw(); 15405 strHDName = Bstr("HDD 1").raw(); 15406 15407 /* Floppy recommended? add one. */ 15408 rc = osType->COMGETTER(RecommendedFloppy(&recommendedFloppy)); 15409 if (FAILED(rc)) return rc; 15410 if (recommendedFloppy) 15411 { 15412 rc = addStorageController(strFloppyName, 15413 StorageBus_Floppy, 15414 floppyController); 15415 if (FAILED(rc)) return rc; 15416 } 15417 15418 /* Setup one DVD storage controller. */ 15419 rc = osType->COMGETTER(RecommendedDVDStorageController)(&dvdStorageControllerType); 15420 if (FAILED(rc)) return rc; 15421 15422 rc = osType->COMGETTER(RecommendedDVDStorageBus)(&dvdStorageBusType); 15423 if (FAILED(rc)) return rc; 15424 15425 rc = addStorageController(strDVDName, 15426 dvdStorageBusType, 15427 dvdController); 15428 if (FAILED(rc)) return rc; 15429 15430 rc = dvdController->COMSETTER(ControllerType)(dvdStorageControllerType); 15431 if (FAILED(rc)) return rc; 15432 15433 /* Setup one HDD storage controller. */ 15434 rc = osType->COMGETTER(RecommendedHDStorageController)(&hdStorageControllerType); 15435 if (FAILED(rc)) return rc; 15436 15437 rc = osType->COMGETTER(RecommendedHDStorageBus)(&hdStorageBusType); 15438 if (FAILED(rc)) return rc; 15439 15440 if (hdStorageBusType != dvdStorageBusType && hdStorageControllerType != dvdStorageControllerType) 15441 { 15442 rc = addStorageController(strHDName, 15443 hdStorageBusType, 15444 hdController); 15445 if (FAILED(rc)) return rc; 15446 15447 rc = hdController->COMSETTER(ControllerType)(hdStorageControllerType); 15448 if (FAILED(rc)) return rc; 15449 } 15450 else 15451 { 15452 /* The HD controller is the same as DVD: */ 15453 hdController = dvdController; 15454 strHDName = Bstr("DVD 1").raw(); 15455 } 15456 15457 /* Limit the AHCI port count if it's used because windows has trouble with 15458 * too many ports and other guest (OS X in particular) may take extra long 15459 * boot: */ 15460 15461 // pParent = static_cast<Medium*>(aP) 15462 IStorageController *temp = hdController; 15463 ComObjPtr<StorageController> storageController; 15464 storageController = static_cast<StorageController *>(temp); 15465 15466 // tempHDController = aHDController; 15467 if (hdStorageControllerType == StorageControllerType_IntelAhci) 15468 storageController->COMSETTER(PortCount)(1 + (dvdStorageControllerType == StorageControllerType_IntelAhci)); 15469 else if (dvdStorageControllerType == StorageControllerType_IntelAhci) 15470 storageController->COMSETTER(PortCount)(1); 15471 15472 /* USB stuff */ 15473 15474 bool ohciEnabled = false; 15475 15476 ComPtr<IUSBController> usbController; 15477 BOOL recommendedUSB3; 15478 BOOL recommendedUSB; 15479 BOOL usbProxyAvailable; 15480 15481 getUSBProxyAvailable(&usbProxyAvailable); 15482 if (FAILED(rc)) return rc; 15483 15484 rc = osType->COMGETTER(RecommendedUSB3)(&recommendedUSB3); 15485 if (FAILED(rc)) return rc; 15486 rc = osType->COMGETTER(RecommendedUSB)(&recommendedUSB); 15487 if (FAILED(rc)) return rc; 15488 15489 if (!usbDeviceFilters.isNull() && recommendedUSB3 && usbProxyAvailable) 15490 { 15491 /* USB 3.0 is only available if the proper ExtPack is installed. */ 15492 ExtPackManager *aManager = mParent->i_getExtPackManager(); 15493 if (aManager->i_isExtPackUsable(ORACLE_PUEL_EXTPACK_NAME)) 15494 { 15495 rc = addUSBController("XHCI", USBControllerType_XHCI, usbController); 15496 if (FAILED(rc)) return rc; 15497 15498 /* xHci includes OHCI */ 15499 ohciEnabled = true; 15500 } 15501 } 15502 if ( !ohciEnabled 15503 && !usbDeviceFilters.isNull() && recommendedUSB && usbProxyAvailable) 15504 { 15505 rc = addUSBController("OHCI", USBControllerType_OHCI, usbController); 15506 if (FAILED(rc)) return rc; 15507 ohciEnabled = true; 15508 15509 /* USB 2.0 is only available if the proper ExtPack is installed. 15510 * Note. Configuring EHCI here and providing messages about 15511 * the missing extpack isn't exactly clean, but it is a 15512 * necessary evil to patch over legacy compatability issues 15513 * introduced by the new distribution model. */ 15514 ExtPackManager *manager = mParent->i_getExtPackManager(); 15515 if (manager->i_isExtPackUsable(ORACLE_PUEL_EXTPACK_NAME)) 15516 { 15517 rc = addUSBController("EHCI", USBControllerType_EHCI, usbController); 15518 if (FAILED(rc)) return rc; 15519 } 15520 } 15521 15522 /* Set recommended human interface device types: */ 15523 BOOL recommendedUSBHID; 15524 rc = osType->COMGETTER(RecommendedUSBHID)(&recommendedUSBHID); 15525 if (FAILED(rc)) return rc; 15526 15527 if (recommendedUSBHID) 15528 { 15529 mHWData->mKeyboardHIDType = KeyboardHIDType_USBKeyboard; 15530 mHWData->mPointingHIDType = PointingHIDType_USBMouse; 15531 if (!ohciEnabled && !usbDeviceFilters.isNull()) 15532 { 15533 rc = addUSBController("OHCI", USBControllerType_OHCI, usbController); 15534 if (FAILED(rc)) return rc; 15535 } 15536 } 15537 15538 BOOL recommendedUSBTablet; 15539 rc = osType->COMGETTER(RecommendedUSBTablet)(&recommendedUSBTablet); 15540 if (FAILED(rc)) return rc; 15541 15542 if (recommendedUSBTablet) 15543 { 15544 mHWData->mPointingHIDType = PointingHIDType_USBTablet; 15545 if (!ohciEnabled && !usbDeviceFilters.isNull()) 15546 { 15547 rc = addUSBController("OHCI", USBControllerType_OHCI, usbController); 15548 if (FAILED(rc)) return rc; 15549 } 15550 } 15551 return S_OK; 15283 15552 } 15284 15553
Note:
See TracChangeset
for help on using the changeset viewer.