VirtualBox

Ignore:
Timestamp:
Sep 15, 2010 5:04:48 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
65913
Message:

Main/Medium+MediumFormat+GuestOSType+SystemPropertiesImpl+Console+Global: consistently use bytes as size units, forgotten const value in API, MaxVDISize method renamed to InfoVDSize, STDMETHOD macro usage fixes, whitespace cleanup

Frontends/VirtualBox+VBoxManage+VBoxShell: adapt to changed disk size units

Main/StorageControllerImpl: check the storage controller instance limit to avoid creating unusable VM configs, simplify unnecessarily complex code for querying the controller properties

Location:
trunk/src/VBox/Frontends/VBoxManage
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp

    r31568 r32531  
    555555    /* just try it */
    556556    char *pszFormat = NULL;
    557     int rc = VDGetFormat(NULL, argv[1], &pszFormat);
     557    int rc = VDGetFormat(NULL /* pVDIfsDisk */, argv[1], &pszFormat);
    558558    if (RT_FAILURE(rc))
    559559    {
     
    616616    /* just try it */
    617617    char *pszFormat = NULL;
    618     int rc = VDGetFormat(NULL, argv[0], &pszFormat);
     618    int rc = VDGetFormat(NULL /* pVDIfsDisk */, argv[0], &pszFormat);
    619619    if (RT_FAILURE(rc))
    620620    {
     
    848848        else
    849849        {
    850             return errorSyntax(USAGE_LISTPARTITIONS, "Invalid parameter '%s'", Utf8Str(argv[i]).c_str());
     850            return errorSyntax(USAGE_LISTPARTITIONS, "Invalid parameter '%s'", argv[i]);
    851851        }
    852852    }
     
    910910{
    911911    HRESULT rc = S_OK;
    912     Bstr filename;
     912    Utf8Str filename;
    913913    const char *pszMBRFilename = NULL;
    914914    Utf8Str rawdisk;
     
    972972#endif /* RT_OS_LINUX */
    973973        else
    974             return errorSyntax(USAGE_CREATERAWVMDK, "Invalid parameter '%s'", Utf8Str(argv[i]).c_str());
     974            return errorSyntax(USAGE_CREATERAWVMDK, "Invalid parameter '%s'", argv[i]);
    975975    }
    976976
     
    14441444    LCHS.cHeads = 0;
    14451445    LCHS.cSectors = 0;
    1446     vrc = VDCreateBase(pDisk, "VMDK", Utf8Str(filename).c_str(), cbSize,
     1446    vrc = VDCreateBase(pDisk, "VMDK", filename.c_str(), cbSize,
    14471447                       VD_IMAGE_FLAGS_FIXED | VD_VMDK_IMAGE_FLAGS_RAWDISK,
    14481448                       (char *)&RawDescriptor, &PCHS, &LCHS, NULL,
     
    14531453        goto out;
    14541454    }
    1455     RTPrintf("RAW host disk access VMDK file %s created successfully.\n", Utf8Str(filename).c_str());
     1455    RTPrintf("RAW host disk access VMDK file %s created successfully.\n", filename.c_str());
    14561456
    14571457    VDCloseAll(pDisk);
     
    14751475    {
    14761476        ComPtr<IMedium> hardDisk;
    1477         CHECK_ERROR(aVirtualBox, OpenMedium(filename, DeviceType_HardDisk, AccessMode_ReadWrite, hardDisk.asOutParam()));
     1477        CHECK_ERROR(aVirtualBox, OpenMedium(Bstr(filename), DeviceType_HardDisk, AccessMode_ReadWrite, hardDisk.asOutParam()));
    14781478    }
    14791479
     
    14871487static int CmdRenameVMDK(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
    14881488{
    1489     Bstr src;
    1490     Bstr dst;
     1489    Utf8Str src;
     1490    Utf8Str dst;
    14911491    /* Parse the arguments. */
    14921492    for (int i = 0; i < argc; i++)
     
    15121512        else
    15131513        {
    1514             return errorSyntax(USAGE_RENAMEVMDK, "Invalid parameter '%s'", Utf8Str(argv[i]).c_str());
     1514            return errorSyntax(USAGE_RENAMEVMDK, "Invalid parameter '%s'", argv[i]);
    15151515        }
    15161516    }
     
    15431543    else
    15441544    {
    1545         vrc = VDOpen(pDisk, "VMDK", Utf8Str(src).c_str(), VD_OPEN_FLAGS_NORMAL, NULL);
     1545        vrc = VDOpen(pDisk, "VMDK", src.c_str(), VD_OPEN_FLAGS_NORMAL, NULL);
    15461546        if (RT_FAILURE(vrc))
    15471547        {
     
    15501550        else
    15511551        {
    1552             vrc = VDCopy(pDisk, 0, pDisk, "VMDK", Utf8Str(dst).c_str(), true, 0, VD_IMAGE_FLAGS_NONE, NULL, NULL, NULL, NULL);
     1552            vrc = VDCopy(pDisk, 0, pDisk, "VMDK", dst.c_str(), true, 0, VD_IMAGE_FLAGS_NONE, NULL, NULL, NULL, NULL);
    15531553            if (RT_FAILURE(vrc))
    15541554            {
     
    15631563static int CmdConvertToRaw(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
    15641564{
    1565     Bstr srcformat;
    1566     Bstr src;
    1567     Bstr dst;
     1565    Utf8Str srcformat;
     1566    Utf8Str src;
     1567    Utf8Str dst;
    15681568    bool fWriteToStdOut = false;
    15691569
     
    15941594        else
    15951595        {
    1596             return errorSyntax(USAGE_CONVERTTORAW, "Invalid parameter '%s'", Utf8Str(argv[i]).c_str());
     1596            return errorSyntax(USAGE_CONVERTTORAW, "Invalid parameter '%s'", argv[i]);
    15971597        }
    15981598    }
     
    16301630        outFile = 1;
    16311631    else
    1632         vrc = RTFileOpen(&outFile, Utf8Str(dst).c_str(), RTFILE_O_WRITE | RTFILE_O_CREATE | RTFILE_O_DENY_ALL);
     1632        vrc = RTFileOpen(&outFile, dst.c_str(), RTFILE_O_WRITE | RTFILE_O_CREATE | RTFILE_O_DENY_ALL);
    16331633    if (RT_FAILURE(vrc))
    16341634    {
    16351635        VDCloseAll(pDisk);
    1636         RTPrintf("Error while creating destination file \"%s\": %Rrc\n", Utf8Str(dst).c_str(), vrc);
     1636        RTPrintf("Error while creating destination file \"%s\": %Rrc\n", dst.c_str(), vrc);
    16371637        return 1;
    16381638    }
     
    16411641    {
    16421642        char *pszFormat = NULL;
    1643         vrc = VDGetFormat(NULL, Utf8Str(src).c_str(), &pszFormat);
     1643        vrc = VDGetFormat(NULL /* pVDIfsDisk */, src.c_str(), &pszFormat);
    16441644        if (RT_FAILURE(vrc))
    16451645        {
     
    16481648            {
    16491649                RTFileClose(outFile);
    1650                 RTFileDelete(Utf8Str(dst).c_str());
     1650                RTFileDelete(dst.c_str());
    16511651            }
    16521652            RTPrintf("No file format specified and autodetect failed - please specify format: %Rrc\n", vrc);
     
    16561656        RTStrFree(pszFormat);
    16571657    }
    1658     vrc = VDOpen(pDisk, Utf8Str(srcformat).c_str(), Utf8Str(src).c_str(), VD_OPEN_FLAGS_READONLY, NULL);
     1658    vrc = VDOpen(pDisk, srcformat.c_str(), src.c_str(), VD_OPEN_FLAGS_READONLY, NULL);
    16591659    if (RT_FAILURE(vrc))
    16601660    {
     
    16631663        {
    16641664            RTFileClose(outFile);
    1665             RTFileDelete(Utf8Str(dst).c_str());
     1665            RTFileDelete(dst.c_str());
    16661666        }
    16671667        RTPrintf("Error while opening the source image: %Rrc\n", vrc);
     
    16761676    if (pvBuf)
    16771677    {
    1678         RTPrintf("Converting image \"%s\" with size %RU64 bytes (%RU64MB) to raw...\n", Utf8Str(src).c_str(), cbSize, (cbSize + _1M - 1) / _1M);
     1678        RTPrintf("Converting image \"%s\" with size %RU64 bytes (%RU64MB) to raw...\n", src.c_str(), cbSize, (cbSize + _1M - 1) / _1M);
    16791679        while (offFile < cbSize)
    16801680        {
     
    16941694            {
    16951695                RTFileClose(outFile);
    1696                 RTFileDelete(Utf8Str(dst).c_str());
     1696                RTFileDelete(dst.c_str());
    16971697            }
    16981698            RTPrintf("Error copying image data: %Rrc\n", vrc);
     
    17071707        {
    17081708            RTFileClose(outFile);
    1709             RTFileDelete(Utf8Str(dst).c_str());
     1709            RTFileDelete(dst.c_str());
    17101710        }
    17111711        RTPrintf("Error allocating read buffer: %Rrc\n", vrc);
     
    17211721static int CmdConvertHardDisk(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
    17221722{
    1723     Bstr srcformat;
    1724     Bstr dstformat;
    1725     Bstr src;
    1726     Bstr dst;
     1723    Utf8Str srcformat;
     1724    Utf8Str dstformat;
     1725    Utf8Str src;
     1726    Utf8Str dst;
    17271727    int vrc;
    17281728    PVBOXHDD pSrcDisk = NULL;
     
    17601760        else
    17611761        {
    1762             return errorSyntax(USAGE_CONVERTHD, "Invalid parameter '%s'", Utf8Str(argv[i]).c_str());
     1762            return errorSyntax(USAGE_CONVERTHD, "Invalid parameter '%s'", argv[i]);
    17631763        }
    17641764    }
     
    17881788        {
    17891789            char *pszFormat = NULL;
    1790             vrc = VDGetFormat(NULL, Utf8Str(src).c_str(), &pszFormat);
     1790            vrc = VDGetFormat(NULL /* pVDIfsDisk */, src.c_str(), &pszFormat);
    17911791            if (RT_FAILURE(vrc))
    17921792            {
     
    18061806
    18071807        /* Open the input image */
    1808         vrc = VDOpen(pSrcDisk, Utf8Str(srcformat).c_str(), Utf8Str(src).c_str(), VD_OPEN_FLAGS_READONLY, NULL);
     1808        vrc = VDOpen(pSrcDisk, srcformat.c_str(), src.c_str(), VD_OPEN_FLAGS_READONLY, NULL);
    18091809        if (RT_FAILURE(vrc))
    18101810        {
     
    18251825
    18261826        uint64_t cbSize = VDGetSize(pSrcDisk, VD_LAST_IMAGE);
    1827         RTPrintf("Converting image \"%s\" with size %RU64 bytes (%RU64MB)...\n", Utf8Str(src).c_str(), cbSize, (cbSize + _1M - 1) / _1M);
     1827        RTPrintf("Converting image \"%s\" with size %RU64 bytes (%RU64MB)...\n", src.c_str(), cbSize, (cbSize + _1M - 1) / _1M);
    18281828
    18291829        /* Create the output image */
    1830         vrc = VDCopy(pSrcDisk, VD_LAST_IMAGE, pDstDisk, Utf8Str(dstformat).c_str(),
    1831                      Utf8Str(dst).c_str(), false, 0, VD_VMDK_IMAGE_FLAGS_STREAM_OPTIMIZED, NULL, NULL, NULL, NULL);
     1830        vrc = VDCopy(pSrcDisk, VD_LAST_IMAGE, pDstDisk, dstformat.c_str(),
     1831                     dst.c_str(), false, 0, VD_VMDK_IMAGE_FLAGS_STREAM_OPTIMIZED,
     1832                     NULL, NULL, NULL, NULL);
    18321833        if (RT_FAILURE(vrc))
    18331834        {
     
    20342035
    20352036    /* default: */
    2036     return errorSyntax(USAGE_ALL, "Invalid command '%s'", Utf8Str(a->argv[0]).c_str());
    2037 }
    2038 
     2037    return errorSyntax(USAGE_ALL, "Invalid command '%s'", a->argv[0]);
     2038}
     2039
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp

    r32081 r32531  
    153153    { "--size",         's', RTGETOPT_REQ_UINT64 },
    154154    { "-size",          's', RTGETOPT_REQ_UINT64 },     // deprecated
     155    { "--sizebyte",     'S', RTGETOPT_REQ_UINT64 },
    155156    { "--format",       'o', RTGETOPT_REQ_STRING },
    156157    { "-format",        'o', RTGETOPT_REQ_STRING },     // deprecated
     
    174175    int vrc;
    175176    Bstr filename;
    176     uint64_t sizeMB = 0;
     177    uint64_t size = 0;
    177178    Bstr format = "VDI";
    178179    MediumVariant_T DiskVariant = MediumVariant_Standard;
     
    196197
    197198            case 's':   // --size
    198                 sizeMB = ValueUnion.u64;
     199                size = ValueUnion.u64 * _1M;
     200                break;
     201
     202            case 'S':   // --sizebyte
     203                size = ValueUnion.u64;
    199204                break;
    200205
     
    256261    /* check the outcome */
    257262    if (   !filename
    258         || sizeMB == 0)
     263        || size == 0)
    259264        return errorSyntax(USAGE_CREATEHD, "Parameters --filename and --size are required");
    260265
     
    287292
    288293        ComPtr<IProgress> progress;
    289         CHECK_ERROR(hardDisk, CreateBaseStorage(sizeMB, DiskVariant, progress.asOutParam()));
     294        CHECK_ERROR(hardDisk, CreateBaseStorage(size, DiskVariant, progress.asOutParam()));
    290295        if (SUCCEEDED(rc) && progress)
    291296        {
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp

    r32448 r32531  
    485485    {
    486486        RTPrintf("VBoxManage createhd         --filename <filename>\n"
    487                  "                            --size <megabytes>\n"
     487                 "                            --size <megabytes>|--sizebyte <bytes>\n"
    488488                 "                            [--format VDI|VMDK|VHD] (default: VDI)\n"
    489489                 "                            [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp

    r31698 r32531  
    839839            systemProperties->COMGETTER(MaxGuestCPUCount)(&ulValue);
    840840            RTPrintf("Maximum guest CPU count:         %u\n", ulValue);
    841             systemProperties->COMGETTER(MaxVDISize)(&i64Value);
    842             RTPrintf("Maximum VDI size:                %lld Megabytes\n", i64Value);
     841            systemProperties->COMGETTER(InfoVDSize)(&i64Value);
     842            RTPrintf("Virtual disk limit (info):       %lld Bytes\n", i64Value);
    843843            systemProperties->COMGETTER(NetworkAdapterCount)(&ulValue);
    844844            RTPrintf("Maximum Network Adapter count:   %u\n", ulValue);
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