[libvirt] [PATCH] LXC: blkio: allow to setup weight_device

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 | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c index 5c8acb3..4443b83 100644 --- a/src/lxc/lxc_cgroup.c +++ b/src/lxc/lxc_cgroup.c @@ -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; } -- 1.8.1.4

On Thu, Jun 27, 2013 at 04:32:30PM +0800, Gao feng wrote:
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 | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c index 5c8acb3..4443b83 100644 --- a/src/lxc/lxc_cgroup.c +++ b/src/lxc/lxc_cgroup.c @@ -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; }
Matches equivalent code in qemu_cgroup.c, so ACK & I'll push shortly. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (2)
-
Daniel P. Berrange
-
Gao feng