/* setaffinity fails if you set bits for CPUs which
* aren't present, so we have to limit ourselves */
- if ((hostcpus = nodeGetCPUCount()) < 0)
+ if ((hostcpus = nodeGetCPUCount(NULL)) < 0)
return -1;
if (maxcpu > hostcpus)
}
int
-nodeGetCPUCount(void)
+nodeGetCPUCount(const char *sysfs_prefix ATTRIBUTE_UNUSED)
{
#if defined(__linux__)
/* To support older kernels that lack cpu/present, such as 2.6.18
* will be consecutive.
*/
char *present_path = NULL;
+ const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH;
char *cpupath = NULL;
int ncpu = -1;
- if (!(present_path = linuxGetCPUPresentPath(NULL)))
+ if (!(present_path = linuxGetCPUPresentPath(prefix)))
return -1;
if (virFileExists(present_path)) {
ncpu = linuxParseCPUmax(present_path);
- } else if (virFileExists(SYSFS_SYSTEM_PATH "/cpu/cpu0")) {
+ goto cleanup;
+ }
+
+ if (virAsprintf(&cpupath, "%s/cpu/cpu0", prefix) < 0)
+ goto cleanup;
+ if (virFileExists(cpupath)) {
ncpu = 0;
do {
ncpu++;
VIR_FREE(cpupath);
if (virAsprintf(&cpupath, "%s/cpu/cpu%d",
- SYSFS_SYSTEM_PATH, ncpu) < 0) {
+ prefix, ncpu) < 0) {
ncpu = -1;
goto cleanup;
}
virBitmapPtr bitmap = NULL;
#endif
- if ((max_present = nodeGetCPUCount()) < 0)
+ if ((max_present = nodeGetCPUCount(NULL)) < 0)
return NULL;
#ifdef __linux__
virBitmapPtr cpumap;
int present;
- present = nodeGetCPUCount();
+ present = nodeGetCPUCount(NULL);
if (present < 0)
return NULL;
virCheckFlags(0, -1);
if (!cpumap && !online)
- return nodeGetCPUCount();
+ return nodeGetCPUCount(NULL);
if (!(cpus = nodeGetCPUBitmap(&maxpresent)))
goto cleanup;
virBitmapPtr nodeGetPresentCPUBitmap(void);
virBitmapPtr nodeGetCPUBitmap(int *max_id);
-int nodeGetCPUCount(void);
+int nodeGetCPUCount(const char *sysfs_prefix);
int nodeGetMemoryParameters(virTypedParameterPtr params,
int *nparams,
if (!(def = virDomainObjGetOneDef(vm, flags)))
goto cleanup;
- if ((hostcpus = nodeGetCPUCount()) < 0)
+ if ((hostcpus = nodeGetCPUCount(NULL)) < 0)
goto cleanup;
if (!(allcpumap = virBitmapNew(hostcpus)))
if (!(def = virDomainObjGetOneDef(vm, flags)))
goto cleanup;
- if ((hostcpus = nodeGetCPUCount()) < 0)
+ if ((hostcpus = nodeGetCPUCount(NULL)) < 0)
goto cleanup;
if (def->cputune.emulatorpin) {
if (targetDef->iothreads == 0)
return 0;
- if ((hostcpus = nodeGetCPUCount()) < 0)
+ if ((hostcpus = nodeGetCPUCount(NULL)) < 0)
goto cleanup;
if (VIR_ALLOC_N(info_ret, targetDef->iothreads) < 0)
/* setaffinity fails if you set bits for CPUs which
* aren't present, so we have to limit ourselves */
- if ((hostcpus = nodeGetCPUCount()) < 0)
+ if ((hostcpus = nodeGetCPUCount(NULL)) < 0)
goto cleanup;
if (hostcpus > QEMUD_CPUMASK_LEN)
PRL_RESULT pret;
int ret = -1;
- if ((hostcpus = nodeGetCPUCount()) < 0)
+ if ((hostcpus = nodeGetCPUCount(NULL)) < 0)
goto cleanup;
/* get number of CPUs */
goto cleanup;
}
- if (nodeGetCPUCount() != EXPECTED_NCPUS) {
- fprintf(stderr, "Unexpected: nodeGetCPUCount() yields: %d\n", nodeGetCPUCount());
+ if (nodeGetCPUCount(NULL) != EXPECTED_NCPUS) {
+ fprintf(stderr, "Unexpected: nodeGetCPUCount() yields: %d\n", nodeGetCPUCount(NULL));
goto cleanup;
}