[pve-devel] [PATCH] add diskio throttling option to drive
Dietmar Maurer
dietmar at proxmox.com
Mon May 14 06:59:31 CEST 2012
committed, thanks.
> -----Original Message-----
> From: pve-devel-bounces at pve.proxmox.com [mailto:pve-devel-
> bounces at pve.proxmox.com] On Behalf Of Alexandre Derumier
> Sent: Mittwoch, 09. Mai 2012 14:29
> To: pve-devel at pve.proxmox.com
> Subject: [pve-devel] [PATCH] add diskio throttling option to drive
>
> 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 | 34 ++++++++++++++++++++++++++++++++--
> 1 files changed, 32 insertions(+), 2 deletions(-)
>
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index
> fbd4b54..58e52bc 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|rerr
> or|werror|backup|aio)=(.+)$/) {
> + if ($p =~
> +m/^(file|volume|cyls|heads|secs|trans|media|snapshot|cache|format|re
> rro
> +r|werror|backup|aio|bps|bps_rd|bps_wr|iops|iops_rd|iops_wr)=(.+)$/) {
> my ($k, $v) = ($1, $2);
>
> $k = 'file' if $k eq 'volume';
> @@ -861,6 +861,19 @@ sub parse_drive {
> return undef if $res->{backup} && $res->{backup} !~ m/^(yes|no)$/;
> return undef if $res->{aio} && $res->{aio} !~ m/^(native|threads)$/;
>
> + return undef if $res->{bps_rd} && $res->{bps};
> + return undef if $res->{bps_wr} && $res->{bps};
> + return undef if $res->{iops_rd} && $res->{iops};
> + return undef if $res->{iops_wr} && $res->{iops};
> +
> + return undef if $res->{bps} && $res->{bps} !~ m/^\d+$/;
> + return undef if $res->{bps_rd} && $res->{bps_rd} !~ m/^\d+$/;
> + return undef if $res->{bps_wr} && $res->{bps_wr} !~ m/^\d+$/;
> + return undef if $res->{iops} && $res->{iops} !~ m/^\d+$/;
> + return undef if $res->{iops_rd} && $res->{iops_rd} !~ m/^\d+$/;
> + return undef if $res->{iops_wr} && $res->{iops_wr} !~ m/^\d+$/;
> +
> +
> if ($res->{media} && ($res->{media} eq 'cdrom')) {
> return undef if $res->{snapshot} || $res->{trans} || $res->{format};
> return undef if $res->{heads} || $res->{secs} || $res->{cyls}; @@ -
> 875,7 +888,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 +2573,23 @@ 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;
> +
> + 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
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
More information about the pve-devel
mailing list