VirtualBox

Changeset 6526 in vbox


Ignore:
Timestamp:
Jan 28, 2008 1:22:22 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
27552
Message:

VBoxManage: added 'list runningvms'

File:
1 edited

Legend:

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

    r6479 r6526  
    268268    if (u64Cmd & USAGE_LIST)
    269269    {
    270         RTPrintf("VBoxManage list             vms|ostypes|hostdvds|hostfloppies|");
     270        RTPrintf("VBoxManage list             vms|runningvms|ostypes|hostdvds|hostfloppies|\n");
    271271        if (fWin)
    272272            RTPrintf(                         "hostifs|");
    273         RTPrintf(                             "\n"
    274                  "                            hdds|dvds|floppies|usbhost|usbfilters|\n"
     273        RTPrintf("                            hdds|dvds|floppies|usbhost|usbfilters|\n"
    275274                 "                            systemproperties\n"
    276275                 "\n");
     
    24342433    }
    24352434    else
     2435    if (strcmp(argv[0], "runningvms") == 0)
     2436    {
     2437        /*
     2438         * Get the list of all _running_ VMs
     2439         */
     2440        ComPtr<IMachineCollection> collection;
     2441        rc = virtualBox->COMGETTER(Machines)(collection.asOutParam());
     2442        ComPtr<IMachineEnumerator> enumerator;
     2443        if (SUCCEEDED(rc))
     2444            rc = collection->Enumerate(enumerator.asOutParam());
     2445        if (SUCCEEDED(rc))
     2446        {
     2447            /*
     2448             * Iterate through the collection
     2449             */
     2450            BOOL hasMore = FALSE;
     2451            while (enumerator->HasMore(&hasMore), hasMore)
     2452            {
     2453                ComPtr<IMachine> machine;
     2454                rc = enumerator->GetNext(machine.asOutParam());
     2455                if ((SUCCEEDED(rc)) && machine)
     2456                {
     2457                    MachineState_T machineState;
     2458                    rc = machine->COMGETTER(State)(&machineState);
     2459                    if (SUCCEEDED(rc))
     2460                    {
     2461                        switch (machineState)
     2462                        {
     2463                            case MachineState_Running:
     2464                            case MachineState_Paused:
     2465                                {
     2466                                    Guid uuid;
     2467                                    rc = machine->COMGETTER(Id) (uuid.asOutParam());
     2468                                    if (SUCCEEDED(rc))
     2469                                        RTPrintf ("%s\n", uuid.toString().raw());
     2470                                    break;
     2471                                }
     2472                        }
     2473                    }
     2474                }
     2475            }
     2476        }
     2477    }
     2478    else
    24362479    if (strcmp(argv[0], "ostypes") == 0)
    24372480    {
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