VirtualBox

Changeset 53266 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 7, 2014 4:02:36 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
96836
Message:

Frontend/VBoxManage: minor cleanup of showVMInfo, and fixing a ULONG/size_t warning

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

Legend:

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

    r51889 r53266  
    225225                      int level = 0);
    226226int handleShowVMInfo(HandlerArg *a);
    227 HRESULT showVMInfo(ComPtr<IVirtualBox> virtualBox,
    228                    ComPtr<IMachine> machine,
    229                    VMINFO_DETAILS details = VMINFO_NONE,
    230                    ComPtr<IConsole> console = ComPtr<IConsole>());
     227HRESULT showVMInfo(ComPtr<IVirtualBox> pVirtualBox,
     228                   ComPtr<IMachine> pMachine,
     229                   ComPtr<ISession> pSession,
     230                   VMINFO_DETAILS details = VMINFO_NONE);
    231231const char *machineStateToName(MachineState_T machineState, bool fShort);
    232232HRESULT showBandwidthGroups(ComPtr<IBandwidthControl> &bwCtrl,
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageBandwidthControl.cpp

    r50085 r53266  
    55
    66/*
    7  * Copyright (C) 2006-2012 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    289289    }
    290290
    291     /* See showVMInfo. */
    292291    if (FAILED(showBandwidthGroups(rptrBWControl, enmDetails)))
    293292        return RTEXITCODE_FAILURE;
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp

    r52978 r53266  
    351351#endif
    352352
    353 HRESULT showVMInfo(ComPtr<IVirtualBox> virtualBox,
     353HRESULT showVMInfo(ComPtr<IVirtualBox> pVirtualBox,
    354354                   ComPtr<IMachine> machine,
    355                    VMINFO_DETAILS details /*= VMINFO_NONE*/,
    356                    ComPtr<IConsole> console /*= ComPtr<IConsole> ()*/)
     355                   ComPtr<ISession> pSession,
     356                   VMINFO_DETAILS details /*= VMINFO_NONE*/)
    357357{
    358358    HRESULT rc;
     359    ComPtr<IConsole> pConsole;
     360    if (pSession)
     361        pSession->COMGETTER(Console)(pConsole.asOutParam());
    359362
    360363#define SHOW_BOOLEAN_PROP(a_pObj, a_Prop, a_szMachine, a_szHuman) \
     
    500503    CHECK_ERROR2_RET(machine, COMGETTER(OSTypeId)(osTypeId.asOutParam()), hrcCheck);
    501504    ComPtr<IGuestOSType> osType;
    502     CHECK_ERROR2_RET(virtualBox, GetGuestOSType(osTypeId.raw(), osType.asOutParam()), hrcCheck);
     505    CHECK_ERROR2_RET(pVirtualBox, GetGuestOSType(osTypeId.raw(), osType.asOutParam()), hrcCheck);
    503506    SHOW_STRINGARRAY_PROP( machine, Groups,                     "groups",               "Groups");
    504507    SHOW_STRING_PROP(       osType, Description,                "ostype",               "Guest OS");
     
    609612
    610613    ComPtr<ISystemProperties> systemProperties;
    611     CHECK_ERROR2_RET(virtualBox, COMGETTER(SystemProperties)(systemProperties.asOutParam()), hrcCheck);
     614    CHECK_ERROR2_RET(pVirtualBox, COMGETTER(SystemProperties)(systemProperties.asOutParam()), hrcCheck);
    612615    ULONG maxBootPosition = 0;
    613616    CHECK_ERROR2_RET(systemProperties, COMGETTER(MaxBootPosition)(&maxBootPosition), hrcCheck);
     
    957960
    958961    /* get the maximum amount of NICS */
    959     ULONG maxNICs = getMaxNics(virtualBox, machine);
     962    ULONG maxNICs = getMaxNics(pVirtualBox, machine);
    960963
    961964    for (ULONG currentNIC = 0; currentNIC < maxNICs; currentNIC++)
     
    13371340
    13381341    ComPtr<ISystemProperties> sysProps;
    1339     virtualBox->COMGETTER(SystemProperties)(sysProps.asOutParam());
     1342    pVirtualBox->COMGETTER(SystemProperties)(sysProps.asOutParam());
    13401343
    13411344    /* get the maximum amount of UARTs */
     
    16671670    }
    16681671
    1669     if (console)
     1672    if (pConsole)
    16701673    {
    16711674        do
    16721675        {
    16731676            ComPtr<IDisplay> display;
    1674             rc = console->COMGETTER(Display)(display.asOutParam());
     1677            rc = pConsole->COMGETTER(Display)(display.asOutParam());
    16751678            if (rc == E_ACCESSDENIED || display.isNull())
    16761679                break; /* VM not powered up */
    16771680            if (FAILED(rc))
    16781681            {
    1679                 com::GlueHandleComError(console, "COMGETTER(Display)(display.asOutParam())", rc, __FILE__, __LINE__);
     1682                com::GlueHandleComError(pConsole, "COMGETTER(Display)(display.asOutParam())", rc, __FILE__, __LINE__);
    16801683                return rc;
    16811684            }
     
    17531756                    break;
    17541757            }
    1755             if (console)
     1758            if (pConsole)
    17561759            {
    17571760                ComPtr<IVRDEServerInfo> vrdeServerInfo;
    1758                 CHECK_ERROR_RET(console, COMGETTER(VRDEServerInfo)(vrdeServerInfo.asOutParam()), rc);
     1761                CHECK_ERROR_RET(pConsole, COMGETTER(VRDEServerInfo)(vrdeServerInfo.asOutParam()), rc);
    17591762                if (!vrdeServerInfo.isNull())
    17601763                {
     
    17901793                    address = "0.0.0.0";
    17911794                RTPrintf("VRDE:            enabled (Address %ls, Ports %ls, MultiConn: %s, ReuseSingleConn: %s, Authentication type: %s)\n", address.raw(), ports.raw(), fMultiCon ? "on" : "off", fReuseCon ? "on" : "off", strAuthType);
    1792                 if (console && currentPort != -1 && currentPort != 0)
     1795                if (pConsole && currentPort != -1 && currentPort != 0)
    17931796                   RTPrintf("VRDE port:       %d\n", currentPort);
    17941797                if (fVideoChannel)
     
    19691972        }
    19701973
    1971         if (console)
     1974        if (pConsole)
    19721975        {
    19731976            /* scope */
     
    19771980
    19781981                SafeIfaceArray <IHostUSBDevice> coll;
    1979                 CHECK_ERROR_RET(console, COMGETTER(RemoteUSBDevices)(ComSafeArrayAsOutParam(coll)), rc);
     1982                CHECK_ERROR_RET(pConsole, COMGETTER(RemoteUSBDevices)(ComSafeArrayAsOutParam(coll)), rc);
    19801983
    19811984                if (coll.size() == 0)
     
    20662069
    20672070                SafeIfaceArray <IUSBDevice> coll;
    2068                 CHECK_ERROR_RET(console, COMGETTER(USBDevices)(ComSafeArrayAsOutParam(coll)), rc);
     2071                CHECK_ERROR_RET(pConsole, COMGETTER(USBDevices)(ComSafeArrayAsOutParam(coll)), rc);
    20692072
    20702073                if (coll.size() == 0)
     
    22142217    {
    22152218        SafeIfaceArray <ISharedFolder> sfColl;
    2216         CHECK_ERROR_RET(virtualBox, COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(sfColl)), rc);
     2219        CHECK_ERROR_RET(pVirtualBox, COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(sfColl)), rc);
    22172220        for (size_t i = 0; i < sfColl.size(); ++i)
    22182221        {
     
    22572260    }
    22582261    /* transient mappings */
    2259     if (console)
     2262    if (pConsole)
    22602263    {
    22612264        com::SafeIfaceArray <ISharedFolder> folders;
    22622265
    2263         CHECK_ERROR_RET(console, COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(folders)), rc);
     2266        CHECK_ERROR_RET(pConsole, COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(folders)), rc);
    22642267
    22652268        for (size_t i = 0; i < folders.size(); ++i)
     
    22892292        RTPrintf("\n");
    22902293
    2291     if (console)
     2294    if (pConsole)
    22922295    {
    22932296        /*
     
    22952298         */
    22962299        ComPtr<IVRDEServerInfo> vrdeServerInfo;
    2297         CHECK_ERROR_RET(console, COMGETTER(VRDEServerInfo)(vrdeServerInfo.asOutParam()), rc);
     2300        CHECK_ERROR_RET(pConsole, COMGETTER(VRDEServerInfo)(vrdeServerInfo.asOutParam()), rc);
    22982301        BOOL    Active = FALSE;
    22992302        ULONG   NumberOfClients = 0;
     
    25032506    }
    25042507
    2505     if (console)
     2508    if (pConsole)
    25062509    {
    25072510        ComPtr<IGuest> guest;
    2508         rc = console->COMGETTER(Guest)(guest.asOutParam());
     2511        rc = pConsole->COMGETTER(Guest)(guest.asOutParam());
    25092512        if (SUCCEEDED(rc) && !guest.isNull())
    25102513        {
     
    26982701        ULONG64 uOffset = 0;
    26992702        SafeArray<BYTE> aLogData;
    2700         ULONG cbLogData;
     2703        size_t cbLogData;
    27012704        while (true)
    27022705        {
     
    27122715             * Unix style, as RTStrmWrite does the LF -> CR/LF replacement on
    27132716             * Windows. Otherwise we end up with CR/CR/LF on Windows. */
    2714             ULONG cbLogDataPrint = cbLogData;
     2717            size_t cbLogDataPrint = cbLogData;
    27152718            for (BYTE *s = aLogData.raw(), *d = s;
    27162719                 s - aLogData.raw() < (ssize_t)cbLogData;
     
    27412744            details = VMINFO_STANDARD;
    27422745
    2743         ComPtr<IConsole> console;
    2744 
    27452746        /* open an existing session for the VM */
    27462747        rc = machine->LockMachine(a->session, LockType_Shared);
     
    27482749            /* get the session machine */
    27492750            rc = a->session->COMGETTER(Machine)(machine.asOutParam());
    2750         if (SUCCEEDED(rc))
    2751             /* get the session console */
    2752             rc = a->session->COMGETTER(Console)(console.asOutParam());
    2753 
    2754         rc = showVMInfo(a->virtualBox, machine, details, console);
    2755 
    2756         if (console)
    2757             a->session->UnlockMachine();
     2751
     2752        rc = showVMInfo(a->virtualBox, machine, a->session, details);
     2753
     2754        a->session->UnlockMachine();
    27582755    }
    27592756
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp

    r52200 r53266  
    55
    66/*
    7  * Copyright (C) 2006-2013 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    862862                {
    863863                    if (machines[i])
    864                         rc = showVMInfo(pVirtualBox, machines[i], fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
     864                        rc = showVMInfo(pVirtualBox, machines[i], NULL, fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
    865865                }
    866866            }
     
    895895                            case MachineState_Paused:
    896896                            case MachineState_TeleportingPausedVM:
    897                                 rc = showVMInfo(pVirtualBox, machines[i], fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
     897                                rc = showVMInfo(pVirtualBox, machines[i], NULL, fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
    898898                                break;
    899899                        }
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageSnapshot.cpp

    r47544 r53266  
    55
    66/*
    7  * Copyright (C) 2006-2012 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    162162 * @returns Exit code.
    163163 * @param   pArgs           The handler argument package.
    164  * @param   rptrMachine     Reference to the VM (locked) we're operating on.
    165  */
    166 static RTEXITCODE handleSnapshotList(HandlerArg *pArgs, ComPtr<IMachine> &rptrMachine)
     164 * @param   pMachine        Reference to the VM (locked) we're operating on.
     165 */
     166static RTEXITCODE handleSnapshotList(HandlerArg *pArgs, ComPtr<IMachine> &pMachine)
    167167{
    168168    static const RTGETOPTDEF g_aOptions[] =
     
    188188    }
    189189
    190     /* See showVMInfo. */
    191     ComPtr<ISnapshot> ptrSnapshot;
    192     HRESULT hrc = rptrMachine->FindSnapshot(Bstr().raw(), ptrSnapshot.asOutParam());
     190    ComPtr<ISnapshot> pSnapshot;
     191    HRESULT hrc = pMachine->FindSnapshot(Bstr().raw(), pSnapshot.asOutParam());
    193192    if (FAILED(hrc))
    194193    {
     
    196195        return RTEXITCODE_FAILURE;
    197196    }
    198     if (ptrSnapshot)
    199     {
    200         ComPtr<ISnapshot> ptrCurrentSnapshot;
    201         CHECK_ERROR2_RET(rptrMachine,COMGETTER(CurrentSnapshot)(ptrCurrentSnapshot.asOutParam()), RTEXITCODE_FAILURE);
    202         hrc = showSnapshots(ptrSnapshot, ptrCurrentSnapshot, enmDetails);
     197    if (pSnapshot)
     198    {
     199        ComPtr<ISnapshot> pCurrentSnapshot;
     200        CHECK_ERROR2_RET(pMachine,COMGETTER(CurrentSnapshot)(pCurrentSnapshot.asOutParam()), RTEXITCODE_FAILURE);
     201        hrc = showSnapshots(pSnapshot, pCurrentSnapshot, enmDetails);
    203202        if (FAILED(hrc))
    204203            return RTEXITCODE_FAILURE;
     
    276275    /* the first argument must be the VM */
    277276    Bstr bstrMachine(a->argv[0]);
    278     ComPtr<IMachine> ptrMachine;
     277    ComPtr<IMachine> pMachine;
    279278    CHECK_ERROR(a->virtualBox, FindMachine(bstrMachine.raw(),
    280                                            ptrMachine.asOutParam()));
    281     if (!ptrMachine)
     279                                           pMachine.asOutParam()));
     280    if (!pMachine)
    282281        return 1;
    283282
     
    285284    {
    286285        /* we have to open a session for this task (new or shared) */
    287         rc = ptrMachine->LockMachine(a->session, LockType_Shared);
    288         ComPtr<IConsole> console;
    289         CHECK_ERROR_BREAK(a->session, COMGETTER(Console)(console.asOutParam()));
     286        rc = pMachine->LockMachine(a->session, LockType_Shared);
    290287
    291288        /* switch based on the command */
     
    347344                break;
    348345
    349             if (fPause)
    350             {
    351                 MachineState_T machineState;
    352                 CHECK_ERROR_BREAK(console, COMGETTER(State)(&machineState));
    353                 if (machineState == MachineState_Running)
    354                     CHECK_ERROR_BREAK(console, Pause());
    355                 else
    356                     fPause = false;
    357             }
    358 
    359             ComPtr<IProgress> progress;
    360             CHECK_ERROR_BREAK(console, TakeSnapshot(name.raw(), desc.raw(),
    361                                                     progress.asOutParam()));
    362 
    363             rc = showProgress(progress);
    364             CHECK_PROGRESS_ERROR(progress, ("Failed to take snapshot"));
    365 
    366             if (fPause)
    367             {
    368                 MachineState_T machineState;
    369                 CHECK_ERROR_BREAK(console, COMGETTER(State)(&machineState));
    370                 if (machineState == MachineState_Paused)
    371                 {
    372                     if (SUCCEEDED(rc))
    373                         CHECK_ERROR_BREAK(console, Resume());
    374                     else
    375                         console->Resume();
    376                 }
    377             }
     346            ComPtr<IProgress> pProgress;
     347            CHECK_ERROR_BREAK(pMachine, TakeSnapshot(name.raw(), desc.raw(),
     348                                                     fPause,
     349                                                     pProgress.asOutParam()));
     350
     351            rc = showProgress(pProgress);
     352            CHECK_PROGRESS_ERROR(pProgress, ("Failed to take snapshot"));
    378353        }
    379354        else if (    (fDelete = !strcmp(a->argv[1], "delete"))
     
    405380            if (fRestoreCurrent)
    406381            {
    407                 CHECK_ERROR_BREAK(ptrMachine, COMGETTER(CurrentSnapshot)(pSnapshot.asOutParam()));
     382                CHECK_ERROR_BREAK(pMachine, COMGETTER(CurrentSnapshot)(pSnapshot.asOutParam()));
    408383            }
    409384            else
    410385            {
    411386                // restore or delete snapshot: then resolve cmd line argument to snapshot instance
    412                 CHECK_ERROR_BREAK(ptrMachine, FindSnapshot(Bstr(a->argv[2]).raw(),
     387                CHECK_ERROR_BREAK(pMachine, FindSnapshot(Bstr(a->argv[2]).raw(),
    413388                                                         pSnapshot.asOutParam()));
    414389            }
     
    418393            if (fDelete)
    419394            {
    420                 CHECK_ERROR_BREAK(console, DeleteSnapshot(bstrSnapGuid.raw(),
    421                                                           pProgress.asOutParam()));
     395                CHECK_ERROR_BREAK(pMachine, DeleteSnapshot(bstrSnapGuid.raw(),
     396                                                           pProgress.asOutParam()));
    422397            }
    423398            else
     
    425400                // restore or restore current
    426401                RTPrintf("Restoring snapshot %ls\n", bstrSnapGuid.raw());
    427                 CHECK_ERROR_BREAK(console, RestoreSnapshot(pSnapshot, pProgress.asOutParam()));
     402                CHECK_ERROR_BREAK(pMachine, RestoreSnapshot(pSnapshot, pProgress.asOutParam()));
    428403            }
    429404
     
    440415            }
    441416
    442             ComPtr<ISnapshot> snapshot;
     417            ComPtr<ISnapshot> pSnapshot;
    443418
    444419            if (   !strcmp(a->argv[2], "--current")
    445420                || !strcmp(a->argv[2], "-current"))
    446421            {
    447                 CHECK_ERROR_BREAK(ptrMachine, COMGETTER(CurrentSnapshot)(snapshot.asOutParam()));
     422                CHECK_ERROR_BREAK(pMachine, COMGETTER(CurrentSnapshot)(pSnapshot.asOutParam()));
    448423            }
    449424            else
    450425            {
    451                 CHECK_ERROR_BREAK(ptrMachine, FindSnapshot(Bstr(a->argv[2]).raw(),
    452                                                            snapshot.asOutParam()));
     426                CHECK_ERROR_BREAK(pMachine, FindSnapshot(Bstr(a->argv[2]).raw(),
     427                                                         pSnapshot.asOutParam()));
    453428            }
    454429
     
    467442                    }
    468443                    i++;
    469                     snapshot->COMSETTER(Name)(Bstr(a->argv[i]).raw());
     444                    pSnapshot->COMSETTER(Name)(Bstr(a->argv[i]).raw());
    470445                }
    471446                else if (   !strcmp(a->argv[i], "--description")
     
    480455                    }
    481456                    i++;
    482                     snapshot->COMSETTER(Description)(Bstr(a->argv[i]).raw());
     457                    pSnapshot->COMSETTER(Description)(Bstr(a->argv[i]).raw());
    483458                }
    484459                else
     
    501476            }
    502477
    503             ComPtr<ISnapshot> snapshot;
    504 
    505             CHECK_ERROR_BREAK(ptrMachine, FindSnapshot(Bstr(a->argv[2]).raw(),
    506                                                        snapshot.asOutParam()));
     478            ComPtr<ISnapshot> pSnapshot;
     479
     480            CHECK_ERROR_BREAK(pMachine, FindSnapshot(Bstr(a->argv[2]).raw(),
     481                                                     pSnapshot.asOutParam()));
    507482
    508483            /* get the machine of the given snapshot */
    509             ComPtr<IMachine> ptrMachine2;
    510             snapshot->COMGETTER(Machine)(ptrMachine2.asOutParam());
    511             showVMInfo(a->virtualBox, ptrMachine2, VMINFO_NONE, console);
     484            ComPtr<IMachine> pMachine2;
     485            pSnapshot->COMGETTER(Machine)(pMachine2.asOutParam());
     486            showVMInfo(a->virtualBox, pMachine2, NULL, VMINFO_NONE);
    512487        }
    513488        else if (!strcmp(a->argv[1], "list"))
    514             rc = handleSnapshotList(a, ptrMachine) == RTEXITCODE_SUCCESS ? S_OK : E_FAIL;
     489            rc = handleSnapshotList(a, pMachine) == RTEXITCODE_SUCCESS ? S_OK : E_FAIL;
    515490        else if (!strcmp(a->argv[1], "dump"))          // undocumented parameter to debug snapshot info
    516             DumpSnapshot(ptrMachine);
     491            DumpSnapshot(pMachine);
    517492        else
    518493        {
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