Changeset 67193 in vbox
- Timestamp:
- Jun 1, 2017 8:44:31 AM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 115870
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/Makefile.kmk
r67184 r67193 374 374 $(if $(VBOX_WITH_NEW_USB_CODE_ON_DARWIN),VBOX_WITH_NEW_USB_CODE_ON_DARWIN,) 375 375 endif 376 if defined(VBOX_WITH_NEW_TAR_CREATOR) #|| "$(USERNAME)" == "bird" # temporary376 if defined(VBOX_WITH_NEW_TAR_CREATOR) || "$(USERNAME)" == "bird" # temporary 377 377 VBoxSVC_DEFS += VBOX_WITH_NEW_TAR_CREATOR 378 378 endif -
trunk/src/VBox/Main/include/ApplianceImpl.h
r67184 r67193 219 219 HRESULT i_writeFSOVF(TaskOVF *pTask, AutoWriteLockBase& writeLock); 220 220 HRESULT i_writeFSOVA(TaskOVF *pTask, AutoWriteLockBase& writeLock); 221 HRESULT i_writeFSOPC(TaskOVF *pTask, AutoWriteLockBase& writeLock); 221 222 #ifdef VBOX_WITH_NEW_TAR_CREATOR 222 HRESULT i_writeFSImpl(TaskOVF *pTask, AutoWriteLockBase &writeLock, RTVFSFSSTREAM hVfsFssDst); 223 HRESULT i_writeFSImpl(TaskOVF *pTask, AutoWriteLockBase &writeLock, RTVFSFSSTREAM hVfsFssDst, 224 bool fOvfFile = true, bool fStreamOptimizedVmdk = true); 223 225 HRESULT i_writeBufferToFile(RTVFSFSSTREAM hVfsFssDst, const char *pszFilename, const void *pvContent, size_t cbContent); 224 226 #else -
trunk/src/VBox/Main/src-server/ApplianceImplExport.cpp
r67190 r67193 673 673 return E_ACCESSDENIED; 674 674 675 // see if we can handle this file; for now we insist it has an ".ovf" extension 676 if (!( aPath.endsWith(".ovf", Utf8Str::CaseInsensitive) 677 || aPath.endsWith(".ova", Utf8Str::CaseInsensitive))) 678 return setError(VBOX_E_FILE_ERROR, 679 tr("Appliance file must have .ovf or .ova extension")); 680 675 // figure the export format. We exploit the unknown version value for oracle public cloud. 681 676 ovf::OVFVersion_T ovfF; 682 677 if (aFormat == "ovf-0.9") … … 686 681 else if (aFormat == "ovf-2.0") 687 682 ovfF = ovf::OVFVersion_2_0; 683 else if (aFormat == "opc") 684 ovfF = ovf::OVFVersion_unknown; 688 685 else 689 686 return setError(VBOX_E_FILE_ERROR, 690 687 tr("Invalid format \"%s\" specified"), aFormat.c_str()); 688 689 // Check the extension. 690 if (ovfF == ovf::OVFVersion_unknown) 691 { 692 if (!aPath.endsWith(".tar.gz", Utf8Str::CaseInsensitive)) 693 return setError(VBOX_E_FILE_ERROR, 694 tr("OPC appliance file must have .tar.gz extension")); 695 } 696 else if ( !aPath.endsWith(".ovf", Utf8Str::CaseInsensitive) 697 && !aPath.endsWith(".ova", Utf8Str::CaseInsensitive)) 698 return setError(VBOX_E_FILE_ERROR, tr("Appliance file must have .ovf or .ova extension")); 699 691 700 692 701 /* As of OVF 2.0 we have to use SHA-256 in the manifest. */ … … 1976 1985 m->state = Data::ApplianceExporting; 1977 1986 1978 if (pTask->locInfo.strPath.endsWith(".ovf", Utf8Str::CaseInsensitive)) 1987 if (pTask->enFormat == ovf::OVFVersion_unknown) 1988 #ifdef VBOX_WITH_NEW_TAR_CREATOR 1989 rc = i_writeFSOPC(pTask, multiLock); 1990 #else 1991 rc = E_NOTIMPL; 1992 #endif 1993 else if (pTask->locInfo.strPath.endsWith(".ovf", Utf8Str::CaseInsensitive)) 1979 1994 rc = i_writeFSOVF(pTask, multiLock); 1980 1995 else … … 2182 2197 2183 2198 #ifdef VBOX_WITH_NEW_TAR_CREATOR 2184 HRESULT Appliance::i_writeFSImpl(TaskOVF *pTask, AutoWriteLockBase &writeLock, RTVFSFSSTREAM hVfsFssDst) 2199 /** 2200 * Writes the Oracle Public Cloud appliance. 2201 * 2202 * It expect raw disk images inside a gzipped tarball. We enable sparse files 2203 * to save diskspace on the target host system. 2204 */ 2205 HRESULT Appliance::i_writeFSOPC(TaskOVF *pTask, AutoWriteLockBase &writeLock) 2206 { 2207 LogFlowFuncEnter(); 2208 2209 /* 2210 * Open the output file, pipe it thru gzip and attach a TAR creator. 2211 */ 2212 HRESULT hrc; 2213 RTVFSIOSTREAM hVfsIosFile; 2214 int vrc = RTVfsIoStrmOpenNormal(pTask->locInfo.strPath.c_str(), 2215 RTFILE_O_CREATE | RTFILE_O_WRITE | RTFILE_O_DENY_WRITE, 2216 &hVfsIosFile); 2217 if (RT_SUCCESS(vrc)) 2218 { 2219 2220 RTVFSIOSTREAM hVfsIosGzip; 2221 vrc = RTZipGzipCompressIoStream(hVfsIosFile, 0 /*fFlags*/, 6 /*uLevel*/, &hVfsIosGzip); 2222 RTVfsIoStrmRelease(hVfsIosFile); 2223 if (RT_SUCCESS(vrc)) 2224 { 2225 2226 RTVFSFSSTREAM hVfsFssTar; 2227 vrc = RTZipTarFsStreamToIoStream(hVfsIosGzip, RTZIPTARFORMAT_GNU, RTZIPTAR_C_SPARSE, &hVfsFssTar); 2228 RTVfsIoStrmRelease(hVfsIosGzip); 2229 if (RT_SUCCESS(vrc)) 2230 { 2231 /* 2232 * Before we do the actual writing, disable OVF and manifest creation. 2233 */ 2234 bool fManifestSaved = m->fManifest; 2235 m->fManifest = false; 2236 2237 __debugbreak(); 2238 hrc = i_writeFSImpl(pTask, writeLock, hVfsFssTar, false /*fOvfFile*/, false /*fStreamOptimizedVmdk*/); 2239 RTVfsFsStrmRelease(hVfsFssTar); 2240 2241 m->fManifest = fManifestSaved; 2242 } 2243 else 2244 hrc = setErrorVrc(vrc, tr("Failed create TAR creator for '%s' (%Rrc)"), pTask->locInfo.strPath.c_str(), vrc); 2245 } 2246 else 2247 hrc = setErrorVrc(vrc, tr("Failed create gzipper for '%s' (%Rrc)"), pTask->locInfo.strPath.c_str(), vrc); 2248 2249 /* Delete the OVA on failure. */ 2250 if (FAILED(hrc)) 2251 RTFileDelete(pTask->locInfo.strPath.c_str()); 2252 } 2253 else 2254 hrc = setErrorVrc(vrc, tr("Failed to open '%s' for writing (%Rrc)"), pTask->locInfo.strPath.c_str(), vrc); 2255 2256 LogFlowFuncLeave(); 2257 return hrc; 2258 2259 } 2260 #endif 2261 2262 #ifdef VBOX_WITH_NEW_TAR_CREATOR 2263 HRESULT Appliance::i_writeFSImpl(TaskOVF *pTask, AutoWriteLockBase &writeLock, RTVFSFSSTREAM hVfsFssDst, 2264 bool fOvfFile /*= true*/, bool fStreamOptimizedVmdk /*= true*/) 2185 2265 #else 2186 2266 HRESULT Appliance::i_writeFSImpl(TaskOVF *pTask, AutoWriteLockBase& writeLock, PVDINTERFACEIO pIfIo, PSHASTORAGE pStorage) … … 2214 2294 #endif 2215 2295 2216 /* Render a valid ovf document into a memory buffer. */ 2296 /* Render a valid ovf document into a memory buffer. The unknown 2297 version upgrade relates to the OPC hack up in Appliance::write(). */ 2217 2298 xml::Document doc; 2218 i_buildXML(writeLock, doc, stack, pTask->locInfo.strPath, pTask->enFormat); 2219 2220 void *pvBuf = NULL; 2221 size_t cbSize = 0; 2222 xml::XmlMemWriter writer; 2223 writer.write(doc, &pvBuf, &cbSize); 2224 if (RT_UNLIKELY(!pvBuf)) 2225 throw setError(VBOX_E_FILE_ERROR, 2226 tr("Could not create OVF file '%s'"), 2227 strOvfFile.c_str()); 2228 2229 /* Write the ovf file to "disk". */ 2299 i_buildXML(writeLock, doc, stack, pTask->locInfo.strPath, 2300 pTask->enFormat != ovf::OVFVersion_unknown ? pTask->enFormat : ovf::OVFVersion_2_0); 2301 2230 2302 #ifdef VBOX_WITH_NEW_TAR_CREATOR 2231 rc = i_writeBufferToFile(hVfsFssDst, strOvfFile.c_str(), pvBuf, cbSize); 2232 if (FAILED(rc)) 2233 throw rc; 2303 if (fOvfFile) 2304 #endif 2305 { 2306 void *pvBuf = NULL; 2307 size_t cbSize = 0; 2308 xml::XmlMemWriter writer; 2309 writer.write(doc, &pvBuf, &cbSize); 2310 if (RT_UNLIKELY(!pvBuf)) 2311 throw setError(VBOX_E_FILE_ERROR, tr("Could not create OVF file '%s'"), strOvfFile.c_str()); 2312 2313 /* Write the ovf file to "disk". */ 2314 #ifdef VBOX_WITH_NEW_TAR_CREATOR 2315 rc = i_writeBufferToFile(hVfsFssDst, strOvfFile.c_str(), pvBuf, cbSize); 2316 if (FAILED(rc)) 2317 throw rc; 2234 2318 #else 2235 vrc = writeBufferToFile(strOvfFile.c_str(), pvBuf, cbSize, pIfIo, pStorage);2236 if (RT_FAILURE(vrc))2237 throw setErrorVrc(vrc, tr("Could not create OVF file '%s' (%Rrc)"), strOvfFile.c_str(), vrc);2319 vrc = writeBufferToFile(strOvfFile.c_str(), pvBuf, cbSize, pIfIo, pStorage); 2320 if (RT_FAILURE(vrc)) 2321 throw setErrorVrc(vrc, tr("Could not create OVF file '%s' (%Rrc)"), strOvfFile.c_str(), vrc); 2238 2322 #endif 2239 2323 2240 2324 #ifndef VBOX_WITH_NEW_TAR_CREATOR 2241 fileList.push_back(STRPAIR(strOvfFile, pStorage->strDigest));2325 fileList.push_back(STRPAIR(strOvfFile, pStorage->strDigest)); 2242 2326 #endif 2327 } 2243 2328 } 2244 2329 … … 2348 2433 #ifdef VBOX_WITH_NEW_TAR_CREATOR 2349 2434 /* For compressed VMDK fun, we let i_exportFile produce the image bytes. */ 2350 if ( true)2435 if (fStreamOptimizedVmdk) 2351 2436 { 2352 2437 RTVFSIOSTREAM hVfsIosDst;
Note:
See TracChangeset
for help on using the changeset viewer.