int nodecpus, nodecores, nodesockets, nodethreads, offline = 0;
int threads_per_subcore = 0;
unsigned int node;
- int ret = -1;
g_autofree char *sysfs_nodedir = NULL;
g_autofree char *sysfs_cpudir_fallback = NULL;
int direrr;
/* 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 */
- present_cpus_map = virHostCPUGetPresentBitmap();
- if (!present_cpus_map)
- goto cleanup;
- online_cpus_map = virHostCPUGetOnlineBitmap();
- if (!online_cpus_map)
- goto cleanup;
+ if (!(present_cpus_map = virHostCPUGetPresentBitmap()))
+ return -1;
+
+ if (!(online_cpus_map = virHostCPUGetOnlineBitmap()))
+ return -1;
/* OK, we've parsed clock speed out of /proc/cpuinfo. Get the
* core, node, socket, thread and topology information from /sys
* On hosts other than POWER this will be 0, in which case a simpler
* thread-counting logic will be used */
if ((threads_per_subcore = virHostCPUGetThreadsPerSubcore(arch)) < 0)
- goto cleanup;
+ return -1;
/* If the subcore configuration is not valid, just pretend subcores
* are not in use and count threads one by one */
threads_per_subcore,
&nodesockets, &nodecores,
&nodethreads, &offline)) < 0)
- goto cleanup;
+ return -1;
*cpus += nodecpus;
}
if (direrr < 0)
- goto cleanup;
+ return -1;
if (*cpus && *nodes)
goto done;
threads_per_subcore,
&nodesockets, &nodecores,
&nodethreads, &offline)) < 0)
- goto cleanup;
+ return -1;
*nodes = 1;
*cpus = nodecpus;
/* There should always be at least one cpu, socket, node, and thread. */
if (*cpus == 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no CPUs found"));
- goto cleanup;
+ return -1;
}
if (*sockets == 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no sockets found"));
- goto cleanup;
+ return -1;
}
if (*threads == 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no threads found"));
- goto cleanup;
+ return -1;
}
/* Now check if the topology makes sense. There are machines that don't
*threads = 1;
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
# define TICK_TO_NSEC (1000ull * 1000ull * 1000ull / sysconf(_SC_CLK_TCK))