VirtualBox

Changeset 43689 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Oct 19, 2012 10:54:01 AM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
81517
Message:

Main/Snapshot: issue 4386. Check available free space on the storages before merging. Changings for accordance the coding rules

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/SnapshotImpl.cpp

    r43677 r43689  
    24842484        }
    24852485
    2486         {/* issue 4386 */
     2486        {/* see @bugref{4386} */
    24872487            /*check available place on the storage*/
    2488             RTFOFF pcbTotal=0;
    2489             RTFOFF pcbFree=0;
    2490             uint32_t pcbBlock=0;
    2491             uint32_t pcbSector=0;
     2488            RTFOFF pcbTotal = 0;
     2489            RTFOFF pcbFree = 0;
     2490            uint32_t pcbBlock = 0;
     2491            uint32_t pcbSector = 0;
    24922492            std::multimap<uint32_t,uint64_t> neededStorageFreeSpace;
    24932493            std::map<uint32_t,const char*> serialMapToStoragePath;
     
    24952495            MediumDeleteRecList::const_iterator it_md = toDelete.begin();
    24962496
    2497             while(it_md!=toDelete.end())
     2497            while (it_md != toDelete.end())
    24982498            {
    2499                 uint64_t diskSize=0;
    2500                 uint32_t pu32Serial=0;
     2499                uint64_t diskSize = 0;
     2500                uint32_t pu32Serial = 0;
    25012501                ComObjPtr<Medium> pSource_local = it_md->mpSource;
    25022502                ComObjPtr<Medium> pTarget_local = it_md->mpTarget;
    25032503
    2504                 rc = RTFsQuerySerial(pTarget_local->getLocationFull().c_str(), &pu32Serial);
    2505                 if (FAILED(rc))
    2506                     throw rc;
    2507 
    2508                 /* 0xc0ffee - some magic number from the file fs-stubs-generic.cpp. Case of using stub */
    2509                 if(pu32Serial==0xc0ffee)
     2504                int vrc = RTFsQuerySerial(pTarget_local->getLocationFull().c_str(), &pu32Serial);
     2505                if (RT_FAILURE(vrc))
    25102506                {
    2511                     LogFlowThisFunc(("Can't find storage UID, function isn't implemented...\n"));
    2512                     rc = setError(VERR_NOT_IMPLEMENTED,
    2513                                       tr(" Impossible merging with '%s'. Can't find storage UID, function isn't implemented."),
     2507                    rc = setError(E_FAIL,
     2508                                      tr(" Impossible merging with '%s'. Can't get storage UID."),
    25142509                                      pTarget_local->getLocationFull().c_str());
    25152510                    throw rc;
     
    25252520            }
    25262521
    2527             while(!neededStorageFreeSpace.empty())
     2522            while (!neededStorageFreeSpace.empty())
    25282523            {
    25292524                std::pair<std::multimap<uint32_t,uint64_t>::iterator,std::multimap<uint32_t,uint64_t>::iterator> ret;
     
    25342529                std::multimap<uint32_t,uint64_t>::const_iterator it_ns = ret.first;
    25352530
    2536                 for(;it_ns!=ret.second;++it_ns)
     2531                for (; it_ns != ret.second ; ++it_ns)
    25372532                {
    2538                     commonSourceStoragesSize+=it_ns->second;
     2533                    commonSourceStoragesSize += it_ns->second;
    25392534                }
    25402535
    25412536                /* find appropriate path by storage UID*/
    2542                 std::map<uint32_t,const char*>::const_iterator it_sm = serialMapToStoragePath.find(it_ns->first);
    2543                 /* get info about storage */
    2544                 rc = RTFsQuerySizes(it_sm->second, &pcbTotal, &pcbFree,&pcbBlock, &pcbSector);
    2545                 if (FAILED(rc))
     2537                std::map<uint32_t,const char*>::const_iterator it_sm = serialMapToStoragePath.find(ret.first->first);
     2538                /* get info about a storage */
     2539                if (it_sm == serialMapToStoragePath.end())
     2540                {
     2541                    LogFlowThisFunc(("Path to the storage wasn't found...\n"));
     2542
     2543                    rc = setError(E_INVALIDARG,
     2544                                      tr(" Impossible merging with '%s'. Path to the storage wasn't found."),
     2545                                      it_sm->second);
    25462546                    throw rc;
    2547 
    2548                 if(commonSourceStoragesSize > (uint64_t)pcbFree)
     2547                }
     2548
     2549                int vrc = RTFsQuerySizes(it_sm->second, &pcbTotal, &pcbFree,&pcbBlock, &pcbSector);
     2550                if (RT_FAILURE(vrc))
    25492551                {
    2550                     LogFlowThisFunc(("Free space on the target disk less than needed for merging ...\n"));
    2551                     //what is more suitable?
    2552                     //VERR_NO_TMP_MEMORY, VERR_NO_PHYS_MEMORY, VERR_FILE_AIO_INSUFFICIENT_RESSOURCES, VERR_FILE_AIO_LIMIT_EXCE
    2553                     rc = setError(VERR_FILE_AIO_INSUFFICIENT_RESSOURCES,
    2554                                       tr(" Impossible merging with '%s'. Free space on the target disk less than needed for merging"),
     2552                    rc = setError(E_FAIL,
     2553                                      tr(" Impossible merging with '%s'. Can't get the storage size."),
     2554                                      it_sm->second);
     2555                    throw rc;
     2556                }
     2557
     2558                if (commonSourceStoragesSize > (uint64_t)pcbFree)
     2559                {
     2560                    LogFlowThisFunc(("There isn't enough space than it is needed for merging...\n"));
     2561
     2562                    rc = setError(E_OUTOFMEMORY,
     2563                                      tr(" Impossible merging with '%s'. "
     2564                                         "There isn't enough space than it is needed for merging"),
    25552565                                      it_sm->second);
    25562566                    throw rc;
     
    27882798        }
    27892799    }
    2790     catch (HRESULT aRC) { rc = aRC; }
     2800    catch (HRESULT aRC) {
     2801        rc = aRC;
     2802    }
    27912803
    27922804    if (FAILED(rc))
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