[pve-devel] [PATCH qemu-server v2 37/49] blockdev: move helper for configuring throttle limits to module
Fiona Ebner
f.ebner at proxmox.com
Tue Jul 1 17:40:57 CEST 2025
Replace the deprecated check_running() call while at it.
Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
src/PVE/QemuServer.pm | 53 +---------------------------------
src/PVE/QemuServer/Blockdev.pm | 50 ++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 52 deletions(-)
diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 6e44132e..4cc5ea34 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -4290,57 +4290,6 @@ sub qemu_cpu_hotplug {
}
}
-sub qemu_block_set_io_throttle {
- my (
- $vmid,
- $deviceid,
- $bps,
- $bps_rd,
- $bps_wr,
- $iops,
- $iops_rd,
- $iops_wr,
- $bps_max,
- $bps_rd_max,
- $bps_wr_max,
- $iops_max,
- $iops_rd_max,
- $iops_wr_max,
- $bps_max_length,
- $bps_rd_max_length,
- $bps_wr_max_length,
- $iops_max_length,
- $iops_rd_max_length,
- $iops_wr_max_length,
- ) = @_;
-
- return if !check_running($vmid);
-
- 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),
- bps_max => int($bps_max),
- bps_rd_max => int($bps_rd_max),
- bps_wr_max => int($bps_wr_max),
- iops_max => int($iops_max),
- iops_rd_max => int($iops_rd_max),
- iops_wr_max => int($iops_wr_max),
- bps_max_length => int($bps_max_length),
- bps_rd_max_length => int($bps_rd_max_length),
- bps_wr_max_length => int($bps_wr_max_length),
- iops_max_length => int($iops_max_length),
- iops_rd_max_length => int($iops_rd_max_length),
- iops_wr_max_length => int($iops_wr_max_length),
- );
-
-}
-
sub qemu_volume_snapshot {
my ($vmid, $deviceid, $storecfg, $volid, $snap) = @_;
@@ -5141,7 +5090,7 @@ sub vmconfig_update_disk {
$old_drive->{iops_wr_max_length})
) {
- qemu_block_set_io_throttle(
+ PVE::QemuServer::Blockdev::set_io_throttle(
$vmid,
"drive-$opt",
($drive->{mbps} || 0) * 1024 * 1024,
diff --git a/src/PVE/QemuServer/Blockdev.pm b/src/PVE/QemuServer/Blockdev.pm
index c6798eda..bb42b4c5 100644
--- a/src/PVE/QemuServer/Blockdev.pm
+++ b/src/PVE/QemuServer/Blockdev.pm
@@ -596,4 +596,54 @@ sub change_medium {
}
}
+sub set_io_throttle {
+ my (
+ $vmid,
+ $deviceid,
+ $bps,
+ $bps_rd,
+ $bps_wr,
+ $iops,
+ $iops_rd,
+ $iops_wr,
+ $bps_max,
+ $bps_rd_max,
+ $bps_wr_max,
+ $iops_max,
+ $iops_rd_max,
+ $iops_wr_max,
+ $bps_max_length,
+ $bps_rd_max_length,
+ $bps_wr_max_length,
+ $iops_max_length,
+ $iops_rd_max_length,
+ $iops_wr_max_length,
+ ) = @_;
+
+ return if !PVE::QemuServer::Helpers::vm_running_locally($vmid);
+
+ 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),
+ bps_max => int($bps_max),
+ bps_rd_max => int($bps_rd_max),
+ bps_wr_max => int($bps_wr_max),
+ iops_max => int($iops_max),
+ iops_rd_max => int($iops_rd_max),
+ iops_wr_max => int($iops_wr_max),
+ bps_max_length => int($bps_max_length),
+ bps_rd_max_length => int($bps_rd_max_length),
+ bps_wr_max_length => int($bps_wr_max_length),
+ iops_max_length => int($iops_max_length),
+ iops_rd_max_length => int($iops_rd_max_length),
+ iops_wr_max_length => int($iops_wr_max_length),
+ );
+}
+
1;
--
2.47.2
More information about the pve-devel
mailing list