Currently we are using libnuma to set up numa, but it's desired to
use cgroup cpuset to do the job instead. But for old systems that
don't have cgroup cpuset, we fall back to libnuma.
---
src/conf/domain_conf.h | 8 ++++++++
src/qemu/qemu_process.c | 11 ++++++++---
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index c360674..29ac165 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1352,6 +1352,12 @@ enum virDomainNumatuneMemMode {
VIR_DOMAIN_NUMATUNE_MEM_LAST
};
+enum virDomainNumatuneBackend {
+ VIR_DOMAIN_NUMATUNE_BACKEND_NONE,
+ VIR_DOMAIN_NUMATUNE_BACKEND_LIBNUMA,
+ VIR_DOMAIN_NUMATUNE_BACKEND_CGROUP_CPUSET,
+};
+
typedef struct _virDomainNumatuneDef virDomainNumatuneDef;
typedef virDomainNumatuneDef *virDomainNumatuneDefPtr;
struct _virDomainNumatuneDef {
@@ -1360,6 +1366,8 @@ struct _virDomainNumatuneDef {
int mode;
} memory;
+ int backend;
+
/* Future NUMA tuning related stuff should go here. */
};
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 2882ef8..8add0b8 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1334,12 +1334,16 @@ qemuProcessInitNumaMemoryPolicy(virDomainObjPtr vm)
if (!vm->def->numatune.memory.nodemask)
return 0;
+ if (vm->def->numatune.backend != VIR_DOMAIN_NUMATUNE_BACKEND_NONE)
+ return 0;
+ vm->def->numatune.backend = VIR_DOMAIN_NUMATUNE_BACKEND_LIBNUMA;
+
VIR_DEBUG("Setting NUMA memory policy");
if (numa_available() < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Host kernel is not aware of
NUMA."));
- return -1;
+ goto cleanup;
}
maxnode = numa_max_node() + 1;
@@ -1351,7 +1355,7 @@ qemuProcessInitNumaMemoryPolicy(virDomainObjPtr vm)
if (i > NUMA_NUM_NODES) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("Host cannot support NUMA node %d"), i);
- return -1;
+ goto cleanup;
}
if (i > maxnode && !warned) {
VIR_WARN("nodeset is out of range, there is only %d NUMA "
@@ -1397,9 +1401,10 @@ qemuProcessInitNumaMemoryPolicy(virDomainObjPtr vm)
goto cleanup;
}
- ret = 0;
+ return 0;
cleanup:
+ vm->def->numatune.backend = VIR_DOMAIN_NUMATUNE_BACKEND_NONE;
return ret;
}
#else
--
1.7.3.1