PerformanceSolaris.cpp revision a7fa70aa3f4882730fdba02b706acaef5616cbfb
/* $Id$ */
/** @file
*
* VBox Solaris-specific Performance Classes implementation.
*/
/*
* Copyright (C) 2008-2013 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.
*/
#include <procfs.h>
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <kstat.h>
#include <unistd.h>
#include "Logging.h"
#include "Performance.h"
#include <dlfcn.h>
#include <libzfs.h>
#include <libnvpair.h>
#include <map>
namespace pm {
typedef libzfs_handle_t *(*PFNZFSINIT)(void);
typedef void (*PFNZFSFINI)(libzfs_handle_t *);
typedef void (*PFNZFSCLOSE)(zfs_handle_t *);
typedef void (*PFNZPOOLCLOSE)(zpool_handle_t *);
class CollectorSolaris : public CollectorHAL
{
public:
virtual ~CollectorSolaris();
virtual int getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total);
private:
void updateFilesystemMap(void);
void *mZfsSo;
};
{
return new CollectorSolaris();
}
// Collector HAL for Solaris
: mKC(0),
mSysPages(0),
mZFSCache(0),
mZfsLib(0),
mCpus(0)
{
if ((mKC = kstat_open()) == 0)
{
return;
}
{
return;
}
{
}
/* Try to load libzfs dynamically, it may be missing. */
if (mZfsSo)
{
if ( mZfsInit
&& mZfsOpen
&& mZfsClose
&& mZpoolOpen
&& mZpoolClose
&& mZpoolVdevName)
else
LogRel(("Incompatible libzfs? libzfs_init=%p zfs_open=%p zfs_close=%p zfs_prop_get_int=%p\n",
}
/* Notice that mCpus member will be initialized by HostCpuLoadRaw::init() */
if (RT_FAILURE(rc))
totalRAM = 0;
else
}
{
if (mKC)
/* Not calling libzfs_fini() causes file descriptor leaks (#6788). */
if (mZfsSo)
}
{
int rc = VINF_SUCCESS;
int cpus;
if (mKC == 0)
return VERR_INTERNAL_ERROR;
{
return VERR_INTERNAL_ERROR;
}
++cpus;
}
}
if (cpus == 0)
{
Log(("no cpu stats found!\n"));
return VERR_INTERNAL_ERROR;
}
else
return rc;
}
int CollectorSolaris::getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total)
{
int rc = VINF_SUCCESS;
char *pszName;
if (h != -1)
{
{
//Assert((pid_t)process == pstatus.pr_pid);
//Log(("user=%u kernel=%u total=%u\n", prusage.pr_utime.tv_sec, prusage.pr_stime.tv_sec, prusage.pr_tstamp.tv_sec));
/*
* The CPU time spent must be adjusted by the number of cores for compatibility with
* other platforms (see @bugref{6345}).
*/
if (mCpus)
{
}
else
//Log(("user=%llu kernel=%llu total=%llu\n", *user, *kernel, *total));
}
else
{
}
close(h);
}
else
{
}
return rc;
}
{
if (RT_SUCCESS(rc))
{
}
return rc;
}
{
int rc = VINF_SUCCESS;
if (h != -1)
{
{
}
else
{
}
close(h);
}
else
{
}
return rc;
}
{
/*
* Get the instance number from the interface name, then clip it off.
*/
int cbInstance = 0;
for (int i = 0; i < cbIface - 1; i++)
{
if (!RT_C_IS_DIGIT(*pszEnd))
break;
cbInstance++;
pszEnd--;
}
return uInstance;
}
{
{
/* wrap has occurred */
corrected += 0x100000000;
LogFlowThisFunc(("Corrected wrap on %s (%u < %u), returned %llu.\n",
}
return corrected;
}
{
static bool fNotSeen = true;
{
fNotSeen = false;
}
return cur;
}
/*
* WARNING! This function expects the previous values of rx and tx counter to
* be passed in as well as returnes new values in the same parameters. This is
* needed to provide a workaround for 32-bit counter wrapping.
*/
{
static bool g_fNotReported = true;
if (ksAdapter == 0)
{
char szModule[KSTAT_STRLEN];
if (ksAdapter == 0)
{
if (ksAdapter == 0)
{
return VERR_INTERNAL_ERROR;
}
}
}
{
return VERR_INTERNAL_ERROR;
}
{
if (g_fNotReported)
{
g_fNotReported = false;
LogRel(("Failed to locate rbytes64, falling back to 32-bit counters...\n"));
}
{
return VERR_INTERNAL_ERROR;
}
}
else
{
if (g_fNotReported)
{
g_fNotReported = false;
LogRel(("Failed to locate obytes64, falling back to 32-bit counters...\n"));
}
{
return VERR_INTERNAL_ERROR;
}
}
else
return VINF_SUCCESS;
}
{
int rc = VINF_SUCCESS;
if (ksDisk != 0)
{
{
}
else
{
/*
* We do not care for wrap possibility here, although we may
* reconsider in about 300 years (9223372036854775807 ns).
*/
}
}
else
{
}
return rc;
}
uint64_t CollectorSolaris::getZfsTotal(uint64_t cbTotal, const char *szFsType, const char *szFsName)
{
return cbTotal;
return cbTotal;
while (pszEnd)
{
*pszEnd = 0;
if (!hDataset)
break;
if (uAvail == 0)
{
if (uAvail == 0)
uAvail = UINT64_MAX;
}
if (!pszEnd)
{
}
}
}
int CollectorSolaris::getHostFilesystemUsage(const char *path, ULONG *total, ULONG *used, ULONG *available)
{
{
return VERR_ACCESS_DENIED;
}
return VINF_SUCCESS;
}
{
int rc = VINF_SUCCESS;
char szName[KSTAT_STRLEN];
if (ksDisk != 0)
{
{
}
else
{
{
return VERR_INTERNAL_ERROR;
}
}
}
else
{
}
return rc;
}
{
if (!fp)
return RTCString();
char szBuf[RTPATH_MAX];
{
{
char *pszDriver, *pszInstance;
if (pszDriver)
{
*pszDriver = '\0';
if (pszDriver)
{
*pszDriver++ = '\0';
if (pszInstance)
{
*pszInstance = '\0';
if (pszInstance)
{
*pszInstance++ = '\0';
break;
}
}
}
}
}
}
return strInstName;
}
{
char szLink[RTPATH_MAX];
{
{
return physToInstName(pszStart);
}
}
return RTCString(pcszDevPathName);
}
{
return VERR_INVALID_PARAMETER;
{
if (zh)
{
unsigned int cChildren = 0;
{
for (unsigned int i = 0; i < cChildren; ++i)
{
{
char szLink[RTPATH_MAX];
{
{
}
}
}
}
}
}
}
else
return VINF_SUCCESS;
}
void CollectorSolaris::updateFilesystemMap(void)
{
if (fp)
{
int rc = 0;
if (rc != -1)
}
}
}