VirtualBox

Changeset 59577 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Feb 4, 2016 2:18:36 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
105389
Message:

Main: Removed the VBOX_WITH_S3 code because we haven't maintained it properly for years.

Location:
trunk/src/VBox/Main
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/Makefile.kmk

    r59473 r59577  
    291291        $(if $(VBOX_WITH_EXTPACK),VBOX_WITH_EXTPACK,) \
    292292        $(if $(VBOX_WITH_VUSB),VBOX_WITH_VUSB,) \
    293         $(if $(VBOX_WITH_S3),VBOX_WITH_S3,) \
    294293        $(if $(VBOX_WITH_PCI_PASSTHROUGH),VBOX_WITH_PCI_PASSTHROUGH,) \
    295294        $(if $(VBOX_WITH_NAT_SERVICE),VBOX_WITH_NAT_SERVICE,) \
  • trunk/src/VBox/Main/include/ApplianceImpl.h

    r59555 r59577  
    158158    HRESULT i_readFSOVA(TaskOVF *pTask);
    159159    HRESULT i_readFSImpl(TaskOVF *pTask, const RTCString &strFilename, PVDINTERFACEIO pCallbacks, PSHASTORAGE pStorage);
    160     HRESULT i_readS3(TaskOVF *pTask);
    161160    /** @}  */
    162161
     
    169168    HRESULT i_importFSOVF(TaskOVF *pTask, AutoWriteLockBase& writeLock);
    170169    HRESULT i_importFSOVA(TaskOVF *pTask, AutoWriteLockBase& writeLock);
    171     HRESULT i_importS3(TaskOVF *pTask);
    172170
    173171    HRESULT i_readFileToBuf(const Utf8Str &strFile,
     
    230228    HRESULT i_writeFSOVA(TaskOVF *pTask, AutoWriteLockBase& writeLock);
    231229    HRESULT i_writeFSImpl(TaskOVF *pTask, AutoWriteLockBase& writeLock, PVDINTERFACEIO pCallbacks, PSHASTORAGE pStorage);
    232     HRESULT i_writeS3(TaskOVF *pTask);
    233230
    234231    struct XMLStack;
  • trunk/src/VBox/Main/include/VFSExplorerImpl.h

    r55611 r59577  
    11/* $Id$ */
    2 
    32/** @file
    4  *
    53 * VirtualBox COM class implementation
    64 */
     
    8179    HRESULT i_updateFS(TaskVFSExplorer *aTask);
    8280    HRESULT i_deleteFS(TaskVFSExplorer *aTask);
    83     HRESULT i_updateS3(TaskVFSExplorer *aTask);
    84     HRESULT i_deleteS3(TaskVFSExplorer *aTask);
    8581
    8682};
    8783
    88 #endif /* ____H_VFSEXPLORERIMPL */
     84#endif /* !____H_VFSEXPLORERIMPL */
    8985
  • trunk/src/VBox/Main/src-server/ApplianceImpl.cpp

    r59268 r59577  
    11871187 * Thread function for the thread started in Appliance::readImpl() and Appliance::importImpl()
    11881188 * and Appliance::writeImpl().
    1189  * This will in turn call Appliance::readFS() or Appliance::readS3() or Appliance::importFS()
    1190  * or Appliance::importS3() or Appliance::writeFS() or Appliance::writeS3().
     1189 *
     1190 * This will in turn call Appliance::readFS() or Appliance::importFS() or
     1191 * Appliance::writeFS().
    11911192 *
    11921193 * @param aThread
     
    12121213                taskrc = pAppliance->i_readFS(task);
    12131214            else if (task->locInfo.storageType == VFSType_S3)
    1214 #ifdef VBOX_WITH_S3
    1215                 taskrc = pAppliance->i_readS3(task);
    1216 #else
    12171215                taskrc = VERR_NOT_IMPLEMENTED;
    1218 #endif
    12191216        break;
    12201217
     
    12231220                taskrc = pAppliance->i_importFS(task);
    12241221            else if (task->locInfo.storageType == VFSType_S3)
    1225 #ifdef VBOX_WITH_S3
    1226                 taskrc = pAppliance->i_importS3(task);
    1227 #else
    12281222                taskrc = VERR_NOT_IMPLEMENTED;
    1229 #endif
    12301223        break;
    12311224
     
    12341227                taskrc = pAppliance->i_writeFS(task);
    12351228            else if (task->locInfo.storageType == VFSType_S3)
    1236 #ifdef VBOX_WITH_S3
    1237                 taskrc = pAppliance->i_writeS3(task);
    1238 #else
    12391229                taskrc = VERR_NOT_IMPLEMENTED;
    1240 #endif
    12411230        break;
    12421231    }
  • trunk/src/VBox/Main/src-server/ApplianceImplExport.cpp

    r58005 r59577  
    729729 * Appliance::taskThreadWriteOVF().
    730730 *
    731  * This is in a separate private method because it is used from two locations:
     731 * This is in a separate private method because it is used from one location:
    732732 *
    733733 * 1) from the public Appliance::Write().
     
    735735 * 2) in a second worker thread; in that case, Appliance::Write() called Appliance::i_writeImpl(), which
    736736 *    called Appliance::i_writeFSOVA(), which called Appliance::i_writeImpl(), which then called this again.
    737  *
    738  * 3) from Appliance::i_writeS3(), which got called from a previous instance of Appliance::taskThreadWriteOVF().
    739737 *
    740738 * @param aFormat
     
    19261924/**
    19271925 * Actual worker code for writing out OVF/OVA to disk. This is called from Appliance::taskThreadWriteOVF()
    1928  * and therefore runs on the OVF/OVA write worker thread. This runs in two contexts:
     1926 * and therefore runs on the OVF/OVA write worker thread.
     1927 *
     1928 * This runs in one context:
    19291929 *
    19301930 * 1) in a first worker thread; in that case, Appliance::Write() called Appliance::i_writeImpl();
    1931  *
    1932  * 2) in a second worker thread; in that case, Appliance::Write() called Appliance::i_writeImpl(), which
    1933  *    called Appliance::i_writeS3(), which called Appliance::i_writeImpl(), which then called this. In other
    1934  *    words, to write to the cloud, the first worker thread first starts a second worker thread to create
    1935  *    temporary files and then uploads them to the S3 cloud server.
    19361931 *
    19371932 * @param pTask
     
    23902385}
    23912386
    2392 #ifdef VBOX_WITH_S3
    2393 /**
    2394  * Worker code for writing out OVF to the cloud. This is called from Appliance::taskThreadWriteOVF()
    2395  * in S3 mode and therefore runs on the OVF write worker thread. This then starts a second worker
    2396  * thread to create temporary files (see Appliance::i_writeFS()).
    2397  *
    2398  * @param pTask
    2399  * @return
    2400  */
    2401 HRESULT Appliance::i_writeS3(TaskOVF *pTask)
    2402 {
    2403     LogFlowFuncEnter();
    2404     LogFlowFunc(("Appliance %p\n", this));
    2405 
    2406     AutoCaller autoCaller(this);
    2407     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    2408 
    2409     HRESULT rc = S_OK;
    2410 
    2411     AutoWriteLock appLock(this COMMA_LOCKVAL_SRC_POS);
    2412 
    2413     int vrc = VINF_SUCCESS;
    2414     RTS3 hS3 = NIL_RTS3;
    2415     char szOSTmpDir[RTPATH_MAX];
    2416     RTPathTemp(szOSTmpDir, sizeof(szOSTmpDir));
    2417     /* The template for the temporary directory created below */
    2418     char *pszTmpDir = RTPathJoinA(szOSTmpDir, "vbox-ovf-XXXXXX");
    2419     list< pair<Utf8Str, ULONG> > filesList;
    2420 
    2421     // todo:
    2422     // - usable error codes
    2423     // - seems snapshot filenames are problematic {uuid}.vdi
    2424     try
    2425     {
    2426         /* Extract the bucket */
    2427         Utf8Str tmpPath = pTask->locInfo.strPath;
    2428         Utf8Str bucket;
    2429         i_parseBucket(tmpPath, bucket);
    2430 
    2431         /* We need a temporary directory which we can put the OVF file & all
    2432          * disk images in */
    2433         vrc = RTDirCreateTemp(pszTmpDir, 0700);
    2434         if (RT_FAILURE(vrc))
    2435             throw setError(VBOX_E_FILE_ERROR,
    2436                            tr("Cannot create temporary directory '%s' (%Rrc)"), pszTmpDir, vrc);
    2437 
    2438         /* The temporary name of the target OVF file */
    2439         Utf8StrFmt strTmpOvf("%s/%s", pszTmpDir, RTPathFilename(tmpPath.c_str()));
    2440 
    2441         /* Prepare the temporary writing of the OVF */
    2442         ComObjPtr<Progress> progress;
    2443         /* Create a temporary file based location info for the sub task */
    2444         LocationInfo li;
    2445         li.strPath = strTmpOvf;
    2446         rc = i_writeImpl(pTask->enFormat, li, progress);
    2447         if (FAILED(rc)) throw rc;
    2448 
    2449         /* Unlock the appliance for the writing thread */
    2450         appLock.release();
    2451         /* Wait until the writing is done, but report the progress back to the
    2452            caller */
    2453         ComPtr<IProgress> progressInt(progress);
    2454         i_waitForAsyncProgress(pTask->pProgress, progressInt); /* Any errors will be thrown */
    2455 
    2456         /* Again lock the appliance for the next steps */
    2457         appLock.acquire();
    2458 
    2459         vrc = RTPathExists(strTmpOvf.c_str()); /* Paranoid check */
    2460         if (RT_FAILURE(vrc))
    2461             throw setError(VBOX_E_FILE_ERROR,
    2462                            tr("Cannot find source file '%s' (%Rrc)"), strTmpOvf.c_str(), vrc);
    2463         /* Add the OVF file */
    2464         filesList.push_back(pair<Utf8Str, ULONG>(strTmpOvf, m->ulWeightForXmlOperation)); /* Use 1% of the
    2465                                                                                              total for the OVF file upload */
    2466         /* Add the manifest file */
    2467         if (m->fManifest)
    2468         {
    2469             Utf8Str strMfFile = Utf8Str(strTmpOvf).stripSuffix().append(".mf");
    2470             filesList.push_back(pair<Utf8Str, ULONG>(strMfFile , m->ulWeightForXmlOperation)); /* Use 1% of the total
    2471                                                                                                   for the manifest file upload */
    2472         }
    2473 
    2474         /* Now add every disks of every virtual system */
    2475         list< ComObjPtr<VirtualSystemDescription> >::const_iterator it;
    2476         for (it = m->virtualSystemDescriptions.begin();
    2477              it != m->virtualSystemDescriptions.end();
    2478              ++it)
    2479         {
    2480             ComObjPtr<VirtualSystemDescription> vsdescThis = (*it);
    2481             std::list<VirtualSystemDescriptionEntry*> avsdeHDs =
    2482                 vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskImage);
    2483             std::list<VirtualSystemDescriptionEntry*>::const_iterator itH;
    2484             for (itH = avsdeHDs.begin();
    2485                  itH != avsdeHDs.end();
    2486                  ++itH)
    2487             {
    2488                 const Utf8Str &strTargetFileNameOnly = (*itH)->strOvf;
    2489                 /* Target path needs to be composed from where the output OVF is */
    2490                 Utf8Str strTargetFilePath(strTmpOvf);
    2491                 strTargetFilePath.stripFilename();
    2492                 strTargetFilePath.append("/");
    2493                 strTargetFilePath.append(strTargetFileNameOnly);
    2494                 vrc = RTPathExists(strTargetFilePath.c_str()); /* Paranoid check */
    2495                 if (RT_FAILURE(vrc))
    2496                     throw setError(VBOX_E_FILE_ERROR,
    2497                                    tr("Cannot find source file '%s' (%Rrc)"), strTargetFilePath.c_str(), vrc);
    2498                 filesList.push_back(pair<Utf8Str, ULONG>(strTargetFilePath, (*itH)->ulSizeMB));
    2499             }
    2500         }
    2501         /* Next we have to upload the OVF & all disk images */
    2502         vrc = RTS3Create(&hS3, pTask->locInfo.strUsername.c_str(), pTask->locInfo.strPassword.c_str(),
    2503                          pTask->locInfo.strHostname.c_str(), "virtualbox-agent/" VBOX_VERSION_STRING);
    2504         if (RT_FAILURE(vrc))
    2505             throw setError(VBOX_E_IPRT_ERROR,
    2506                            tr("Cannot create S3 service handler"));
    2507         RTS3SetProgressCallback(hS3, pTask->updateProgress, &pTask);
    2508 
    2509         /* Upload all files */
    2510         for (list< pair<Utf8Str, ULONG> >::const_iterator it1 = filesList.begin(); it1 != filesList.end(); ++it1)
    2511         {
    2512             const pair<Utf8Str, ULONG> &s = (*it1);
    2513             char *pszFilename = RTPathFilename(s.first.c_str());
    2514             /* Advance to the next operation */
    2515             pTask->pProgress->SetNextOperation(BstrFmt(tr("Uploading file '%s'"), pszFilename).raw(), s.second);
    2516             vrc = RTS3PutKey(hS3, bucket.c_str(), pszFilename, s.first.c_str());
    2517             if (RT_FAILURE(vrc))
    2518             {
    2519                 if (vrc == VERR_S3_CANCELED)
    2520                     break;
    2521                 else if (vrc == VERR_S3_ACCESS_DENIED)
    2522                     throw setError(E_ACCESSDENIED,
    2523                                    tr("Cannot upload file '%s' to S3 storage server (Access denied). Make sure that your credentials are right. Also check that your host clock is properly synced"), pszFilename);
    2524                 else if (vrc == VERR_S3_NOT_FOUND)
    2525                     throw setError(VBOX_E_FILE_ERROR,
    2526                                    tr("Cannot upload file '%s' to S3 storage server (File not found)"), pszFilename);
    2527                 else
    2528                     throw setError(VBOX_E_IPRT_ERROR,
    2529                                    tr("Cannot upload file '%s' to S3 storage server (%Rrc)"), pszFilename, vrc);
    2530             }
    2531         }
    2532     }
    2533     catch(HRESULT aRC)
    2534     {
    2535         rc = aRC;
    2536     }
    2537     /* Cleanup */
    2538     RTS3Destroy(hS3);
    2539     /* Delete all files which where temporary created */
    2540     for (list< pair<Utf8Str, ULONG> >::const_iterator it1 = filesList.begin(); it1 != filesList.end(); ++it1)
    2541     {
    2542         const char *pszFilePath = (*it1).first.c_str();
    2543         if (RTPathExists(pszFilePath))
    2544         {
    2545             vrc = RTFileDelete(pszFilePath);
    2546             if (RT_FAILURE(vrc))
    2547                 rc = setError(VBOX_E_FILE_ERROR,
    2548                               tr("Cannot delete file '%s' (%Rrc)"), pszFilePath, vrc);
    2549         }
    2550     }
    2551     /* Delete the temporary directory */
    2552     if (RTPathExists(pszTmpDir))
    2553     {
    2554         vrc = RTDirRemove(pszTmpDir);
    2555         if (RT_FAILURE(vrc))
    2556             rc = setError(VBOX_E_FILE_ERROR,
    2557                           tr("Cannot delete temporary directory '%s' (%Rrc)"), pszTmpDir, vrc);
    2558     }
    2559     if (pszTmpDir)
    2560         RTStrFree(pszTmpDir);
    2561 
    2562     LogFlowFunc(("rc=%Rhrc\n", rc));
    2563     LogFlowFuncLeave();
    2564 
    2565     return rc;
    2566 }
    2567 #endif /* VBOX_WITH_S3 */
  • trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp

    r59576 r59577  
    833833 *
    834834 * This starts a new thread which will call
    835  * Appliance::taskThreadImportOrExport() which will then call readFS() or
    836  * readS3(). This will then open the OVF with ovfreader.cpp.
     835 * Appliance::taskThreadImportOrExport() which will then call readFS(). This
     836 * will then open the OVF with ovfreader.cpp.
    837837 *
    838  * This is in a separate private method because it is used from three locations:
     838 * This is in a separate private method because it is used from two locations:
    839839 *
    840840 * 1) from the public Appliance::Read().
     
    842842 * 2) in a second worker thread; in that case, Appliance::ImportMachines() called Appliance::i_importImpl(), which
    843843 *    called Appliance::readFSOVA(), which called Appliance::i_importImpl(), which then called this again.
    844  *
    845  * 3) from Appliance::readS3(), which got called from a previous instance of Appliance::taskThreadImportOrExport().
    846844 *
    847845 * @param   aLocInfo    The OVF location.
     
    896894 * and therefore runs on the OVF read worker thread. This opens the OVF with ovfreader.cpp.
    897895 *
    898  * This runs in two contexts:
     896 * This runs in one context:
    899897 *
    900898 * 1) in a first worker thread; in that case, Appliance::Read() called Appliance::readImpl();
    901  *
    902  * 2) in a second worker thread; in that case, Appliance::Read() called Appliance::readImpl(), which
    903  *    called Appliance::readS3(), which called Appliance::readImpl(), which then called this.
    904899 *
    905900 * @param pTask
     
    11621157}
    11631158
    1164 #ifdef VBOX_WITH_S3
    1165 /**
    1166  * Worker code for reading OVF from the cloud. This is called from Appliance::taskThreadImportOrExport()
    1167  * in S3 mode and therefore runs on the OVF read worker thread. This then starts a second worker
    1168  * thread to create temporary files (see Appliance::readFS()).
    1169  *
    1170  * @param pTask
    1171  * @return
    1172  */
    1173 HRESULT Appliance::i_readS3(TaskOVF *pTask)
    1174 {
    1175     LogFlowFuncEnter();
    1176     LogFlowFunc(("Appliance %p\n", this));
    1177 
    1178     AutoCaller autoCaller(this);
    1179     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    1180 
    1181     AutoWriteLock appLock(this COMMA_LOCKVAL_SRC_POS);
    1182 
    1183     HRESULT rc = S_OK;
    1184     int vrc = VINF_SUCCESS;
    1185     RTS3 hS3 = NIL_RTS3;
    1186     char szOSTmpDir[RTPATH_MAX];
    1187     RTPathTemp(szOSTmpDir, sizeof(szOSTmpDir));
    1188     /* The template for the temporary directory created below */
    1189     char *pszTmpDir = RTPathJoinA(szOSTmpDir, "vbox-ovf-XXXXXX");
    1190     list< pair<Utf8Str, ULONG> > filesList;
    1191     Utf8Str strTmpOvf;
    1192 
    1193     try
    1194     {
    1195         /* Extract the bucket */
    1196         Utf8Str tmpPath = pTask->locInfo.strPath;
    1197         Utf8Str bucket;
    1198         i_parseBucket(tmpPath, bucket);
    1199 
    1200         /* We need a temporary directory which we can put the OVF file & all
    1201          * disk images in */
    1202         vrc = RTDirCreateTemp(pszTmpDir, 0700);
    1203         if (RT_FAILURE(vrc))
    1204             throw setError(VBOX_E_FILE_ERROR,
    1205                            tr("Cannot create temporary directory '%s'"), pszTmpDir);
    1206 
    1207         /* The temporary name of the target OVF file */
    1208         strTmpOvf = Utf8StrFmt("%s/%s", pszTmpDir, RTPathFilename(tmpPath.c_str()));
    1209 
    1210         /* Next we have to download the OVF */
    1211         vrc = RTS3Create(&hS3,
    1212                          pTask->locInfo.strUsername.c_str(),
    1213                          pTask->locInfo.strPassword.c_str(),
    1214                          pTask->locInfo.strHostname.c_str(),
    1215                          "virtualbox-agent/" VBOX_VERSION_STRING);
    1216         if (RT_FAILURE(vrc))
    1217             throw setError(VBOX_E_IPRT_ERROR,
    1218                            tr("Cannot create S3 service handler"));
    1219         RTS3SetProgressCallback(hS3, pTask->updateProgress, &pTask);
    1220 
    1221         /* Get it */
    1222         char *pszFilename = RTPathFilename(strTmpOvf.c_str());
    1223         vrc = RTS3GetKey(hS3, bucket.c_str(), pszFilename, strTmpOvf.c_str());
    1224         if (RT_FAILURE(vrc))
    1225         {
    1226             if (vrc == VERR_S3_CANCELED)
    1227                 throw S_OK; /* todo: !!!!!!!!!!!!! */
    1228             else if (vrc == VERR_S3_ACCESS_DENIED)
    1229                 throw setError(E_ACCESSDENIED,
    1230                                tr("Cannot download file '%s' from S3 storage server (Access denied). Make sure that "
    1231                                   "your credentials are right. "
    1232                                   "Also check that your host clock is properly synced"),
    1233                                pszFilename);
    1234             else if (vrc == VERR_S3_NOT_FOUND)
    1235                 throw setError(VBOX_E_FILE_ERROR,
    1236                                tr("Cannot download file '%s' from S3 storage server (File not found)"), pszFilename);
    1237             else
    1238                 throw setError(VBOX_E_IPRT_ERROR,
    1239                                tr("Cannot download file '%s' from S3 storage server (%Rrc)"), pszFilename, vrc);
    1240         }
    1241 
    1242         /* Close the connection early */
    1243         RTS3Destroy(hS3);
    1244         hS3 = NIL_RTS3;
    1245 
    1246         pTask->pProgress->SetNextOperation(Bstr(tr("Reading")).raw(), 1);
    1247 
    1248         /* Prepare the temporary reading of the OVF */
    1249         ComObjPtr<Progress> progress;
    1250         LocationInfo li;
    1251         li.strPath = strTmpOvf;
    1252         /* Start the reading from the fs */
    1253         rc = i_readImpl(li, progress);
    1254         if (FAILED(rc)) throw rc;
    1255 
    1256         /* Unlock the appliance for the reading thread */
    1257         appLock.release();
    1258         /* Wait until the reading is done, but report the progress back to the
    1259            caller */
    1260         ComPtr<IProgress> progressInt(progress);
    1261         i_waitForAsyncProgress(pTask->pProgress, progressInt); /* Any errors will be thrown */
    1262 
    1263         /* Again lock the appliance for the next steps */
    1264         appLock.acquire();
    1265     }
    1266     catch(HRESULT aRC)
    1267     {
    1268         rc = aRC;
    1269     }
    1270     /* Cleanup */
    1271     RTS3Destroy(hS3);
    1272     /* Delete all files which where temporary created */
    1273     if (RTPathExists(strTmpOvf.c_str()))
    1274     {
    1275         vrc = RTFileDelete(strTmpOvf.c_str());
    1276         if (RT_FAILURE(vrc))
    1277             rc = setError(VBOX_E_FILE_ERROR,
    1278                           tr("Cannot delete file '%s' (%Rrc)"), strTmpOvf.c_str(), vrc);
    1279     }
    1280     /* Delete the temporary directory */
    1281     if (RTPathExists(pszTmpDir))
    1282     {
    1283         vrc = RTDirRemove(pszTmpDir);
    1284         if (RT_FAILURE(vrc))
    1285             rc = setError(VBOX_E_FILE_ERROR,
    1286                           tr("Cannot delete temporary directory '%s' (%Rrc)"), pszTmpDir, vrc);
    1287     }
    1288     if (pszTmpDir)
    1289         RTStrFree(pszTmpDir);
    1290 
    1291     LogFlowFunc(("rc=%Rhrc\n", rc));
    1292     LogFlowFuncLeave();
    1293 
    1294     return rc;
    1295 }
    1296 #endif /* VBOX_WITH_S3 */
    12971159
    12981160/*******************************************************************************
     
    13071169 * Appliance::Interpret().
    13081170 *
    1309  * This is in a separate private method because it is used from two locations:
     1171 * This is in a separate private method because it is used from one location:
    13101172 *
    13111173 * 1) from the public Appliance::ImportMachines().
    1312  * 2) from Appliance::i_importS3(), which got called from a previous instance of Appliance::taskThreadImportOrExport().
    13131174 *
    13141175 * @param aLocInfo
     
    13591220 * Appliance::Interpret().
    13601221 *
    1361  * This runs in three contexts:
     1222 * This runs in two contexts:
    13621223 *
    13631224 * 1) in a first worker thread; in that case, Appliance::ImportMachines() called Appliance::i_importImpl();
     
    13651226 * 2) in a second worker thread; in that case, Appliance::ImportMachines() called Appliance::i_importImpl(), which
    13661227 *    called Appliance::i_i_importFSOVA(), which called Appliance::i_importImpl(), which then called this again.
    1367  *
    1368  * 3) in a second worker thread; in that case, Appliance::ImportMachines() called Appliance::i_importImpl(), which
    1369  *    called Appliance::i_importS3(), which called Appliance::i_importImpl(), which then called this again.
    13701228 *
    13711229 * @param   pTask       The OVF task data.
     
    18111669    return rc;
    18121670}
    1813 
    1814 #ifdef VBOX_WITH_S3
    1815 /**
    1816  * Worker code for importing OVF from the cloud. This is called from Appliance::taskThreadImportOrExport()
    1817  * in S3 mode and therefore runs on the OVF import worker thread. This then starts a second worker
    1818  * thread to import from temporary files (see Appliance::i_importFS()).
    1819  * @param pTask
    1820  * @return
    1821  */
    1822 HRESULT Appliance::i_importS3(TaskOVF *pTask)
    1823 {
    1824     LogFlowFuncEnter();
    1825     LogFlowFunc(("Appliance %p\n", this));
    1826 
    1827     AutoWriteLock appLock(this COMMA_LOCKVAL_SRC_POS);
    1828 
    1829     int vrc = VINF_SUCCESS;
    1830     RTS3 hS3 = NIL_RTS3;
    1831     char szOSTmpDir[RTPATH_MAX];
    1832     RTPathTemp(szOSTmpDir, sizeof(szOSTmpDir));
    1833     /* The template for the temporary directory created below */
    1834     char *pszTmpDir = RTPathJoinA(szOSTmpDir, "vbox-ovf-XXXXXX");
    1835     list< pair<Utf8Str, ULONG> > filesList;
    1836 
    1837     HRESULT rc = S_OK;
    1838     try
    1839     {
    1840         /* Extract the bucket */
    1841         Utf8Str tmpPath = pTask->locInfo.strPath;
    1842         Utf8Str bucket;
    1843         i_parseBucket(tmpPath, bucket);
    1844 
    1845         /* We need a temporary directory which we can put the all disk images
    1846          * in */
    1847         vrc = RTDirCreateTemp(pszTmpDir, 0700);
    1848         if (RT_FAILURE(vrc))
    1849             throw setError(VBOX_E_FILE_ERROR,
    1850                            tr("Cannot create temporary directory '%s' (%Rrc)"), pszTmpDir, vrc);
    1851 
    1852         /* Add every disks of every virtual system to an internal list */
    1853         list< ComObjPtr<VirtualSystemDescription> >::const_iterator it;
    1854         for (it = m->virtualSystemDescriptions.begin();
    1855              it != m->virtualSystemDescriptions.end();
    1856              ++it)
    1857         {
    1858             ComObjPtr<VirtualSystemDescription> vsdescThis = (*it);
    1859             std::list<VirtualSystemDescriptionEntry*> avsdeHDs =
    1860                 vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskImage);
    1861             std::list<VirtualSystemDescriptionEntry*>::const_iterator itH;
    1862             for (itH = avsdeHDs.begin();
    1863                  itH != avsdeHDs.end();
    1864                  ++itH)
    1865             {
    1866                 const Utf8Str &strTargetFile = (*itH)->strOvf;
    1867                 if (!strTargetFile.isEmpty())
    1868                 {
    1869                     /* The temporary name of the target disk file */
    1870                     Utf8StrFmt strTmpDisk("%s/%s", pszTmpDir, RTPathFilename(strTargetFile.c_str()));
    1871                     filesList.push_back(pair<Utf8Str, ULONG>(strTmpDisk, (*itH)->ulSizeMB));
    1872                 }
    1873             }
    1874         }
    1875 
    1876         /* Next we have to download the disk images */
    1877         vrc = RTS3Create(&hS3,
    1878                          pTask->locInfo.strUsername.c_str(),
    1879                          pTask->locInfo.strPassword.c_str(),
    1880                          pTask->locInfo.strHostname.c_str(),
    1881                          "virtualbox-agent/" VBOX_VERSION_STRING);
    1882         if (RT_FAILURE(vrc))
    1883             throw setError(VBOX_E_IPRT_ERROR,
    1884                            tr("Cannot create S3 service handler"));
    1885         RTS3SetProgressCallback(hS3, pTask->updateProgress, &pTask);
    1886 
    1887         /* Download all files */
    1888         for (list< pair<Utf8Str, ULONG> >::const_iterator it1 = filesList.begin(); it1 != filesList.end(); ++it1)
    1889         {
    1890             const pair<Utf8Str, ULONG> &s = (*it1);
    1891             const Utf8Str &strSrcFile = s.first;
    1892             /* Construct the source file name */
    1893             char *pszFilename = RTPathFilename(strSrcFile.c_str());
    1894             /* Advance to the next operation */
    1895             if (!pTask->pProgress.isNull())
    1896                 pTask->pProgress->SetNextOperation(BstrFmt(tr("Downloading file '%s'"), pszFilename).raw(), s.second);
    1897 
    1898             vrc = RTS3GetKey(hS3, bucket.c_str(), pszFilename, strSrcFile.c_str());
    1899             if (RT_FAILURE(vrc))
    1900             {
    1901                 if (vrc == VERR_S3_CANCELED)
    1902                     throw S_OK; /* todo: !!!!!!!!!!!!! */
    1903                 else if (vrc == VERR_S3_ACCESS_DENIED)
    1904                     throw setError(E_ACCESSDENIED,
    1905                                    tr("Cannot download file '%s' from S3 storage server (Access denied). "
    1906                                       "Make sure that your credentials are right. Also check that your host clock is "
    1907                                       "properly synced"),
    1908                                    pszFilename);
    1909                 else if (vrc == VERR_S3_NOT_FOUND)
    1910                     throw setError(VBOX_E_FILE_ERROR,
    1911                                    tr("Cannot download file '%s' from S3 storage server (File not found)"),
    1912                                    pszFilename);
    1913                 else
    1914                     throw setError(VBOX_E_IPRT_ERROR,
    1915                                    tr("Cannot download file '%s' from S3 storage server (%Rrc)"),
    1916                                    pszFilename, vrc);
    1917             }
    1918         }
    1919 
    1920         /* Provide a OVF file (haven't to exist) so the import routine can
    1921          * figure out where the disk images/manifest file are located. */
    1922         Utf8StrFmt strTmpOvf("%s/%s", pszTmpDir, RTPathFilename(tmpPath.c_str()));
    1923         /* Now check if there is an manifest file. This is optional. */
    1924         Utf8Str strManifestFile; //= queryManifestFileName(strTmpOvf);
    1925 //        Utf8Str strManifestFile = queryManifestFileName(strTmpOvf);
    1926         char *pszFilename = RTPathFilename(strManifestFile.c_str());
    1927         if (!pTask->pProgress.isNull())
    1928             pTask->pProgress->SetNextOperation(BstrFmt(tr("Downloading file '%s'"), pszFilename).raw(), 1);
    1929 
    1930         /* Try to download it. If the error is VERR_S3_NOT_FOUND, it isn't fatal. */
    1931         vrc = RTS3GetKey(hS3, bucket.c_str(), pszFilename, strManifestFile.c_str());
    1932         if (RT_SUCCESS(vrc))
    1933             filesList.push_back(pair<Utf8Str, ULONG>(strManifestFile, 0));
    1934         else if (RT_FAILURE(vrc))
    1935         {
    1936             if (vrc == VERR_S3_CANCELED)
    1937                 throw S_OK; /* todo: !!!!!!!!!!!!! */
    1938             else if (vrc == VERR_S3_NOT_FOUND)
    1939                 vrc = VINF_SUCCESS; /* Not found is ok */
    1940             else if (vrc == VERR_S3_ACCESS_DENIED)
    1941                 throw setError(E_ACCESSDENIED,
    1942                                tr("Cannot download file '%s' from S3 storage server (Access denied)."
    1943                                   "Make sure that your credentials are right. "
    1944                                   "Also check that your host clock is properly synced"),
    1945                                pszFilename);
    1946             else
    1947                 throw setError(VBOX_E_IPRT_ERROR,
    1948                                tr("Cannot download file '%s' from S3 storage server (%Rrc)"),
    1949                                pszFilename, vrc);
    1950         }
    1951 
    1952         /* Close the connection early */
    1953         RTS3Destroy(hS3);
    1954         hS3 = NIL_RTS3;
    1955 
    1956         pTask->pProgress->SetNextOperation(BstrFmt(tr("Importing appliance")).raw(), m->ulWeightForXmlOperation);
    1957 
    1958         ComObjPtr<Progress> progress;
    1959         /* Import the whole temporary OVF & the disk images */
    1960         LocationInfo li;
    1961         li.strPath = strTmpOvf;
    1962         rc = i_importImpl(li, progress);
    1963         if (FAILED(rc)) throw rc;
    1964 
    1965         /* Unlock the appliance for the fs import thread */
    1966         appLock.release();
    1967         /* Wait until the import is done, but report the progress back to the
    1968            caller */
    1969         ComPtr<IProgress> progressInt(progress);
    1970         i_waitForAsyncProgress(pTask->pProgress, progressInt); /* Any errors will be thrown */
    1971 
    1972         /* Again lock the appliance for the next steps */
    1973         appLock.acquire();
    1974     }
    1975     catch(HRESULT aRC)
    1976     {
    1977         rc = aRC;
    1978     }
    1979     /* Cleanup */
    1980     RTS3Destroy(hS3);
    1981     /* Delete all files which where temporary created */
    1982     for (list< pair<Utf8Str, ULONG> >::const_iterator it1 = filesList.begin(); it1 != filesList.end(); ++it1)
    1983     {
    1984         const char *pszFilePath = (*it1).first.c_str();
    1985         if (RTPathExists(pszFilePath))
    1986         {
    1987             vrc = RTFileDelete(pszFilePath);
    1988             if (RT_FAILURE(vrc))
    1989                 rc = setError(VBOX_E_FILE_ERROR,
    1990                               tr("Cannot delete file '%s' (%Rrc)"), pszFilePath, vrc);
    1991         }
    1992     }
    1993     /* Delete the temporary directory */
    1994     if (RTPathExists(pszTmpDir))
    1995     {
    1996         vrc = RTDirRemove(pszTmpDir);
    1997         if (RT_FAILURE(vrc))
    1998             rc = setError(VBOX_E_FILE_ERROR,
    1999                           tr("Cannot delete temporary directory '%s' (%Rrc)"), pszTmpDir, vrc);
    2000     }
    2001     if (pszTmpDir)
    2002         RTStrFree(pszTmpDir);
    2003 
    2004     LogFlowFunc(("rc=%Rhrc\n", rc));
    2005     LogFlowFuncLeave();
    2006 
    2007     return rc;
    2008 }
    2009 #endif /* VBOX_WITH_S3 */
    20101671
    20111672HRESULT Appliance::i_readFileToBuf(const Utf8Str &strFile,
  • trunk/src/VBox/Main/src-server/VFSExplorerImpl.cpp

    r57415 r59577  
    11/* $Id$ */
    22/** @file
    3  *
    43 * IVFSExplorer COM class implementations.
    54 */
     
    211210                rc = pVFSExplorer->i_updateFS(task.get());
    212211            else if (pVFSExplorer->m->storageType == VFSType_S3)
    213 #ifdef VBOX_WITH_S3
    214                 rc = pVFSExplorer->i_updateS3(task.get());
    215 #else
    216212                rc = VERR_NOT_IMPLEMENTED;
    217 #endif
    218213            break;
    219214        }
     
    223218                rc = pVFSExplorer->i_deleteFS(task.get());
    224219            else if (pVFSExplorer->m->storageType == VFSType_S3)
    225 #ifdef VBOX_WITH_S3
    226                 rc = pVFSExplorer->i_deleteS3(task.get());
    227 #else
    228220                rc = VERR_NOT_IMPLEMENTED;
    229 #endif
    230221            break;
    231222        }
     
    397388}
    398389
    399 #ifdef VBOX_WITH_S3
    400 HRESULT VFSExplorer::i_updateS3(TaskVFSExplorer *aTask)
    401 {
    402     LogFlowFuncEnter();
    403 
    404     AutoCaller autoCaller(this);
    405     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    406 
    407     AutoWriteLock appLock(this COMMA_LOCKVAL_SRC_POS);
    408 
    409     HRESULT rc = S_OK;
    410 
    411     RTS3 hS3 = NULL;
    412     std::list<VFSExplorer::Data::DirEntry> fileList;
    413     try
    414     {
    415         int vrc = RTS3Create(&hS3, m->strUsername.c_str(), m->strPassword.c_str(),
    416                              m->strHostname.c_str(), "virtualbox-agent/" VBOX_VERSION_STRING);
    417         if (RT_FAILURE(vrc))
    418             throw setError(E_FAIL, tr ("Can't open S3 storage service (%Rrc)"), vrc);
    419 
    420         RTS3SetProgressCallback(hS3, VFSExplorer::TaskVFSExplorer::uploadProgress, &aTask);
    421         /* Do we need the list of buckets or keys? */
    422         if (m->strBucket.isEmpty())
    423         {
    424             PCRTS3BUCKETENTRY pBuckets = NULL;
    425             vrc = RTS3GetBuckets(hS3, &pBuckets);
    426             if (RT_FAILURE(vrc))
    427                 throw setError(E_FAIL, tr ("Can't get buckets (%Rrc)"), vrc);
    428 
    429             PCRTS3BUCKETENTRY pTmpBuckets = pBuckets;
    430             while (pBuckets)
    431             {
    432                 /* Set always read/write permissions of the current logged in user. */
    433                 fileList.push_back(VFSExplorer::Data::DirEntry(pBuckets->pszName, FsObjType_Directory,
    434                                    0, RTFS_UNIX_IRUSR | RTFS_UNIX_IWUSR));
    435                 pBuckets = pBuckets->pNext;
    436             }
    437             RTS3BucketsDestroy(pTmpBuckets);
    438         }
    439         else
    440         {
    441             PCRTS3KEYENTRY pKeys = NULL;
    442             vrc = RTS3GetBucketKeys(hS3, m->strBucket.c_str(), &pKeys);
    443             if (RT_FAILURE(vrc))
    444                 throw setError(E_FAIL, tr ("Can't get keys for bucket (%Rrc)"), vrc);
    445 
    446             PCRTS3KEYENTRY pTmpKeys = pKeys;
    447             while (pKeys)
    448             {
    449                 Utf8Str name(pKeys->pszName);
    450                 /* Set always read/write permissions of the current logged in user. */
    451                 fileList.push_back(VFSExplorer::Data::DirEntry(pKeys->pszName, FsObjType_File, pKeys->cbFile,
    452                                    RTFS_UNIX_IRUSR | RTFS_UNIX_IWUSR));
    453                 pKeys = pKeys->pNext;
    454             }
    455             RTS3KeysDestroy(pTmpKeys);
    456         }
    457     }
    458     catch(HRESULT aRC)
    459     {
    460         rc = aRC;
    461     }
    462 
    463     if (hS3 != NULL)
    464         RTS3Destroy(hS3);
    465 
    466     /* Assign the result on success (this clears the old list) */
    467     if (rc == S_OK)
    468         m->entryList.assign(fileList.begin(), fileList.end());
    469 
    470     aTask->rc = rc;
    471 
    472     if (!aTask->progress.isNull())
    473         aTask->progress->i_notifyComplete(rc);
    474 
    475     LogFlowFunc(("rc=%Rhrc\n", rc));
    476     LogFlowFuncLeave();
    477 
    478     return VINF_SUCCESS;
    479 }
    480 
    481 HRESULT VFSExplorer::i_deleteS3(TaskVFSExplorer *aTask)
    482 {
    483     LogFlowFuncEnter();
    484 
    485     AutoCaller autoCaller(this);
    486     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    487 
    488     AutoWriteLock appLock(this COMMA_LOCKVAL_SRC_POS);
    489 
    490     HRESULT rc = S_OK;
    491 
    492     RTS3 hS3 = NULL;
    493     float fPercentStep = 100.0f / aTask->filenames.size();
    494     try
    495     {
    496         int vrc = RTS3Create(&hS3, m->strUsername.c_str(), m->strPassword.c_str(),
    497                              m->strHostname.c_str(), "virtualbox-agent/" VBOX_VERSION_STRING);
    498         if (RT_FAILURE(vrc))
    499             throw setError(E_FAIL, tr ("Can't open S3 storage service (%Rrc)"), vrc);
    500 
    501         RTS3SetProgressCallback(hS3, VFSExplorer::TaskVFSExplorer::uploadProgress, &aTask);
    502 
    503         std::list<Utf8Str>::const_iterator it;
    504         size_t i = 0;
    505         for (it = aTask->filenames.begin();
    506              it != aTask->filenames.end();
    507              ++it, ++i)
    508         {
    509             vrc = RTS3DeleteKey(hS3, m->strBucket.c_str(), (*it).c_str());
    510             if (RT_FAILURE(vrc))
    511                 throw setError(VBOX_E_FILE_ERROR, tr ("Can't delete file '%s' (%Rrc)"), (*it).c_str(), vrc);
    512             if (aTask->progress)
    513                 aTask->progress->SetCurrentOperationProgress((ULONG)(fPercentStep * i));
    514         }
    515     }
    516     catch(HRESULT aRC)
    517     {
    518         rc = aRC;
    519     }
    520 
    521     aTask->rc = rc;
    522 
    523     if (hS3 != NULL)
    524         RTS3Destroy(hS3);
    525 
    526     if (!aTask->progress.isNull())
    527         aTask->progress->i_notifyComplete(rc);
    528 
    529     LogFlowFunc(("rc=%Rhrc\n", rc));
    530     LogFlowFuncLeave();
    531 
    532     return VINF_SUCCESS;
    533 }
    534 #endif /* VBOX_WITH_S3 */
    535 
    536390HRESULT VFSExplorer::update(ComPtr<IProgress> &aProgress)
    537391{
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette