Changeset 68024 in vbox
- Timestamp:
- Jul 18, 2017 1:54:10 PM (7 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 4 edited
-
Frontends/VBoxManage/VBoxManageMisc.cpp (modified) (3 diffs)
-
Main/idl/VirtualBox.xidl (modified) (7 diffs)
-
Main/include/MachineImpl.h (modified) (3 diffs)
-
Main/src-server/MachineImpl.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
r67898 r68024 1384 1384 return errorSyntax(USAGE_UNATTENDEDINSTALL, "Missing VM name/UUID"); 1385 1385 1386 if (!pszSettingsFile) 1387 { 1388 if (!pszUser) 1389 return errorSyntax(USAGE_UNATTENDEDINSTALL, "Missing required --user (or --settings-file) option"); 1390 if (!pszPassword) 1391 return errorSyntax(USAGE_UNATTENDEDINSTALL, "Missing required --password (or --settings-file) option"); 1392 if (!pszIsoPath) 1393 return errorSyntax(USAGE_UNATTENDEDINSTALL, "Missing required --iso-path (or --settings-file) option"); 1394 } 1386 if (!pszSettingsFile && !pszIsoPath) 1387 return errorSyntax(USAGE_UNATTENDEDINSTALL, "Missing required --iso-path (or --settings-file) option"); 1395 1388 1396 1389 /* … … 1435 1428 Utf8Str(bstrUuid).c_str()); 1436 1429 1430 { 1431 /* 1432 * Instantiate and configure the unattended installer. 1433 */ 1434 ComPtr<IUnattended> ptrUnattended; 1435 CHECK_ERROR_BREAK(machine, CreateUnattendedInstaller(ptrUnattended.asOutParam())); 1436 1437 if (pszSettingsFile) 1438 CHECK_ERROR_BREAK(ptrUnattended, LoadSettings(Bstr(pszSettingsFile).raw())); 1439 1440 if (pszIsoPath) 1441 CHECK_ERROR_BREAK(ptrUnattended, COMSETTER(IsoPath)(Bstr(pszIsoPath).raw())); 1442 if (pszUser) 1443 CHECK_ERROR_BREAK(ptrUnattended, COMSETTER(User)(Bstr(pszUser).raw())); 1444 if (pszPassword) 1445 CHECK_ERROR_BREAK(ptrUnattended, COMSETTER(Password)(Bstr(pszPassword).raw())); 1446 if (pszFullUserName) 1447 CHECK_ERROR_BREAK(ptrUnattended, COMSETTER(FullUserName)(Bstr(pszFullUserName).raw())); 1448 if (pszProductKey) 1449 CHECK_ERROR_BREAK(ptrUnattended, COMSETTER(ProductKey)(Bstr(pszProductKey).raw())); 1450 if (pszAdditionsIsoPath) 1451 CHECK_ERROR_BREAK(ptrUnattended, COMSETTER(AdditionsIsoPath)(Bstr(pszAdditionsIsoPath).raw())); 1452 if (fInstallAdditions >= 0) 1453 CHECK_ERROR_BREAK(ptrUnattended, COMSETTER(InstallGuestAdditions)(fInstallAdditions != (int)false)); 1454 if (fSetImageIdx) 1455 CHECK_ERROR_BREAK(ptrUnattended, COMSETTER(ImageIndex)(idxImage)); 1456 if (pszAuxiliaryBasePath) 1457 CHECK_ERROR_BREAK(ptrUnattended, COMSETTER(AuxiliaryBasePath)(Bstr(pszAuxiliaryBasePath).raw())); 1458 1459 CHECK_ERROR_BREAK(ptrUnattended,Prepare()); 1460 CHECK_ERROR_BREAK(ptrUnattended,ConstructMedia()); 1461 CHECK_ERROR_BREAK(ptrUnattended,ReconfigureVM()); 1462 1463 /* 1464 * Retrieve and display the parameters actually used. 1465 */ 1466 RTPrintf("Using values:\n"); 1467 #define SHOW_ATTR(a_Attr, a_szText, a_Type, a_szFmt) do { \ 1468 a_Type Value; \ 1469 HRESULT hrc2 = ptrUnattended->COMGETTER(a_Attr)(&Value); \ 1470 if (SUCCEEDED(hrc2)) \ 1471 RTPrintf(" %22s = " a_szFmt "\n", a_szText, Value); \ 1472 else \ 1473 RTPrintf(" %22s = failed: %Rhrc\n", a_szText, hrc2); \ 1474 } while (0) 1475 #define SHOW_STR_ATTR(a_Attr, a_szText) do { \ 1476 Bstr bstrString; \ 1477 HRESULT hrc2 = ptrUnattended->COMGETTER(a_Attr)(bstrString.asOutParam()); \ 1478 if (SUCCEEDED(hrc2)) \ 1479 RTPrintf(" %22s = %ls\n", a_szText, bstrString.raw()); \ 1480 else \ 1481 RTPrintf(" %22s = failed: %Rhrc\n", a_szText, hrc2); \ 1482 } while (0) 1483 1484 SHOW_STR_ATTR(IsoPath, "isoPath"); 1485 SHOW_STR_ATTR(User, "user"); 1486 SHOW_STR_ATTR(Password, "password"); 1487 SHOW_STR_ATTR(FullUserName, "fullUserName"); 1488 SHOW_STR_ATTR(ProductKey, "productKey"); 1489 SHOW_STR_ATTR(AdditionsIsoPath, "additionsIsoPath"); 1490 SHOW_ATTR( InstallGuestAdditions, "installGuestAdditions", BOOL, "%RTbool"); 1491 SHOW_STR_ATTR(ValidationKitIsoPath, "validationKitIsoPath"); 1492 SHOW_ATTR( InstallTestExecService, "installTestExecService", BOOL, "%RTbool"); 1493 SHOW_STR_ATTR(AuxiliaryBasePath, "auxiliaryBasePath"); 1494 SHOW_ATTR( ImageIndex, "imageIndex", ULONG, "%u"); 1495 SHOW_STR_ATTR(ScriptTemplatePath, "scriptTemplatePath"); 1496 1497 #undef SHOW_STR_ATTR 1498 #undef SHOW_ATTR 1499 } 1500 1501 a->session->UnlockMachine(); 1502 1437 1503 /* 1438 * Instantiate and configure the unattended installer.1504 * Start the VM if requested. 1439 1505 */ 1440 ComPtr<IUnattended> unAttended; 1441 CHECK_ERROR_BREAK(machine, COMGETTER(Unattended)(unAttended.asOutParam())); 1442 1443 /* Always calls 'done' to clean up from any aborted previous session. */ 1444 CHECK_ERROR_BREAK(unAttended,Done()); 1445 1446 if (pszSettingsFile) 1447 CHECK_ERROR_BREAK(unAttended, LoadSettings(Bstr(pszSettingsFile).raw())); 1448 1449 if (pszIsoPath) 1450 CHECK_ERROR_BREAK(unAttended, COMSETTER(IsoPath)(Bstr(pszIsoPath).raw())); 1451 if (pszUser) 1452 CHECK_ERROR_BREAK(unAttended, COMSETTER(User)(Bstr(pszUser).raw())); 1453 if (pszPassword) 1454 CHECK_ERROR_BREAK(unAttended, COMSETTER(Password)(Bstr(pszPassword).raw())); 1455 if (pszFullUserName) 1456 CHECK_ERROR_BREAK(unAttended, COMSETTER(FullUserName)(Bstr(pszFullUserName).raw())); 1457 if (pszProductKey) 1458 CHECK_ERROR_BREAK(unAttended, COMSETTER(ProductKey)(Bstr(pszProductKey).raw())); 1459 if (pszAdditionsIsoPath) 1460 CHECK_ERROR_BREAK(unAttended, COMSETTER(AdditionsIsoPath)(Bstr(pszAdditionsIsoPath).raw())); 1461 if (fInstallAdditions >= 0) 1462 CHECK_ERROR_BREAK(unAttended, COMSETTER(InstallGuestAdditions)(fInstallAdditions != (int)false)); 1463 if (fSetImageIdx) 1464 CHECK_ERROR_BREAK(unAttended, COMSETTER(ImageIndex)(idxImage)); 1465 if (pszAuxiliaryBasePath) 1466 CHECK_ERROR_BREAK(unAttended, COMSETTER(AuxiliaryBasePath)(Bstr(pszAuxiliaryBasePath).raw())); 1467 1468 CHECK_ERROR_BREAK(unAttended,Prepare()); 1469 CHECK_ERROR_BREAK(unAttended,ConstructMedia()); 1470 CHECK_ERROR_BREAK(unAttended,ReconfigureVM()); 1471 CHECK_ERROR_BREAK(unAttended,Done()); 1472 1473 /* 1474 * Start the VM. 1475 */ 1476 a->session->UnlockMachine(); 1477 1506 if (RTStrICmp(pszSessionType, "none") != 0) 1478 1507 { 1479 1508 Bstr env; 1480 1481 1509 #if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) 1482 1510 /* make sure the VM process will start on the same display as VBoxManage */ … … 1520 1548 } 1521 1549 } 1522 } 1523 1524 /* 1525 * Retrieve and display the parameters actually used. 1526 */ 1527 Bstr bstrAdditionsIsoPath; 1528 CHECK_ERROR_BREAK(unAttended, COMGETTER(AdditionsIsoPath)(bstrAdditionsIsoPath.asOutParam())); 1529 BOOL fInstallGuestAdditions = FALSE; 1530 CHECK_ERROR_BREAK(unAttended, COMGETTER(InstallGuestAdditions)(&fInstallGuestAdditions)); 1531 Bstr bstrIsoPath; 1532 CHECK_ERROR_BREAK(unAttended, COMGETTER(IsoPath)(bstrIsoPath.asOutParam())); 1533 Bstr bstrUser; 1534 CHECK_ERROR_BREAK(unAttended, COMGETTER(User)(bstrUser.asOutParam())); 1535 Bstr bstrPassword; 1536 CHECK_ERROR_BREAK(unAttended, COMGETTER(Password)(bstrPassword.asOutParam())); 1537 Bstr bstrFullUserName; 1538 CHECK_ERROR_BREAK(unAttended, COMGETTER(FullUserName)(bstrFullUserName.asOutParam())); 1539 Bstr bstrProductKey; 1540 CHECK_ERROR_BREAK(unAttended, COMGETTER(ProductKey)(bstrProductKey.asOutParam())); 1541 Bstr bstrAuxiliaryBasePath; 1542 CHECK_ERROR_BREAK(unAttended, COMGETTER(AuxiliaryBasePath)(bstrAuxiliaryBasePath.asOutParam())); 1543 ULONG idxImageActual = 0; 1544 CHECK_ERROR_BREAK(unAttended, COMGETTER(ImageIndex)(&idxImageActual)); 1545 RTPrintf("Got values:\n" 1546 " user: %ls\n" 1547 " password: %ls\n" 1548 " fullUserName: %ls\n" 1549 " productKey: %ls\n" 1550 " image index: %u\n" 1551 " isoPath: %ls\n" 1552 " additionsIsoPath: %ls\n" 1553 " installGuestAdditions: %RTbool\n" 1554 " auxiliaryBasePath: %ls", 1555 bstrUser.raw(), 1556 bstrPassword.raw(), 1557 bstrFullUserName.raw(), 1558 bstrProductKey.raw(), 1559 idxImageActual, 1560 bstrIsoPath.raw(), 1561 bstrAdditionsIsoPath.raw(), 1562 fInstallGuestAdditions, 1563 bstrAuxiliaryBasePath.raw()); 1550 1551 /* 1552 * Do we wait for the VM to power down? 1553 */ 1554 } 1555 1564 1556 } while (0); 1565 1557 -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r67898 r68024 3767 3767 <interface 3768 3768 name="IUnattended" extends="$unknown" 3769 uuid=" a6ba3585-5fc3-4465-d61d-5b70540690af"3769 uuid="b365bb45-267f-44fa-c32a-cad265372f8e" 3770 3770 wsmap="managed" 3771 3771 reservedMethods="4" reservedAttributes="16" … … 3776 3776 the Guest OS for fully automated install. 3777 3777 3778 It is based on the IMachine: 3779 <link to="IMachine::unattended"/> attribute. 3778 The typical workflow is: 3779 <ol> 3780 <li>Call <link to="IMachine::createUnattendedInstaller"/> to create the object</li> 3781 <li>Set the IUnattended attributes.</li> 3782 <li>Call <link to="IUnattended::prepare"/> for the object to check the 3783 attribute values and create an internal installer instance.</li> 3784 <li>Call <link to="IUnattended::constructMedia"/> to create additional 3785 media files (ISO/floppy) needed.</li> 3786 <li>Call <link to="IUnattended::reconfigureVM"/> to reconfigure the VM 3787 with the installation ISO, additional media files and whatnot </li> 3788 <li>Optionally call <link to="IUnattended::done"/> to destroy the internal 3789 installer and allow restarting from the second step.</li> 3790 </ol> 3780 3791 </desc> 3781 3792 … … 3815 3826 <attribute name="additionsIsoPath" type="wstring"> 3816 3827 <desc> 3817 Guest Additions ISO image path 3828 Guest Additions ISO image path. This defaults to 3829 <link to="ISystemProperties::defaultAdditionsISO"/> when the Unattended 3830 object is instantiated. 3831 3832 This property is ignored when <link to="IUnattended::installGuestAdditions"/> is false. 3818 3833 </desc> 3819 3834 </attribute> … … 3826 3841 distribution, only the installation of additions pointed to by 3827 3842 <link to="IUnattended::additionsIsoPath"/>. 3843 </desc> 3844 </attribute> 3845 3846 <attribute name="validationKitIsoPath" type="wstring"> 3847 <desc> 3848 VirtualBox ValidationKit ISO image path. This is used when 3849 <link to="IUnattended::installTestExecService"/> is set to true. 3850 </desc> 3851 </attribute> 3852 3853 <attribute name="installTestExecService" type="boolean"> 3854 <desc> 3855 Indicates whether the test execution service (TXS) from the VBox 3856 ValidationKit should be installed. 3857 3858 The TXS binary will be taken from the ISO indicated by 3859 <link to="IUnattended::validationKitIsoPath"/>. 3828 3860 </desc> 3829 3861 </attribute> … … 3846 3878 Used only with Windows installation CD/DVD: 3847 3879 https://technet.microsoft.com/en-us/library/cc766022%28v=ws.10%29.aspx 3880 </desc> 3881 </attribute> 3882 3883 <attribute name="machine" type="IMachine" readonly="yes"> 3884 <desc> 3885 The associated machine object. 3886 </desc> 3887 </attribute> 3888 3889 <attribute name="scriptTemplatePath" type="wstring"> 3890 <desc> 3891 The unattended installation script template file. 3892 3893 The template default is based on the guest OS type and is determined by the 3894 internal installer when when <link to="IUnattended::prepare"/> is invoked. 3895 Most users will want the defaults. 3896 3897 After <link to="IUnattended::prepare"/> is called, it can be read to see 3898 which file is being used. 3848 3899 </desc> 3849 3900 </attribute> … … 5386 5437 </attribute> 5387 5438 5388 <attribute name="unattended" type="IUnattended" readonly="yes">5389 <desc>Associated unattended install class, always present.</desc>5390 </attribute>5391 5392 5439 <method name="lockMachine"> 5393 5440 <desc> … … 7968 8015 <param name="progress" type="IProgress" dir="return"> 7969 8016 <desc>Progress object to track the operation completion.</desc> 8017 </param> 8018 </method> 8019 8020 <method name="createUnattendedInstaller"> 8021 <desc> 8022 Creates a new <link to="IUnattended"/> guest installation object. 8023 </desc> 8024 <param name="unattended" type="IUnattended" dir="return"> 8025 <desc>New unattended object.</desc> 7970 8026 </param> 7971 8027 </method> -
trunk/src/VBox/Main/include/MachineImpl.h
r67738 r68024 776 776 const ComObjPtr<BIOSSettings> mBIOSSettings; 777 777 const ComObjPtr<BandwidthControl> mBandwidthControl; 778 #ifdef VBOX_WITH_UNATTENDED779 const ComObjPtr<Unattended> mUnattended;780 #endif781 778 782 779 typedef std::vector<ComObjPtr<NetworkAdapter> > NetworkAdapterVector; … … 984 981 HRESULT getVMProcessPriority(com::Utf8Str &aVMProcessPriority); 985 982 HRESULT setVMProcessPriority(const com::Utf8Str &aVMProcessPriority); 986 HRESULT getUnattended(ComPtr<IUnattended> &aUnattended);987 983 988 984 // wrapped IMachine methods … … 1202 1198 HRESULT restoreSnapshot(const ComPtr<ISnapshot> &aSnapshot, 1203 1199 ComPtr<IProgress> &aProgress); 1200 HRESULT createUnattendedInstaller(ComPtr<IUnattended> &aUnattended); 1204 1201 HRESULT applyDefaults(const com::Utf8Str &aFlags); 1205 1202 -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r67738 r68024 7184 7184 } 7185 7185 7186 HRESULT Machine::getUnattended(ComPtr<IUnattended> &aUnattended)7187 {7188 #ifdef VBOX_WITH_UNATTENDED7189 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);7190 if (mUnattended.isNotNull())7191 aUnattended = mUnattended;7192 else7193 {7194 /* Do on-demand creation. */7195 alock.release();7196 AutoWriteLock wlock(this COMMA_LOCKVAL_SRC_POS);7197 if (mUnattended.isNull())7198 {7199 unconst(mUnattended).createObject();7200 HRESULT hrc = mUnattended->init(this);7201 if (FAILED(hrc))7202 {7203 mUnattended->uninit();7204 unconst(mUnattended).setNull();7205 return hrc;7206 }7207 }7208 aUnattended = mUnattended;7209 }7210 return S_OK;7211 #else7212 NOREF(aUnattended);7213 return E_NOTIMPL;7214 #endif7215 }7216 7217 7186 HRESULT Machine::cloneTo(const ComPtr<IMachine> &aTarget, CloneMode_T aMode, const std::vector<CloneOptions_T> &aOptions, 7218 7187 ComPtr<IProgress> &aProgress) … … 8445 8414 mBandwidthControl->init(this); 8446 8415 8447 #ifdef VBOX_WITH_UNATTENDED8448 Assert(mUnattended.isNull()); /* Created on-demand. */8449 #endif8450 8451 8416 return S_OK; 8452 8417 } … … 8525 8490 unconst(mBIOSSettings).setNull(); 8526 8491 } 8527 8528 #ifdef VBOX_WITH_UNATTENDED8529 if (mUnattended)8530 {8531 mUnattended->uninit();8532 unconst(mUnattended).setNull();8533 }8534 #endif8535 8492 8536 8493 /* Deassociate media (only when a real Machine or a SnapshotMachine … … 15158 15115 } 15159 15116 15117 HRESULT Machine::createUnattendedInstaller(ComPtr<IUnattended> &aUnattended) 15118 { 15119 #ifdef VBOX_WITH_UNATTENDED 15120 ComObjPtr<Unattended> ptrUnattended; 15121 HRESULT hrc = ptrUnattended.createObject(); 15122 if (SUCCEEDED(hrc)) 15123 { 15124 AutoReadLock wlock(this COMMA_LOCKVAL_SRC_POS); 15125 hrc = ptrUnattended->init(this); 15126 if (SUCCEEDED(hrc)) 15127 hrc = ptrUnattended.queryInterfaceTo(aUnattended.asOutParam()); 15128 } 15129 return hrc; 15130 #else 15131 NOREF(aUnattended); 15132 return E_NOTIMPL; 15133 #endif 15134 } 15135 15160 15136 HRESULT Machine::applyDefaults(const com::Utf8Str &aFlags) 15161 15137 {
Note:
See TracChangeset
for help on using the changeset viewer.

