VirtualBox

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


Ignore:
Timestamp:
Jul 11, 2020 2:28:23 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139196
Message:

Main/ApplianceImplImport.cpp: Fixed a bunch of VERR/HRESULT mixups, Appliance::i_gettingCloudData was especially bad considering that it's a recent function. Misc other things Clang 11 got upset about. bugref:9790

File:
1 edited

Legend:

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

    r84535 r85219  
    12231223    {
    12241224        Utf8Str strBasename(pTask->locInfo.strPath);
    1225         RTCList<RTCString, RTCString *> parts = strBasename.split("/" );
     1225        RTCList<RTCString, RTCString *> parts = strBasename.split("/");
    12261226        if (parts.size() != 2)//profile + instance id
    1227         {
    1228             return setErrorVrc(VERR_MISMATCH, tr("%s: The profile name or instance id are absent or"
    1229                                                  "contain unsupported characters.", __FUNCTION__));
    1230         }
     1227            return setErrorVrc(VERR_MISMATCH,
     1228                               tr("%s: The profile name or instance id are absent or contain unsupported characters: %s"),
     1229                               __FUNCTION__, strBasename.c_str());
    12311230
    12321231        //Get information about the passed cloud instance
     
    12341233        hrc = mVirtualBox->COMGETTER(CloudProviderManager)(cpm.asOutParam());
    12351234        if (FAILED(hrc))
    1236             return setErrorVrc(VERR_COM_OBJECT_NOT_FOUND, tr("%s: Cloud provider manager object wasn't found"), __FUNCTION__);
     1235            return setError(VBOX_E_OBJECT_NOT_FOUND, tr("%s: Cloud provider manager object wasn't found (%Rhrc)"), __FUNCTION__, hrc);
    12371236
    12381237        Utf8Str strProviderName = pTask->locInfo.strProvider;
     
    12421241
    12431242        if (FAILED(hrc))
    1244             return setErrorVrc(VERR_COM_OBJECT_NOT_FOUND, tr("%s: Cloud provider object wasn't found"), __FUNCTION__);
     1243            return setError(VBOX_E_OBJECT_NOT_FOUND, tr("%s: Cloud provider object wasn't found (%Rhrc)"), __FUNCTION__, hrc);
    12451244
    12461245        Utf8Str profileName(parts.at(0));//profile
    12471246        if (profileName.isEmpty())
    1248             return setErrorVrc(VBOX_E_OBJECT_NOT_FOUND, tr("%s: Cloud user profile name wasn't found"), __FUNCTION__);
     1247            return setError(VBOX_E_OBJECT_NOT_FOUND, tr("%s: Cloud user profile name wasn't found (%Rhrc)"), __FUNCTION__, hrc);
    12491248
    12501249        hrc = cloudProvider->GetProfileByName(Bstr(parts.at(0)).raw(), cloudProfile.asOutParam());
    12511250        if (FAILED(hrc))
    1252             return setErrorVrc(VERR_COM_OBJECT_NOT_FOUND, tr("%s: Cloud profile object wasn't found"), __FUNCTION__);
     1251            return setError(VBOX_E_OBJECT_NOT_FOUND, tr("%s: Cloud profile object wasn't found (%Rhrc)"), __FUNCTION__, hrc);
    12531252
    12541253        ComObjPtr<ICloudClient> cloudClient;
    12551254        hrc = cloudProfile->CreateCloudClient(cloudClient.asOutParam());
    12561255        if (FAILED(hrc))
    1257             return setErrorVrc(VERR_COM_OBJECT_NOT_FOUND, tr("%s: Cloud client object wasn't found"), __FUNCTION__);
     1256            return setError(VBOX_E_OBJECT_NOT_FOUND, tr("%s: Cloud client object wasn't found (%Rhrc)"), __FUNCTION__, hrc);
    12581257
    12591258        m->virtualSystemDescriptions.clear();//clear all for assurance before creating new
     
    12641263        if (FAILED(hrc)) throw hrc;
    12651264        if (requestedVSDnums != newVSDnums)
    1266             throw setErrorVrc(VERR_MISMATCH, tr("%s: Requested and created numbers of VSD are differ."), __FUNCTION__);
     1265            throw setErrorVrc(VERR_MISMATCH, tr("%s: Requested (%d) and created (%d) numbers of VSD are differ ."),
     1266                              __FUNCTION__, requestedVSDnums, newVSDnums);
    12671267
    12681268        hrc = getVirtualSystemDescriptions(vsdArray);
     
    12791279
    12801280        // set cloud profile
    1281         instanceDescription->AddDescription(VirtualSystemDescriptionType_CloudProfileName,
    1282                              Bstr(profileName).raw(),
    1283                              NULL);
     1281        instanceDescription->AddDescription(VirtualSystemDescriptionType_CloudProfileName, Bstr(profileName).raw(),  NULL);
    12841282
    12851283        Utf8StrFmt strSetting("VM with id %s imported from the cloud provider %s",
    12861284                              parts.at(1).c_str(), strProviderName.c_str());
    12871285        // set description
    1288         instanceDescription->AddDescription(VirtualSystemDescriptionType_Description,
    1289                              Bstr(strSetting).raw(),
    1290                              NULL);
     1286        instanceDescription->AddDescription(VirtualSystemDescriptionType_Description, Bstr(strSetting).raw(), NULL);
    12911287    }
    12921288    catch (HRESULT arc)
     
    19201916                        {
    19211917                            hrc = aRc;
    1922                             strLastActualErrorDesc = Utf8StrFmt("%s: Processing the downloaded object was failed. "
    1923                                     "The exception (%Rrc)\n", __FUNCTION__, hrc);
     1918                            strLastActualErrorDesc.printf("%s: Processing the downloaded object was failed. The exception (%Rhrc)\n",
     1919                                                          __FUNCTION__, hrc);
    19241920                            LogRel((strLastActualErrorDesc.c_str()));
    19251921                        }
     
    19271923                        {
    19281924                            hrc = setErrorVrc(aRc);
    1929                             strLastActualErrorDesc = Utf8StrFmt("%s: Processing the downloaded object was failed. "
    1930                                     "The exception (%Rrc)\n", __FUNCTION__, aRc);
     1925                            strLastActualErrorDesc.printf("%s: Processing the downloaded object was failed. The exception (%Rrc/%Rhrc)\n",
     1926                                                          __FUNCTION__, aRc, hrc);
    19311927                            LogRel((strLastActualErrorDesc.c_str()));
    19321928                        }
    19331929                        catch (...)
    19341930                        {
    1935                             hrc = VERR_UNEXPECTED_EXCEPTION;
    1936                             strLastActualErrorDesc = Utf8StrFmt("%s: Processing the downloaded object was failed. "
    1937                                     "The exception (%Rrc)\n", __FUNCTION__, hrc);
     1931                            hrc = setErrorVrc(VERR_UNEXPECTED_EXCEPTION);
     1932                            strLastActualErrorDesc.printf("%s: Processing the downloaded object was failed. The exception (VERR_UNEXPECTED_EXCEPTION/%Rhrc)\n",
     1933                                                          __FUNCTION__, hrc);
    19381934                            LogRel((strLastActualErrorDesc.c_str()));
    19391935                        }
     
    19551951                        hrc = mVirtualBox->i_findHardDiskByLocation(strAbsDstPath, false, NULL);
    19561952                        if (SUCCEEDED(hrc))
    1957                             throw setError(VERR_ALREADY_EXISTS, tr("The hard disk '%s' already exists."), strAbsDstPath.c_str());
     1953                            throw setErrorVrc(VERR_ALREADY_EXISTS, tr("The hard disk '%s' already exists."), strAbsDstPath.c_str());
    19581954
    19591955                        /* Create an IMedium object. */
     
    19781974
    19791975                        hrc = pProgressImportTmp->init(mVirtualBox,
    1980                                                       static_cast<IAppliance*>(this),
    1981                                                       Utf8StrFmt(tr("Importing medium '%s'"),
    1982                                                                  pszName),
    1983                                                       TRUE);
     1976                                                       static_cast<IAppliance*>(this),
     1977                                                       Utf8StrFmt(tr("Importing medium '%s'"), pszName),
     1978                                                       TRUE);
    19841979                        if (FAILED(hrc))
    19851980                            throw hrc;
     
    20162011                            d.strHref = pTargetMedium->i_getLocationFull();
    20172012                            d.strFormat = pTargetMedium->i_getFormat();
    2018                             d.iSize = pTargetMedium->i_getSize();
     2013                            d.iSize = (int64_t)pTargetMedium->i_getSize();
    20192014                            d.ulSuggestedSizeMB = (uint32_t)(d.iSize/_1M);
    20202015
     
    20712066        {
    20722067            hrc = aRc;
    2073             strLastActualErrorDesc = Utf8StrFmt("%s: Cloud import (local phase) failed. "
    2074                     "The exception (%Rrc)\n", __FUNCTION__, hrc);
     2068            strLastActualErrorDesc.printf("%s: Cloud import (local phase) failed. The exception (%Rhrc)\n",
     2069                                          __FUNCTION__, hrc);
    20752070            LogRel((strLastActualErrorDesc.c_str()));
    20762071        }
     
    20782073        {
    20792074            hrc = setErrorVrc(aRc);
    2080             strLastActualErrorDesc = Utf8StrFmt("%s: Cloud import (local phase) failed. "
    2081                     "The exception (%Rrc)\n", __FUNCTION__, aRc);
     2075            strLastActualErrorDesc.printf("%s: Cloud import (local phase) failed. The exception (%Rrc/%Rhrc)\n",
     2076                                          __FUNCTION__, aRc, hrc);
    20822077            LogRel((strLastActualErrorDesc.c_str()));
    20832078        }
    20842079        catch (...)
    20852080        {
    2086             hrc = VERR_UNRESOLVED_ERROR;
    2087             strLastActualErrorDesc = Utf8StrFmt("%s: Cloud import (local phase) failed. "
    2088                     "The exception (%Rrc)\n", __FUNCTION__, hrc);
     2081            hrc = setErrorVrc(VERR_UNRESOLVED_ERROR);
     2082            strLastActualErrorDesc.printf("%s: Cloud import (local phase) failed. The exception (VERR_UNRESOLVED_ERROR/%Rhrc)\n",
     2083                                          __FUNCTION__, hrc);
    20892084            LogRel((strLastActualErrorDesc.c_str()));
    20902085        }
     
    23122307     */
    23132308    char *pszNameBuf = (char *)alloca(pTask->locInfo.strPath.length() + 16);
    2314     AssertReturn(pszNameBuf, VERR_NO_TMP_MEMORY);
     2309    AssertReturn(pszNameBuf, E_OUTOFMEMORY);
    23152310    memcpy(pszNameBuf, pTask->locInfo.strPath.c_str(), pTask->locInfo.strPath.length() + 1);
    23162311    RTPathStripSuffix(pszNameBuf);
     
    26672662        const char *pszSuffix = strrchr(pszSubFileNm, '.');
    26682663        AssertReturn(pszSuffix, E_FAIL);
    2669         strManifestName = Utf8Str(pszSubFileNm, pszSuffix - pszSubFileNm);
     2664        strManifestName = Utf8Str(pszSubFileNm, (size_t)(pszSuffix - pszSubFileNm));
    26702665        strManifestName.append(".mf");
    26712666    }
     
    27322727        {
    27332728            RTVFSIOSTREAM hVfsIosTmp;
    2734             vrc = RTVfsIoStrmFromBuffer(RTFILE_O_READ, pvSignature, pszSplit - (char *)pvSignature, &hVfsIosTmp);
     2729            vrc = RTVfsIoStrmFromBuffer(RTFILE_O_READ, pvSignature, (size_t)(pszSplit - (char *)pvSignature), &hVfsIosTmp);
    27352730            if (RT_SUCCESS(vrc))
    27362731            {
     
    39203915                    {
    39213916                        // secondary master
    3922                         lControllerPort = (long)1;
    3923                         lDevice = (long)0;
     3917                        lControllerPort = 1;
     3918                        lDevice         = 0;
    39243919                    }
    39253920                    else // primary master
    39263921                    {
    3927                         lControllerPort = (long)0;
    3928                         lDevice = (long)0;
     3922                        lControllerPort = 0;
     3923                        lDevice         = 0;
    39293924                    }
    3930                 break;
     3925                    break;
    39313926
    39323927                case 1: // slave
     
    39343929                    {
    39353930                        // secondary slave
    3936                         lControllerPort = (long)1;
    3937                         lDevice = (long)1;
     3931                        lControllerPort = 1;
     3932                        lDevice         = 1;
    39383933                    }
    39393934                    else // primary slave
    39403935                    {
    3941                         lControllerPort = (long)0;
    3942                         lDevice = (long)1;
     3936                        lControllerPort = 0;
     3937                        lDevice         = 1;
    39433938                    }
    3944                 break;
     3939                    break;
    39453940
    39463941                // used by older VBox exports
    39473942                case 2:     // interpret this as secondary master
    3948                     lControllerPort = (long)1;
    3949                     lDevice = (long)0;
    3950                 break;
     3943                    lControllerPort = 1;
     3944                    lDevice         = 0;
     3945                    break;
    39513946
    39523947                // used by older VBox exports
    39533948                case 3:     // interpret this as secondary slave
    3954                     lControllerPort = (long)1;
    3955                     lDevice = (long)1;
    3956                 break;
     3949                    lControllerPort = 1;
     3950                    lDevice         = 1;
     3951                    break;
    39573952
    39583953                default:
    39593954                    throw setError(VBOX_E_NOT_SUPPORTED,
    3960                                    tr("Invalid channel %RI16 specified; IDE controllers support only 0, 1 or 2"),
     3955                                   tr("Invalid channel %RU32 specified; IDE controllers support only 0, 1 or 2"),
    39613956                                   ulAddressOnParent);
    3962                 break;
    3963             }
    3964         break;
     3957                    break;
     3958            }
     3959            break;
    39653960
    39663961        case ovf::HardDiskController::SATA:
    3967             controllerName = "SATA";
    3968             lControllerPort = (long)ulAddressOnParent;
    3969             lDevice = (long)0;
     3962            controllerName  = "SATA";
     3963            lControllerPort = (int32_t)ulAddressOnParent;
     3964            lDevice         = 0;
    39703965            break;
    39713966
    39723967        case ovf::HardDiskController::SCSI:
    39733968        {
    3974             if(hdc.strControllerType.compare("lsilogicsas")==0)
     3969            if (hdc.strControllerType.compare("lsilogicsas")==0)
    39753970                controllerName = "SAS";
    39763971            else
    39773972                controllerName = "SCSI";
    3978             lControllerPort = (long)ulAddressOnParent;
    3979             lDevice = (long)0;
     3973            lControllerPort = (int32_t)ulAddressOnParent;
     3974            lDevice         = 0;
    39803975            break;
    39813976        }
    39823977
    39833978        case ovf::HardDiskController::VIRTIOSCSI:
    3984             controllerName = "VirtioSCSI";
    3985             lControllerPort = (long)ulAddressOnParent;
    3986             lDevice = (long)0;
     3979            controllerName  = "VirtioSCSI";
     3980            lControllerPort = (int32_t)ulAddressOnParent;
     3981            lDevice         = 0;
    39873982            break;
    39883983
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