The main goal of the patch is to effectively cap the disk I/O speed or counts of one single VM. It is only one draft, so it unavoidably has some drawbacks, if you catch them, please let me know.
The patch will mainly introduce one global timer and one block queue for each I/O limits enabled drive. When a block request is coming in, a block I/O throttling algorithm will check if its I/O rate or counts exceed the limits; if yes, then it will enqueue to the block queue; The timer will periodically handle the I/O requests in it. Some available features follow as below: (1) global bps limit. -drive bps=xxx in bytes/s (2) only read bps limit -drive bps_rd=xxx in bytes/s (3) only write bps limit -drive bps_wr=xxx in bytes/s (4) global iops limit -drive iops=xxx in ios/s (5) only read iops limit -drive iops_rd=xxx in ios/s (6) only write iops limit -drive iops_wr=xxx in ios/s (7) the combination of some limits. -drive bps=xxx,iops=xxx Known Limitations: (1) #1 can not coexist with #2, #3 (2) #4 can not coexist with #5, #6 Zhi Yong Wu (1): Submit the codes for QEMU disk I/O limits. Makefile.objs | 2 +- block.c | 248 +++++++++++++++++++++++++++++++++++++++++++++++++++++ block.h | 1 - block/blk-queue.c | 99 +++++++++++++++++++++ block/blk-queue.h | 73 ++++++++++++++++ block_int.h | 21 +++++ blockdev.c | 20 +++++ qemu-config.c | 24 +++++ qemu-option.c | 17 ++++ qemu-option.h | 1 + qemu-options.hx | 1 + 11 files changed, 505 insertions(+), 2 deletions(-) create mode 100644 block/blk-queue.c create mode 100644 block/blk-queue.h -- 1.7.2.3