[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 4/6] cputune: support cputune xml for LXC driver



LXC driver doesn't support vcpu affinity yet, so just need
to modify it to support cpu shares.

* src/lxc/lxc_controller.c (Setup cpu shares for domain)
* src/lxc/lxc_driver.c (Update domain config when "lxcSetSchedulerParameters"
  is invoked)
---
 src/lxc/lxc_controller.c |   10 ++++++++++
 src/lxc/lxc_driver.c     |    2 ++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index d2b113c..1837beb 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -115,6 +115,16 @@ static int lxcSetContainerResources(virDomainDefPtr def)
         }
     }
 
+    if (def->cputune.shares) {
+        rc = virCgroupSetCpuShares(cgroup, def->cputune.shares);
+        if (rc != 0) {
+            virReportSystemError(-rc,
+                                 _("Unable to set cpu shares for domain %s"),
+                                 def->name);
+            goto cleanup;
+        }
+    }
+
     rc = virCgroupSetMemory(cgroup, def->mem.max_balloon);
     if (rc != 0) {
         virReportSystemError(-rc,
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 70e74d5..77f5f82 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2321,6 +2321,8 @@ static int lxcSetSchedulerParameters(virDomainPtr domain,
                                  params[i].value.ul);
             goto cleanup;
         }
+
+        vm->def->cputune.shares = params[i].value.ul;
     }
     ret = 0;
 
-- 
1.7.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]