blockdev: move helper for configuring throttle limits to module
Replace the deprecated check_running() call while at it. Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
parent
5344463c59
commit
0b6229f5cd
2 changed files with 51 additions and 52 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -595,4 +595,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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue