From 9b2c0efbd65c5ed9b4c3717c7149433752cbea9b Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 12 Jun 2013 07:08:02 +0200 Subject: [PATCH] correctly handle undef values when calling qemu_block_set_io_throttle --- PVE/API2/Qemu.pm | 10 +++++++--- PVE/QemuServer.pm | 7 ------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 6651d167..076356c7 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -766,9 +766,13 @@ my $vmconfig_update_disk = sub { &$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})) { - PVE::QemuServer::qemu_block_set_io_throttle($vmid,"drive-$opt", $drive->{mbps}*1024*1024, - $drive->{mbps_rd}*1024*1024, $drive->{mbps_wr}*1024*1024, - $drive->{iops}, $drive->{iops_rd}, $drive->{iops_wr}) + 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) if !PVE::QemuServer::drive_is_cdrom($drive); } } diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index d669d6be..d2b942fe 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -2803,13 +2803,6 @@ sub qemu_block_set_io_throttle { return if !check_running($vmid) ; - $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; - vm_mon_cmd($vmid, "block_set_io_throttle", device => $deviceid, bps => int($bps), bps_rd => int($bps_rd), bps_wr => int($bps_wr), iops => int($iops), iops_rd => int($iops_rd), iops_wr => int($iops_wr)); }