Re: [PATCH 8/8] lxc: allow to setup throttle blkio cgroup through virsh

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

 



On Wed, Dec 11, 2013 at 04:29:53PM +0800, Gao feng wrote:
> With this patch,user can set throttle blkio cgroup for
> lxc domain through virsh tool.
> 
> The functions are copied from qemu_driver.
> 
> Signed-off-by: Guan Qiang <hzguanqiang@xxxxxxxxxxxxxxxx>
> Signed-off-by: Gao feng <gaofeng@xxxxxxxxxxxxxx>
> ---
>  src/lxc/lxc_driver.c | 649 +++++++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 624 insertions(+), 25 deletions(-)

ACK


> +        if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) {
> +            if (virStrToLong_ui(temp, &p, 10, &result[i].weight) < 0)
> +                goto error;
> +        } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS)) {
> +            if (virStrToLong_ui(temp, &p, 10, &result[i].riops) < 0)
> +                goto error;
> +        } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)) {
> +            if (virStrToLong_ui(temp, &p, 10, &result[i].wiops) < 0)
> +                goto error;
> +        } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) {
> +            if (virStrToLong_ull(temp, &p, 10, &result[i].rbps) < 0)
> +                goto error;
> +        } else {
> +            if (virStrToLong_ull(temp, &p, 10, &result[i].wbps) < 0)
> +                goto error;
> +        }

Check the WRITE_BPS string too and report an error in the else clause

> +
> +        i++;
> +
> +        if (*p == '\0')
> +            break;
> +        else if (*p != ',')
> +            goto error;
> +        temp = p + 1;
> +    }
> +
> +    if (!i)
> +        VIR_FREE(result);
> +
> +    *dev = result;
> +    *size = i;
> +
> +    return 0;
> +
> +error:
> +    virReportError(VIR_ERR_INVALID_ARG,
> +                   _("unable to parse device weight '%s'"), blkioDeviceStr);
> +cleanup:
> +    virBlkioDeviceArrayClear(result, ndevices);
> +    VIR_FREE(result);
> +    return -1;
> +}
> +
> +static int
> +lxcDomainMergeBlkioDevice(virBlkioDevicePtr *dest_array,
> +                          size_t *dest_size,
> +                          virBlkioDevicePtr src_array,
> +                          size_t src_size,
> +                          const char *type)
> +{
> +    size_t i, j;
> +    virBlkioDevicePtr dest, src;
> +
> +    for (i = 0; i < src_size; i++) {
> +        bool found = false;
> +
> +        src = &src_array[i];
> +        for (j = 0; j < *dest_size; j++) {
> +            dest = &(*dest_array)[j];
> +            if (STREQ(src->path, dest->path)) {
> +                found = true;
> +
> +                if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT))
> +                    dest->weight = src->weight;
> +                else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS))
> +                    dest->riops = src->riops;
> +                else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS))
> +                    dest->wiops = src->wiops;
> +                else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS))
> +                    dest->rbps = src->rbps;
> +                else
> +                    dest->wbps = src->wbps;

Check the WRITE_BPS string too and report an error in the else clause

> +
> +                break;
> +            }
> +        }
> +        if (!found) {
> +            if (!src->weight && !src->riops && !src->wiops && !src->rbps && !src->wbps)
> +                continue;
> +            if (VIR_EXPAND_N(*dest_array, *dest_size, 1) < 0)
> +                return -1;
> +            dest = &(*dest_array)[*dest_size - 1];
> +            dest->path = src->path;
> +
> +            if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT))
> +                dest->weight = src->weight;
> +            else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS))
> +                dest->riops = src->riops;
> +            else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS))
> +                dest->wiops = src->wiops;
> +            else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS))
> +                dest->rbps = src->rbps;
> +            else
> +                dest->wbps = src->wbps;

Check the WRITE_BPS string too and report an error in the else clause


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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]