VirtualBox

Changeset 90349 in vbox for trunk/src


Ignore:
Timestamp:
Jul 26, 2021 11:09:33 PM (4 years ago)
Author:
vboxsync
Message:

VBoxManage: cloud machine console-history - bugref:10065.

File:
1 edited

Legend:

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

    r90274 r90349  
    3737static RTEXITCODE handleCloudMachineImpl(HandlerArg *a, int iFirst,
    3838                                         const ComPtr<ICloudProfile> &pProfile);
     39
     40static RTEXITCODE handleCloudMachineConsoleHistory(HandlerArg *a, int iFirst,
     41                                                   const ComPtr<ICloudProfile> &pProfile);
    3942static RTEXITCODE listCloudMachinesImpl(HandlerArg *a, int iFirst,
    4043                                        const ComPtr<ICloudProfile> &pProfile);
     
    273276    {
    274277        kMachineIota = 1000,
     278        kMachine_ConsoleHistory,
    275279        kMachine_Info,
    276280        kMachine_List,
     
    279283    static const RTGETOPTDEF s_aOptions[] =
    280284    {
    281         { "info",           kMachine_Info,          RTGETOPT_REQ_NOTHING },
    282         { "list",           kMachine_List,          RTGETOPT_REQ_NOTHING },
     285        { "console-history",    kMachine_ConsoleHistory,    RTGETOPT_REQ_NOTHING },
     286        { "consolehistory",     kMachine_ConsoleHistory,    RTGETOPT_REQ_NOTHING },
     287        { "info",               kMachine_Info,              RTGETOPT_REQ_NOTHING },
     288        { "list",               kMachine_List,              RTGETOPT_REQ_NOTHING },
    283289          CLOUD_MACHINE_RTGETOPTDEF_HELP
    284290    };
     
    302308        switch (ch)
    303309        {
     310            case kMachine_ConsoleHistory:
     311                return handleCloudMachineConsoleHistory(a, OptState.iNext, pProfile);
     312
    304313            case kMachine_Info:
    305314                return handleCloudMachineInfo(a, OptState.iNext, pProfile);
     
    517526
    518527
     528/*
     529 * cloud machine info "id" ...
     530 */
    519531static RTEXITCODE
    520532handleCloudMachineInfo(HandlerArg *a, int iFirst,
     
    523535    HRESULT hrc;
    524536
    525     if (a->argc == iFirst)
     537    if (iFirst == a->argc)
    526538    {
    527539        return RTMsgErrorExit(RTEXITCODE_SYNTAX,
     
    773785    return S_OK;
    774786}
     787
     788
     789/*
     790 * cloud machine console-history "id"
     791 */
     792static RTEXITCODE
     793handleCloudMachineConsoleHistory(HandlerArg *a, int iFirst,
     794                                 const ComPtr<ICloudProfile> &pProfile)
     795{
     796    HRESULT hrc;
     797
     798    if (iFirst == a->argc)
     799    {
     800        return RTMsgErrorExit(RTEXITCODE_SYNTAX,
     801                   "cloud machine info: machine id required\n"
     802                   "Try '--help' for more information.");
     803    }
     804
     805    if (a->argc - iFirst > 1)
     806    {
     807        return RTMsgErrorExit(RTEXITCODE_SYNTAX,
     808                   "cloud machine info: too many arguments\n"
     809                   "Try '--help' for more information.");
     810    }
     811
     812    ComPtr<ICloudMachine> pMachine;
     813    hrc = getMachineById(pMachine, pProfile, a->argv[iFirst]);
     814    if (FAILED(hrc))
     815        return RTEXITCODE_FAILURE;
     816
     817    ComPtr<IDataStream> pHistoryStream;
     818    ComPtr<IProgress> pHistoryProgress;
     819    CHECK_ERROR2_RET(hrc, pMachine,
     820        GetConsoleHistory(pHistoryStream.asOutParam(),
     821                          pHistoryProgress.asOutParam()),
     822            RTEXITCODE_FAILURE);
     823
     824    hrc = showProgress(pHistoryProgress, SHOW_PROGRESS_NONE);
     825    if (FAILED(hrc))
     826        return RTEXITCODE_FAILURE;
     827
     828    bool fEOF = false;
     829    while (!fEOF)
     830    {
     831        com::SafeArray<BYTE> aChunk;
     832        CHECK_ERROR2_RET(hrc, pHistoryStream,
     833            Read(64 *_1K, 0, ComSafeArrayAsOutParam(aChunk)),
     834                RTEXITCODE_FAILURE);
     835        if (aChunk.size() == 0)
     836            break;
     837
     838        RTStrmWrite(g_pStdOut, aChunk.raw(), aChunk.size());
     839    }
     840
     841    return SUCCEEDED(hrc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
     842}
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