[libvirt] [PATCH 03/10] use cpuset to manage numa

Hu Tao hutao at cn.fujitsu.com
Thu Nov 3 11:55:18 UTC 2011


This patch deprecates libnuma and uses cpuset to manage numa.
We can further add a `numatune' command to adjust numa parameters
through cpuset.
---
 src/qemu/qemu_cgroup.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 2a10bd2..49307b2 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -365,6 +365,29 @@ int qemuSetupCgroup(struct qemud_driver *driver,
         }
     }
 
+    if (vm->def->numatune.memory.nodemask) {
+        if (qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPUSET)) {
+            char *mask = virDomainCpuSetFormat(vm->def->numatune.memory.nodemask, VIR_DOMAIN_CPUMASK_LEN);
+            if (!mask) {
+                qemuReportError(VIR_ERR_INTERNAL_ERROR,
+                                _("failed to convert memory nodemask"));
+                goto cleanup;
+            }
+
+            rc = virCgroupSetCpusetMems(cgroup, mask);
+            if (rc != 0) {
+                virReportSystemError(-rc,
+                                     _("Unable to set cpuset.mems for domain %s"),
+                                     vm->def->name);
+                goto cleanup;
+            }
+        } else {
+            qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                            _("Unable to set numa for domain %s since cpuset cgroup is "
+                              "not available on this host"), vm->def->name);
+            goto cleanup;
+        }
+    }
 done:
     virCgroupFree(&cgroup);
     return 0;
-- 
1.7.3.1




More information about the libvir-list mailing list