]> xenbits.xensource.com Git - people/dariof/libvirt.git/commitdiff
LXC: blkio: allow to setup weight_device
authorGao feng <gaofeng@cn.fujitsu.com>
Wed, 3 Jul 2013 11:35:54 +0000 (12:35 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 3 Jul 2013 11:35:54 +0000 (12:35 +0100)
libivrt lxc can only set generic weight for container,
This patch allows user to setup per device blkio
weigh for container.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
src/lxc/lxc_cgroup.c

index 5c8acb3595048ebccd0f812ca4e1d9c65f248928..4443b83ae621659da7956c3c9bf92826e8a42dff 100644 (file)
@@ -123,21 +123,35 @@ cleanup:
 static int virLXCCgroupSetupBlkioTune(virDomainDefPtr def,
                                       virCgroupPtr cgroup)
 {
-    int ret = -1;
+    int i, rc;
 
     if (def->blkio.weight) {
-        int rc = virCgroupSetBlkioWeight(cgroup, def->blkio.weight);
+        rc = virCgroupSetBlkioWeight(cgroup, def->blkio.weight);
         if (rc != 0) {
             virReportSystemError(-rc,
                                  _("Unable to set Blkio weight for domain %s"),
                                  def->name);
-            goto cleanup;
+            return -1;
         }
     }
 
-    ret = 0;
-cleanup:
-    return ret;
+    if (def->blkio.ndevices) {
+        for (i = 0; i < def->blkio.ndevices; i++) {
+            virBlkioDeviceWeightPtr dw = &def->blkio.devices[i];
+            if (!dw->weight)
+                continue;
+            rc = virCgroupSetBlkioDeviceWeight(cgroup, dw->path, dw->weight);
+            if (rc != 0) {
+                virReportSystemError(-rc,
+                                     _("Unable to set io device weight "
+                                       "for domain %s"),
+                                     def->name);
+                return -1;
+            }
+        }
+    }
+
+    return 0;
 }