[libvirt] [PATCH 6/8] cputune: support cputune for lxc driver

Osier Yang jyang at redhat.com
Tue Mar 29 06:32:24 UTC 2011


LXC driver doesn't support vcpu affinity yet, so just need
to modify it to support cpu shares.
---
 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 1ab6351..7ea69fb 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -117,6 +117,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 3159e1b..8433318 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2292,6 +2292,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




More information about the libvir-list mailing list