nodeinfo: rename all CPU APIs to have a virHostCPU prefix

In preparation for moving all the CPU related APIs out of
the nodeinfo file, give them a virHostCPU name prefix.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2016-04-13 18:16:16 +01:00
parent dcfe37e682
commit 4053350bfe
18 changed files with 171 additions and 171 deletions

View File

@ -1162,7 +1162,7 @@ bhyveNodeGetCPUStats(virConnectPtr conn,
if (virNodeGetCPUStatsEnsureACL(conn) < 0) if (virNodeGetCPUStatsEnsureACL(conn) < 0)
return -1; return -1;
return nodeGetCPUStats(cpuNum, params, nparams, flags); return virHostCPUGetStats(cpuNum, params, nparams, flags);
} }
static int static int
@ -1361,7 +1361,7 @@ bhyveNodeGetCPUMap(virConnectPtr conn,
if (virNodeGetCPUMapEnsureACL(conn) < 0) if (virNodeGetCPUMapEnsureACL(conn) < 0)
return -1; return -1;
return nodeGetCPUMap(cpumap, online, flags); return virHostCPUGetMap(cpumap, online, flags);
} }
static int static int

View File

@ -3,9 +3,9 @@
# #
# nodeinfo.h # nodeinfo.h
linuxNodeGetCPUStats; virHostCPUGetInfoPopulateLinux;
linuxNodeInfoCPUPopulate; virHostCPUGetStatsLinux;
linuxNodeInfoSetSysFSSystemPath; virHostCPUSetSysFSSystemPathLinux;
# Let emacs know we want case-insensitive sorting # Let emacs know we want case-insensitive sorting
# Local Variables: # Local Variables:

View File

@ -1060,13 +1060,13 @@ virLogManagerNew;
# nodeinfo.h # nodeinfo.h
nodeCapsInitNUMA; nodeCapsInitNUMA;
nodeGetCPUCount;
nodeGetCPUMap;
nodeGetCPUStats;
nodeGetInfo; nodeGetInfo;
nodeGetOnlineCPUBitmap; virHostCPUGetCount;
nodeGetPresentCPUBitmap; virHostCPUGetMap;
nodeGetThreadsPerSubcore; virHostCPUGetOnlineBitmap;
virHostCPUGetPresentBitmap;
virHostCPUGetStats;
virHostCPUGetThreadsPerSubcore;
virHostMemAllocPages; virHostMemAllocPages;
virHostMemGetCellsFree; virHostMemGetCellsFree;
virHostMemGetFreePages; virHostMemGetFreePages;

View File

@ -730,7 +730,7 @@ static int virLXCControllerSetupCpuAffinity(virLXCControllerPtr ctrl)
/* setaffinity fails if you set bits for CPUs which /* setaffinity fails if you set bits for CPUs which
* aren't present, so we have to limit ourselves */ * aren't present, so we have to limit ourselves */
if ((hostcpus = nodeGetCPUCount()) < 0) if ((hostcpus = virHostCPUGetCount()) < 0)
return -1; return -1;
if (maxcpu > hostcpus) if (maxcpu > hostcpus)

View File

@ -5232,7 +5232,7 @@ lxcNodeGetCPUStats(virConnectPtr conn,
if (virNodeGetCPUStatsEnsureACL(conn) < 0) if (virNodeGetCPUStatsEnsureACL(conn) < 0)
return -1; return -1;
return nodeGetCPUStats(cpuNum, params, nparams, flags); return virHostCPUGetStats(cpuNum, params, nparams, flags);
} }
@ -5313,7 +5313,7 @@ lxcNodeGetCPUMap(virConnectPtr conn,
if (virNodeGetCPUMapEnsureACL(conn) < 0) if (virNodeGetCPUMapEnsureACL(conn) < 0)
return -1; return -1;
return nodeGetCPUMap(cpumap, online, flags); return virHostCPUGetMap(cpumap, online, flags);
} }

View File

@ -68,7 +68,7 @@ VIR_LOG_INIT("nodeinfo");
#if defined(__FreeBSD__) || defined(__APPLE__) #if defined(__FreeBSD__) || defined(__APPLE__)
static int static int
appleFreebsdNodeGetCPUCount(void) virHostCPUGetCountAppleFreeBSD(void)
{ {
int ncpu_mib[2] = { CTL_HW, HW_NCPU }; int ncpu_mib[2] = { CTL_HW, HW_NCPU };
unsigned long ncpu; unsigned long ncpu;
@ -90,9 +90,9 @@ appleFreebsdNodeGetCPUCount(void)
# define TICK_TO_NSEC (1000ull * 1000ull * 1000ull / (stathz ? stathz : hz)) # define TICK_TO_NSEC (1000ull * 1000ull * 1000ull / (stathz ? stathz : hz))
static int static int
freebsdNodeGetCPUStats(int cpuNum, virHostCPUGetStatsFreebsd(int cpuNum,
virNodeCPUStatsPtr params, virNodeCPUStatsPtr params,
int *nparams) int *nparams)
{ {
const char *sysctl_name; const char *sysctl_name;
long *cpu_times; long *cpu_times;
@ -139,7 +139,7 @@ freebsdNodeGetCPUStats(int cpuNum,
offset = 0; offset = 0;
} else { } else {
sysctl_name = "kern.cp_times"; sysctl_name = "kern.cp_times";
cpu_times_num = appleFreebsdNodeGetCPUCount(); cpu_times_num = virHostCPUGetCountAppleFreeBSD();
if (cpuNum >= cpu_times_num) { if (cpuNum >= cpu_times_num) {
virReportInvalidArg(cpuNum, virReportInvalidArg(cpuNum,
@ -275,7 +275,7 @@ virHostMemGetStatsFreeBSD(virNodeMemoryStatsPtr params,
static const char *sysfs_system_path = SYSFS_SYSTEM_PATH; static const char *sysfs_system_path = SYSFS_SYSTEM_PATH;
void linuxNodeInfoSetSysFSSystemPath(const char *path) void virHostCPUSetSysFSSystemPathLinux(const char *path)
{ {
if (path) if (path)
sysfs_system_path = path; sysfs_system_path = path;
@ -330,7 +330,7 @@ virNodeGetCpuValue(const char *dir, unsigned int cpu, const char *file,
} }
static unsigned long static unsigned long
virNodeCountThreadSiblings(const char *dir, unsigned int cpu) virHostCPUCountThreadSiblings(const char *dir, unsigned int cpu)
{ {
unsigned long ret = 0; unsigned long ret = 0;
char *path; char *path;
@ -363,9 +363,9 @@ virNodeCountThreadSiblings(const char *dir, unsigned int cpu)
} }
static int static int
virNodeParseSocket(const char *dir, virHostCPUParseSocket(const char *dir,
virArch arch, virArch arch,
unsigned int cpu) unsigned int cpu)
{ {
int ret = virNodeGetCpuValue(dir, cpu, "topology/physical_package_id", 0); int ret = virNodeGetCpuValue(dir, cpu, "topology/physical_package_id", 0);
@ -385,15 +385,15 @@ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3)
ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(6) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(6)
ATTRIBUTE_NONNULL(7) ATTRIBUTE_NONNULL(8) ATTRIBUTE_NONNULL(7) ATTRIBUTE_NONNULL(8)
ATTRIBUTE_NONNULL(9) ATTRIBUTE_NONNULL(9)
virNodeParseNode(const char *node, virHostCPUParseNode(const char *node,
virArch arch, virArch arch,
virBitmapPtr present_cpus_map, virBitmapPtr present_cpus_map,
virBitmapPtr online_cpus_map, virBitmapPtr online_cpus_map,
int threads_per_subcore, int threads_per_subcore,
int *sockets, int *sockets,
int *cores, int *cores,
int *threads, int *threads,
int *offline) int *offline)
{ {
/* Biggest value we can expect to be used as either socket id /* Biggest value we can expect to be used as either socket id
* or core id. Bitmaps will need to be sized accordingly */ * or core id. Bitmaps will need to be sized accordingly */
@ -446,7 +446,7 @@ virNodeParseNode(const char *node,
continue; continue;
/* Parse socket */ /* Parse socket */
if ((sock = virNodeParseSocket(node, arch, cpu)) < 0) if ((sock = virHostCPUParseSocket(node, arch, cpu)) < 0)
goto cleanup; goto cleanup;
if (sock > ID_MAX) { if (sock > ID_MAX) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
@ -501,7 +501,7 @@ virNodeParseNode(const char *node,
processors++; processors++;
/* Parse socket */ /* Parse socket */
if ((sock = virNodeParseSocket(node, arch, cpu)) < 0) if ((sock = virHostCPUParseSocket(node, arch, cpu)) < 0)
goto cleanup; goto cleanup;
if (!virBitmapIsBitSet(sockets_map, sock)) { if (!virBitmapIsBitSet(sockets_map, sock)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@ -528,7 +528,7 @@ virNodeParseNode(const char *node,
if (virBitmapSetBit(cores_maps[sock], core) < 0) if (virBitmapSetBit(cores_maps[sock], core) < 0)
goto cleanup; goto cleanup;
if (!(siblings = virNodeCountThreadSiblings(node, cpu))) if (!(siblings = virHostCPUCountThreadSiblings(node, cpu)))
goto cleanup; goto cleanup;
if (siblings > *threads) if (siblings > *threads)
@ -576,7 +576,7 @@ virNodeParseNode(const char *node,
* A valid configuration is one where no secondary thread is online; * A valid configuration is one where no secondary thread is online;
* the primary thread in a subcore is always the first one */ * the primary thread in a subcore is always the first one */
static bool static bool
nodeHasValidSubcoreConfiguration(int threads_per_subcore) virHostCPUHasValidSubcoreConfiguration(int threads_per_subcore)
{ {
virBitmapPtr online_cpus = NULL; virBitmapPtr online_cpus = NULL;
int cpu = -1; int cpu = -1;
@ -586,7 +586,7 @@ nodeHasValidSubcoreConfiguration(int threads_per_subcore)
if (threads_per_subcore <= 0) if (threads_per_subcore <= 0)
goto cleanup; goto cleanup;
if (!(online_cpus = nodeGetOnlineCPUBitmap())) if (!(online_cpus = virHostCPUGetOnlineBitmap()))
goto cleanup; goto cleanup;
while ((cpu = virBitmapNextSetBit(online_cpus, cpu)) >= 0) { while ((cpu = virBitmapNextSetBit(online_cpus, cpu)) >= 0) {
@ -606,14 +606,14 @@ nodeHasValidSubcoreConfiguration(int threads_per_subcore)
} }
int int
linuxNodeInfoCPUPopulate(FILE *cpuinfo, virHostCPUGetInfoPopulateLinux(FILE *cpuinfo,
virArch arch, virArch arch,
unsigned int *cpus, unsigned int *cpus,
unsigned int *mhz, unsigned int *mhz,
unsigned int *nodes, unsigned int *nodes,
unsigned int *sockets, unsigned int *sockets,
unsigned int *cores, unsigned int *cores,
unsigned int *threads) unsigned int *threads)
{ {
virBitmapPtr present_cpus_map = NULL; virBitmapPtr present_cpus_map = NULL;
virBitmapPtr online_cpus_map = NULL; virBitmapPtr online_cpus_map = NULL;
@ -713,10 +713,10 @@ linuxNodeInfoCPUPopulate(FILE *cpuinfo,
/* Get information about what CPUs are present in the host and what /* Get information about what CPUs are present in the host and what
* CPUs are online, so that we don't have to so for each node */ * CPUs are online, so that we don't have to so for each node */
present_cpus_map = nodeGetPresentCPUBitmap(); present_cpus_map = virHostCPUGetPresentBitmap();
if (!present_cpus_map) if (!present_cpus_map)
goto cleanup; goto cleanup;
online_cpus_map = nodeGetOnlineCPUBitmap(); online_cpus_map = virHostCPUGetOnlineBitmap();
if (!online_cpus_map) if (!online_cpus_map)
goto cleanup; goto cleanup;
@ -753,12 +753,12 @@ linuxNodeInfoCPUPopulate(FILE *cpuinfo,
* offline/online randomly. * offline/online randomly.
* On hosts other than POWER this will be 0, in which case a simpler * On hosts other than POWER this will be 0, in which case a simpler
* thread-counting logic will be used */ * thread-counting logic will be used */
if ((threads_per_subcore = nodeGetThreadsPerSubcore(arch)) < 0) if ((threads_per_subcore = virHostCPUGetThreadsPerSubcore(arch)) < 0)
goto cleanup; goto cleanup;
/* If the subcore configuration is not valid, just pretend subcores /* If the subcore configuration is not valid, just pretend subcores
* are not in use and count threads one by one */ * are not in use and count threads one by one */
if (!nodeHasValidSubcoreConfiguration(threads_per_subcore)) if (!virHostCPUHasValidSubcoreConfiguration(threads_per_subcore))
threads_per_subcore = 0; threads_per_subcore = 0;
while ((direrr = virDirRead(nodedir, &nodedirent, sysfs_nodedir)) > 0) { while ((direrr = virDirRead(nodedir, &nodedirent, sysfs_nodedir)) > 0) {
@ -771,12 +771,12 @@ linuxNodeInfoCPUPopulate(FILE *cpuinfo,
sysfs_system_path, nodedirent->d_name) < 0) sysfs_system_path, nodedirent->d_name) < 0)
goto cleanup; goto cleanup;
if ((nodecpus = virNodeParseNode(sysfs_cpudir, arch, if ((nodecpus = virHostCPUParseNode(sysfs_cpudir, arch,
present_cpus_map, present_cpus_map,
online_cpus_map, online_cpus_map,
threads_per_subcore, threads_per_subcore,
&nodesockets, &nodecores, &nodesockets, &nodecores,
&nodethreads, &offline)) < 0) &nodethreads, &offline)) < 0)
goto cleanup; goto cleanup;
VIR_FREE(sysfs_cpudir); VIR_FREE(sysfs_cpudir);
@ -805,12 +805,12 @@ linuxNodeInfoCPUPopulate(FILE *cpuinfo,
if (virAsprintf(&sysfs_cpudir, "%s/cpu", sysfs_system_path) < 0) if (virAsprintf(&sysfs_cpudir, "%s/cpu", sysfs_system_path) < 0)
goto cleanup; goto cleanup;
if ((nodecpus = virNodeParseNode(sysfs_cpudir, arch, if ((nodecpus = virHostCPUParseNode(sysfs_cpudir, arch,
present_cpus_map, present_cpus_map,
online_cpus_map, online_cpus_map,
threads_per_subcore, threads_per_subcore,
&nodesockets, &nodecores, &nodesockets, &nodecores,
&nodethreads, &offline)) < 0) &nodethreads, &offline)) < 0)
goto cleanup; goto cleanup;
*nodes = 1; *nodes = 1;
@ -870,7 +870,7 @@ linuxNodeInfoCPUPopulate(FILE *cpuinfo,
} }
static int static int
virNodeCPUStatsAssign(virNodeCPUStatsPtr param, virHostCPUStatsAssign(virNodeCPUStatsPtr param,
const char *name, const char *name,
unsigned long long value) unsigned long long value)
{ {
@ -887,10 +887,10 @@ virNodeCPUStatsAssign(virNodeCPUStatsPtr param,
# define TICK_TO_NSEC (1000ull * 1000ull * 1000ull / sysconf(_SC_CLK_TCK)) # define TICK_TO_NSEC (1000ull * 1000ull * 1000ull / sysconf(_SC_CLK_TCK))
int int
linuxNodeGetCPUStats(FILE *procstat, virHostCPUGetStatsLinux(FILE *procstat,
int cpuNum, int cpuNum,
virNodeCPUStatsPtr params, virNodeCPUStatsPtr params,
int *nparams) int *nparams)
{ {
int ret = -1; int ret = -1;
char line[1024]; char line[1024];
@ -930,19 +930,19 @@ linuxNodeGetCPUStats(FILE *procstat,
continue; continue;
} }
if (virNodeCPUStatsAssign(&params[0], VIR_NODE_CPU_STATS_KERNEL, if (virHostCPUStatsAssign(&params[0], VIR_NODE_CPU_STATS_KERNEL,
(sys + irq + softirq) * TICK_TO_NSEC) < 0) (sys + irq + softirq) * TICK_TO_NSEC) < 0)
goto cleanup; goto cleanup;
if (virNodeCPUStatsAssign(&params[1], VIR_NODE_CPU_STATS_USER, if (virHostCPUStatsAssign(&params[1], VIR_NODE_CPU_STATS_USER,
(usr + ni) * TICK_TO_NSEC) < 0) (usr + ni) * TICK_TO_NSEC) < 0)
goto cleanup; goto cleanup;
if (virNodeCPUStatsAssign(&params[2], VIR_NODE_CPU_STATS_IDLE, if (virHostCPUStatsAssign(&params[2], VIR_NODE_CPU_STATS_IDLE,
idle * TICK_TO_NSEC) < 0) idle * TICK_TO_NSEC) < 0)
goto cleanup; goto cleanup;
if (virNodeCPUStatsAssign(&params[3], VIR_NODE_CPU_STATS_IOWAIT, if (virHostCPUStatsAssign(&params[3], VIR_NODE_CPU_STATS_IOWAIT,
iowait * TICK_TO_NSEC) < 0) iowait * TICK_TO_NSEC) < 0)
goto cleanup; goto cleanup;
@ -1066,7 +1066,7 @@ virHostMemGetStatsLinux(FILE *meminfo,
} }
static char * static char *
linuxGetCPUGlobalPath(const char *file) virHostCPUGetGlobalPathLinux(const char *file)
{ {
char *path = NULL; char *path = NULL;
@ -1077,21 +1077,21 @@ linuxGetCPUGlobalPath(const char *file)
} }
static char * static char *
linuxGetCPUPresentPath(void) virHostCPUGetPresentPathLinux(void)
{ {
return linuxGetCPUGlobalPath("present"); return virHostCPUGetGlobalPathLinux("present");
} }
static char * static char *
linuxGetCPUOnlinePath(void) virHostCPUGetOnlinePathLinux(void)
{ {
return linuxGetCPUGlobalPath("online"); return virHostCPUGetGlobalPathLinux("online");
} }
/* Determine the number of CPUs (maximum CPU id + 1) from a file containing /* Determine the number of CPUs (maximum CPU id + 1) from a file containing
* a list of CPU ids, like the Linux sysfs cpu/present file */ * a list of CPU ids, like the Linux sysfs cpu/present file */
static int static int
linuxParseCPUCount(const char *path) virHostCPUParseCountLinux(const char *path)
{ {
char *str = NULL; char *str = NULL;
char *tmp; char *tmp;
@ -1123,7 +1123,7 @@ linuxParseCPUCount(const char *path)
* 0-4,6-7. This function parses it and returns cpumap. * 0-4,6-7. This function parses it and returns cpumap.
*/ */
static virBitmapPtr static virBitmapPtr
linuxParseCPUmap(int max_cpuid, const char *path) virHostCPUParseMapLinux(int max_cpuid, const char *path)
{ {
virBitmapPtr map = NULL; virBitmapPtr map = NULL;
char *str = NULL; char *str = NULL;
@ -1145,7 +1145,7 @@ linuxParseCPUmap(int max_cpuid, const char *path)
static virBitmapPtr static virBitmapPtr
virNodeGetSiblingsList(const char *dir, int cpu_id) virNodeGetSiblingsListLinux(const char *dir, int cpu_id)
{ {
char *path = NULL; char *path = NULL;
char *buf = NULL; char *buf = NULL;
@ -1170,13 +1170,13 @@ virNodeGetSiblingsList(const char *dir, int cpu_id)
static int static int
nodeGetCPUInfo(virArch hostarch, virHostCPUGetInfo(virArch hostarch,
unsigned int *cpus, unsigned int *cpus,
unsigned int *mhz, unsigned int *mhz,
unsigned int *nodes, unsigned int *nodes,
unsigned int *sockets, unsigned int *sockets,
unsigned int *cores, unsigned int *cores,
unsigned int *threads) unsigned int *threads)
{ {
#ifdef __linux__ #ifdef __linux__
int ret = -1; int ret = -1;
@ -1188,9 +1188,9 @@ nodeGetCPUInfo(virArch hostarch,
return -1; return -1;
} }
ret = linuxNodeInfoCPUPopulate(cpuinfo, hostarch, ret = virHostCPUGetInfoPopulateLinux(cpuinfo, hostarch,
cpus, mhz, nodes, cpus, mhz, nodes,
sockets, cores, threads); sockets, cores, threads);
if (ret < 0) if (ret < 0)
goto cleanup; goto cleanup;
@ -1201,7 +1201,7 @@ nodeGetCPUInfo(virArch hostarch,
unsigned long cpu_freq; unsigned long cpu_freq;
size_t cpu_freq_len = sizeof(cpu_freq); size_t cpu_freq_len = sizeof(cpu_freq);
*cpus = appleFreebsdNodeGetCPUCount(); *cpus = virHostCPUGetCountAppleFreeBSD();
if (*cpus == -1) if (*cpus == -1)
return -1; return -1;
@ -1251,20 +1251,20 @@ nodeGetInfo(virNodeInfoPtr nodeinfo)
return -1; return -1;
nodeinfo->memory = memorybytes / 1024; nodeinfo->memory = memorybytes / 1024;
if (nodeGetCPUInfo(hostarch, if (virHostCPUGetInfo(hostarch,
&nodeinfo->cpus, &nodeinfo->mhz, &nodeinfo->cpus, &nodeinfo->mhz,
&nodeinfo->nodes, &nodeinfo->sockets, &nodeinfo->nodes, &nodeinfo->sockets,
&nodeinfo->cores, &nodeinfo->threads) < 0) &nodeinfo->cores, &nodeinfo->threads) < 0)
return -1; return -1;
return 0; return 0;
} }
int int
nodeGetCPUStats(int cpuNum ATTRIBUTE_UNUSED, virHostCPUGetStats(int cpuNum ATTRIBUTE_UNUSED,
virNodeCPUStatsPtr params ATTRIBUTE_UNUSED, virNodeCPUStatsPtr params ATTRIBUTE_UNUSED,
int *nparams ATTRIBUTE_UNUSED, int *nparams ATTRIBUTE_UNUSED,
unsigned int flags) unsigned int flags)
{ {
virCheckFlags(0, -1); virCheckFlags(0, -1);
@ -1277,13 +1277,13 @@ nodeGetCPUStats(int cpuNum ATTRIBUTE_UNUSED,
_("cannot open %s"), PROCSTAT_PATH); _("cannot open %s"), PROCSTAT_PATH);
return -1; return -1;
} }
ret = linuxNodeGetCPUStats(procstat, cpuNum, params, nparams); ret = virHostCPUGetStatsLinux(procstat, cpuNum, params, nparams);
VIR_FORCE_FCLOSE(procstat); VIR_FORCE_FCLOSE(procstat);
return ret; return ret;
} }
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
return freebsdNodeGetCPUStats(cpuNum, params, nparams); return virHostCPUGetStatsFreeBSD(cpuNum, params, nparams);
#else #else
virReportError(VIR_ERR_NO_SUPPORT, "%s", virReportError(VIR_ERR_NO_SUPPORT, "%s",
_("node CPU stats not implemented on this platform")); _("node CPU stats not implemented on this platform"));
@ -1349,7 +1349,7 @@ virHostMemGetStats(int cellNum ATTRIBUTE_UNUSED,
} }
int int
nodeGetCPUCount(void) virHostCPUGetCount(void)
{ {
#if defined(__linux__) #if defined(__linux__)
/* To support older kernels that lack cpu/present, such as 2.6.18 /* To support older kernels that lack cpu/present, such as 2.6.18
@ -1361,11 +1361,11 @@ nodeGetCPUCount(void)
char *cpupath = NULL; char *cpupath = NULL;
int ncpu = -1; int ncpu = -1;
if (!(present_path = linuxGetCPUPresentPath())) if (!(present_path = virHostCPUGetPresentPathLinux()))
return -1; return -1;
if (virFileExists(present_path)) { if (virFileExists(present_path)) {
ncpu = linuxParseCPUCount(present_path); ncpu = virHostCPUParseCountLinux(present_path);
goto cleanup; goto cleanup;
} }
@ -1393,7 +1393,7 @@ nodeGetCPUCount(void)
VIR_FREE(cpupath); VIR_FREE(cpupath);
return ncpu; return ncpu;
#elif defined(__FreeBSD__) || defined(__APPLE__) #elif defined(__FreeBSD__) || defined(__APPLE__)
return appleFreebsdNodeGetCPUCount(); return virHostCPUGetCountAppleFreeBSD();
#else #else
virReportError(VIR_ERR_NO_SUPPORT, "%s", virReportError(VIR_ERR_NO_SUPPORT, "%s",
_("host cpu counting not implemented on this platform")); _("host cpu counting not implemented on this platform"));
@ -1402,22 +1402,22 @@ nodeGetCPUCount(void)
} }
virBitmapPtr virBitmapPtr
nodeGetPresentCPUBitmap(void) virHostCPUGetPresentBitmap(void)
{ {
#ifdef __linux__ #ifdef __linux__
virBitmapPtr present_cpus = NULL; virBitmapPtr present_cpus = NULL;
char *present_path = NULL; char *present_path = NULL;
int npresent_cpus; int npresent_cpus;
if ((npresent_cpus = nodeGetCPUCount()) < 0) if ((npresent_cpus = virHostCPUGetCount()) < 0)
goto cleanup; goto cleanup;
if (!(present_path = linuxGetCPUPresentPath())) if (!(present_path = virHostCPUGetPresentPathLinux()))
goto cleanup; goto cleanup;
/* If the cpu/present file is available, parse it and exit */ /* If the cpu/present file is available, parse it and exit */
if (virFileExists(present_path)) { if (virFileExists(present_path)) {
present_cpus = linuxParseCPUmap(npresent_cpus, present_path); present_cpus = virHostCPUParseMapLinux(npresent_cpus, present_path);
goto cleanup; goto cleanup;
} }
@ -1440,7 +1440,7 @@ nodeGetPresentCPUBitmap(void)
} }
virBitmapPtr virBitmapPtr
nodeGetOnlineCPUBitmap(void) virHostCPUGetOnlineBitmap(void)
{ {
#ifdef __linux__ #ifdef __linux__
char *online_path = NULL; char *online_path = NULL;
@ -1448,14 +1448,14 @@ nodeGetOnlineCPUBitmap(void)
virBitmapPtr cpumap; virBitmapPtr cpumap;
int present; int present;
present = nodeGetCPUCount(); present = virHostCPUGetCount();
if (present < 0) if (present < 0)
return NULL; return NULL;
if (!(online_path = linuxGetCPUOnlinePath())) if (!(online_path = virHostCPUGetOnlinePathLinux()))
return NULL; return NULL;
if (virFileExists(online_path)) { if (virFileExists(online_path)) {
cpumap = linuxParseCPUmap(present, online_path); cpumap = virHostCPUParseMapLinux(present, online_path);
} else { } else {
size_t i; size_t i;
@ -1792,9 +1792,9 @@ virHostMemGetParameters(virTypedParameterPtr params ATTRIBUTE_UNUSED,
} }
int int
nodeGetCPUMap(unsigned char **cpumap, virHostCPUGetMap(unsigned char **cpumap,
unsigned int *online, unsigned int *online,
unsigned int flags) unsigned int flags)
{ {
virBitmapPtr cpus = NULL; virBitmapPtr cpus = NULL;
int ret = -1; int ret = -1;
@ -1803,9 +1803,9 @@ nodeGetCPUMap(unsigned char **cpumap,
virCheckFlags(0, -1); virCheckFlags(0, -1);
if (!cpumap && !online) if (!cpumap && !online)
return nodeGetCPUCount(); return virHostCPUGetCount();
if (!(cpus = nodeGetOnlineCPUBitmap())) if (!(cpus = virHostCPUGetOnlineBitmap()))
goto cleanup; goto cleanup;
if (cpumap && virBitmapToData(cpus, cpumap, &dummy) < 0) if (cpumap && virBitmapToData(cpus, cpumap, &dummy) < 0)
@ -1966,7 +1966,7 @@ virNodeCapsFillCPUInfo(const char *cpupath ATTRIBUTE_UNUSED,
cpu->core_id = tmp; cpu->core_id = tmp;
if (!(cpu->siblings = virNodeGetSiblingsList(cpupath, cpu_id))) if (!(cpu->siblings = virNodeGetSiblingsListLinux(cpupath, cpu_id)))
return -1; return -1;
return 0; return 0;
@ -2312,7 +2312,7 @@ virHostMemAllocPages(unsigned int npages,
* Returns the number of threads per subcore if subcores are in use, zero * Returns the number of threads per subcore if subcores are in use, zero
* if subcores are not in use, and a negative value on error */ * if subcores are not in use, and a negative value on error */
int int
nodeGetThreadsPerSubcore(virArch arch) virHostCPUGetThreadsPerSubcore(virArch arch)
{ {
int threads_per_subcore = 0; int threads_per_subcore = 0;
const char *kvmpath = "/dev/kvm"; const char *kvmpath = "/dev/kvm";
@ -2359,7 +2359,7 @@ nodeGetThreadsPerSubcore(virArch arch)
/* Fallback for nodeGetThreadsPerSubcore() used when KVM headers /* Fallback for nodeGetThreadsPerSubcore() used when KVM headers
* are not available on the system */ * are not available on the system */
int int
nodeGetThreadsPerSubcore(virArch arch ATTRIBUTE_UNUSED) virHostCPUGetThreadsPerSubcore(virArch arch ATTRIBUTE_UNUSED)
{ {
return 0; return 0;
} }

View File

@ -29,10 +29,10 @@
int nodeGetInfo(virNodeInfoPtr nodeinfo); int nodeGetInfo(virNodeInfoPtr nodeinfo);
int nodeCapsInitNUMA(virCapsPtr caps); int nodeCapsInitNUMA(virCapsPtr caps);
int nodeGetCPUStats(int cpuNum, int virHostCPUGetStats(int cpuNum,
virNodeCPUStatsPtr params, virNodeCPUStatsPtr params,
int *nparams, int *nparams,
unsigned int flags); unsigned int flags);
int virHostMemGetStats(int cellNum, int virHostMemGetStats(int cellNum,
virNodeMemoryStatsPtr params, virNodeMemoryStatsPtr params,
int *nparams, int *nparams,
@ -43,10 +43,10 @@ int virHostMemGetCellsFree(unsigned long long *freeMems,
int virHostMemGetInfo(unsigned long long *mem, int virHostMemGetInfo(unsigned long long *mem,
unsigned long long *freeMem); unsigned long long *freeMem);
virBitmapPtr nodeGetPresentCPUBitmap(void); virBitmapPtr virHostCPUGetPresentBitmap(void);
virBitmapPtr nodeGetOnlineCPUBitmap(void); virBitmapPtr virHostCPUGetOnlineBitmap(void);
int nodeGetCPUCount(void); int virHostCPUGetCount(void);
int nodeGetThreadsPerSubcore(virArch arch); int virHostCPUGetThreadsPerSubcore(virArch arch);
int virHostMemGetParameters(virTypedParameterPtr params, int virHostMemGetParameters(virTypedParameterPtr params,
int *nparams, int *nparams,
@ -56,9 +56,9 @@ int virHostMemSetParameters(virTypedParameterPtr params,
int nparams, int nparams,
unsigned int flags); unsigned int flags);
int nodeGetCPUMap(unsigned char **cpumap, int virHostCPUGetMap(unsigned char **cpumap,
unsigned int *online, unsigned int *online,
unsigned int flags); unsigned int flags);
int virHostMemGetFreePages(unsigned int npages, int virHostMemGetFreePages(unsigned int npages,
unsigned int *pages, unsigned int *pages,

View File

@ -25,21 +25,21 @@
# include "nodeinfo.h" # include "nodeinfo.h"
# ifdef __linux__ # ifdef __linux__
void linuxNodeInfoSetSysFSSystemPath(const char *path); void virHostCPUSetSysFSSystemPathLinux(const char *path);
int linuxNodeInfoCPUPopulate(FILE *cpuinfo, int virHostCPUGetInfoPopulateLinux(FILE *cpuinfo,
virArch arch, virArch arch,
unsigned int *cpus, unsigned int *cpus,
unsigned int *mhz, unsigned int *mhz,
unsigned int *nodes, unsigned int *nodes,
unsigned int *sockets, unsigned int *sockets,
unsigned int *cores, unsigned int *cores,
unsigned int *threads); unsigned int *threads);
int linuxNodeGetCPUStats(FILE *procstat, int virHostCPUGetStatsLinux(FILE *procstat,
int cpuNum, int cpuNum,
virNodeCPUStatsPtr params, virNodeCPUStatsPtr params,
int *nparams); int *nparams);
# endif # endif
#endif /* __NODEINFO_PRIV_H__ */ #endif /* __NODEINFO_PRIV_H__ */

View File

@ -2168,7 +2168,7 @@ openvzNodeGetCPUStats(virConnectPtr conn ATTRIBUTE_UNUSED,
int *nparams, int *nparams,
unsigned int flags) unsigned int flags)
{ {
return nodeGetCPUStats(cpuNum, params, nparams, flags); return virHostCPUGetStats(cpuNum, params, nparams, flags);
} }
@ -2209,7 +2209,7 @@ openvzNodeGetCPUMap(virConnectPtr conn ATTRIBUTE_UNUSED,
unsigned int *online, unsigned int *online,
unsigned int flags) unsigned int flags)
{ {
return nodeGetCPUMap(cpumap, online, flags); return virHostCPUGetMap(cpumap, online, flags);
} }

View File

@ -5152,7 +5152,7 @@ qemuDomainGetVcpuPinInfo(virDomainPtr dom,
priv = vm->privateData; priv = vm->privateData;
ret = virDomainDefGetVcpuPinInfoHelper(def, maplen, ncpumaps, cpumaps, ret = virDomainDefGetVcpuPinInfoHelper(def, maplen, ncpumaps, cpumaps,
nodeGetCPUCount(), virHostCPUGetCount(),
priv->autoCpuset); priv->autoCpuset);
cleanup: cleanup:
virDomainObjEndAPI(&vm); virDomainObjEndAPI(&vm);
@ -5297,7 +5297,7 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom,
if (!(def = virDomainObjGetOneDef(vm, flags))) if (!(def = virDomainObjGetOneDef(vm, flags)))
goto cleanup; goto cleanup;
if ((hostcpus = nodeGetCPUCount()) < 0) if ((hostcpus = virHostCPUGetCount()) < 0)
goto cleanup; goto cleanup;
priv = vm->privateData; priv = vm->privateData;
@ -5545,7 +5545,7 @@ qemuDomainGetIOThreadsConfig(virDomainDefPtr targetDef,
if (targetDef->niothreadids == 0) if (targetDef->niothreadids == 0)
return 0; return 0;
if ((hostcpus = nodeGetCPUCount()) < 0) if ((hostcpus = virHostCPUGetCount()) < 0)
goto cleanup; goto cleanup;
if (VIR_ALLOC_N(info_ret, targetDef->niothreadids) < 0) if (VIR_ALLOC_N(info_ret, targetDef->niothreadids) < 0)
@ -18095,7 +18095,7 @@ qemuNodeGetCPUStats(virConnectPtr conn,
if (virNodeGetCPUStatsEnsureACL(conn) < 0) if (virNodeGetCPUStatsEnsureACL(conn) < 0)
return -1; return -1;
return nodeGetCPUStats(cpuNum, params, nparams, flags); return virHostCPUGetStats(cpuNum, params, nparams, flags);
} }
@ -18176,7 +18176,7 @@ qemuNodeGetCPUMap(virConnectPtr conn,
if (virNodeGetCPUMapEnsureACL(conn) < 0) if (virNodeGetCPUMapEnsureACL(conn) < 0)
return -1; return -1;
return nodeGetCPUMap(cpumap, online, flags); return virHostCPUGetMap(cpumap, online, flags);
} }

View File

@ -2229,7 +2229,7 @@ qemuProcessInitCpuAffinity(virDomainObjPtr vm)
/* setaffinity fails if you set bits for CPUs which /* setaffinity fails if you set bits for CPUs which
* aren't present, so we have to limit ourselves */ * aren't present, so we have to limit ourselves */
if ((hostcpus = nodeGetCPUCount()) < 0) if ((hostcpus = virHostCPUGetCount()) < 0)
goto cleanup; goto cleanup;
if (hostcpus > QEMUD_CPUMASK_LEN) if (hostcpus > QEMUD_CPUMASK_LEN)

View File

@ -2788,7 +2788,7 @@ umlNodeGetCPUStats(virConnectPtr conn,
if (virNodeGetCPUStatsEnsureACL(conn) < 0) if (virNodeGetCPUStatsEnsureACL(conn) < 0)
return -1; return -1;
return nodeGetCPUStats(cpuNum, params, nparams, flags); return virHostCPUGetStats(cpuNum, params, nparams, flags);
} }
@ -2869,7 +2869,7 @@ umlNodeGetCPUMap(virConnectPtr conn,
if (virNodeGetCPUMapEnsureACL(conn) < 0) if (virNodeGetCPUMapEnsureACL(conn) < 0)
return -1; return -1;
return nodeGetCPUMap(cpumap, online, flags); return virHostCPUGetMap(cpumap, online, flags);
} }

View File

@ -3147,7 +3147,7 @@ virCgroupGetPercpuStats(virCgroupPtr group,
} }
/* To parse account file, we need to know how many cpus are present. */ /* To parse account file, we need to know how many cpus are present. */
if (!(cpumap = nodeGetPresentCPUBitmap())) if (!(cpumap = virHostCPUGetPresentBitmap()))
return -1; return -1;
total_cpus = virBitmapSize(cpumap); total_cpus = virBitmapSize(cpumap);

View File

@ -919,7 +919,7 @@ vzNodeGetCPUMap(virConnectPtr conn ATTRIBUTE_UNUSED,
unsigned int *online, unsigned int *online,
unsigned int flags) unsigned int flags)
{ {
return nodeGetCPUMap(cpumap, online, flags); return virHostCPUGetMap(cpumap, online, flags);
} }
static int static int
@ -1477,7 +1477,7 @@ vzNodeGetCPUStats(virConnectPtr conn ATTRIBUTE_UNUSED,
int *nparams, int *nparams,
unsigned int flags) unsigned int flags)
{ {
return nodeGetCPUStats(cpuNum, params, nparams, flags); return virHostCPUGetStats(cpuNum, params, nparams, flags);
} }
static int static int

View File

@ -1151,7 +1151,7 @@ prlsdkConvertCpuInfo(PRL_HANDLE sdkdom,
PRL_RESULT pret; PRL_RESULT pret;
int ret = -1; int ret = -1;
if ((hostcpus = nodeGetCPUCount()) < 0) if ((hostcpus = virHostCPUGetCount()) < 0)
goto cleanup; goto cleanup;
/* get number of CPUs */ /* get number of CPUs */

View File

@ -23,7 +23,7 @@
#include "nodeinfo.h" #include "nodeinfo.h"
int int
nodeGetThreadsPerSubcore(virArch arch) virHostCPUGetThreadsPerSubcore(virArch arch)
{ {
int threads_per_subcore = 0; int threads_per_subcore = 0;

View File

@ -41,10 +41,10 @@ linuxTestCompareFiles(const char *cpuinfofile,
} }
memset(&nodeinfo, 0, sizeof(nodeinfo)); memset(&nodeinfo, 0, sizeof(nodeinfo));
if (linuxNodeInfoCPUPopulate(cpuinfo, arch, if (virHostCPUGetInfoPopulateLinux(cpuinfo, arch,
&nodeinfo.cpus, &nodeinfo.mhz, &nodeinfo.cpus, &nodeinfo.mhz,
&nodeinfo.nodes, &nodeinfo.sockets, &nodeinfo.nodes, &nodeinfo.sockets,
&nodeinfo.cores, &nodeinfo.threads) < 0) { &nodeinfo.cores, &nodeinfo.threads) < 0) {
if (virTestGetDebug()) { if (virTestGetDebug()) {
if (virGetLastError()) if (virGetLastError())
VIR_TEST_DEBUG("\n%s\n", virGetLastErrorMessage()); VIR_TEST_DEBUG("\n%s\n", virGetLastErrorMessage());
@ -113,14 +113,14 @@ linuxCPUStatsCompareFiles(const char *cpustatfile,
goto fail; goto fail;
} }
if (linuxNodeGetCPUStats(NULL, 0, NULL, &nparams) < 0) if (virHostCPUGetStatsLinux(NULL, 0, NULL, &nparams) < 0)
goto fail; goto fail;
if (VIR_ALLOC_N(params, nparams) < 0) if (VIR_ALLOC_N(params, nparams) < 0)
goto fail; goto fail;
if (linuxNodeGetCPUStats(cpustat, VIR_NODE_CPU_STATS_ALL_CPUS, params, if (virHostCPUGetStatsLinux(cpustat, VIR_NODE_CPU_STATS_ALL_CPUS, params,
&nparams) < 0) &nparams) < 0)
goto fail; goto fail;
if (linuxCPUStatsToBuf(&buf, VIR_NODE_CPU_STATS_ALL_CPUS, if (linuxCPUStatsToBuf(&buf, VIR_NODE_CPU_STATS_ALL_CPUS,
@ -128,7 +128,7 @@ linuxCPUStatsCompareFiles(const char *cpustatfile,
goto fail; goto fail;
for (i = 0; i < ncpus; i++) { for (i = 0; i < ncpus; i++) {
if (linuxNodeGetCPUStats(cpustat, i, params, &nparams) < 0) if (virHostCPUGetStatsLinux(cpustat, i, params, &nparams) < 0)
goto fail; goto fail;
if (linuxCPUStatsToBuf(&buf, i, params, nparams) < 0) if (linuxCPUStatsToBuf(&buf, i, params, nparams) < 0)
goto fail; goto fail;
@ -177,9 +177,9 @@ linuxTestNodeInfo(const void *opaque)
goto cleanup; goto cleanup;
} }
linuxNodeInfoSetSysFSSystemPath(sysfs_prefix); virHostCPUSetSysFSSystemPathLinux(sysfs_prefix);
result = linuxTestCompareFiles(cpuinfo, data->arch, output); result = linuxTestCompareFiles(cpuinfo, data->arch, output);
linuxNodeInfoSetSysFSSystemPath(NULL); virHostCPUSetSysFSSystemPathLinux(NULL);
cleanup: cleanup:
VIR_FREE(cpuinfo); VIR_FREE(cpuinfo);

View File

@ -649,8 +649,8 @@ static int testCgroupGetPercpuStats(const void *args ATTRIBUTE_UNUSED)
goto cleanup; goto cleanup;
} }
if (nodeGetCPUCount() != EXPECTED_NCPUS) { if (virHostCPUGetCount() != EXPECTED_NCPUS) {
fprintf(stderr, "Unexpected: nodeGetCPUCount() yields: %d\n", nodeGetCPUCount()); fprintf(stderr, "Unexpected: virHostCPUGetCount() yields: %d\n", virHostCPUGetCount());
goto cleanup; goto cleanup;
} }