Changeset 31562 in vbox for trunk/src/VBox/Main
- Timestamp:
- Aug 11, 2010 10:02:40 AM (14 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ApplianceImpl.cpp
r30881 r31562 611 611 /* @todo: Maybe too cost-intensive; try to find a lighter way */ 612 612 while ( RTPathExists(tmpName) 613 || mVirtualBox->Find HardDisk(Bstr(tmpName), &harddisk) != VBOX_E_OBJECT_NOT_FOUND613 || mVirtualBox->FindMedium(Bstr(tmpName), DeviceType_HardDisk, &harddisk) != VBOX_E_OBJECT_NOT_FOUND 614 614 ) 615 615 { -
trunk/src/VBox/Main/ApplianceImplExport.cpp
r31539 r31562 1483 1483 1484 1484 Log(("Finding source disk \"%ls\"\n", bstrSrcFilePath.raw())); 1485 rc = mVirtualBox->Find HardDisk(bstrSrcFilePath, pSourceDisk.asOutParam());1485 rc = mVirtualBox->FindMedium(bstrSrcFilePath, DeviceType_HardDisk, pSourceDisk.asOutParam()); 1486 1486 if (FAILED(rc)) throw rc; 1487 1487 -
trunk/src/VBox/Main/MachineImpl.cpp
r31546 r31562 3173 3173 case DeviceType_HardDisk: 3174 3174 /* find a hard disk by UUID */ 3175 rc = mParent->findHardDisk(&uuid, NULL, true /* aSetError */, &medium);3175 rc = mParent->findHardDisk(&uuid, Utf8Str::Empty, true /* aSetError */, &medium); 3176 3176 if (FAILED(rc)) return rc; 3177 3177 break; … … 7141 7141 { 7142 7142 /* find a hard disk by UUID */ 7143 rc = mParent->findHardDisk(&dev.uuid, NULL, true /* aDoSetError */, &medium);7143 rc = mParent->findHardDisk(&dev.uuid, Utf8Str::Empty, true /* aDoSetError */, &medium); 7144 7144 if (FAILED(rc)) 7145 7145 { -
trunk/src/VBox/Main/MediumImpl.cpp
r31539 r31562 3634 3634 Guid id = parentId; 3635 3635 ComObjPtr<Medium> pParent; 3636 rc = m->pVirtualBox->findHardDisk(&id, NULL, false /* aSetError */, &pParent);3636 rc = m->pVirtualBox->findHardDisk(&id, Utf8Str::Empty, false /* aSetError */, &pParent); 3637 3637 if (FAILED(rc)) 3638 3638 { -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r31552 r31562 1469 1469 } 1470 1470 1471 STDMETHODIMP VirtualBox::GetHardDisk(IN_BSTR aId, 1472 IMedium **aHardDisk) 1473 { 1474 CheckComArgOutSafeArrayPointerValid(aHardDisk); 1471 STDMETHODIMP VirtualBox::FindMedium(IN_BSTR aLocation, 1472 DeviceType_T aDeviceType, 1473 IMedium **aMedium) 1474 { 1475 CheckComArgOutSafeArrayPointerValid(aMedium); 1475 1476 1476 1477 AutoCaller autoCaller(this); 1477 1478 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1478 1479 1479 Guid id(aId); 1480 ComObjPtr<Medium> hardDisk; 1481 HRESULT rc = findHardDisk(&id, NULL, true /* setError */, &hardDisk); 1480 Guid id(aLocation); 1481 Utf8Str strLocation(aLocation); 1482 1483 HRESULT rc; 1484 ComObjPtr<Medium> pMedium; 1485 1486 switch (aDeviceType) 1487 { 1488 case DeviceType_HardDisk: 1489 if (!id.isEmpty()) 1490 rc = findHardDisk(&id, Utf8Str::Empty, true /* setError */, &pMedium); 1491 else 1492 rc = findHardDisk(NULL, strLocation, true /* setError */, &pMedium); 1493 break; 1494 1495 case DeviceType_Floppy: 1496 case DeviceType_DVD: 1497 if (!id.isEmpty()) 1498 rc = findDVDOrFloppyImage(aDeviceType, &id, Utf8Str::Empty, true /* setError */, &pMedium); 1499 else 1500 rc = findDVDOrFloppyImage(aDeviceType, NULL, strLocation, true /* setError */, &pMedium); 1501 break; 1502 1503 default: 1504 return setError(E_INVALIDARG, 1505 tr("Invalid device type %d"), aDeviceType); 1506 } 1482 1507 1483 1508 /* the below will set *aHardDisk to NULL if hardDisk is null */ 1484 hardDisk.queryInterfaceTo(aHardDisk); 1485 1486 return rc; 1487 } 1488 1489 STDMETHODIMP VirtualBox::FindHardDisk(IN_BSTR aLocation, 1490 IMedium **aHardDisk) 1491 { 1492 CheckComArgStrNotEmptyOrNull(aLocation); 1493 CheckComArgOutSafeArrayPointerValid(aHardDisk); 1494 1495 AutoCaller autoCaller(this); 1496 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1497 1498 ComObjPtr<Medium> hardDisk; 1499 HRESULT rc = findHardDisk(NULL, aLocation, true /* setError */, &hardDisk); 1500 1501 /* the below will set *aHardDisk to NULL if hardDisk is null */ 1502 hardDisk.queryInterfaceTo(aHardDisk); 1509 pMedium.queryInterfaceTo(aMedium); 1503 1510 1504 1511 return rc; … … 1553 1560 } 1554 1561 1555 /** @note Locks objects! */1556 STDMETHODIMP VirtualBox::GetDVDImage(IN_BSTR aId, IMedium **aDVDImage)1557 {1558 CheckComArgOutSafeArrayPointerValid(aDVDImage);1559 1560 AutoCaller autoCaller(this);1561 if (FAILED(autoCaller.rc())) return autoCaller.rc();1562 1563 Guid id(aId);1564 ComObjPtr<Medium> image;1565 HRESULT rc = findDVDOrFloppyImage(DeviceType_DVD, &id, Utf8Str::Empty, true /* setError */, &image);1566 1567 /* the below will set *aDVDImage to NULL if image is null */1568 image.queryInterfaceTo(aDVDImage);1569 1570 return rc;1571 }1572 1573 /** @note Locks objects! */1574 STDMETHODIMP VirtualBox::FindDVDImage(IN_BSTR aLocation, IMedium **aDVDImage)1575 {1576 CheckComArgStrNotEmptyOrNull(aLocation);1577 CheckComArgOutSafeArrayPointerValid(aDVDImage);1578 1579 AutoCaller autoCaller(this);1580 if (FAILED(autoCaller.rc())) return autoCaller.rc();1581 1582 ComObjPtr<Medium> image;1583 HRESULT rc = findDVDOrFloppyImage(DeviceType_DVD, NULL, aLocation, true /* setError */, &image);1584 1585 /* the below will set *aDVDImage to NULL if dvd is null */1586 image.queryInterfaceTo(aDVDImage);1587 1588 return rc;1589 }1590 1591 1562 /** @note Doesn't lock anything. */ 1592 1563 STDMETHODIMP VirtualBox::OpenFloppyImage(IN_BSTR aLocation, … … 1633 1604 } 1634 1605 } 1635 1636 return rc;1637 }1638 1639 /** @note Locks objects! */1640 STDMETHODIMP VirtualBox::GetFloppyImage(IN_BSTR aId, IMedium **aFloppyImage)1641 1642 {1643 CheckComArgOutSafeArrayPointerValid(aFloppyImage);1644 1645 AutoCaller autoCaller(this);1646 if (FAILED(autoCaller.rc())) return autoCaller.rc();1647 1648 Guid id(aId);1649 ComObjPtr<Medium> image;1650 HRESULT rc = findDVDOrFloppyImage(DeviceType_Floppy, &id, Utf8Str::Empty, true /* setError */, &image);1651 1652 /* the below will set *aFloppyImage to NULL if image is null */1653 image.queryInterfaceTo(aFloppyImage);1654 1655 return rc;1656 }1657 1658 /** @note Locks objects! */1659 STDMETHODIMP VirtualBox::FindFloppyImage(IN_BSTR aLocation,1660 IMedium **aFloppyImage)1661 {1662 CheckComArgStrNotEmptyOrNull(aLocation);1663 CheckComArgOutSafeArrayPointerValid(aFloppyImage);1664 1665 AutoCaller autoCaller(this);1666 if (FAILED(autoCaller.rc())) return autoCaller.rc();1667 1668 ComObjPtr<Medium> image;1669 HRESULT rc = findDVDOrFloppyImage(DeviceType_Floppy, NULL, aLocation, true /* setError */, &image);1670 1671 /* the below will set *aFloppyImage to NULL if img is null */1672 image.queryInterfaceTo(aFloppyImage);1673 1606 1674 1607 return rc; … … 2712 2645 */ 2713 2646 HRESULT VirtualBox::findHardDisk(const Guid *aId, 2714 CBSTR aLocation,2647 const Utf8Str &strLocation, 2715 2648 bool aSetError, 2716 2649 ComObjPtr<Medium> *aHardDisk /*= NULL*/) 2717 2650 { 2718 AssertReturn(aId || aLocation, E_INVALIDARG);2651 AssertReturn(aId || !strLocation.isEmpty(), E_INVALIDARG); 2719 2652 2720 2653 // we use the hard disks map, but it is protected by the … … 2736 2669 /* then iterate and search by location */ 2737 2670 int result = -1; 2738 if (aLocation) 2739 { 2740 Utf8Str location = aLocation; 2741 2671 if (!strLocation.isEmpty()) 2672 { 2742 2673 for (HardDiskMap::const_iterator it = m->mapHardDisks.begin(); 2743 2674 it != m->mapHardDisks.end(); … … 2746 2677 const ComObjPtr<Medium> &hd = (*it).second; 2747 2678 2748 HRESULT rc = hd->compareLocationTo( location, result);2679 HRESULT rc = hd->compareLocationTo(strLocation, result); 2749 2680 if (FAILED(rc)) return rc; 2750 2681 … … 2769 2700 else 2770 2701 setError(rc, 2771 tr("Could not find a hard disk with location '% ls' in the media registry ('%s')"),2772 aLocation,2702 tr("Could not find a hard disk with location '%s' in the media registry ('%s')"), 2703 strLocation.c_str(), 2773 2704 m->strSettingsFilePath.c_str()); 2774 2705 } -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r31464 r31562 1768 1768 After the storage unit is successfully created, the medium gets 1769 1769 remembered by this VirtualBox installation and will be accessible 1770 through <link to="#getHardDisk"/> and <link to="#findHardDisk"/>1771 methods. Remembered base medium are also returned as part of1772 the <link to="#hardDisks"/> array. See IMediumfor more details.1770 through the <link to="#findMedium"/> method. Remembered base medium 1771 are also returned as part of the <link to="#hardDisks"/> array. 1772 See <link to="IMedium" /> for more details. 1773 1773 1774 1774 The list of all storage formats supported by this VirtualBox … … 1813 1813 After the medium is successfully opened by this method, it gets 1814 1814 remembered by (known to) this VirtualBox installation and will be 1815 accessible through <link to="#getHardDisk"/> and 1816 <link to="#findHardDisk"/> methods. Remembered base media 1815 accessible through the <link to="#findMedium"/> method. Remembered base media 1817 1816 are also returned as part of the <link to="#hardDisks"/> array and can 1818 be attached to virtual machines. See IMediumfor more details.1817 be attached to virtual machines. See <link to="IMedium" /> for more details. 1819 1818 1820 1819 If a differencing medium is to be opened by this method, the … … 1890 1889 </method> 1891 1890 1892 <method name="getHardDisk" const="yes"> 1893 <desc> 1894 Returns a medium with the given UUID. 1895 1896 The medium with the given UUID must be known to this VirtualBox 1897 installation, i.e. it must be previously created by 1898 <link to="#createHardDisk"/> or opened by <link 1899 to="#openHardDisk"/>, or attached to some known virtual machine. 1900 1901 <result name="VBOX_E_OBJECT_NOT_FOUND"> 1902 No medium object matching @a id found. 1903 </result> 1904 1905 </desc> 1906 <param name="id" type="uuid" mod="string" dir="in"> 1907 <desc>UUID of the medium to look for.</desc> 1908 </param> 1909 <param name="medium" type="IMedium" dir="return"> 1910 <desc>Found medium object.</desc> 1911 </param> 1912 </method> 1913 1914 <method name="findHardDisk"> 1915 <desc> 1916 Returns a medium that uses the given location to store medium data. 1891 <method name="findMedium"> 1892 <desc> 1893 Returns a medium of the given type that uses the given location or 1894 UUID to store medium data. 1917 1895 1918 1896 The given medium must be known to this VirtualBox installation, i.e. 1919 it must be previously created by 1920 <link to="#createHardDisk"/> or opened by <link1921 to="#openHardDisk"/>, or attached to some known virtual machine.1897 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" />. 1922 1900 1923 1901 The search is done by comparing the value of the @a location argument to 1924 the <link to="IMedium::location"/> attribute of each known medium. 1902 the <link to="IMedium::location"/> and <link to="IMedium::id" /> 1903 attributes of each known medium. 1925 1904 1926 1905 For locations represented by file names in the host's file system, the … … 1936 1915 No medium object matching @a location found. 1937 1916 </result> 1938 1939 1917 </desc> 1940 1918 <param name="location" type="wstring" dir="in"> 1941 <desc>Location string to search for.</desc> 1919 <desc>What to search for. This can either be the UUID or the location string of an open medium.</desc> 1920 </param> 1921 <param name="type" type="DeviceType" dir="in"> 1922 <desc>Device type (must be HardDisk, DVD or Floppy)</desc> 1942 1923 </param> 1943 1924 <param name="medium" type="IMedium" dir="return"> 1944 <desc> Found medium object.</desc>1925 <desc>Medium object, if found.</desc> 1945 1926 </param> 1946 1927 </method> … … 1953 1934 After the image is successfully opened by this method, it gets 1954 1935 remembered by (known to) this VirtualBox installation and will be 1955 accessible through <link to="#getDVDImage"/> and1956 <link to="#findDVDImage"/> methods. Remembered images are also1957 returned as part of the <link to="#DVDImages"/> array and can be mounted1958 to virtual machines. See IMediumfor more details.1936 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. 1959 1940 1960 1941 See <link to="IMedium::location"/> to get more details about the format … … 1991 1972 </method> 1992 1973 1993 <method name="getDVDImage">1994 <desc>1995 Returns a CD/DVD image with the given UUID.1996 1997 The image with the given UUID must be known to this VirtualBox1998 installation, i.e. it must be previously opened by <link1999 to="#openDVDImage"/>, or mounted to some known virtual machine.2000 2001 <result name="VBOX_E_OBJECT_NOT_FOUND">2002 No matching DVD image found in the media registry.2003 </result>2004 2005 </desc>2006 <param name="id" type="uuid" mod="string" dir="in">2007 <desc>UUID of the image to look for.</desc>2008 </param>2009 <param name="image" type="IMedium" dir="return">2010 <desc>Found CD/DVD image object.</desc>2011 </param>2012 </method>2013 2014 <method name="findDVDImage">2015 <desc>2016 Returns a CD/DVD image with the given image location.2017 2018 The image with the given UUID must be known to this VirtualBox2019 installation, i.e. it must be previously opened by <link2020 to="#openDVDImage"/>, or mounted to some known virtual machine.2021 2022 The search is done by comparing the value of the @a location argument to2023 the <link to="IMedium::location"/> attribute of each known CD/DVD image.2024 2025 The requested location can be a path relative to the2026 <link to="IVirtualBox::homeFolder">VirtualBox home folder</link>. If2027 only a file name without any path is given, the2028 <link to="ISystemProperties::defaultHardDiskFolder"> default hard disk2029 folder</link> will be prepended to the file name before searching. Note2030 that on case sensitive file systems, a case sensitive comparison is2031 performed, otherwise the case in the file path is ignored.2032 2033 <result name="VBOX_E_FILE_ERROR">2034 Invalid image file location.2035 </result>2036 <result name="VBOX_E_OBJECT_NOT_FOUND">2037 No matching DVD image found in the media registry.2038 </result>2039 2040 </desc>2041 <param name="location" type="wstring" dir="in">2042 <desc>CD/DVD image file path to look for.</desc>2043 </param>2044 <param name="image" type="IMedium" dir="return">2045 <desc>Found CD/DVD image object.</desc>2046 </param>2047 </method>2048 2049 1974 <method name="openFloppyImage"> 2050 1975 <desc> … … 2054 1979 After the image is successfully opened by this method, it gets 2055 1980 remembered by (known to) this VirtualBox installation and will be 2056 accessible through <link to="#getFloppyImage"/> and2057 <link to="#findFloppyImage"/> methods. Remembered images are also2058 returned as part of the <link to="#floppyImages"/> array and can be2059 mounted to virtual machines. See IMediumfor more details.1981 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. 2060 1985 2061 1986 See <link to="IMedium::location"/> to get more details about the format … … 2088 2013 <param name="image" type="IMedium" dir="return"> 2089 2014 <desc>Opened floppy image object.</desc> 2090 </param>2091 </method>2092 2093 <method name="getFloppyImage">2094 <desc>2095 Returns a floppy image with the given UUID.2096 2097 The image with the given UUID must be known to this VirtualBox2098 installation, i.e. it must be previously opened by <link2099 to="#openFloppyImage"/>, or mounted to some known virtual machine.2100 2101 <result name="VBOX_E_OBJECT_NOT_FOUND">2102 No matching floppy image found in the media registry.2103 </result>2104 2105 </desc>2106 <param name="id" type="uuid" mod="string" dir="in">2107 <desc>UUID of the image to look for.</desc>2108 </param>2109 <param name="image" type="IMedium" dir="return">2110 <desc>Found floppy image object.</desc>2111 </param>2112 </method>2113 2114 <method name="findFloppyImage">2115 <desc>2116 Returns a floppy image with the given image location.2117 2118 The image with the given UUID must be known to this VirtualBox2119 installation, i.e. it must be previously opened by <link2120 to="#openFloppyImage"/>, or mounted to some known virtual machine.2121 2122 The search is done by comparing the value of the @a location argument to2123 the <link to="IMedium::location"/> attribute of each known floppy image.2124 2125 The requested location can be a path relative to the2126 <link to="IVirtualBox::homeFolder">VirtualBox home folder</link>. If2127 only a file name without any path is given, the2128 <link to="ISystemProperties::defaultHardDiskFolder"> default hard disk2129 folder</link> will be prepended to the file name before searching. Note2130 that on case sensitive file systems, a case sensitive comparison is2131 performed, otherwise the case of symbols in the file path is ignored.2132 2133 <result name="VBOX_E_FILE_ERROR">2134 Invalid image file location.2135 </result>2136 <result name="VBOX_E_OBJECT_NOT_FOUND">2137 No matching floppy image found in the media registry.2138 </result>2139 2140 </desc>2141 <param name="location" type="wstring" dir="in">2142 <desc>Floppy image file path to look for.</desc>2143 </param>2144 <param name="image" type="IMedium" dir="return">2145 <desc>Found floppy image object.</desc>2146 2015 </param> 2147 2016 </method> … … 8719 8588 <link to="IVirtualBox::DVDImages"/> and 8720 8589 <link to="IVirtualBox::floppyImages"/> attributes. Individual media can be 8721 quickly found by UUID using <link to="IVirtualBox::getHardDisk"/> 8722 and similar methods or by location using 8723 <link to="IVirtualBox::findHardDisk"/> and similar methods. 8590 quickly found using the <link to="IVirtualBox::findMedium"/> method. 8724 8591 8725 8592 Only known media can be attached to virtual machines. … … 8793 8660 or opened, it becomes a known hard disk (remembered in the internal media 8794 8661 registry). Known hard disks can be attached to a virtual machine, accessed 8795 through <link to="IVirtualBox::getHardDisk"/> and 8796 <link to="IVirtualBox::findHardDisk"/> methods or enumerated using the 8662 through <link to="IVirtualBox::findMedium"/> or enumerated using the 8797 8663 <link to="IVirtualBox::hardDisks"/> array (only for base hard disks). 8798 8664 -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r31482 r31562 136 136 BOOL aSetParentId, IN_BSTR aParentId, 137 137 IMedium **aHardDisk); 138 STDMETHOD(GetHardDisk) (IN_BSTR aId, IMedium **aHardDisk); 139 STDMETHOD(FindHardDisk) (IN_BSTR aLocation, IMedium **aHardDisk); 138 STDMETHOD(FindMedium) (IN_BSTR aLocation, DeviceType_T deviceType, IMedium **aMedium); 140 139 141 140 STDMETHOD(OpenDVDImage) (IN_BSTR aLocation, IN_BSTR aId, 142 141 IMedium **aDVDImage); 143 STDMETHOD(GetDVDImage) (IN_BSTR aId, IMedium **aDVDImage);144 STDMETHOD(FindDVDImage) (IN_BSTR aLocation, IMedium **aDVDImage);145 146 142 STDMETHOD(OpenFloppyImage) (IN_BSTR aLocation, IN_BSTR aId, 147 143 IMedium **aFloppyImage); 148 STDMETHOD(GetFloppyImage) (IN_BSTR aId, IMedium **aFloppyImage);149 STDMETHOD(FindFloppyImage) (IN_BSTR aLocation, IMedium **aFloppyImage);150 144 151 145 STDMETHOD(GetGuestOSType) (IN_BSTR aId, IGuestOSType **aType); … … 221 215 ComObjPtr<Machine> *machine = NULL); 222 216 223 HRESULT findHardDisk(const Guid *aId, CBSTR aLocation, 224 bool aSetError, ComObjPtr<Medium> *aHardDisk = NULL); 217 HRESULT findHardDisk(const Guid *aId, 218 const Utf8Str &strLocation, 219 bool aSetError, 220 ComObjPtr<Medium> *aHardDisk = NULL); 225 221 HRESULT findDVDOrFloppyImage(DeviceType_T mediumType, 226 222 const Guid *aId,
Note:
See TracChangeset
for help on using the changeset viewer.