[libvirt] [PATCH 6/9] qemu: allow to setup throttle blkio cgroup through virsh
Daniel P. Berrange
berrange at redhat.com
Tue Dec 10 15:38:37 UTC 2013
On Mon, Dec 02, 2013 at 02:48:01PM +0800, Gao feng wrote:
> With this patch, user can setup the throttle blkio cgorup
> for domain through the virsh cmd, such as:
>
> virsh blkiotune domain1 --device-read-bps /dev/sda1,10000,/dev/sda2,20000
> --device-write-bps /dev/sda1,10000 --device-read-iops /dev/sda1,10000
> --device-write-iops /dev/sda1,10000,/dev/sda2,0
>
> Signed-off-by: Guan Qiang <hzguanqiang at corp.netease.com>
> Signed-off-by: Gao feng <gaofeng at cn.fujitsu.com>
> ---
> include/libvirt/libvirt.h.in | 45 +++++
> src/qemu/qemu_driver.c | 418 +++++++++++++++++++++++++++++++++++++++----
> tools/virsh-domain.c | 64 +++++++
> 3 files changed, 488 insertions(+), 39 deletions(-)
>
> diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
> index 5aad75c..d054900 100644
> --- a/include/libvirt/libvirt.h.in
> +++ b/include/libvirt/libvirt.h.in
> @@ -1806,6 +1806,51 @@ char * virDomainGetSchedulerType(virDomainPtr domain,
>
> #define VIR_DOMAIN_BLKIO_DEVICE_WEIGHT "device_weight"
>
> +
> +/**
> + * VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS:
> + *
> + * Macro for the blkio tunable throttle.read_iops_device: it represents
> + * the number of reading the block device per second, as a string. The
> + * string is parsed as a series of /path/to/device, read_iops elements,
> + * separated by ','.
> + */
> +
> +#define VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS "device_read_iops"
> +
> +
> +/**
> + * VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS:
> + *
> + * Macro for the blkio tunable throttle.write_iops_device: it represents
> + * the number of writing the block device per second, as a string. The
> + * string is parsed as a series of /path/to/device, write_iops elements,
> + * separated by ','.
> + */
> +#define VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS "device_write_iops"
> +
> +
> +/**
> + * VIR_DOMAIN_BLKIO_DEVICE_READ_BPS:
> + *
> + * Macro for the blkio tunable throttle.read_iops_device: it represents
> + * the bytes of reading the block device per second, as a string. The
> + * string is parsed as a series of /path/to/device, read_bps elements,
> + * separated by ','.
> + */
> +#define VIR_DOMAIN_BLKIO_DEVICE_READ_BPS "device_read_bps"
> +
> +
> +/**
> + * VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS:
> + *
> + * Macro for the blkio tunable throttle.read_iops_device: it represents
> + * the number of reading the block device per second, as a string. The
> + * string is parsed as a series of /path/to/device, read_iops elements,
> + * separated by ','.
> + */
> +#define VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS "device_write_bps"
Again please use naming that matches the existing
VIR_DOMAIN_BLOCK_IOTUNE_* constants
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 61dbe7f..1ad5b94 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
The additions ot the QEMU driver should really be separate from
the patch to the public API & virsh.
> @@ -7753,6 +7842,7 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
> VIR_TYPED_PARAM_UINT, val) < 0)
> goto cleanup;
> break;
> +
> case 1: /* blkiotune.device_weight */
> if (vm->def->blkio.ndevices > 0) {
> virBuffer buf = VIR_BUFFER_INITIALIZER;
> @@ -7782,6 +7872,122 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
> goto cleanup;
> break;
>
> + case 2: /* blkiotune.device_read_iops */
> diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
> index 1fe138c..f01691d 100644
> --- a/tools/virsh-domain.c
> +++ b/tools/virsh-domain.c
> @@ -1250,6 +1250,22 @@ static const vshCmdOptDef opts_blkiotune[] = {
> .type = VSH_OT_STRING,
> .help = N_("per-device IO Weights, in the form of /path/to/device,weight,...")
> },
> + {.name = "device-read-iops",
> + .type = VSH_OT_STRING,
> + .help = N_("per-device read I/O limit per second, in the form of /path/to/device,read_iops,...")
> + },
> + {.name = "device-write-iops",
> + .type = VSH_OT_STRING,
> + .help = N_("per-device write I/O limit per second, in the form of /path/to/device,write_iops,...")
> + },
> + {.name = "device-read-bps",
> + .type = VSH_OT_STRING,
> + .help = N_("per-device bytes read per second, in the form of /path/to/device,read-bps,...")
> + },
> + {.name = "device-write-bps",
> + .type = VSH_OT_STRING,
> + .help = N_("per-device bytes wrote per second, in the form of /path/to/device,write-bps,...")
Again naming consistency with existing code please.
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