public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH qemu-server 19/22] drive: create a throttle group for each drive starting with machine version 10.0
Date: Fri, 13 Jun 2025 13:23:37 +0200	[thread overview]
Message-ID: <1749813535.eadqoip30x.astroid@yuna.none> (raw)
In-Reply-To: <20250612140253.106555-20-f.ebner@proxmox.com>

On June 12, 2025 4:02 pm, Fiona Ebner wrote:
> The throttle group will be referenced via the 'blockdev' schema.
> 
> Co-developed-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
> ---
>  PVE/QemuServer.pm          | 51 ++++++++++++++++++++++++++++++++++++++
>  PVE/QemuServer/Blockdev.pm | 44 ++++++++++++++++++++++++++++++++
>  PVE/QemuServer/Makefile    |  1 +
>  3 files changed, 96 insertions(+)
>  create mode 100644 PVE/QemuServer/Blockdev.pm
> 
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index e5f8a607..bfadba98 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -51,6 +51,7 @@ use PVE::Tools qw(run_command file_read_firstline file_get_contents dir_glob_for
>  use PVE::QMPClient;
>  use PVE::QemuConfig;
>  use PVE::QemuConfig::NoWrite;
> +use PVE::QemuServer::Blockdev;
>  use PVE::QemuServer::Helpers qw(config_aware_timeout min_version kvm_user_version windows_version);
>  use PVE::QemuServer::Cloudinit;
>  use PVE::QemuServer::CGroup;
> @@ -3943,6 +3944,12 @@ sub config_to_command {
>  	    push @$devices, '-blockdev', $live_restore->{blockdev};
>  	}
>  
> +	if (min_version($machine_version, 10, 0)) {
> +	    my $drive_id = PVE::QemuServer::Drive::get_drive_id($drive);

this is done in generate_throttle_group as well, and the var is not used
here?

> +	    my $throttle_group = PVE::QemuServer::Blockdev::generate_throttle_group($drive);
> +	    push @$cmd, '-object', to_json($throttle_group, { canonical => 1 });
> +	}
> +
>  	my $drive_cmd = print_drive_commandline_full($storecfg, $vmid, $drive, $live_blockdev_name);
>  
>  	# extra protection for templates, but SATA and IDE don't support it..
> @@ -4315,6 +4322,14 @@ sub qemu_iothread_del {
>  sub qemu_driveadd {
>      my ($storecfg, $vmid, $device) = @_;
>  
> +    my $machine_type = PVE::QemuServer::Machine::get_current_qemu_machine($vmid);
> +
> +    if (PVE::QemuServer::Machine::is_machine_version_at_least($machine_type, 10, 0)) {
> +	my $drive_id = PVE::QemuServer::Drive::get_drive_id($device);

same

> +	my $throttle_group = PVE::QemuServer::Blockdev::generate_throttle_group($device);
> +	mon_cmd($vmid, 'object-add', %$throttle_group);
> +    }
> +
>      my $drive = print_drive_commandline_full($storecfg, $vmid, $device, undef);
>      $drive =~ s/\\/\\\\/g;
>      my $ret = PVE::QemuServer::Monitor::hmp_cmd($vmid, "drive_add auto \"$drive\"", 60);
> @@ -4328,6 +4343,12 @@ sub qemu_driveadd {
>  sub qemu_drivedel {
>      my ($vmid, $deviceid) = @_;
>  
> +    my $machine_type = PVE::QemuServer::Machine::get_current_qemu_machine($vmid);
> +
> +    if (PVE::QemuServer::Machine::is_machine_version_at_least($machine_type, 10, 0)) {
> +	mon_cmd($vmid, 'object-del', id => 'throttle-drive-$deviceid');
> +    }
> +
>      my $ret = PVE::QemuServer::Monitor::hmp_cmd($vmid, "drive_del drive-$deviceid", 10 * 60);
>      $ret =~ s/^\s+//;
>  
> @@ -4571,6 +4592,36 @@ sub qemu_block_set_io_throttle {
>  
>      return if !check_running($vmid) ;
>  
> +    my $machine_type = PVE::QemuServer::Machine::get_current_qemu_machine($vmid);
> +    if (PVE::QemuServer::Machine::is_machine_version_at_least($machine_type, 10, 0)) {
> +	mon_cmd(
> +	    $vmid,
> +	    'qom-set',
> +	    path => "throttle-$deviceid",
> +	    property => "limits",
> +	    value => {
> +		'bps-total' => int($bps),
> +		'bps-read' => int($bps_rd),
> +		'bps-write' => int($bps_wr),
> +		'iops-total' => int($iops),
> +		'iops-read' => int($iops_rd),
> +		'iops-write' => int($iops_wr),
> +		'bps-total-max' => int($bps_max),
> +		'bps-read-max' => int($bps_rd_max),
> +		'bps-write-max' => int($bps_wr_max),
> +		'iops-total-max' => int($iops_max),
> +		'iops-read-max' => int($iops_rd_max),
> +		'iops-write-max' => int($iops_wr_max),
> +		'bps-total-max-length' => int($bps_max_length),
> +		'bps-read-max-length' => int($bps_rd_max_length),
> +		'bps-write-max-length' => int($bps_wr_max_length),
> +		'iops-total-max-length' => int($iops_max_length),
> +		'iops-read-max-length' => int($iops_rd_max_length),
> +		'iops-write-max-length' => int($iops_wr_max_length),
> +	    }
> +	);
> +    }
> +
>      mon_cmd($vmid, "block_set_io_throttle", device => $deviceid,
>  	bps => int($bps),
>  	bps_rd => int($bps_rd),
> diff --git a/PVE/QemuServer/Blockdev.pm b/PVE/QemuServer/Blockdev.pm
> new file mode 100644
> index 00000000..b1150141
> --- /dev/null
> +++ b/PVE/QemuServer/Blockdev.pm
> @@ -0,0 +1,44 @@
> +package PVE::QemuServer::Blockdev;
> +
> +use strict;
> +use warnings;
> +
> +use PVE::QemuServer::Drive;
> +
> +sub generate_throttle_group {
> +    my ($drive) = @_;
> +
> +    my $drive_id = PVE::QemuServer::Drive::get_drive_id($drive);
> +
> +    my $limits = {};
> +
> +    for my $type (['', '-total'], [_rd => '-read'], [_wr => '-write']) {
> +	my ($dir, $qmpname) = @$type;
> +	if (my $v = $drive->{"mbps$dir"}) {
> +	    $limits->{"bps$qmpname"} = int($v*1024*1024);
> +	}
> +	if (my $v = $drive->{"mbps${dir}_max"}) {
> +	    $limits->{"bps$qmpname-max"} = int($v*1024*1024);
> +	}
> +	if (my $v = $drive->{"bps${dir}_max_length"}) {
> +	    $limits->{"bps$qmpname-max-length"} = int($v);
> +	}
> +	if (my $v = $drive->{"iops${dir}"}) {
> +	    $limits->{"iops$qmpname"} = int($v);
> +	}
> +	if (my $v = $drive->{"iops${dir}_max"}) {
> +	    $limits->{"iops$qmpname-max"} = int($v);
> +	}
> +	if (my $v = $drive->{"iops${dir}_max_length"}) {
> +	    $limits->{"iops$qmpname-max-length"} = int($v);
> +	}
> +    }
> +
> +    return {
> +	id => "throttle-drive-$drive_id",
> +	limits => $limits,
> +	'qom-type' => 'throttle-group',
> +    };
> +}
> +
> +1;
> diff --git a/PVE/QemuServer/Makefile b/PVE/QemuServer/Makefile
> index bbd5b5c0..8054a93b 100644
> --- a/PVE/QemuServer/Makefile
> +++ b/PVE/QemuServer/Makefile
> @@ -1,4 +1,5 @@
>  SOURCES=PCI.pm		\
> +	Blockdev.pm	\
>  	RNG.pm		\
>  	USB.pm		\
>  	Memory.pm	\
> -- 
> 2.39.5
> 
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 
> 


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  reply	other threads:[~2025-06-13 11:23 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-12 14:02 [pve-devel] [PATCH-SERIES qemu-server 00/22] preparation for switch to blockdev Fiona Ebner
2025-06-12 14:02 ` [pve-devel] [PATCH qemu-server 01/22] drive: code cleanup: drop unused $vmid parameter from get_path_and_format() Fiona Ebner
2025-06-12 14:02 ` [pve-devel] [PATCH qemu-server 02/22] cfg2cmd: require at least QEMU binary version 6.0 Fiona Ebner
2025-06-13  9:18   ` Fabian Grünbichler
2025-06-16  8:47     ` Fiona Ebner
2025-06-12 14:02 ` [pve-devel] [PATCH qemu-server 03/22] drive: parse: use hash argument for optional parameters Fiona Ebner
2025-06-12 14:02 ` [pve-devel] [PATCH qemu-server 04/22] drive: parse drive: support parsing with additional properties Fiona Ebner
2025-06-12 14:02 ` [pve-devel] [PATCH qemu-server 05/22] restore: parse drive " Fiona Ebner
2025-06-13  9:30   ` Fabian Grünbichler
2025-06-16  8:51     ` Fiona Ebner
2025-06-12 14:02 ` [pve-devel] [PATCH qemu-server 06/22] drive: remove geometry options gone since QEMU 3.1 Fiona Ebner
2025-06-12 14:02 ` [pve-devel] [PATCH qemu-server 07/22] clone disk: io uring check: fix call to determine cache direct Fiona Ebner
2025-06-12 14:02 ` [pve-devel] [PATCH qemu-server 08/22] drive: move storage_allows_io_uring_default() and drive_uses_cache_direct() helpers to drive module Fiona Ebner
2025-06-12 14:02 ` [pve-devel] [PATCH qemu-server 09/22] drive: introduce aio_cmdline_option() helper Fiona Ebner
2025-06-12 14:02 ` [pve-devel] [PATCH qemu-server 10/22] drive: introduce detect_zeroes_cmdline_option() helper Fiona Ebner
2025-06-12 14:02 ` [pve-devel] [PATCH qemu-server 11/22] introduce StateFile module for state file related helpers Fiona Ebner
2025-06-12 14:02 ` [pve-devel] [PATCH qemu-server 12/22] vm start: move state file handling to dedicated module Fiona Ebner
2025-06-13 10:00   ` Fabian Grünbichler
2025-06-16 10:34     ` Fiona Ebner
2025-06-16 10:54       ` Fabian Grünbichler
2025-06-16 10:57         ` Fiona Ebner
2025-06-12 14:02 ` [pve-devel] [PATCH qemu-server 13/22] vm start: move config_to_command() call further down Fiona Ebner
2025-06-13 10:05   ` Fabian Grünbichler
2025-06-16 10:54     ` Fiona Ebner
2025-06-12 14:02 ` [pve-devel] [PATCH qemu-server 14/22] vm start/commandline: also clean up pci reservation when config_to_command() fails Fiona Ebner
2025-06-12 14:02 ` [pve-devel] [PATCH qemu-server 15/22] vm start/commandline: activate volumes before config_to_command() Fiona Ebner
2025-06-13 10:16   ` Fabian Grünbichler
2025-06-17  7:46     ` Fiona Ebner
2025-06-13 10:25   ` Fabian Grünbichler
2025-06-16 11:31   ` DERUMIER, Alexandre via pve-devel
2025-06-16 11:51     ` Fiona Ebner
2025-06-16 12:46       ` Fabian Grünbichler
2025-06-16 12:57         ` Fiona Ebner
2025-06-16 13:15           ` Fabian Grünbichler
2025-06-16 13:27             ` Fiona Ebner
     [not found]   ` <409e12ad0b53d1b51c30717e6b9df3d370112df4.camel@groupe-cyllene.com>
2025-06-17  6:04     ` DERUMIER, Alexandre via pve-devel
2025-06-17  7:35       ` Fiona Ebner
2025-06-12 14:02 ` [pve-devel] [PATCH qemu-server 16/22] print drive device: explicitly set write-cache starting with machine version 10.0 Fiona Ebner
2025-06-13 10:28   ` Fabian Grünbichler
2025-06-17  7:47     ` Fiona Ebner
2025-06-12 14:02 ` [pve-devel] [PATCH qemu-server 17/22] print drive device: set {r, w}error front-end properties " Fiona Ebner
2025-06-12 14:02 ` [pve-devel] [PATCH qemu-server 18/22] print drive device: don't reference any drive for 'none' " Fiona Ebner
2025-06-13 11:14   ` Fabian Grünbichler
2025-06-17  7:54     ` Fiona Ebner
2025-06-12 14:02 ` [pve-devel] [PATCH qemu-server 19/22] drive: create a throttle group for each drive " Fiona Ebner
2025-06-13 11:23   ` Fabian Grünbichler [this message]
2025-06-17  7:58     ` Fiona Ebner
2025-06-12 14:02 ` [pve-devel] [PATCH qemu-server 20/22] blockdev: add helpers to generate blockdev commandline Fiona Ebner
2025-06-13 11:35   ` Fabian Grünbichler
2025-06-17  9:37     ` Fiona Ebner
2025-06-17  9:58       ` Fabian Grünbichler
2025-06-16 11:07   ` DERUMIER, Alexandre via pve-devel
2025-06-17 10:02     ` Fiona Ebner
2025-06-12 14:02 ` [pve-devel] [RFC qemu-server 21/22] blockdev: add support for NBD paths Fiona Ebner
2025-06-16 10:46   ` DERUMIER, Alexandre via pve-devel
2025-06-17 10:11     ` Fiona Ebner
2025-06-12 14:02 ` [pve-devel] [RFC qemu-server 22/22] command line: switch to blockdev starting with machine version 10.0 Fiona Ebner
2025-06-16 10:40   ` DERUMIER, Alexandre via pve-devel
2025-06-18 11:39     ` Fiona Ebner
2025-06-18 12:04       ` DERUMIER, Alexandre via pve-devel
2025-06-16  6:22 ` [pve-devel] [PATCH-SERIES qemu-server 00/22] preparation for switch to blockdev DERUMIER, Alexandre via pve-devel
2025-06-16  8:44   ` Fiona Ebner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1749813535.eadqoip30x.astroid@yuna.none \
    --to=f.gruenbichler@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal