提交 98d83094 编写于 作者: E Eric Blake

build: fix NUMA build on RHEL 5

Use NUMA's older nodemask_t (fixed-size map) rather than the newer
'struct bitmask' (variable-size) in order to still compile on RHEL 5,
with its numactl-devel-0.9.8.

* src/qemu/qemu_process.c [HAVE_NUMA]: Prefer back-compat mode.
(qemuProcessInitNumaMemoryPolicy): Use older nodemask_t.
上级 b4683297
......@@ -40,6 +40,7 @@
#include "qemu_bridge_filter.h"
#if HAVE_NUMACTL
# define NUMA_VERSION1_COMPATIBILITY 1
# include <numa.h>
#endif
......@@ -1279,7 +1280,7 @@ qemuProcessDetectVcpuPIDs(struct qemud_driver *driver,
static int
qemuProcessInitNumaMemoryPolicy(virDomainObjPtr vm)
{
struct bitmask *mask = NULL;
nodemask_t mask;
virErrorPtr orig_err = NULL;
virErrorPtr err = NULL;
int mode = -1;
......@@ -1287,6 +1288,7 @@ qemuProcessInitNumaMemoryPolicy(virDomainObjPtr vm)
int ret = -1;
int i = 0;
int maxnode = 0;
bool warned = false;
if (!vm->def->numatune.memory.nodemask)
return 0;
......@@ -1299,47 +1301,23 @@ qemuProcessInitNumaMemoryPolicy(virDomainObjPtr vm)
return -1;
}
if (VIR_ALLOC(mask) < 0) {
virReportOOMError();
return -1;
}
maxnode = numa_max_node() + 1;
mask->size = VIR_DOMAIN_CPUMASK_LEN / sizeof (unsigned long);
if (VIR_ALLOC_N(mask->maskp, mask->size) < 0) {
virReportOOMError();
goto cleanup;
}
/* Convert nodemask to NUMA bitmask. */
nodemask_zero(&mask);
for (i = 0; i < VIR_DOMAIN_CPUMASK_LEN; i++) {
int cur = 0;
int mod = 0;
if (i) {
cur = i / (8 * sizeof (unsigned long));
mod = i % (8 * sizeof (unsigned long));
}
if (vm->def->numatune.memory.nodemask[i]) {
mask->maskp[cur] |= 1 << mod;
}
}
maxnode = numa_max_node() + 1;
for (i = 0; i < mask->size; i++) {
if (i < (maxnode % (8 * sizeof (unsigned long)))) {
if (mask->maskp[i] & ~maxnode) {
if (i > NUMA_NUM_NODES) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("Host cannot support NUMA node %d"), i);
return -1;
}
if (i > maxnode && !warned) {
VIR_WARN("nodeset is out of range, there is only %d NUMA "
"nodes on host", maxnode);
break;
warned = true;
}
continue;
}
if (mask->maskp[i]) {
VIR_WARN("nodeset is out of range, there is only %d NUMA nodes "
"on host", maxnode);
nodemask_set(&mask, i);
}
}
......@@ -1348,7 +1326,7 @@ qemuProcessInitNumaMemoryPolicy(virDomainObjPtr vm)
if (mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT) {
numa_set_bind_policy(1);
numa_set_membind(mask);
numa_set_membind(&mask);
numa_set_bind_policy(0);
err = virGetLastError();
......@@ -1362,8 +1340,8 @@ qemuProcessInitNumaMemoryPolicy(virDomainObjPtr vm)
}
} else if (mode == VIR_DOMAIN_NUMATUNE_MEM_PREFERRED) {
int nnodes = 0;
for (i = 0; i < mask->size; i++) {
if (numa_bitmask_isbitset(mask, i)) {
for (i = 0; i < NUMA_NUM_NODES; i++) {
if (nodemask_isset(&mask, i)) {
node = i;
nnodes++;
}
......@@ -1389,7 +1367,7 @@ qemuProcessInitNumaMemoryPolicy(virDomainObjPtr vm)
goto cleanup;
}
} else if (mode == VIR_DOMAIN_NUMATUNE_MEM_INTERLEAVE) {
numa_set_interleave_mask(mask);
numa_set_interleave_mask(&mask);
err = virGetLastError();
if ((err && (err->code != orig_err->code)) ||
......@@ -1412,7 +1390,6 @@ qemuProcessInitNumaMemoryPolicy(virDomainObjPtr vm)
ret = 0;
cleanup:
numa_bitmask_free(mask);
return ret;
}
#else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册