[libvirt] [RFC PATCH 0/8 v2] Summary on block IO throttle

Changes since V1 - Implement the support to get the block io throttling for a device as read only connection - QMP/HMP. - Split virDomainBlockIoThrottle into two separate functions virDomainSetBlockIoThrottle - Set block I/O limits for a device - Requires a connection in 'write' mode. - Limits (info) structure passed as an input parameter virDomainGetBlockIoThrottle - Get the current block I/O limits for a device - Works on a read-only connection. - Current limits are written to the output parameter (reply). - And Other fixups suggested by Adam Litke, Daniel P. Berrange. - For dynamically allocate the blkiothrottle struct, I will fix it when implement --current --live --config options support. Today libvirt supports the cgroups blkio-controller, which handles proportional shares and throughput/iops limits on host block devices. blkio-controller does not support network file systems (NFS) or other QEMU remote block drivers (curl, Ceph/rbd, sheepdog) since they are not host block devices. QEMU I/O throttling works with all types of drive and can be applied independently to each drive attached to a guest and supports throughput/iops limits. To help add QEMU I/O throttling support to libvirt, we plan to complete it with add new API virDomainBlockIoThrottle(), new command 'blkiothrottle' and Python bindings. Notes: we are sending this series out now(even though they are not completed yet.)because we want to start the review process. #1)#2) features were implemented by Zhi Yong Wu: 1) Enable the blkio throttling in xml when guest is starting up. Add blkio throttling in xml as follows: <disk type='file' device='disk'> <driver name='qemu' type='raw'/> <source file='/var/lib/libvirt/images/kvm-one.img'/> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> <iotune bps='n'.../> </disk> 2) Enable blkio throttling setting at guest running time. virsh blkiothrottle <domain> <device> [--bps<number>] [--bps_rd<number>] \ [--bps_wr<number>] [--iops<number>] [--iops_rd<number>] [--iops_wr<number>] 3) The support to get the current block i/o throttling for a device - HMP/QMP. virsh blkiothrottle <domain> <device> bps: bps_rd: bps_wr: iops: iops_rd: iops_wr: And I will address feedback and work on the missing features in few days includes: 4) Python binding support for setting blkio throttling. 5) --current --live --config options support to unify the libvirt API. daemon/remote.c | 85 +++++++++++++++++ include/libvirt/libvirt.h.in | 25 +++++ python/generator.py | 2 + python/libvirt-override-api.xml | 16 ++++ python/libvirt-override.c | 43 +++++++++ src/conf/domain_conf.c | 77 ++++++++++++++++ src/conf/domain_conf.h | 11 +++ src/driver.h | 18 ++++ src/libvirt.c | 120 ++++++++++++++++++++++++ src/libvirt_public.syms | 2 + src/qemu/qemu_command.c | 35 +++++++ src/qemu/qemu_driver.c | 108 ++++++++++++++++++++++ src/qemu/qemu_monitor.c | 36 ++++++++ src/qemu/qemu_monitor.h | 10 ++ src/qemu/qemu_monitor_json.c | 191 +++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 10 ++ src/qemu/qemu_monitor_text.c | 88 ++++++++++++++++++ src/qemu/qemu_monitor_text.h | 10 ++ src/remote/remote_driver.c | 81 +++++++++++++++++ src/remote/remote_protocol.x | 39 ++++++++- src/remote_protocol-structs | 34 +++++++ src/util/xml.h | 3 + tools/virsh.c | 100 ++++++++++++++++++++ tools/virsh.pod | 13 +++ 24 files changed, 1156 insertions(+), 1 deletions(-) -- Lei

On 10/27/2011 03:12 AM, Lei Li wrote:
1) Enable the blkio throttling in xml when guest is starting up.
Add blkio throttling in xml as follows:
<disk type='file' device='disk'> <driver name='qemu' type='raw'/> <source file='/var/lib/libvirt/images/kvm-one.img'/> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> <iotune bps='n'.../> </disk>
2) Enable blkio throttling setting at guest running time.
virsh blkiothrottle<domain> <device> [--bps<number>] [--bps_rd<number>] \ [--bps_wr<number>] [--iops<number>] [--iops_rd<number>] [--iops_wr<number>]
3) The support to get the current block i/o throttling for a device - HMP/QMP.
virsh blkiothrottle<domain> <device>
Given that the XML is named <iotune> under <disk>, we should probably name the virsh command 'blkiotune' or 'disk-iotune', not 'blkiothrottle'. Also, <iotune bps='n'.../> doesn't look right. This should be similar to the top-level XML. Here, taking into account the other proposal for per-block-device values (which can't be tied to individual <disk>): <domain...> <blkiotune> <weight>800</weight> <device> <path>/path/to/device</path> <weight>200</weight> </device> </blkiotune> <devices> <disk ...> <iotune> <bps>800</bps> ... </iotune> </disk> </devices> </domain>
daemon/remote.c | 85 +++++++++++++++++ include/libvirt/libvirt.h.in | 25 +++++
Missing changes in docs/formatdomain.html.in (to describe the new XML), docs/schemas/domaincommon.rng (to validate the new xml), and tests/ (probably qemuxml2argvdata), to test it. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 10/27/2011 11:45 PM, Eric Blake wrote:
On 10/27/2011 03:12 AM, Lei Li wrote:
1) Enable the blkio throttling in xml when guest is starting up.
Add blkio throttling in xml as follows:
<disk type='file' device='disk'> <driver name='qemu' type='raw'/> <source file='/var/lib/libvirt/images/kvm-one.img'/> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> <iotune bps='n'.../> </disk>
2) Enable blkio throttling setting at guest running time.
virsh blkiothrottle<domain> <device> [--bps<number>] [--bps_rd<number>] \ [--bps_wr<number>] [--iops<number>] [--iops_rd<number>] [--iops_wr<number>]
3) The support to get the current block i/o throttling for a device - HMP/QMP.
virsh blkiothrottle<domain> <device>
Given that the XML is named <iotune> under <disk>, we should probably name the virsh command 'blkiotune' or 'disk-iotune', not 'blkiothrottle'.
Hi Eric, we used<iothrottle> first, I changed it since Daniel P. Berrange proposed<iotune> for per-disk element instead of<iothrottle> when we discussed at RFC V1. The command 'blkiotune' already exist, supported the cgroups blkio-controller, which handles proportional shares and throughput/iops limits on host block devices, global to the domain, but blkio throttling is specified per-disk and can vary across multiple disks. They are different two mechanism. So how about use<iothrottle> again? :)
Also, <iotune bps='n'.../> doesn't look right. This should be similar to the top-level XML. Here, taking into account the other proposal for per-block-device values (which can't be tied to individual <disk>):
<domain...> <blkiotune> <weight>800</weight> <device> <path>/path/to/device</path> <weight>200</weight> </device> </blkiotune> <devices> <disk ...> <iotune> <bps>800</bps> ... </iotune> </disk> </devices> </domain>
OK. I will do it at v3.
daemon/remote.c | 85 +++++++++++++++++ include/libvirt/libvirt.h.in | 25 +++++
Missing changes in docs/formatdomain.html.in (to describe the new XML), docs/schemas/domaincommon.rng (to validate the new xml), and tests/ (probably qemuxml2argvdata), to test it.
-- Lei

On 10/28/2011 02:59 AM, Lei Li wrote:
Given that the XML is named <iotune> under <disk>, we should probably name the virsh command 'blkiotune' or 'disk-iotune', not 'blkiothrottle'.
Hi Eric, we used<iothrottle> first, I changed it since Daniel P. Berrange proposed<iotune> for per-disk element instead of<iothrottle> when we discussed at RFC V1.
The command 'blkiotune' already exist, supported the cgroups blkio-controller, which handles proportional shares and throughput/iops limits on host block devices, global to the domain, but blkio throttling is specified per-disk and can vary across multiple disks. They are different two mechanism.
So how about use<iothrottle> again? :)
For extensibility, I _don't_ want to hardcode 'throttle' into the name; the goal here is that we want this xml element to contain all tuning parameters that are appropriate for a single disk, which could be more than just throttling. So using 'virsh disk-iotune' sounds like the best name for the virsh side of the command. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Fri, Oct 28, 2011 at 08:09:32AM -0600, Eric Blake wrote:
On 10/28/2011 02:59 AM, Lei Li wrote:
Given that the XML is named <iotune> under <disk>, we should probably name the virsh command 'blkiotune' or 'disk-iotune', not 'blkiothrottle'.
Hi Eric, we used<iothrottle> first, I changed it since Daniel P. Berrange proposed<iotune> for per-disk element instead of<iothrottle> when we discussed at RFC V1.
The command 'blkiotune' already exist, supported the cgroups blkio-controller, which handles proportional shares and throughput/iops limits on host block devices, global to the domain, but blkio throttling is specified per-disk and can vary across multiple disks. They are different two mechanism.
So how about use<iothrottle> again? :)
For extensibility, I _don't_ want to hardcode 'throttle' into the name; the goal here is that we want this xml element to contain all tuning parameters that are appropriate for a single disk, which could be more than just throttling. So using 'virsh disk-iotune' sounds like the best name for the virsh side of the command.
I'd prefer 'blkdeviotune', so it is discoverable alongside blkiotune Regards, 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 :|

On Fri, Oct 28, 2011 at 04:59:40PM +0800, Lei Li wrote:
On 10/27/2011 11:45 PM, Eric Blake wrote:
On 10/27/2011 03:12 AM, Lei Li wrote:
1) Enable the blkio throttling in xml when guest is starting up.
Add blkio throttling in xml as follows:
<disk type='file' device='disk'> <driver name='qemu' type='raw'/> <source file='/var/lib/libvirt/images/kvm-one.img'/> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> <iotune bps='n'.../> </disk>
2) Enable blkio throttling setting at guest running time.
virsh blkiothrottle<domain> <device> [--bps<number>] [--bps_rd<number>] \ [--bps_wr<number>] [--iops<number>] [--iops_rd<number>] [--iops_wr<number>]
3) The support to get the current block i/o throttling for a device - HMP/QMP.
virsh blkiothrottle<domain> <device>
Given that the XML is named <iotune> under <disk>, we should probably name the virsh command 'blkiotune' or 'disk-iotune', not 'blkiothrottle'.
Hi Eric, we used<iothrottle> first, I changed it since Daniel P. Berrange proposed<iotune> for per-disk element instead of<iothrottle> when we discussed at RFC V1.
The command 'blkiotune' already exist, supported the cgroups blkio-controller, which handles proportional shares and throughput/iops limits on host block devices, global to the domain, but blkio throttling is specified per-disk and can vary across multiple disks. They are different two mechanism.
This is a per-device tunable, so just insert 'dev' into the command name. ie: blkdeviotune 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 (3)
-
Daniel P. Berrange
-
Eric Blake
-
Lei Li