Changeset 31568 in vbox for trunk/src/VBox/Main
- Timestamp:
- Aug 11, 2010 1:35:59 PM (14 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ApplianceImplImport.cpp
r31539 r31568 1342 1342 1343 1343 // First open the existing disk image 1344 rc = mVirtualBox->OpenHardDisk(Bstr(strSrcFilePath), 1345 AccessMode_ReadOnly, 1346 false, 1347 NULL, 1348 false, 1349 NULL, 1350 pSourceHD.asOutParam()); 1344 rc = mVirtualBox->OpenMedium(Bstr(strSrcFilePath), 1345 DeviceType_HardDisk, 1346 AccessMode_ReadOnly, 1347 pSourceHD.asOutParam()); 1351 1348 if (FAILED(rc)) DebugBreakThrow(rc); 1352 1349 fSourceHdNeedsClosing = true; -
trunk/src/VBox/Main/MediumImpl.cpp
r31562 r31568 97 97 hddOpenMode(OpenReadWrite), 98 98 autoReset(false), 99 setImageId(false),100 setParentId(false),101 99 hostDrive(false), 102 100 implicit(false), … … 143 141 144 142 /** the following members are invalid after changing UUID on open */ 145 bool setImageId : 1; 146 bool setParentId : 1; 147 const Guid imageId; 148 const Guid parentId; 143 const Guid uuidImage; 144 const Guid uuidParentImage; 149 145 150 146 bool hostDrive : 1; … … 824 820 * @param enOpenMode Whether to open the medium read/write or read-only. 825 821 * @param aDeviceType Device type of medium. 826 * @param aSetImageId Whether to set the medium UUID or not.827 * @param aImageId New medium UUID if @aSetId is true. Empty string means828 * create a new UUID, and a zero UUID is invalid.829 * @param aSetParentId Whether to set the parent UUID or not.830 * @param aParentId New parent UUID if @aSetParentId is true. Empty string831 * means create a new UUID, and a zero UUID is valid.832 822 */ 833 823 HRESULT Medium::init(VirtualBox *aVirtualBox, 834 824 const Utf8Str &aLocation, 835 825 HDDOpenMode enOpenMode, 836 DeviceType_T aDeviceType, 837 BOOL aSetImageId, 838 const Guid &aImageId, 839 BOOL aSetParentId, 840 const Guid &aParentId) 826 DeviceType_T aDeviceType) 841 827 { 842 828 AssertReturn(aVirtualBox, E_INVALIDARG); … … 870 856 if (FAILED(rc)) return rc; 871 857 872 /* save the new uuid values, will be used by queryInfo() */873 m->setImageId = !!aSetImageId;874 unconst(m->imageId) = aImageId;875 m->setParentId = !!aSetParentId;876 unconst(m->parentId) = aParentId;877 878 858 /* get all the information about the medium from the storage unit */ 879 rc = queryInfo( );859 rc = queryInfo(false /* fSetImageId */, false /* fSetParentId */); 880 860 881 861 if (SUCCEEDED(rc)) … … 1655 1635 } 1656 1636 1637 STDMETHODIMP Medium::SetIDs(BOOL aSetImageId, 1638 IN_BSTR aImageId, 1639 BOOL aSetParentId, 1640 IN_BSTR aParentId) 1641 { 1642 AutoCaller autoCaller(this); 1643 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1644 1645 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1646 1647 Guid imageId, parentId; 1648 if (aSetImageId) 1649 { 1650 imageId = Guid(aImageId); 1651 if (imageId.isEmpty()) 1652 return setError(E_INVALIDARG, tr("Argument %s is empty"), "aImageId"); 1653 } 1654 if (aSetParentId) 1655 parentId = Guid(aParentId); 1656 1657 unconst(m->uuidImage) = imageId; 1658 unconst(m->uuidParentImage) = parentId; 1659 1660 HRESULT rc = queryInfo(!!aSetImageId /* fSetImageId */, 1661 !!aSetParentId /* fSetParentId */); 1662 1663 return rc; 1664 } 1665 1657 1666 STDMETHODIMP Medium::RefreshState(MediumState_T *aState) 1658 1667 { … … 1673 1682 case MediumState_LockedRead: 1674 1683 { 1675 rc = queryInfo( );1684 rc = queryInfo(false /* fSetImageId */, false /* fSetParentId */); 1676 1685 break; 1677 1686 } … … 3437 3446 * for the first time). Locks mParent for reading. Locks this object for 3438 3447 * writing. 3439 */ 3440 HRESULT Medium::queryInfo() 3448 * 3449 * @param fSetImageId Whether to reset the UUID contained in the image file to the UUID in the medium instance data (see SetIDs()) 3450 * @param fSetParentId Whether to reset the parent UUID contained in the image file to the parent UUID in the medium instance data (see SetIDs()) 3451 * @return 3452 */ 3453 HRESULT Medium::queryInfo(bool fSetImageId, bool fSetParentId) 3441 3454 { 3442 3455 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 3550 3563 /* Modify the UUIDs if necessary. The associated fields are 3551 3564 * not modified by other code, so no need to copy. */ 3552 if ( m->setImageId)3565 if (fSetImageId) 3553 3566 { 3554 vrc = VDSetUuid(hdd, 0, m-> imageId);3567 vrc = VDSetUuid(hdd, 0, m->uuidImage); 3555 3568 ComAssertRCThrow(vrc, E_FAIL); 3556 3569 } 3557 if ( m->setParentId)3570 if (fSetParentId) 3558 3571 { 3559 vrc = VDSetParentUuid(hdd, 0, m-> parentId);3572 vrc = VDSetParentUuid(hdd, 0, m->uuidParentImage); 3560 3573 ComAssertRCThrow(vrc, E_FAIL); 3561 3574 } 3562 3575 /* zap the information, these are no long-term members */ 3563 m->setImageId = false; 3564 unconst(m->imageId).clear(); 3565 m->setParentId = false; 3566 unconst(m->parentId).clear(); 3576 unconst(m->uuidImage).clear(); 3577 unconst(m->uuidParentImage).clear(); 3567 3578 3568 3579 /* check the UUID */ … … 3603 3614 if (isImport) 3604 3615 { 3605 if ( m->setImageId)3606 mediumId = m-> imageId;3616 if (fSetImageId) 3617 mediumId = m->uuidImage; 3607 3618 else 3608 3619 mediumId.create(); -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r31562 r31568 1404 1404 } 1405 1405 1406 STDMETHODIMP VirtualBox::OpenHardDisk(IN_BSTR aLocation, 1407 AccessMode_T accessMode, 1408 BOOL aSetImageId, 1409 IN_BSTR aImageId, 1410 BOOL aSetParentId, 1411 IN_BSTR aParentId, 1412 IMedium **aHardDisk) 1406 STDMETHODIMP VirtualBox::OpenMedium(IN_BSTR aLocation, 1407 DeviceType_T deviceType, 1408 AccessMode_T accessMode, 1409 IMedium **aMedium) 1413 1410 { 1414 1411 CheckComArgStrNotEmptyOrNull(aLocation); 1415 CheckComArgOutSafeArrayPointerValid(a HardDisk);1412 CheckComArgOutSafeArrayPointerValid(aMedium); 1416 1413 1417 1414 AutoCaller autoCaller(this); … … 1419 1416 1420 1417 /* we don't access non-const data members so no need to lock */ 1421 1422 1418 HRESULT rc = E_FAIL; 1423 1419 1424 ComObjPtr<Medium> hardDisk; 1425 hardDisk.createObject(); 1426 Guid imageId, parentId; 1427 if (aSetImageId) 1428 { 1429 imageId = Guid(aImageId); 1430 if (imageId.isEmpty()) 1431 return setError(E_INVALIDARG, tr("Argument %s is empty"), "aImageId"); 1432 } 1433 if (aSetParentId) 1434 parentId = Guid(aParentId); 1435 rc = hardDisk->init(this, 1436 aLocation, 1437 (accessMode == AccessMode_ReadWrite) ? Medium::OpenReadWrite : Medium::OpenReadOnly, 1438 DeviceType_HardDisk, 1439 aSetImageId, 1440 imageId, 1441 aSetParentId, 1442 parentId); 1420 switch (deviceType) 1421 { 1422 case DeviceType_HardDisk: 1423 case DeviceType_Floppy: 1424 break; 1425 1426 case DeviceType_DVD: 1427 accessMode = AccessMode_ReadOnly; 1428 break; 1429 1430 default: 1431 return setError(E_INVALIDARG, "Device type must be HardDisk, DVD or Floppy"); 1432 } 1433 1434 ComObjPtr<Medium> pMedium; 1435 pMedium.createObject(); 1436 rc = pMedium->init(this, 1437 aLocation, 1438 (accessMode == AccessMode_ReadWrite) ? Medium::OpenReadWrite : Medium::OpenReadOnly, 1439 deviceType); 1443 1440 1444 1441 if (SUCCEEDED(rc)) 1445 1442 { 1446 bool fNeedsSaveSettings = false; 1447 { 1448 AutoWriteLock treeLock(getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 1449 rc = registerHardDisk(hardDisk, &fNeedsSaveSettings); 1450 } 1443 bool fNeedsGlobalSaveSettings = false; 1444 1445 AutoWriteLock treeLock(getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 1446 1447 switch (deviceType) 1448 { 1449 case DeviceType_HardDisk: 1450 rc = registerHardDisk(pMedium, &fNeedsGlobalSaveSettings); 1451 break; 1452 1453 case DeviceType_DVD: 1454 case DeviceType_Floppy: 1455 rc = registerImage(pMedium, deviceType, &fNeedsGlobalSaveSettings); 1456 break; 1457 } 1458 1459 treeLock.release(); 1451 1460 1452 1461 /* Note that it's important to call uninit() on failure to register … … 1455 1464 1456 1465 if (SUCCEEDED(rc)) 1457 hardDisk.queryInterfaceTo(aHardDisk);1466 pMedium.queryInterfaceTo(aMedium); 1458 1467 else 1459 hardDisk->uninit();1460 1461 if (fNeeds SaveSettings)1468 pMedium->uninit(); 1469 1470 if (fNeedsGlobalSaveSettings) 1462 1471 { 1463 1472 AutoWriteLock vboxlock(this COMMA_LOCKVAL_SRC_POS); … … 1508 1517 /* the below will set *aHardDisk to NULL if hardDisk is null */ 1509 1518 pMedium.queryInterfaceTo(aMedium); 1510 1511 return rc;1512 }1513 1514 /** @note Doesn't lock anything. */1515 STDMETHODIMP VirtualBox::OpenDVDImage(IN_BSTR aLocation,1516 IN_BSTR aId,1517 IMedium **aDVDImage)1518 {1519 CheckComArgStrNotEmptyOrNull(aLocation);1520 CheckComArgOutSafeArrayPointerValid(aDVDImage);1521 1522 AutoCaller autoCaller(this);1523 if (FAILED(autoCaller.rc())) return autoCaller.rc();1524 1525 HRESULT rc = VBOX_E_FILE_ERROR;1526 1527 Guid id(aId);1528 /* generate an UUID if not specified */1529 if (id.isEmpty())1530 id.create();1531 1532 ComObjPtr<Medium> image;1533 image.createObject();1534 rc = image->init(this,1535 aLocation,1536 Medium::OpenReadOnly,1537 DeviceType_DVD,1538 true /* aSetImageId */,1539 id,1540 false /* aSetParentId */,1541 Guid());1542 if (SUCCEEDED(rc))1543 {1544 AutoWriteLock treeLock(getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);1545 bool fNeedsSaveSettings = false;1546 rc = registerImage(image, DeviceType_DVD, &fNeedsSaveSettings);1547 treeLock.release();1548 1549 if (SUCCEEDED(rc))1550 image.queryInterfaceTo(aDVDImage);1551 1552 if (fNeedsSaveSettings)1553 {1554 AutoWriteLock vboxlock(this COMMA_LOCKVAL_SRC_POS);1555 saveSettings();1556 }1557 }1558 1559 return rc;1560 }1561 1562 /** @note Doesn't lock anything. */1563 STDMETHODIMP VirtualBox::OpenFloppyImage(IN_BSTR aLocation,1564 IN_BSTR aId,1565 IMedium **aFloppyImage)1566 {1567 CheckComArgStrNotEmptyOrNull(aLocation);1568 CheckComArgOutSafeArrayPointerValid(aFloppyImage);1569 1570 AutoCaller autoCaller(this);1571 if (FAILED(autoCaller.rc())) return autoCaller.rc();1572 1573 HRESULT rc = VBOX_E_FILE_ERROR;1574 1575 Guid id(aId);1576 /* generate an UUID if not specified */1577 if (id.isEmpty())1578 id.create();1579 1580 ComObjPtr<Medium> image;1581 image.createObject();1582 rc = image->init(this,1583 aLocation,1584 Medium::OpenReadWrite,1585 DeviceType_Floppy,1586 true /* aSetImageId */,1587 id,1588 false /* aSetParentId */,1589 Guid());1590 if (SUCCEEDED(rc))1591 {1592 AutoWriteLock treeLock(getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);1593 bool fNeedsSaveSettings = false;1594 rc = registerImage(image, DeviceType_Floppy, &fNeedsSaveSettings);1595 treeLock.release();1596 1597 if (SUCCEEDED(rc))1598 image.queryInterfaceTo(aFloppyImage);1599 1600 if (fNeedsSaveSettings)1601 {1602 AutoWriteLock vboxlock(this COMMA_LOCKVAL_SRC_POS);1603 saveSettings();1604 }1605 }1606 1519 1607 1520 return rc; -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r31562 r31568 1806 1806 </method> 1807 1807 1808 <method name="openHardDisk"> 1809 <desc> 1810 Opens a medium from an existing location, optionally replacing 1811 the image UUID and/or parent UUID. 1812 1813 After the medium is successfully opened by this method, it gets 1814 remembered by (known to) this VirtualBox installation and will be 1815 accessible through the <link to="#findMedium"/> method. Remembered base media 1816 are also returned as part of the <link to="#hardDisks"/> array and can 1817 be attached to virtual machines. See <link to="IMedium" /> for more details. 1818 1819 If a differencing medium is to be opened by this method, the 1808 <method name="openMedium"> 1809 <desc> 1810 Opens a medium from an existing storage location. 1811 1812 Once a medium has been opened, VirtualBox saves the medium in a media 1813 registry. Prior to VirtualBox 3.3, this registry had to be the global 1814 media registry in the VirtualBox.xml file, which was shared between 1815 all machines and made transporting machines from one host to another 1816 difficult. Now you can optionally specify an <link to="IMachine" /> 1817 instance, in which case the medium will be remembered in that machine's 1818 registry. This is the recommended procedure for machines created with 1819 VirtualBox 3.3 or later. <i>(not yet implemented)</i> 1820 1821 Depending on the given device type, the file at the storage location 1822 must be in one of the media formats understood by VirtualBox: 1823 1824 <ul> 1825 <li>With a "HardDisk" device type, the file must be a hard disk image 1826 in one of the formats supported by VirtualBox (see 1827 <link to="ISystemProperties::mediumFormats" />). 1828 After this method succeeds, if the medium is a base medium, it 1829 will be added to the <link to="#hardDisks"/> array attribute. </li> 1830 <li>With a "DVD" device type, the file must be an ISO 9960 CD/DVD image. 1831 After this method succeeds, the medium will be added to the 1832 <link to="#DVDImages"/> array attribute.</li> 1833 <li>With a "Floppy" device type, the file must be an RAW floppy image. 1834 After this method succeeds, the medium will be added to the 1835 <link to="#floppyImages"/> array attribute.</li> 1836 </ul> 1837 1838 After having been opened, the medium can be found by the <link to="#findMedium"/> 1839 method and can be attached to virtual machines. See <link to="IMedium" /> for more details. 1840 1841 The UUID of the newly opened medium will either be retrieved from the 1842 storage location, if the format supports it (e.g. for hard disk images), 1843 or a new UUID will be randomly generated (e.g. for ISO and RAW files). 1844 If for some reason you need to change the medium's UUID, use 1845 <link to="IMedium::setIDs" />. 1846 1847 If a differencing hard disk medium is to be opened by this method, the 1820 1848 operation will succeed only if its parent medium and all ancestors, 1821 1849 if any, are already known to this VirtualBox installation (for example, 1822 1850 were opened by this method before). 1823 1851 1824 This method tries to guess the storage format of the specified medium1852 This method attempts to guess the storage format of the specified medium 1825 1853 by reading medium data at the specified location. 1826 1854 1827 If @a accessMode is ReadWrite (which it should be), the image is opened 1828 for read/write access and must have according permissions, as VirtualBox 1829 may actually write status information into the disk's metadata sections. 1830 1831 Note that write access is required for all typical image usage in VirtualBox, 1855 If @a accessMode is ReadWrite (which it should be for hard disks and floppies), 1856 the image is opened for read/write access and must have according permissions, 1857 as VirtualBox may actually write status information into the disk's metadata 1858 sections. 1859 1860 Note that write access is required for all typical hard disk usage in VirtualBox, 1832 1861 since VirtualBox may need to write metadata such as a UUID into the image. 1833 1862 The only exception is opening a source image temporarily for copying and 1834 cloning when the image will quickly be closed again. 1835 1836 Note that the format of the location string is storage format specific. 1837 See <link to="IMedium::location"/>, IMedium and 1863 cloning (see <link to="IMedium::cloneTo" /> when the image will be closed 1864 again soon. 1865 1866 The format of the location string is storage format specific. See 1867 <link to="IMedium::location"/>, IMedium and 1838 1868 <link to="ISystemProperties::defaultHardDiskFolder"/> for more details. 1839 1869 … … 1848 1878 Invalid medium storage format. 1849 1879 </result> 1850 1880 <result name="VBOX_E_INVALID_OBJECT_STATE"> 1881 Medium has already been added to a media registry. 1882 </result> 1851 1883 </desc> 1852 1884 <param name="location" type="wstring" dir="in"> … … 1856 1888 </desc> 1857 1889 </param> 1890 <param name="deviceType" type="DeviceType" dir="in"> 1891 <desc> 1892 Must be one of "HardDisk", "DVD" or "Floppy". 1893 </desc> 1894 </param> 1858 1895 <param name="accessMode" type="AccessMode" dir="in"> 1859 <desc> 1860 Determines whether to open the image in read/write or read-only mode. 1861 </desc> 1862 </param> 1863 <param name="setImageId" type="boolean" dir="in"> 1864 <desc> 1865 Select whether a new image UUID is set or not. 1866 </desc> 1867 </param> 1868 <param name="imageId" type="uuid" mod="string" dir="in"> 1869 <desc> 1870 New UUID for the image. If an empty string is passed, then a new 1871 UUID is automatically created. Specifying a zero UUIDs is not valid. 1872 </desc> 1873 </param> 1874 <param name="setParentId" type="boolean" dir="in"> 1875 <desc> 1876 Select whether a new parent UUID is set or not. 1877 </desc> 1878 </param> 1879 <param name="parentId" type="uuid" mod="string" dir="in"> 1880 <desc> 1881 New parent UUID for the image. If an empty string is passed, then a 1882 new UUID is automatically created, provided @a setParentId is 1883 @c true. A zero UUID is valid. 1884 </desc> 1896 <desc>Whether to open the image in read/write or read-only mode. For 1897 a "DVD" device type, this is ignored and read-only mode is always assumed.</desc> 1885 1898 </param> 1886 1899 <param name="medium" type="IMedium" dir="return"> … … 1896 1909 The given medium must be known to this VirtualBox installation, i.e. 1897 1910 it must be previously created by <link to="#createHardDisk"/> or opened 1898 by <link to="#openHardDisk"/> or <link to="#openDVDImage" /> or 1899 <link to="#openFloppyImage" />. 1911 by <link to="#openMedium"/>. 1900 1912 1901 1913 The search is done by comparing the value of the @a location argument to … … 1924 1936 <param name="medium" type="IMedium" dir="return"> 1925 1937 <desc>Medium object, if found.</desc> 1926 </param>1927 </method>1928 1929 <method name="openDVDImage">1930 <desc>1931 Opens a CD/DVD image contained in the specified file of the supported1932 format and assigns it the given UUID.1933 1934 After the image is successfully opened by this method, it gets1935 remembered by (known to) this VirtualBox installation and will be1936 accessible through the <link to="#findMedium"/> method.1937 Remembered images are also returned as part of the <link to="#DVDImages"/>1938 array and can be mounted to virtual machines. See <link to="IMedium" />1939 for more details.1940 1941 See <link to="IMedium::location"/> to get more details about the format1942 of the location string.1943 1944 <note>1945 Currently only ISO 9960 CD/DVD images are supported by VirtualBox.1946 </note>1947 1948 <result name="VBOX_E_FILE_ERROR">1949 Invalid CD/DVD image file location or could not find the CD/DVD1950 image at the specified location.1951 </result>1952 <result name="VBOX_E_INVALID_OBJECT_STATE">1953 CD/DVD image already exists in the media registry.1954 </result>1955 1956 </desc>1957 <param name="location" type="wstring" dir="in">1958 <desc>1959 Full path to the file that contains a valid CD/DVD image.1960 </desc>1961 </param>1962 <param name="id" type="uuid" mod="string" dir="in">1963 <desc>1964 UUID to assign to the given image within this VirtualBox installation.1965 If an empty (@c null) UUID is specified, the system will randomly1966 generate a new UUID.1967 </desc>1968 </param>1969 <param name="image" type="IMedium" dir="return">1970 <desc>Opened CD/DVD image object.</desc>1971 </param>1972 </method>1973 1974 <method name="openFloppyImage">1975 <desc>1976 Opens a floppy image contained in the specified file of the supported1977 format and assigns it the given UUID.1978 1979 After the image is successfully opened by this method, it gets1980 remembered by (known to) this VirtualBox installation and will be1981 accessible through the <link to="#findMedium"/> method.1982 Remembered images are also returned as part of the <link to="#floppyImages"/>1983 array and can be mounted to virtual machines. See <link to="IMedium" />1984 for more details.1985 1986 See <link to="IMedium::location"/> to get more details about the format1987 of the location string.1988 1989 <result name="VBOX_E_FILE_ERROR">1990 Invalid floppy image file location or could not find the floppy1991 image at the specified location.1992 </result>1993 <result name="VBOX_E_INVALID_OBJECT_STATE">1994 Floppy image already exists in the media registry.1995 </result>1996 1997 <note>1998 Currently, only raw floppy images are supported by VirtualBox.1999 </note>2000 </desc>2001 <param name="location" type="wstring" dir="in">2002 <desc>2003 Full path to the file that contains a valid floppy image.2004 </desc>2005 </param>2006 <param name="id" type="uuid" mod="string" dir="in">2007 <desc>2008 UUID to assign to the given image file within this VirtualBox2009 installation. If an empty (@c null) UUID is specified, the system will2010 randomly generate a new UUID.2011 </desc>2012 </param>2013 <param name="image" type="IMedium" dir="return">2014 <desc>Opened floppy image object.</desc>2015 1938 </param> 2016 1939 </method> … … 7342 7265 IMedium, 7343 7266 <link to="IVirtualBox::createHardDisk"/>, 7344 <link to="IVirtualBox::open HardDisk"/>,7267 <link to="IVirtualBox::openMedium"/>, 7345 7268 <link to="IMedium::location"/> 7346 7269 </see> … … 8554 8477 </ul> 8555 8478 8556 Existing media are opened using the following methods, depending on the 8557 media type: 8558 <ul> 8559 <li><link to="IVirtualBox::openHardDisk"/></li> 8560 <li><link to="IVirtualBox::openDVDImage"/></li> 8561 <li><link to="IVirtualBox::openFloppyImage"/></li> 8562 </ul> 8563 8564 New hard disk media can be created with the VirtualBox API using the 8479 Existing media are opened using <link to="IVirtualBox::openMedium"/>; 8480 new hard disk media can be created with the VirtualBox API using the 8565 8481 <link to="IVirtualBox::createHardDisk"/> method. 8566 8482 … … 8653 8569 New base hard disks are created using 8654 8570 <link to="IVirtualBox::createHardDisk"/>. Existing hard disks are 8655 opened using <link to="IVirtualBox::open HardDisk"/>. Differencing hard8571 opened using <link to="IVirtualBox::openMedium"/>. Differencing hard 8656 8572 disks are usually implicitly created by VirtualBox when needed but may 8657 8573 also be created explicitly using <link to="#createDiffStorage"/>. … … 9169 9085 </attribute> 9170 9086 9087 <method name="setIDs"> 9088 <desc> 9089 Changes the UUID and parent UUID for a hard disk medium. 9090 </desc> 9091 <param name="setImageId" type="boolean" dir="in"> 9092 <desc> 9093 Select whether a new image UUID is set or not. 9094 </desc> 9095 </param> 9096 <param name="imageId" type="uuid" mod="string" dir="in"> 9097 <desc> 9098 New UUID for the image. If an empty string is passed, then a new 9099 UUID is automatically created, provided that @a setImageId is @c true. 9100 Specifying a zero UUID is not allowed. 9101 </desc> 9102 </param> 9103 <param name="setParentId" type="boolean" dir="in"> 9104 <desc> 9105 Select whether a new parent UUID is set or not. 9106 </desc> 9107 </param> 9108 <param name="parentId" type="uuid" mod="string" dir="in"> 9109 <desc> 9110 New parent UUID for the image. If an empty string is passed, then a 9111 new UUID is automatically created, provided @a setParentId is 9112 @c true. A zero UUID is valid. 9113 </desc> 9114 </param> 9115 <result name="E_INVALIDARG"> 9116 Invalid parameter combination. 9117 </result> 9118 <result name="VBOX_E_NOT_SUPPORTED"> 9119 Medium is not a hard disk medium. 9120 </result> 9121 </method> 9122 9171 9123 <method name="refreshState"> 9172 9124 <desc> … … 9397 9349 operation will fail. 9398 9350 9399 When the medium is successfully closed, it gets removed from9400 the list of re membered media, but its storage unit is not9401 deleted. In particular, this means that this medium can be9402 later opened again using the <link9403 to="IVirtualBox::openHardDisk"/>call.9351 When the medium is successfully closed, it is removed from 9352 the list of registered media, but its storage unit is not 9353 deleted. In particular, this means that this medium can 9354 later be opened again using the <link to="IVirtualBox::openMedium"/> 9355 call. 9404 9356 9405 9357 Note that after this method successfully returns, the given medium -
trunk/src/VBox/Main/include/MediumImpl.h
r31482 r31568 79 79 const Utf8Str &aLocation, 80 80 HDDOpenMode enOpenMode, 81 DeviceType_T aDeviceType, 82 BOOL aSetImageId, 83 const Guid &aImageId, 84 BOOL aSetParentId, 85 const Guid &aParentId); 81 DeviceType_T aDeviceType); 86 82 87 83 // initializer used when loading settings … … 129 125 130 126 // IMedium methods 127 STDMETHOD(SetIDs)(BOOL aSetImageId, IN_BSTR aImageId, 128 BOOL aSetParentId, IN_BSTR aParentId); 131 129 STDMETHOD(RefreshState)(MediumState_T *aState); 132 130 STDMETHOD(GetSnapshotIds)(IN_BSTR aMachineId, … … 245 243 private: 246 244 247 HRESULT queryInfo( );245 HRESULT queryInfo(bool fSetImageId, bool fSetParentId); 248 246 249 247 HRESULT canClose(); -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r31562 r31568 132 132 STDMETHOD(CreateHardDisk)(IN_BSTR aFormat, IN_BSTR aLocation, 133 133 IMedium **aHardDisk); 134 STDMETHOD(OpenHardDisk) (IN_BSTR aLocation, AccessMode_T accessMode, 135 BOOL aSetImageId, IN_BSTR aImageId, 136 BOOL aSetParentId, IN_BSTR aParentId, 137 IMedium **aHardDisk); 138 STDMETHOD(FindMedium) (IN_BSTR aLocation, DeviceType_T deviceType, IMedium **aMedium); 139 140 STDMETHOD(OpenDVDImage) (IN_BSTR aLocation, IN_BSTR aId, 141 IMedium **aDVDImage); 142 STDMETHOD(OpenFloppyImage) (IN_BSTR aLocation, IN_BSTR aId, 143 IMedium **aFloppyImage); 134 STDMETHOD(OpenMedium)(IN_BSTR aLocation, 135 DeviceType_T deviceType, 136 AccessMode_T accessMode, 137 IMedium **aMedium); 138 STDMETHOD(FindMedium)(IN_BSTR aLocation, 139 DeviceType_T deviceType, 140 IMedium **aMedium); 144 141 145 142 STDMETHOD(GetGuestOSType) (IN_BSTR aId, IGuestOSType **aType); -
trunk/src/VBox/Main/testcase/tstVBoxAPILinux.cpp
r31070 r31568 356 356 */ 357 357 nsCOMPtr<IMedium> dvdImage; 358 359 rc = virtualBox->OpenDVDImage(NS_LITERAL_STRING("/home/vbox/isos/winnt4ger.iso").get(),360 nsnull, /* NULL UUID, i.e. a new one will be created */361 358 rc = virtualBox->OpenMedium(NS_LITERAL_STRING("/home/vbox/isos/winnt4ger.iso").get(), 359 DeviceType_DVD, 360 AccessMode_ReadOnly, 361 getter_AddRefs(dvdImage)); 362 362 if (NS_FAILED(rc)) 363 {364 363 printf("Error: could not open CD image! rc=%08X\n", rc); 365 }366 364 else 367 365 {
Note:
See TracChangeset
for help on using the changeset viewer.