[libvirt] [PATCH 7/8] qemu: allow to setup throttle blkio cgroup through virsh

Daniel P. Berrange berrange at redhat.com
Thu Dec 12 12:28:09 UTC 2013


On Wed, Dec 11, 2013 at 04:29:52PM +0800, Gao feng wrote:
> With this patch, user can setup throttle blkio cgroup
> through virsh for qemu domain.
> 
> Signed-off-by: Guan Qiang <hzguanqiang at corp.netease.com>
> Signed-off-by: Gao feng <gaofeng at cn.fujitsu.com>
> ---
>  src/qemu/qemu_driver.c | 425 ++++++++++++++++++++++++++++++++++++++++++++-----
>  1 file changed, 386 insertions(+), 39 deletions(-)


> -                for (j = 0; j < ndevices; j++) {
> -                    if (virCgroupSetBlkioDeviceWeight(priv->cgroup,
> -                                                      devices[j].path,
> -                                                      devices[j].weight) < 0) {
> -                        ret = -1;
> -                        break;
> +
> +                if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) {
> +                    for (j = 0; j < ndevices; j++) {
> +                        if (virCgroupSetBlkioDeviceWeight(priv->cgroup,
> +                                                          devices[j].path,
> +                                                          devices[j].weight) < 0) {
> +                            ret = -1;
> +                            break;
> +                        }
> +                    }
> +                } else if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS)) {
> +                    for (j = 0; j < ndevices; j++) {
> +                        if (virCgroupSetBlkioDeviceReadIops(priv->cgroup,
> +                                                            devices[j].path,
> +                                                            devices[j].riops) < 0) {
> +                            ret = -1;
> +                            break;
> +                        }
> +                    }
> +                } else if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)) {
> +                    for (j = 0; j < ndevices; j++) {
> +                        if (virCgroupSetBlkioDeviceWriteIops(priv->cgroup,
> +                                                             devices[j].path,
> +                                                             devices[j].wiops) < 0) {
> +                            ret = -1;
> +                            break;
> +                        }
> +                    }
> +                } else if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) {
> +                    for (j = 0; j < ndevices; j++) {
> +                        if (virCgroupSetBlkioDeviceReadBps(priv->cgroup,
> +                                                           devices[j].path,
> +                                                           devices[j].rbps) < 0) {
> +                            ret = -1;
> +                            break;
> +                        }
> +                    }
> +                } else {

You should check for WRITE_BPS here, and have a final 'else' clause reporting an
error on unknown strings I think

> +                    for (j = 0; j < ndevices; j++) {
> +                        if (virCgroupSetBlkioDeviceWriteBps(priv->cgroup,
> +                                                            devices[j].path,
> +                                                            devices[j].wbps) < 0) {
> +                            ret = -1;
> +                            break;
> +                        }
>                      }
>                  }

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 :|




More information about the libvir-list mailing list