PerformanceWin.cpp revision 98f65e540e4b270afc32507e1d95c9a99869eebc
/* $Id$ */
/** @file
*
* VBox Windows-specific Performance Classes implementation.
*/
/*
* Copyright (C) 2008 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#else /* !_WIN32_WINNT */
#if (_WIN32_WINNT < 0x0500)
#endif /* _WIN32_WINNT < 0x0500 */
#endif /* !_WIN32_WINNT */
#include <windows.h>
#include <winternl.h>
#include <psapi.h>
extern "C" {
#include <powrprof.h>
}
#ifndef VBOX_WITH_VRDP_MEMLEAK_DETECTOR
#endif /* !VBOX_WITH_VRDP_MEMLEAK_DETECTOR */
#include <map>
#include "Logging.h"
#include "Performance.h"
#ifndef NT_ERROR
#endif
namespace pm {
class CollectorWin : public CollectorHAL
{
public:
CollectorWin();
virtual ~CollectorWin();
virtual int getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total);
private:
struct VMProcessStats
{
};
};
{
return new CollectorWin();
}
{
"GetSystemTimes");
if (!mpfnGetSystemTimes)
{
/* Fall back to deprecated NtQuerySystemInformation */
{
LogRel(("Failed to load NTDLL.DLL with error 0x%x. GetSystemTimes() is"
" not available either. CPU and VM metrics will not be collected.\n",
GetLastError()));
}
"NtQuerySystemInformation")))
{
LogRel(("Neither GetSystemTimes() nor NtQuerySystemInformation() is"
" not available. CPU and VM metrics will not be collected.\n"));
}
}
}
{
if (mhNtDll)
}
{
if (RT_FAILURE(rc))
return rc;
{
if (!h)
{
dwError = GetLastError();
break;
}
{
{
dwError = GetLastError();
}
else
{
}
}
{
{
dwError = GetLastError();
}
else
}
CloseHandle(h);
}
return rc;
}
{
return VERR_NOT_IMPLEMENTED;
}
typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
{
{
if (mpfnGetSystemTimes)
{
{
return RTErrConvertFromWin32(dwError);
}
}
else
{
/* GetSystemTimes is not available, fall back to NtQuerySystemInformation */
return VERR_NOT_IMPLEMENTED;
{
return RTErrConvertFromNtStatus(status);
}
/* Sum up values accross all processors */
for (unsigned i = 0; i < ulReturned / sizeof(sppi[0]); ++i)
{
}
}
return VINF_SUCCESS;
}
typedef struct _PROCESSOR_POWER_INFORMATION {
{
PPROCESSOR_POWER_INFORMATION ppi = (PPROCESSOR_POWER_INFORMATION)RTMemAllocZ(nProcessors * sizeof(PROCESSOR_POWER_INFORMATION));
if (!ppi)
return VERR_NO_MEMORY;
nProcessors * sizeof(PROCESSOR_POWER_INFORMATION));
if (ns)
{
return VERR_INTERNAL_ERROR;
}
/* Compute an average over all CPUs */
for (unsigned i = 0; i < nProcessors; i++)
return VINF_SUCCESS;
}
{
if (GlobalMemoryStatusEx(&mstat))
{
}
else
return RTErrConvertFromWin32(GetLastError());
return VINF_SUCCESS;
}
{
return VERR_NOT_IMPLEMENTED;
}
int CollectorWin::getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total)
{
{
return VERR_INTERNAL_ERROR;
}
return VINF_SUCCESS;
}
{
{
return VERR_INTERNAL_ERROR;
}
return VINF_SUCCESS;
}
}