VirtualBox

Ignore:
Timestamp:
Apr 4, 2007 9:41:12 AM (18 years ago)
Author:
vboxsync
Message:

FE/VBoxManage: 'convertdd' accepts the special file stdin now to read from stdin (third size parameter required in that case); 'convertdd' does not need to instantiate a VM session

File:
1 edited

Legend:

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

    r1551 r1916  
    442442    {
    443443        RTPrintf("VBoxManage convertdd        <filename> <outputfile>\n"
     444                 "VBoxManage convertdd        stdin <outputfile> <bytes>\n"
    444445                 "\n");
    445446    }
     
    23272328}
    23282329
    2329 static int handleConvertDDImage(int argc, char *argv[],
    2330                                 ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
     2330static int handleConvertDDImage(int argc, char *argv[])
    23312331{
    2332     if (argc != 2)
    2333     {
     2332#ifdef __LINUX__
     2333    const bool fReadFromStdIn = !strcmp(argv[0], "stdin");
     2334#else
     2335    const bool fReadFromStdIn = false;
     2336#endif
     2337
     2338    if ((!fReadFromStdIn && argc != 2) || (fReadFromStdIn && argc != 3))
    23342339        return errorSyntax(USAGE_CONVERTDD, "Incorrect number of parameters");
    2335     }
    2336 
    23372340
    23382341    RTPrintf("Converting VDI: from DD image file=\"%s\" to file=\"%s\"...\n",
     
    23412344    /* open raw image file. */
    23422345    RTFILE File;
    2343     int rc = RTFileOpen(&File, argv[0], RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);
     2346    int rc = VINF_SUCCESS;
     2347    if (fReadFromStdIn)
     2348        File = 0;
     2349    else
     2350        rc = RTFileOpen(&File, argv[0], RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);
    23442351    if (VBOX_FAILURE(rc))
    23452352    {
     
    23482355    }
    23492356
     2357    uint64_t cbFile;
    23502358    /* get image size. */
    2351     uint64_t cbFile;
    2352     rc = RTFileGetSize(File, &cbFile);
     2359    if (fReadFromStdIn)
     2360        cbFile = RTStrToUInt64(argv[2]);
     2361    else
     2362        rc = RTFileGetSize(File, &cbFile);
    23532363    if (VBOX_SUCCESS(rc))
    23542364    {
    2355         RTPrintf("Creating fixed image with size %u Bytes...\n", (unsigned)cbFile);
     2365        RTPrintf("Creating fixed image with size %RU64Bytes (%RU64MB)...\n", cbFile, (cbFile + _1M - 1) / _1M);
     2366        char pszComment[256];
     2367        RTStrPrintf(pszComment, sizeof(pszComment), "Converted image from %s", argv[0]);
    23562368        rc = VDICreateBaseImage(argv[1],
    23572369                                VDI_IMAGE_TYPE_FIXED,
    23582370                                cbFile,
    2359                                 "Converted from DD test image", NULL, NULL);
     2371                                pszComment, NULL, NULL);
    23602372        if (VBOX_SUCCESS(rc))
    23612373        {
     
    23962408            }
    23972409        }
     2410        else
     2411            RTPrintf("Failed to create output file (%Vrc)!\n", rc);
    23982412    }
    23992413    RTFileClose(File);
     
    60946108    ////////////////////////////////////////////////////////////////////////////
    60956109
    6096     /* update settings command (no VirtualBox instantiation!)*/
     6110    /* update settings command (no VirtualBox instantiation!) */
    60976111    if (argc >= 2 && (strcmp(argv[1], "updatesettings") == 0))
    60986112    {
    6099         rc = handleUpdateSettings(argc - 2 , argv + 2);
     6113        rc = handleUpdateSettings(argc - 2, argv + 2);
     6114        break;
     6115    }
     6116
     6117    /* convertdd: does not need a VirtualBox instantiation) */
     6118    if (argc >= 2 && (strcmp(argv[1], "convertdd") == 0))
     6119    {
     6120        rc = handleConvertDDImage(argc - 2, argv + 2);
    61006121        break;
    61016122    }
     
    61466167        { "modifyvm",         handleModifyVM },
    61476168        { "clonevdi",         handleCloneVDI },
    6148         { "convertdd",        handleConvertDDImage },
    61496169        { "startvm",          handleStartVM },
    61506170        { "controlvm",        handleControlVM },
Note: See TracChangeset for help on using the changeset viewer.

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