6bf708
From b3aac82848c6c8d56dca714b3b359253d74fbceb Mon Sep 17 00:00:00 2001
6bf708
Message-Id: <b3aac82848c6c8d56dca714b3b359253d74fbceb@dist-git>
6bf708
From: Martin Kletzander <mkletzan@redhat.com>
6bf708
Date: Mon, 1 Sep 2014 14:02:23 +0200
6bf708
Subject: [PATCH] qemu: leave restricting cpuset.mems after initialization
6bf708
6bf708
https://bugzilla.redhat.com/show_bug.cgi?id=1135871
6bf708
6bf708
When domain is started with numatune memory mode strict and the
6bf708
nodeset does not include host NUMA node with DMA and DMA32 zones, KVM
6bf708
initialization fails.  This is because cgroup restrict even kernel
6bf708
allocations.  We are already doing numa_set_membind() which does the
6bf708
same thing, only it does not restrict kernel allocations.
6bf708
6bf708
This patch leaves the userspace numa_set_membind() in place and moves
6bf708
the cpuset.mems setting after the point where monitor comes up, but
6bf708
before vcpu and emulator sub-groups are created.
6bf708
6bf708
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
6bf708
(cherry picked from commit 7e72ac787848b7434c9359a57c1e2789d92350f8)
6bf708
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6bf708
---
6bf708
 src/qemu/qemu_cgroup.c  | 10 +++++++---
6bf708
 src/qemu/qemu_cgroup.h  |  4 +++-
6bf708
 src/qemu/qemu_process.c |  4 ++++
6bf708
 3 files changed, 14 insertions(+), 4 deletions(-)
6bf708
6bf708
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
6bf708
index 7e60c19..dfe98be 100644
6bf708
--- a/src/qemu/qemu_cgroup.c
6bf708
+++ b/src/qemu/qemu_cgroup.c
6bf708
@@ -592,9 +592,6 @@ qemuSetupCpusetCgroup(virDomainObjPtr vm,
6bf708
     if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET))
6bf708
         return 0;
6bf708
 
6bf708
-    if (qemuSetupCpusetMems(vm, nodemask) < 0)
6bf708
-        goto cleanup;
6bf708
-
6bf708
     if (vm->def->cpumask ||
6bf708
         (vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO)) {
6bf708
 
6bf708
@@ -786,6 +783,13 @@ cleanup:
6bf708
 }
6bf708
 
6bf708
 int
6bf708
+qemuSetupCgroupPostInit(virDomainObjPtr vm,
6bf708
+                        virBitmapPtr nodemask)
6bf708
+{
6bf708
+    return qemuSetupCpusetMems(vm, nodemask);
6bf708
+}
6bf708
+
6bf708
+int
6bf708
 qemuSetupCgroupVcpuBW(virCgroupPtr cgroup,
6bf708
                       unsigned long long period,
6bf708
                       long long quota)
6bf708
diff --git a/src/qemu/qemu_cgroup.h b/src/qemu/qemu_cgroup.h
6bf708
index 14404d1..40a031e 100644
6bf708
--- a/src/qemu/qemu_cgroup.h
6bf708
+++ b/src/qemu/qemu_cgroup.h
6bf708
@@ -1,7 +1,7 @@
6bf708
 /*
6bf708
  * qemu_cgroup.h: QEMU cgroup management
6bf708
  *
6bf708
- * Copyright (C) 2006-2007, 2009-2013 Red Hat, Inc.
6bf708
+ * Copyright (C) 2006-2007, 2009-2014 Red Hat, Inc.
6bf708
  * Copyright (C) 2006 Daniel P. Berrange
6bf708
  *
6bf708
  * This library is free software; you can redistribute it and/or
6bf708
@@ -44,6 +44,8 @@ int qemuConnectCgroup(virQEMUDriverPtr driver,
6bf708
 int qemuSetupCgroup(virQEMUDriverPtr driver,
6bf708
                     virDomainObjPtr vm,
6bf708
                     virBitmapPtr nodemask);
6bf708
+int qemuSetupCgroupPostInit(virDomainObjPtr vm,
6bf708
+                            virBitmapPtr nodemask);
6bf708
 int qemuSetupCgroupVcpuBW(virCgroupPtr cgroup,
6bf708
                           unsigned long long period,
6bf708
                           long long quota);
6bf708
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
6bf708
index af66e0d..3eda15b 100644
6bf708
--- a/src/qemu/qemu_process.c
6bf708
+++ b/src/qemu/qemu_process.c
6bf708
@@ -4028,6 +4028,10 @@ int qemuProcessStart(virConnectPtr conn,
6bf708
     if (!qemuProcessVerifyGuestCPU(driver, vm))
6bf708
         goto cleanup;
6bf708
 
6bf708
+    VIR_DEBUG("Setting up post-init cgroup restrictions");
6bf708
+    if (qemuSetupCgroupPostInit(vm, nodemask) < 0)
6bf708
+        goto cleanup;
6bf708
+
6bf708
     VIR_DEBUG("Detecting VCPU PIDs");
6bf708
     if (qemuProcessDetectVcpuPIDs(driver, vm) < 0)
6bf708
         goto cleanup;
6bf708
-- 
6bf708
2.1.0
6bf708