提交 9571eaaa 编写于 作者: M Michal Privoznik

virNodeParseNode: Propagate host architecture

As in previous commit, there are again some places where we can do
runtime decision instead of compile time. This time it's whether the
'topology/physical_package_id' is allowed to have '-1' within or not.
Then, core ID is pared differently on s390(x) than on the rest of
architectures.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 e8083575
...@@ -389,19 +389,18 @@ virNodeCountThreadSiblings(const char *dir, unsigned int cpu) ...@@ -389,19 +389,18 @@ virNodeCountThreadSiblings(const char *dir, unsigned int cpu)
} }
static int static int
virNodeParseSocket(const char *dir, unsigned int cpu) virNodeParseSocket(const char *dir,
virArch arch,
unsigned int cpu)
{ {
int ret = virNodeGetCpuValue(dir, cpu, "topology/physical_package_id", int ret = virNodeGetCpuValue(dir, cpu, "topology/physical_package_id", 0);
0);
# if defined(__powerpc__) || \ if (ARCH_IS_PPC(arch) || ARCH_IS_S390(arch)) {
defined(__powerpc64__) || \ /* ppc and s390(x) has -1 */
defined(__s390__) || \ if (ret < 0)
defined(__s390x__) || \ ret = 0;
defined(__aarch64__) }
/* ppc and s390(x) has -1 */
if (ret < 0)
ret = 0;
# endif
return ret; return ret;
} }
...@@ -421,10 +420,11 @@ CPU_COUNT(cpu_set_t *set) ...@@ -421,10 +420,11 @@ CPU_COUNT(cpu_set_t *set)
/* parses a node entry, returning number of processors in the node and /* parses a node entry, returning number of processors in the node and
* filling arguments */ * filling arguments */
static int static int
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3)
ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5)
ATTRIBUTE_NONNULL(5) ATTRIBUTE_NONNULL(6)
virNodeParseNode(const char *node, virNodeParseNode(const char *node,
virArch arch,
int *sockets, int *sockets,
int *cores, int *cores,
int *threads, int *threads,
...@@ -467,7 +467,7 @@ virNodeParseNode(const char *node, ...@@ -467,7 +467,7 @@ virNodeParseNode(const char *node,
continue; continue;
/* Parse socket */ /* Parse socket */
if ((sock = virNodeParseSocket(node, cpu)) < 0) if ((sock = virNodeParseSocket(node, arch, cpu)) < 0)
goto cleanup; goto cleanup;
CPU_SET(sock, &sock_map); CPU_SET(sock, &sock_map);
...@@ -504,7 +504,7 @@ virNodeParseNode(const char *node, ...@@ -504,7 +504,7 @@ virNodeParseNode(const char *node,
processors++; processors++;
/* Parse socket */ /* Parse socket */
if ((sock = virNodeParseSocket(node, cpu)) < 0) if ((sock = virNodeParseSocket(node, arch, cpu)) < 0)
goto cleanup; goto cleanup;
if (!CPU_ISSET(sock, &sock_map)) { if (!CPU_ISSET(sock, &sock_map)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
...@@ -513,13 +513,12 @@ virNodeParseNode(const char *node, ...@@ -513,13 +513,12 @@ virNodeParseNode(const char *node,
} }
/* Parse core */ /* Parse core */
# if defined(__s390__) || \ if (ARCH_IS_S390(arch)) {
defined(__s390x__) /* logical cpu is equivalent to a core on s390 */
/* logical cpu is equivalent to a core on s390 */ core = cpu;
core = cpu; } else {
# else core = virNodeGetCpuValue(node, cpu, "topology/core_id", 0);
core = virNodeGetCpuValue(node, cpu, "topology/core_id", 0); }
# endif
CPU_SET(core, &core_maps[sock]); CPU_SET(core, &core_maps[sock]);
...@@ -675,7 +674,8 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo, ...@@ -675,7 +674,8 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
sysfs_dir, nodedirent->d_name) < 0) sysfs_dir, nodedirent->d_name) < 0)
goto cleanup; goto cleanup;
if ((cpus = virNodeParseNode(sysfs_cpudir, &socks, &cores, if ((cpus = virNodeParseNode(sysfs_cpudir, arch,
&socks, &cores,
&threads, &offline)) < 0) &threads, &offline)) < 0)
goto cleanup; goto cleanup;
...@@ -705,7 +705,8 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo, ...@@ -705,7 +705,8 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
if (virAsprintf(&sysfs_cpudir, "%s/cpu", sysfs_dir) < 0) if (virAsprintf(&sysfs_cpudir, "%s/cpu", sysfs_dir) < 0)
goto cleanup; goto cleanup;
if ((cpus = virNodeParseNode(sysfs_cpudir, &socks, &cores, if ((cpus = virNodeParseNode(sysfs_cpudir, arch,
&socks, &cores,
&threads, &offline)) < 0) &threads, &offline)) < 0)
goto cleanup; goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册