Blob Blame History Raw
From b3aac82848c6c8d56dca714b3b359253d74fbceb Mon Sep 17 00:00:00 2001
Message-Id: <b3aac82848c6c8d56dca714b3b359253d74fbceb@dist-git>
From: Martin Kletzander <mkletzan@redhat.com>
Date: Mon, 1 Sep 2014 14:02:23 +0200
Subject: [PATCH] qemu: leave restricting cpuset.mems after initialization

https://bugzilla.redhat.com/show_bug.cgi?id=1135871

When domain is started with numatune memory mode strict and the
nodeset does not include host NUMA node with DMA and DMA32 zones, KVM
initialization fails.  This is because cgroup restrict even kernel
allocations.  We are already doing numa_set_membind() which does the
same thing, only it does not restrict kernel allocations.

This patch leaves the userspace numa_set_membind() in place and moves
the cpuset.mems setting after the point where monitor comes up, but
before vcpu and emulator sub-groups are created.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 7e72ac787848b7434c9359a57c1e2789d92350f8)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_cgroup.c  | 10 +++++++---
 src/qemu/qemu_cgroup.h  |  4 +++-
 src/qemu/qemu_process.c |  4 ++++
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 7e60c19..dfe98be 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -592,9 +592,6 @@ qemuSetupCpusetCgroup(virDomainObjPtr vm,
     if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET))
         return 0;
 
-    if (qemuSetupCpusetMems(vm, nodemask) < 0)
-        goto cleanup;
-
     if (vm->def->cpumask ||
         (vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO)) {
 
@@ -786,6 +783,13 @@ cleanup:
 }
 
 int
+qemuSetupCgroupPostInit(virDomainObjPtr vm,
+                        virBitmapPtr nodemask)
+{
+    return qemuSetupCpusetMems(vm, nodemask);
+}
+
+int
 qemuSetupCgroupVcpuBW(virCgroupPtr cgroup,
                       unsigned long long period,
                       long long quota)
diff --git a/src/qemu/qemu_cgroup.h b/src/qemu/qemu_cgroup.h
index 14404d1..40a031e 100644
--- a/src/qemu/qemu_cgroup.h
+++ b/src/qemu/qemu_cgroup.h
@@ -1,7 +1,7 @@
 /*
  * qemu_cgroup.h: QEMU cgroup management
  *
- * Copyright (C) 2006-2007, 2009-2013 Red Hat, Inc.
+ * Copyright (C) 2006-2007, 2009-2014 Red Hat, Inc.
  * Copyright (C) 2006 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -44,6 +44,8 @@ int qemuConnectCgroup(virQEMUDriverPtr driver,
 int qemuSetupCgroup(virQEMUDriverPtr driver,
                     virDomainObjPtr vm,
                     virBitmapPtr nodemask);
+int qemuSetupCgroupPostInit(virDomainObjPtr vm,
+                            virBitmapPtr nodemask);
 int qemuSetupCgroupVcpuBW(virCgroupPtr cgroup,
                           unsigned long long period,
                           long long quota);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index af66e0d..3eda15b 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4028,6 +4028,10 @@ int qemuProcessStart(virConnectPtr conn,
     if (!qemuProcessVerifyGuestCPU(driver, vm))
         goto cleanup;
 
+    VIR_DEBUG("Setting up post-init cgroup restrictions");
+    if (qemuSetupCgroupPostInit(vm, nodemask) < 0)
+        goto cleanup;
+
     VIR_DEBUG("Detecting VCPU PIDs");
     if (qemuProcessDetectVcpuPIDs(driver, vm) < 0)
         goto cleanup;
-- 
2.1.0