[pve-devel] [PATCH] add diskio throttling option to drive
Alexandre Derumier
aderumier at odiso.com
Mon May 7 12:29:08 CEST 2012
This add disk io limit to drive options.
I also add the qemu monitor command, but I din't have added yet to Qemu.pm
>From qemu mailing:
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
(3) When bps/iops limits are specified to a small value such as 511 bytes/s,
this VM will hang up. We are considering how to handle this senario.
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/QemuServer.pm | 26 ++++++++++++++++++++++++--
1 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index fbd4b54..1929828 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -828,7 +828,7 @@ sub parse_drive {
foreach my $p (split (/,/, $data)) {
next if $p =~ m/^\s*$/;
- if ($p =~ m/^(file|volume|cyls|heads|secs|trans|media|snapshot|cache|format|rerror|werror|backup|aio)=(.+)$/) {
+ if ($p =~ m/^(file|volume|cyls|heads|secs|trans|media|snapshot|cache|format|rerror|werror|backup|aio|bps|bps_rd|bps_wr|iops|iops_rd|iops_wr)=(.+)$/) {
my ($k, $v) = ($1, $2);
$k = 'file' if $k eq 'volume';
@@ -875,7 +875,7 @@ sub parse_drive {
return $res;
}
-my @qemu_drive_options = qw(heads secs cyls trans media format cache snapshot rerror werror aio);
+my @qemu_drive_options = qw(heads secs cyls trans media format cache snapshot rerror werror aio bps bps_rd bps_wr iops iops_rd iops_wr);
sub print_drive {
my ($vmid, $drive) = @_;
@@ -2560,6 +2560,28 @@ sub qemu_netdevdel {
return undef;
}
+sub qemu_block_set_io_throttle {
+ my ($vmid, $deviceid, $bps, $bps_rd, $bps_wr, $iops, $iops_rd, $iops_wr) = @_;
+
+ $bps = 0 if !$bps;
+ $bps_rd = 0 if !$bps_rd;
+ $bps_wr = 0 if !$bps_wr;
+ $iops = 0 if !$iops;
+ $iops_rd = 0 if !$iops_rd;
+ $iops_wr = 0 if !$iops_wr;
+
+ return undef if($bps != 0 && $bps_rd != 0);
+ return undef if($bps != 0 && $bps_wr != 0);
+ return undef if($iops != 0 && $iops_rd != 0);
+ return undef if($iops != 0 && $iops_wr != 0);
+
+ my $ret = vm_monitor_command($vmid, "block_set_io_throttle $deviceid $bps $bps_rd $bps_wr $iops $iops_rd $iops_wr");
+ $ret =~ s/^\s+//;
+ return 1 if $ret eq "";
+ syslog("err", "error setting block_set_io_throttle: $ret");
+ return undef;
+}
+
sub vm_start {
my ($storecfg, $vmid, $statefile, $skiplock) = @_;
--
1.7.2.5
More information about the pve-devel
mailing list