- Timestamp:
- May 30, 2017 2:11:46 PM (8 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/ApplianceImpl.h
r65088 r67142 217 217 HRESULT i_writeFSOVF(TaskOVF *pTask, AutoWriteLockBase& writeLock); 218 218 HRESULT i_writeFSOVA(TaskOVF *pTask, AutoWriteLockBase& writeLock); 219 HRESULT i_writeFSImpl(TaskOVF *pTask, AutoWriteLockBase& writeLock, PVDINTERFACEIO pCallbacks, PSHASTORAGE pStorage); 219 HRESULT i_writeFSImpl(TaskOVF *pTask, AutoWriteLockBase &writeLock, RTVFSFSSTREAM hVfsFss, 220 PVDINTERFACEIO pCallbacks, PSHASTORAGE pStorage); 220 221 221 222 struct XMLStack; -
trunk/src/VBox/Main/include/ApplianceImplPrivate.h
r65807 r67142 18 18 #ifndef ____H_APPLIANCEIMPLPRIVATE 19 19 #define ____H_APPLIANCEIMPLPRIVATE 20 21 #ifdef DEBUG_bird 22 # define MAIN_WITH_NEW_TAR_CREATOR 23 #endif 20 24 21 25 class VirtualSystemDescription; … … 436 440 PVDINTERFACEIO tarWriterCreateInterface(void); 437 441 442 int writeBufferToFile(const char *pszFilename, const void *pvContent, size_t cbContent, RTVFSFSSTREAM hVfsFss); 438 443 int writeBufferToFile(const char *pcszFilename, void *pvBuf, size_t cbSize, PVDINTERFACEIO pIfIo, void *pvUser); 439 444 -
trunk/src/VBox/Main/src-server/ApplianceImplExport.cpp
r66126 r67142 2026 2026 break; 2027 2027 } 2028 rc = i_writeFSImpl(pTask, writeLock, pShaIo, &storage);2028 rc = i_writeFSImpl(pTask, writeLock, NIL_RTVFSFSSTREAM, pShaIo, &storage); 2029 2029 } while (0); 2030 2030 … … 2084 2084 break; 2085 2085 } 2086 rc = i_writeFSImpl(pTask, writeLock, pShaIo, &storage);2086 rc = i_writeFSImpl(pTask, writeLock, NIL_RTVFSFSSTREAM, pShaIo, &storage); 2087 2087 } while (0); 2088 2088 … … 2103 2103 } 2104 2104 2105 HRESULT Appliance::i_writeFSImpl(TaskOVF *pTask, AutoWriteLockBase& writeLock, PVDINTERFACEIO pIfIo, PSHASTORAGE pStorage) 2105 HRESULT Appliance::i_writeFSImpl(TaskOVF *pTask, AutoWriteLockBase& writeLock, RTVFSFSSTREAM hVfsFssOut, 2106 PVDINTERFACEIO pIfIo, PSHASTORAGE pStorage) 2106 2107 { 2107 2108 LogFlowFuncEnter(); … … 2137 2138 strOvfFile.c_str()); 2138 2139 /* Write the ovf file to disk. */ 2139 vrc = writeBufferToFile(strOvfFile.c_str(), pvBuf, cbSize, pIfIo, pStorage); 2140 if (hVfsFssOut != NIL_RTVFSFSSTREAM) 2141 vrc = writeBufferToFile(strOvfFile.c_str(), pvBuf, cbSize, hVfsFssOut); 2142 else 2143 vrc = writeBufferToFile(strOvfFile.c_str(), pvBuf, cbSize, pIfIo, pStorage); 2140 2144 if (RT_FAILURE(vrc)) 2145 2141 2146 throw setError(VBOX_E_FILE_ERROR, 2142 2147 tr("Could not create OVF file '%s' (%Rrc)"), … … 2234 2239 if (pDiskEntry->type == VirtualSystemDescriptionType_HardDiskImage) 2235 2240 { 2241 /* 2242 * Export a disk image. 2243 */ 2236 2244 ComObjPtr<Progress> pProgress2; 2237 2245 pProgress2.createObject(); … … 2241 2249 if (FAILED(rc)) throw rc; 2242 2250 2243 rc = pSourceDisk->i_exportFile(strTargetFilePath.c_str(), 2244 format, 2245 MediumVariant_VmdkStreamOptimized, 2246 m->m_pSecretKeyStore, 2247 pIfIo, 2248 pStorage, 2249 pProgress2); 2251 if (hVfsFssOut != NIL_RTVFSFSSTREAM) 2252 rc = E_NOTIMPL; /** @todo Continue here later. Need to (1) wrap the FSS thing (in the caller?) 2253 * and (2) provide a push API for adding streams. (RTVfsFsStrmAdd is a pull API, 2254 * in that it pulls in the data bytes itself.) */ 2255 else 2256 { 2257 rc = pSourceDisk->i_exportFile(strTargetFilePath.c_str(), 2258 format, 2259 MediumVariant_VmdkStreamOptimized, 2260 m->m_pSecretKeyStore, 2261 pIfIo, 2262 pStorage, 2263 pProgress2); 2264 } 2250 2265 if (FAILED(rc)) throw rc; 2251 2266 … … 2256 2271 else 2257 2272 { 2258 //copy/clone CD/DVD image 2273 /* 2274 * Copy CD/DVD/floppy image. 2275 */ 2259 2276 Assert(pDiskEntry->type == VirtualSystemDescriptionType_CDROM); 2260 2277 2261 /* Read the ISO file and add one to OVA/OVF package */2278 if (hVfsFssOut != NIL_RTVFSFSSTREAM) 2262 2279 { 2280 /* Open the source image and cast it to a VFS base object. */ 2281 RTVFSFILE hVfsSrcFile; 2282 vrc = RTVfsFileOpenNormal(strSrcFilePath.c_str(), 2283 RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_NONE, 2284 &hVfsSrcFile); 2285 if (RT_FAILURE(vrc)) 2286 throw setErrorBoth(VBOX_E_FILE_ERROR, vrc, 2287 tr("Could not create or open file '%s' (%Rrc)"), strSrcFilePath.c_str(), vrc); 2288 2289 RTVFSOBJ hVfsSrc = RTVfsObjFromFile(hVfsSrcFile); 2290 RTVfsFileRelease(hVfsSrcFile); 2291 AssertStmt(hVfsSrc != NIL_RTVFSOBJ, throw VERR_INTERNAL_ERROR); 2292 2293 /* Add it to the output stream. This will pull in all the data from the object. */ 2294 vrc = RTVfsFsStrmAdd(hVfsFssOut, strTargetFilePath.c_str(), hVfsSrc, 0 /*fFlags*/); 2295 RTVfsObjRelease(hVfsSrc); 2296 if (RT_FAILURE(vrc)) 2297 throw setErrorBoth(VBOX_E_FILE_ERROR, vrc, tr("Error during copy CD/DVD image '%s' (%Rrc)"), 2298 strSrcFilePath.c_str(), vrc); 2299 } 2300 else 2301 { 2302 /* Read the ISO file and add one to OVA/OVF package */ 2263 2303 void *pvStorage; 2264 2304 RTFILE pFile = NULL; … … 2380 2420 pStorage->fCreateDigest = false; 2381 2421 /* Write the manifest file to disk. */ 2382 vrc = writeBufferToFile(strMfFilePath.c_str(), pvBuf, cbSize, pIfIo, pStorage); 2422 if (hVfsFssOut != NIL_RTVFSFSSTREAM) 2423 vrc = writeBufferToFile(strMfFilePath.c_str(), pvBuf, cbSize, hVfsFssOut); 2424 else 2425 vrc = writeBufferToFile(strMfFilePath.c_str(), pvBuf, cbSize, pIfIo, pStorage); 2383 2426 RTMemFree(pvBuf); 2384 2427 if (RT_FAILURE(vrc)) -
trunk/src/VBox/Main/src-server/ApplianceImplIO.cpp
r62485 r67142 1229 1229 } 1230 1230 1231 1232 /** 1233 * Writes a memory buffer to a file in the output file system stream. 1234 * 1235 * @returns IPRT status code. 1236 * @param pszFilename The file name (w/ path if desired). 1237 * @param pvContent Pointer to buffer containing the file content. 1238 * @param cbContent Size of the content. 1239 * @param hVfsFss The file system stream to add the file to. 1240 */ 1241 int writeBufferToFile(const char *pszFilename, const void *pvContent, size_t cbContent, RTVFSFSSTREAM hVfsFss) 1242 { 1243 /* 1244 * Create a VFS file around the memory, converting it to a base VFS object handle. 1245 */ 1246 RTVFSFILE hVfsFile; 1247 int rc = RTVfsFileFromBuffer(RTFILE_O_READ, pvContent, cbContent, &hVfsFile); 1248 if (RT_SUCCESS(rc)) 1249 { 1250 RTVFSOBJ hVfsObj = RTVfsObjFromFile(hVfsFile); 1251 RTVfsFileRelease(hVfsFile); 1252 AssertReturn(hVfsObj != NIL_RTVFSOBJ, VERR_INTERNAL_ERROR_2); 1253 1254 /* 1255 * Add it to the stream. 1256 */ 1257 rc = RTVfsFsStrmAdd(hVfsFss, pszFilename, hVfsObj, 0); 1258 RTVfsObjRelease(hVfsObj); 1259 } 1260 1261 return rc; 1262 } 1263 1231 1264 int writeBufferToFile(const char *pcszFilename, void *pvBuf, size_t cbSize, PVDINTERFACEIO pIfIo, void *pvUser) 1232 1265 {
Note:
See TracChangeset
for help on using the changeset viewer.