VirtualBox

Changeset 36128 in vbox for trunk/src/VBox/Main/testcase


Ignore:
Timestamp:
Mar 2, 2011 5:44:04 AM (14 years ago)
Author:
vboxsync
Message:

Main/Metrics: Hypervisor and guest metrics re-done (#5566)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/testcase/tstAPI.cpp

    r33595 r36128  
    12221222
    12231223        // Fill base metrics array
    1224         Bstr baseMetricNames[] = { L"CPU/Load,RAM/Usage" };
     1224        //Bstr baseMetricNames[] = { L"CPU/Load,RAM/Usage" };
     1225        Bstr baseMetricNames[] = { L"RAM/VMM" };
    12251226        com::SafeArray<BSTR> baseMetrics(1);
    12261227        baseMetricNames[0].cloneTo(&baseMetrics[0]);
     
    12351236        Bstr sessionType = argc > 2 ? argv[2] : "headless";
    12361237        RTPrintf("Getting a machine object named '%ls'...\n", name.raw());
    1237         CHECK_RC_BREAK(virtualBox->FindMachine(name, machine.asOutParam()));
     1238        CHECK_ERROR_BREAK(virtualBox, FindMachine(name.raw(), machine.asOutParam()));
    12381239
    12391240        // Open session
    1240         Guid guid;
    1241         CHECK_RC_BREAK(machine->COMGETTER(Id)(guid.asOutParam()));
    1242         RTPrintf("Opening a remote session for this machine...\n");
    12431241        ComPtr<IProgress> progress;
    1244         CHECK_RC_BREAK(virtualBox->OpenRemoteSession(session, guid, sessionType,
    1245                                                        NULL, progress.asOutParam()));
    1246         RTPrintf("Waiting for the session to open...\n");
    1247         CHECK_RC_BREAK(progress->WaitForCompletion(-1));
    1248         ComPtr<IMachine> sessionMachine;
    1249         RTPrintf("Getting machine session object...\n");
    1250         CHECK_RC_BREAK(session->COMGETTER(Machine)(sessionMachine.asOutParam()));
     1242        RTPrintf("Launching VM process...\n");
     1243        CHECK_ERROR_BREAK(machine, LaunchVMProcess(session, sessionType.raw(),
     1244                                                   NULL, progress.asOutParam()));
     1245        RTPrintf("Waiting for the VM to power on...\n");
     1246        CHECK_ERROR_BREAK(progress, WaitForCompletion(-1));
     1247
     1248        // ComPtr<IMachine> sessionMachine;
     1249        // RTPrintf("Getting machine session object...\n");
     1250        // CHECK_ERROR_BREAK(session, COMGETTER(Machine)(sessionMachine.asOutParam()));
    12511251
    12521252        // Setup base metrics
    12531253        // Note that one needs to set up metrics after a session is open for a machine.
    12541254        com::SafeIfaceArray<IPerformanceMetric> affectedMetrics;
    1255         com::SafeIfaceArray<IUnknown> objects(2);
     1255        com::SafeIfaceArray<IUnknown> objects(1);
    12561256        host.queryInterfaceTo(&objects[0]);
    1257         machine.queryInterfaceTo(&objects[1]);
     1257        //machine.queryInterfaceTo(&objects[1]);
    12581258        CHECK_ERROR_BREAK(collector, SetupMetrics(ComSafeArrayAsInParam(baseMetrics),
    12591259                                                   ComSafeArrayAsInParam(objects), 1u, 10u,
     
    12661266        ComPtr<IConsole> console;
    12671267        RTPrintf("Getting console object...\n");
    1268         CHECK_RC_BREAK(session->COMGETTER(Console)(console.asOutParam()));
     1268        CHECK_ERROR_BREAK(session, COMGETTER(Console)(console.asOutParam()));
    12691269
    12701270        RTThreadSleep(5000); // Sleep for 5 seconds
     
    12761276        //RTPrintf("Press enter to pause the VM execution in the remote session...");
    12771277        //getchar();
    1278         CHECK_RC(console->Pause());
     1278        CHECK_ERROR_BREAK(console, Pause());
    12791279
    12801280        RTThreadSleep(5000); // Sleep for 5 seconds
     
    13211321        RTPrintf("Press enter to power off VM...");
    13221322        getchar();
    1323         CHECK_RC(console->PowerDown());
     1323        CHECK_ERROR_BREAK(console, PowerDown(progress.asOutParam()));
     1324        RTPrintf("Waiting for the VM to power down...\n");
     1325        CHECK_ERROR_BREAK(progress, WaitForCompletion(-1));
    13241326        RTPrintf("Press enter to close this session...");
    13251327        getchar();
    1326         session->Close();
     1328        session->UnlockMachine();
    13271329    } while (false);
    13281330#endif /* VBOX_WITH_RESOURCE_USAGE_API */
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