[pve-devel] [PATCH] qemuserver : iothrottle add support for throttling burst max

Alexandre Derumier aderumier at odiso.com
Wed Dec 4 15:12:36 CET 2013


http://git.qemu.org/?p=qemu.git;a=commit;h=3e9fab690d59ac15956c3733fe0794ce1ae4c4af

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/API2/Qemu.pm  |   16 ++++++++++++++--
 PVE/QemuServer.pm |   14 +++++++++++---
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 7bce9e2..4712abb 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -763,14 +763,26 @@ my $vmconfig_update_disk = sub {
                &$safe_num_ne($drive->{mbps_wr}, $old_drive->{mbps_wr}) ||
                &$safe_num_ne($drive->{iops}, $old_drive->{iops}) ||
                &$safe_num_ne($drive->{iops_rd}, $old_drive->{iops_rd}) ||
-               &$safe_num_ne($drive->{iops_wr}, $old_drive->{iops_wr})) {
+               &$safe_num_ne($drive->{iops_wr}, $old_drive->{iops_wr}) ||
+               &$safe_num_ne($drive->{mbps_max}, $old_drive->{mbps_max}) ||
+               &$safe_num_ne($drive->{mbps_rd_max}, $old_drive->{mbps_rd_max}) ||
+               &$safe_num_ne($drive->{mbps_wr_max}, $old_drive->{mbps_wr_max}) ||
+               &$safe_num_ne($drive->{iops_max}, $old_drive->{iops_max}) ||
+               &$safe_num_ne($drive->{iops_rd_max}, $old_drive->{iops_rd_max}) ||
+               &$safe_num_ne($drive->{iops_wr_max}, $old_drive->{iops_wr_max})) {
                PVE::QemuServer::qemu_block_set_io_throttle($vmid,"drive-$opt",
 							   ($drive->{mbps} || 0)*1024*1024,
 							   ($drive->{mbps_rd} || 0)*1024*1024,
 							   ($drive->{mbps_wr} || 0)*1024*1024,
 							   $drive->{iops} || 0,
 							   $drive->{iops_rd} || 0,
-							   $drive->{iops_wr} || 0)
+							   $drive->{iops_wr} || 0,
+							   ($drive->{mbps_max} || 0)*1024*1024,
+							   ($drive->{mbps_rd_max} || 0)*1024*1024,
+							   ($drive->{mbps_wr_max} || 0)*1024*1024,
+							   $drive->{iops_max} || 0,
+							   $drive->{iops_rd_max} || 0,
+							   $drive->{iops_wr_max} || 0)
 		   if !PVE::QemuServer::drive_is_cdrom($drive);
             }
 	}
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 0104c27..d9693c3 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -887,7 +887,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|bps|mbps|bps_rd|mbps_rd|bps_wr|mbps_wr|iops|iops_rd|iops_wr|size|discard)=(.+)$/) {
+	if ($p =~ m/^(file|volume|cyls|heads|secs|trans|media|snapshot|cache|format|rerror|werror|backup|aio|bps|mbps|mbps_max|bps_rd|mbps_rd|mbps_rd_max|bps_wr|mbps_wr|mbps_wr_max|iops|iops_max|iops_rd|iops_rd_max|iops_wr|iops_wr_max|size|discard)=(.+)$/) {
 	    my ($k, $v) = ($1, $2);
 
 	    $k = 'file' if $k eq 'volume';
@@ -934,14 +934,22 @@ sub parse_drive {
     return undef if $res->{mbps_wr} && $res->{mbps};
 
     return undef if $res->{mbps} && $res->{mbps} !~ m/^\d+(\.\d+)?$/;
+    return undef if $res->{mbps_max} && $res->{mbps_max} !~ m/^\d+(\.\d+)?$/;
     return undef if $res->{mbps_rd} && $res->{mbps_rd} !~ m/^\d+(\.\d+)?$/;
+    return undef if $res->{mbps_rd_max} && $res->{mbps_rd_max} !~ m/^\d+(\.\d+)?$/;
     return undef if $res->{mbps_wr} && $res->{mbps_wr} !~ m/^\d+(\.\d+)?$/;
+    return undef if $res->{mbps_wr_max} && $res->{mbps_wr_max} !~ m/^\d+(\.\d+)?$/;
 
     return undef if $res->{iops_rd} && $res->{iops};
     return undef if $res->{iops_wr} && $res->{iops};
+
+
     return undef if $res->{iops} && $res->{iops} !~ m/^\d+$/;
+    return undef if $res->{iops_max} && $res->{iops_max} !~ m/^\d+$/;
     return undef if $res->{iops_rd} && $res->{iops_rd} !~ m/^\d+$/;
+    return undef if $res->{iops_rd_max} && $res->{iops_rd_max} !~ m/^\d+$/;
     return undef if $res->{iops_wr} && $res->{iops_wr} !~ m/^\d+$/;
+    return undef if $res->{iops_wr_max} && $res->{iops_wr_max} !~ m/^\d+$/;
 
 
     if ($res->{size}) {
@@ -962,13 +970,13 @@ sub parse_drive {
     return $res;
 }
 
-my @qemu_drive_options = qw(heads secs cyls trans media format cache snapshot rerror werror aio discard iops iops_rd iops_wr);
+my @qemu_drive_options = qw(heads secs cyls trans media format cache snapshot rerror werror aio discard iops iops_rd iops_wr iops_max iops_rd_max iops_wr_max);
 
 sub print_drive {
     my ($vmid, $drive) = @_;
 
     my $opts = '';
-    foreach my $o (@qemu_drive_options, 'mbps', 'mbps_rd', 'mbps_wr', 'backup') {
+    foreach my $o (@qemu_drive_options, 'mbps', 'mbps_rd', 'mbps_wr', 'mbps_max', 'mbps_rd_max', 'mbps_wr_max', 'backup') {
 	$opts .= ",$o=$drive->{$o}" if $drive->{$o};
     }
 
-- 
1.7.10.4



More information about the pve-devel mailing list