Changeset 14783 in vbox for trunk/src/VBox/Main
- Timestamp:
- Nov 28, 2008 2:55:59 PM (16 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/HardDisk2Impl.cpp
r14772 r14783 438 438 mm.vdIfCallsProgress.enmInterface = VDINTERFACETYPE_PROGRESS; 439 439 mm.vdIfCallsProgress.pfnProgress = vdProgressCall; 440 441 /* Initialize the callbacks of the VD config interface */ 442 mm.vdIfCallsConfig.cbSize = sizeof (VDINTERFACEPROGRESS); 443 mm.vdIfCallsConfig.enmInterface = VDINTERFACETYPE_CONFIG; 444 /// @todo later 445 // mm.vdIfCallsConfig.pfnAreValuesValid = ...; 446 // mm.vdIfCallsConfig.pfnQueryBytes = ...; 440 447 441 448 /* Initialize the per-disk interface chain */ … … 467 474 * storage unit. 468 475 * 476 * For hard disks that don't have the VD_CAP_CREATE_FIXED or 477 * VD_CAP_CREATE_DYNAMIC capability (and therefore cannot be created or deleted 478 * with the means of VirtualBox) the associated storage unit is assumed to be 479 * ready for use so the state of the hard disk object will be set to Created. 480 * 469 481 * @param aVirtualBox VirtualBox object. 470 482 * @param aLocaiton Storage unit location. … … 473 485 const BSTR aLocation) 474 486 { 475 AssertReturn (aVirtualBox != NULL, E_INVALIDARG); 476 AssertReturn (aLocation != NULL, E_INVALIDARG); 477 AssertReturn (aFormat != NULL && *aFormat != '\0', E_INVALIDARG); 487 AssertReturn (aVirtualBox != NULL, E_FAIL); 488 AssertReturn (aFormat != NULL && *aFormat != '\0', E_FAIL); 478 489 479 490 /* Enclose the state transition NotReady->InInit->Ready */ … … 498 509 CheckComRCReturnRC (rc); 499 510 500 rc = setLocation (aLocation); 501 CheckComRCReturnRC (rc); 511 if (mm.formatObj->capabilities() & HardDiskFormatCapabilities_File) 512 { 513 rc = setLocation (aLocation); 514 CheckComRCReturnRC (rc); 515 } 516 else 517 { 518 rc = setLocation (aLocation); 519 CheckComRCReturnRC (rc); 520 521 /// @todo later we may want to use a pfnComposeLocation backend info 522 /// callback to generate a well-formed location value (based on the hard 523 /// disk properties we have) rather than allowing each caller to invent 524 /// its own (pseudo-)location. 525 } 526 527 if (!(mm.formatObj->capabilities() & 528 (HardDiskFormatCapabilities_CreateFixed | 529 HardDiskFormatCapabilities_CreateDynamic))) 530 { 531 /* storage for hard disks of this format can neither be explicitly 532 * created by VirtualBox nor deleted, so we place the hard disk to 533 * Created state here and also add it to the registry */ 534 m.state = MediaState_Created; 535 unconst (m.id).create(); 536 rc = mVirtualBox->registerHardDisk2 (this); 537 538 /// @todo later we may want to use a pfnIsConfigSufficient backend info 539 /// callback that would tell us when we have enough properties to work 540 /// with the hard disk and this information could be used to actually 541 /// move such hard disks from NotCreated to Created state. Instead of 542 /// pfnIsConfigSufficient we can use HardDiskFormat property 543 /// descriptions to see which properties are mandatory 544 } 502 545 503 546 /* Confirm a successful initialization when it's the case */ … … 626 669 CheckComRCReturnRC (rc); 627 670 628 /* properties (note: after setting the format as it populates the map) */ 671 /* properties (after setting the format as it populates the map). Note that 672 * if some properties are not supported but preseint in the settings file, 673 * they will still be read and accessible (for possible backward 674 * compatibility; we can also clean them up from the XML upon next 675 * XML format versino change if we wish) */ 629 676 Key::List properties = aNode.keys ("Property"); 630 677 for (Key::List::const_iterator it = properties.begin(); … … 1024 1071 AutoWriteLock alock (this); 1025 1072 1073 if (!(mm.formatObj->capabilities() & 1074 HardDiskFormatCapabilities_CreateDynamic)) 1075 return setError (VBOX_E_NOT_SUPPORTED, 1076 tr ("Hard disk format '%ls' does not support dynamic storage " 1077 "creation"), mm.format.raw()); 1078 1026 1079 switch (m.state) 1027 1080 { … … 1031 1084 return setStateError(); 1032 1085 } 1033 1034 /// @todo NEWMEDIA use backend capabilities to decide if dynamic storage1035 /// is supported1036 1086 1037 1087 ComObjPtr <Progress> progress; … … 1076 1126 1077 1127 AutoWriteLock alock (this); 1128 1129 if (!(mm.formatObj->capabilities() & 1130 HardDiskFormatCapabilities_CreateFixed)) 1131 return setError (VBOX_E_NOT_SUPPORTED, 1132 tr ("Hard disk format '%ls' does not support fixed storage " 1133 "creation"), mm.format.raw()); 1078 1134 1079 1135 switch (m.state) … … 1469 1525 return name; 1470 1526 } 1471 1472 /// @todo NEWMEDIA remove, should not need anymore1473 #if 01474 1475 /**1476 * Returns @c true if the given location is a file in the host's filesystem.1477 *1478 * @param aLocation Location to check.1479 */1480 /*static*/1481 bool HardDisk2::isFileLocation (const char *aLocation)1482 {1483 /// @todo NEWMEDIA need some library that deals with URLs in a generic way1484 1485 if (aLocation == NULL)1486 return false;1487 1488 size_t len = strlen (aLocation);1489 1490 /* unix-like paths */1491 if (len >= 1 && RTPATH_IS_SLASH (aLocation [0]))1492 return true;1493 1494 /* dos-like paths */1495 if (len >= 2 && RTPATH_IS_VOLSEP (aLocation [1]) &&1496 ((aLocation [0] >= 'A' && aLocation [0] <= 'Z') ||1497 (aLocation [0] >= 'a' && aLocation [0] <= 'z')))1498 return true;1499 1500 /* if there is a '<protocol>:' suffux which is not 'file:', return false */1501 const char *s = strchr (aLocation, ':');1502 if (s != NULL)1503 {1504 if (s - aLocation != 4)1505 return false;1506 if ((aLocation [0] != 'f' && aLocation [0] == 'F') ||1507 (aLocation [1] != 'i' && aLocation [1] == 'I') ||1508 (aLocation [2] != 'l' && aLocation [2] == 'L') ||1509 (aLocation [3] != 'e' && aLocation [3] == 'E'))1510 return false;1511 }1512 1513 /* everything else is treaten as file */1514 return true;1515 }1516 1517 #endif /* if 0 */1518 1527 1519 1528 /** … … 1835 1844 1836 1845 AutoWriteLock alock (this); 1846 1847 if (!(mm.formatObj->capabilities() & 1848 (HardDiskFormatCapabilities_CreateDynamic | 1849 HardDiskFormatCapabilities_CreateFixed))) 1850 return setError (VBOX_E_NOT_SUPPORTED, 1851 tr ("Hard disk format '%ls' does not support storage deletion "), 1852 mm.format.raw()); 1837 1853 1838 1854 switch (m.state) … … 2353 2369 HRESULT HardDisk2::setLocation (const BSTR aLocation) 2354 2370 { 2355 if (aLocation == NULL) 2356 return E_INVALIDARG; 2371 /// @todo so far, we assert but later it makes sense to support null 2372 /// locations for hard disks that are not yet created fail to create a 2373 /// storage unit instead 2374 CheckComArgStrNotEmptyOrNull (aLocation); 2357 2375 2358 2376 AutoCaller autoCaller (this); … … 2504 2522 = mVirtualBox->systemProperties()->hardDiskFormat (aFormat); 2505 2523 if (mm.formatObj.isNull()) 2506 return setError ( E_FAIL,2524 return setError (VBOX_E_OBJECT_NOT_FOUND, 2507 2525 tr ("Invalid hard disk storage format '%ls'"), aFormat); 2508 2526 -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r14772 r14783 1087 1087 IHardDisk2 **aHardDisk) 1088 1088 { 1089 if (!aFormat) 1090 return E_INVALIDARG; 1091 if (!aLocation) 1092 return E_INVALIDARG; 1093 if (!aHardDisk) 1094 return E_POINTER; 1089 CheckComArgStrNotEmptyOrNull (aFormat); 1090 CheckComArgOutPointerValid (aHardDisk); 1095 1091 1096 1092 AutoCaller autoCaller (this); -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r14778 r14783 316 316 </result> 317 317 318 <result name="VBOX_E_NOT_SUPPORTED" value="0x80BB0009"> 319 <desc> 320 Requested operation is not supported. 321 </desc> 322 </result> 323 318 324 <!-- 319 325 Note that src/VBox/Runtime/common/err/errmsgvboxcom.xsl will ignore … … 1602 1608 See <link to="IMedium::location"/>, IHardDisk2 and 1603 1609 <link to="ISystemProperties::defaultHardDiskFolder"/> for more details. 1610 1611 <result name="VBOX_E_OBJECT_NOT_FOUND"> 1612 @a format identifier is invalid. See 1613 <link to="ISystemProperties::hardDiskFormats"/>. 1614 </result> 1615 <result name="VBOX_E_FILE_ERROR"> 1616 @a location is a not valid file name (for file-based formats only). 1617 </result> 1618 <result name="E_INVALIDARG"> 1619 @a format is a null or empty string. 1620 </result> 1604 1621 </desc> 1605 1622 <param name="format" type="wstring" dir="in"> … … 7389 7406 to="MediaState::Created"/>, the hard disk will be remembered by this 7390 7407 VirtualBox installation and may be attached to virtual machines. 7408 7409 <result name="VBOX_E_NOT_SUPPORTED"> 7410 Dynamic storage creation operation is not supported. See <link 7411 to="IHardDiskFormat::capabilities"/>. 7412 </result> 7391 7413 </desc> 7392 7414 <param name="logicalSize" type="unsigned long long" dir="in"> … … 7414 7436 to="MediaState::Created"/>, the hard disk will be remembered by this 7415 7437 VirtualBox installation and may be attached to virtual machines. 7438 7439 <result name="VBOX_E_NOT_SUPPORTED"> 7440 Fixed storage creation operation is not supported. See 7441 <link to="IHardDiskFormat::capabilities"/>. 7442 </result> 7416 7443 </desc> 7417 7444 <param name="logicalSize" type="unsigned long long" dir="in"> … … 7449 7476 <result name="VBOX_E_OBJECT_IN_USE"> 7450 7477 Hard disk is attached to a virtual machine. 7478 </result> 7479 <result name="VBOX_E_NOT_SUPPORTED"> 7480 Storage deletion is not allowed because neither of storage creation 7481 operations are supported. See 7482 <link to="IHardDiskFormat::capabilities"/>. 7451 7483 </result> 7452 7484 </desc> -
trunk/src/VBox/Main/include/HardDisk2Impl.h
r14628 r14783 285 285 VDINTERFACEPROGRESS vdIfCallsProgress; 286 286 287 VDINTERFACE vdIfConfig; 288 VDINTERFACECONFIG vdIfCallsConfig; 289 287 290 PVDINTERFACE vdDiskIfaces; 288 291 }; -
trunk/src/VBox/Main/testcase/tstAPI.cpp
r14698 r14783 641 641 printf (" <none>\n"); 642 642 643 #if 0 643 644 Bstr name ("TargetAddress"); 644 645 Bstr value = Utf8StrFmt ("lalala (%llu)", RTTimeMilliTS()); … … 646 647 printf ("Settings property %ls to %ls...\n", name.raw(), value.raw()); 647 648 CHECK_ERROR (hd, SetProperty (name, value)); 649 #endif 648 650 } 649 651 else
Note:
See TracChangeset
for help on using the changeset viewer.