Changeset 14666 in vbox for trunk/src/VBox/Main
- Timestamp:
- Nov 26, 2008 11:03:23 PM (16 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/MachineImpl.cpp
r14664 r14666 419 419 int vrc = mParent->calculateFullPath (Utf8Str (aConfigFile), configFileFull); 420 420 if (RT_FAILURE (vrc)) 421 return setError ( E_FAIL,421 return setError (VBOX_E_FILE_ERROR, 422 422 tr ("Invalid machine settings file name '%ls' (%Rrc)"), 423 423 aConfigFile, vrc); … … 448 448 if (RT_SUCCESS (vrc) || vrc == VERR_SHARING_VIOLATION) 449 449 { 450 rc = setError ( E_FAIL,450 rc = setError (VBOX_E_FILE_ERROR, 451 451 tr ("Machine settings file '%s' already exists"), 452 452 configFileFull.raw()); … … 457 457 { 458 458 if (vrc != VERR_FILE_NOT_FOUND && vrc != VERR_PATH_NOT_FOUND) 459 rc = setError ( E_FAIL,459 rc = setError (VBOX_E_FILE_ERROR, 460 460 tr ("Invalid machine settings file name '%ls' (%Rrc)"), 461 461 mData->mConfigFileFull.raw(), vrc); … … 497 497 if (aOsType) 498 498 { 499 /* Store ostype */499 /* Store OS type */ 500 500 mUserData->mOSTypeId = aOsType->id(); 501 501 502 /* Apply other machine defaults */ 503 mHWData->mHWVirtExEnabled = aOsType->recommendedVirtEx() ? TSBool_True : TSBool_False; 502 /* Apply machine defaults */ 503 mHWData->mHWVirtExEnabled = aOsType->recommendedVirtEx() ? 504 TSBool_True : TSBool_False; 504 505 505 506 /* Apply BIOS defaults */ 506 507 mBIOSSettings->applyDefaults (aOsType); 507 508 508 509 /* Apply network adapters defaults */ 509 510 for (ULONG slot = 0; slot < RT_ELEMENTS (mNetworkAdapters); ++ slot) -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r14664 r14666 761 761 { 762 762 LogFlowThisFuncEnter(); 763 LogFlowThisFunc (("aBaseFolder='%ls', aName='%ls' aMachine={%p}\n", 764 aBaseFolder, aName, aMachine)); 765 766 if (!aName) 767 return E_INVALIDARG; 768 if (!aMachine) 769 return E_POINTER; 770 771 if (!*aName) 772 return setError (E_INVALIDARG, 773 tr ("Machine name cannot be empty")); 763 764 CheckComArgStrNotEmptyOrNull (aName); 765 CheckComArgOutPointerValid (aMachine); 774 766 775 767 AutoCaller autoCaller (this); … … 799 791 ComObjPtr <Machine> machine; 800 792 rc = machine.createObject(); 801 if (SUCCEEDED (rc)) 802 { 803 /* Create UUID if an empty one was specified. */ 804 Guid id = aId; 805 if (id.isEmpty()) 806 id.create(); 807 808 /* Look for related GuestOsType */ 809 AssertMsg (mData.mGuestOSTypes.size(), ("Guest OS types array must be filled")); 810 GuestOSTypeList::iterator it = mData.mGuestOSTypes.begin(); 811 GuestOSType *osType = *it; 812 while (aOsTypeId && it != mData.mGuestOSTypes.end()) 793 CheckComRCReturnRC (rc); 794 795 /* Create UUID if an empty one was specified. */ 796 Guid id = aId; 797 if (id.isEmpty()) 798 id.create(); 799 800 /* Look for a GuestOSType object */ 801 AssertMsg (mData.mGuestOSTypes.size() != 0, 802 ("Guest OS types array must be filled")); 803 804 GuestOSType *osType = NULL; 805 if (aOsTypeId != NULL) 806 { 807 for (GuestOSTypeList::const_iterator it = mData.mGuestOSTypes.begin(); 808 it != mData.mGuestOSTypes.end(); ++ it) 813 809 { 814 810 if ((*it)->id() == aOsTypeId) … … 817 813 break; 818 814 } 819 ++ it; 820 } 821 822 /* initialize the machine object */ 823 rc = machine->init (this, settingsFile, Machine::Init_New, aName, osType, TRUE, &id); 824 if (SUCCEEDED (rc)) 825 { 826 /* set the return value */ 827 rc = machine.queryInterfaceTo (aMachine); 828 ComAssertComRC (rc); 829 } 830 } 831 832 LogFlowThisFunc (("rc=%08X\n", rc)); 815 } 816 817 if (osType == NULL) 818 return setError (VBOX_E_OBJECT_NOT_FOUND, 819 tr ("Guest OS type '%ls' is invalid"), aOsTypeId); 820 } 821 822 /* initialize the machine object */ 823 rc = machine->init (this, settingsFile, Machine::Init_New, aName, osType, 824 TRUE /* aNameSync */, &id); 825 if (SUCCEEDED (rc)) 826 { 827 /* set the return value */ 828 rc = machine.queryInterfaceTo (aMachine); 829 AssertComRC (rc); 830 } 831 833 832 LogFlowThisFuncLeave(); 834 833 … … 842 841 IMachine **aMachine) 843 842 { 844 /* null and empty strings are not allowed as path names */ 845 if (!aSettingsFile || !(*aSettingsFile)) 846 return E_INVALIDARG; 847 848 if (!aName) 849 return E_INVALIDARG; 850 if (!aMachine) 851 return E_POINTER; 852 853 if (!*aName) 854 return setError (E_INVALIDARG, 855 tr ("Machine name cannot be empty")); 843 CheckComArgStrNotEmptyOrNull (aName); 844 CheckComArgStrNotEmptyOrNull (aSettingsFile); 845 CheckComArgOutPointerValid (aMachine); 856 846 857 847 AutoCaller autoCaller (this); … … 868 858 ComObjPtr<Machine> machine; 869 859 rc = machine.createObject(); 870 if (SUCCEEDED (rc)) 871 { 872 /* Create UUID if an empty one was specified. */ 873 Guid id = aId; 874 if (id.isEmpty()) 875 id.create(); 876 877 /* Look for related GuestOsType */ 878 AssertMsg (mData.mGuestOSTypes.size(), ("Guest OS types array must be filled")); 879 GuestOSTypeList::iterator it = mData.mGuestOSTypes.begin(); 880 GuestOSType *osType = *it; 881 while (aOsTypeId && it != mData.mGuestOSTypes.end()) 860 CheckComRCReturnRC (rc); 861 862 /* Create UUID if an empty one was specified. */ 863 Guid id = aId; 864 if (id.isEmpty()) 865 id.create(); 866 867 /* Look for a GuestOSType object */ 868 AssertMsg (mData.mGuestOSTypes.size() != 0, 869 ("Guest OS types array must be filled")); 870 871 GuestOSType *osType = NULL; 872 if (aOsTypeId != NULL) 873 { 874 for (GuestOSTypeList::const_iterator it = mData.mGuestOSTypes.begin(); 875 it != mData.mGuestOSTypes.end(); ++ it) 882 876 { 883 877 if ((*it)->id() == aOsTypeId) … … 886 880 break; 887 881 } 888 ++ it; 889 } 890 891 /* initialize the machine object */ 892 rc = machine->init (this, Bstr (settingsFile), Machine::Init_New, 893 aName, osType, FALSE /* aNameSync */, &id); 894 if (SUCCEEDED (rc)) 895 { 896 /* set the return value */ 897 rc = machine.queryInterfaceTo (aMachine); 898 ComAssertComRC (rc); 899 } 900 } 882 } 883 884 if (osType == NULL) 885 return setError (VBOX_E_OBJECT_NOT_FOUND, 886 tr ("Guest OS type '%ls' is invalid"), aOsTypeId); 887 } 888 889 /* initialize the machine object */ 890 rc = machine->init (this, Bstr (settingsFile), Machine::Init_New, 891 aName, osType, FALSE /* aNameSync */, &id); 892 if (SUCCEEDED (rc)) 893 { 894 /* set the return value */ 895 rc = machine.queryInterfaceTo (aMachine); 896 AssertComRC (rc); 897 } 898 901 899 return rc; 902 900 } -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r14664 r14666 1109 1109 <interface 1110 1110 name="IVirtualBox" extends="$dispatched" 1111 uuid=" 2aa11223-ba64-4610-84b8-066d2a89384f"1111 uuid="339abca2-f47a-4302-87f5-7bc324e6bbde" 1112 1112 wsmap="managed" 1113 1113 > … … 1297 1297 Creates a new virtual machine. 1298 1298 1299 The new machine will have "empty" default settings and will not1300 yet be registered. The typical sequence to create a virtual machine1301 is therefore something like this:1299 The new machine is created unregistered, with the initial configuration 1300 set according to the specified guest OS type. A typical sequence of 1301 actions to create a new virtual machine is as follows: 1302 1302 1303 1303 <ol> 1304 <li>Call this method (IVirtualBox::createMachine) to have a new 1305 machine created. The machine object returned is "mutable", i.e. 1306 automatically locked for the current session, as if 1307 <link to="#openSession" /> had been called on it.</li> 1308 1309 <li>Assign meaningful settings to the new machine by calling the 1310 respective methods.</li> 1311 1312 <li>Call <link to="IMachine::saveSettings" /> to have the settings written 1313 to the machine's XML settings file. The configuration of the newly 1314 created machine will not be saved to disk (and the settings subfolder 1315 and file, as described below, will not be created) until this method 1316 is called.</li> 1317 1318 <li>Call <link to="#registerMachine" /> to have the 1319 machine show up in the list of machines registered with VirtualBox.</li> 1304 <li> 1305 Call this method to have a new machine created. The returned machine 1306 object will be "mutable" allowing to change any machine property. 1307 </li> 1308 1309 <li> 1310 Configure the machine using the appropriate attributes and methods. 1311 </li> 1312 1313 <li> 1314 Call <link to="IMachine::saveSettings" /> to write the settings 1315 to the machine's XML settings file. The configuration of the newly 1316 created machine will not be saved to disk (and the settings subfolder 1317 and file, as described below, will not be created) until this method 1318 is called. 1319 </li> 1320 1321 <li> 1322 Call <link to="#registerMachine" /> to have the machine show up in 1323 the list of machines registered with VirtualBox. 1324 </li> 1320 1325 </ol> 1326 1327 You should specify valid name for the newly created machine when calling 1328 this method. See the <link to="IMachine::name"/> attribute description 1329 for more details about the machine name. 1330 1331 The specified guest OS type identifier must match an ID of one of known 1332 guest OS types listed in the <link to="IVirtualBox::guestOSTypes"/> 1333 array. 1321 1334 1322 1335 Every machine has a <i>settings file</i> that is used to store … … 1327 1340 where to create the machine settings subfolder using the @a 1328 1341 baseFolder argument. The base folder can be absolute (full path) 1329 or relative to the <link to="IVirtualBox::homeFolder"> 1330 VirtualBox home directory</link>. 1331 1332 If a null or empty string is given as the base folder (which is 1333 recommended), the <link to="ISystemProperties::defaultMachineFolder"> 1334 default machine settings folder</link> will be used as the base 1335 folder to create the machine settings subfolder and file. In 1336 any case, the full path to the settings file will look like: 1342 or relative to the <link to="IVirtualBox::homeFolder">VirtualBox home 1343 directory</link>. 1344 1345 If @a baseFolder is a null or empty string (which is recommended), the 1346 <link to="ISystemProperties::defaultMachineFolder">default machine 1347 settings folder</link> will be used as a base folder to create the 1348 machine settings subfolder and file, otherwise the given folder will be 1349 used. The full path to the resulting settings file will have the 1350 following structure: 1337 1351 <pre> 1338 1352 <base_folder>/<machine_name>/<machine_name>.xml 1339 1353 </pre> 1340 1354 1341 Optionally the UUID of the machine can be predefined. If this is 1342 not desired (i.e. a new UUID should be generated), pass just an 1343 empty or null UUID. 1344 1345 You should also specify a valid name for the machine. 1346 See the <link to="IMachine::name"/> property 1347 description for more details about the machine name. 1348 1349 The created machine remains 1350 unregistered until you call <link to="#registerMachine()"/>. 1355 Note that if the resulting settings file already exists, this method 1356 will fail. 1357 1358 Optionally, you may specify an UUID of to assign to the created machine. 1359 However, this is not recommended and you should normally pass an empty 1360 (null) UUID to this method so that a new UUID will be automatically 1361 generated. 1351 1362 1352 1363 <note> … … 1354 1365 subfolder of the created machine directly. 1355 1366 </note> 1356 </desc> 1367 1368 <result name="VBOX_E_OBJECT_NOT_FOUND"> 1369 @a osTypeId is invalid. 1370 </result> 1371 <result name="VBOX_E_FILE_ERROR"> 1372 Resulting settings file name is invalid or the settings file already 1373 exists or could not be created due to an I/O error. 1374 </result> 1375 <result name="E_INVALIDARG"> 1376 @a name is empty or null. 1377 </result> 1378 </desc> 1379 1357 1380 <param name="name" type="wstring" dir="in"> 1358 1381 <desc>Machine name.</desc> 1359 1382 </param> 1360 1383 <param name="osTypeId" type="wstring" dir="in"> 1361 <desc> MachineOS Type ID.</desc>1384 <desc>Guest OS Type ID.</desc> 1362 1385 </param> 1363 1386 <param name="baseFolder" type="wstring" dir="in"> 1364 <desc> 1365 Name of the folder where to create the machine settings 1366 subfolder containing the settings file. 1367 </desc> 1387 <desc>Base machine folder (optional).</desc> 1368 1388 </param> 1369 1389 <param name="id" type="uuid" dir="in"> 1370 <desc> 1371 UUID of the newly created VM, when non-null or non-empty. 1372 Otherwise a UUID is automatically generated. 1373 </desc> 1390 <desc>Machine UUID (optional).</desc> 1374 1391 </param> 1375 1392 <param name="machine" type="IMachine" dir="return"> … … 1380 1397 <method name="createLegacyMachine"> 1381 1398 <desc> 1382 Creates a new virtual machine in "legacy" mode, using the 1383 s pecified settings file to store machine settings.1399 Creates a new virtual machine in "legacy" mode, using the specified 1400 settings file to store machine settings. 1384 1401 1385 1402 As opposed to machines created by <link to="#createMachine()"/>, 1386 the settings file of the machine created in "legacy" mode 1387 is not automatically renamed when the machine name is 1388 changed -- it will always remain the same as specified in this 1389 method call. 1390 1391 The specified settings file name can be absolute 1392 (full path) or relative to the <link to="IVirtualBox::homeFolder"> 1393 VirtualBox home directory</link>. If the file name doesn't 1394 contain an extension, the default extension (.xml) will be 1395 appended. 1396 1397 Optionally the UUID of the machine can be predefined. If this is 1398 not desired (i.e. a new UUID should be generated), pass just an 1399 empty or null UUID. 1403 the settings file of the machine created in "legacy" mode is not 1404 automatically renamed when the machine name is changed -- it will always 1405 remain the same as specified in this method call. 1406 1407 The specified settings file name can be absolute (full path) or relative 1408 to the <link to="IVirtualBox::homeFolder">VirtualBox home 1409 directory</link>. If the file name doesn't contain an extension, the 1410 default extension (.xml) will be appended. 1400 1411 1401 1412 Note that the configuration of the newly created machine is not … … 1405 1416 <link to="IMachine::saveSettings()"/> will return an error. 1406 1417 1407 You should also specify a valid name for the machine. 1408 See the <link to="IMachine::name"/> property 1409 description for more details about the machine name. 1410 1411 The created machine remains 1412 unregistered until you call <link to="#registerMachine()"/>. 1413 1414 @deprecated This method may be removed later. It is better 1415 to use <link to="IVirtualBox::createMachine()"/>. 1418 See <link to="#createMachine()"/> for more information. 1419 1420 @deprecated This method may be removed later. Use <link 1421 to="IVirtualBox::createMachine()"/> instead. 1416 1422 1417 1423 <note> 1418 1424 There is no way to change the name of the settings file 1419 of the created machine. 1420 </note> 1421 </desc> 1422 <param name="settingsFile" type="wstring" dir="in"> 1423 <desc> 1424 Name of the file where to store machine settings. 1425 </desc> 1426 </param> 1425 of the machine created in "legacy" mode. 1426 </note> 1427 1428 <result name="VBOX_E_OBJECT_NOT_FOUND"> 1429 @a osTypeId is invalid. 1430 </result> 1431 <result name="VBOX_E_FILE_ERROR"> 1432 @a settingsFile is invalid or the settings file already exists or 1433 could not be created due to an I/O error. 1434 </result> 1435 <result name="E_INVALIDARG"> 1436 @a name or @a settingsFile is empty or null. 1437 </result> 1438 </desc> 1439 1427 1440 <param name="name" type="wstring" dir="in"> 1428 1441 <desc>Machine name.</desc> … … 1431 1444 <desc>Machine OS Type ID.</desc> 1432 1445 </param> 1446 <param name="settingsFile" type="wstring" dir="in"> 1447 <desc>Name of the machine settings file.</desc> 1448 </param> 1433 1449 <param name="id" type="uuid" dir="in"> 1434 <desc> 1435 UUID of the newly created VM, when non-null or non-empty. 1436 Otherwise a UUID is automatically generated. 1437 </desc> 1450 <desc>Machine UUID (optional).</desc> 1438 1451 </param> 1439 1452 <param name="machine" type="IMachine" dir="return"> … … 5724 5737 5725 5738 <interface 5726 5727 uuid="da94f478-1f37-4726-b750-2235950dc2fe"5728 5729 5739 name="IGuestOSType" extends="$unknown" 5740 uuid="bc415228-eed0-402c-92f5-96fc4e2dd7e4" 5741 wsmap="struct" 5742 > 5730 5743 <desc> 5731 5744 </desc>
Note:
See TracChangeset
for help on using the changeset viewer.