From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 3468B1FF16B for ; Tue, 1 Jul 2025 17:44:32 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3B556A561; Tue, 1 Jul 2025 17:42:09 +0200 (CEST) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Tue, 1 Jul 2025 17:40:48 +0200 Message-ID: <20250701154117.434512-29-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250701154117.434512-1-f.ebner@proxmox.com> References: <20250701154117.434512-1-f.ebner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.029 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH qemu-server v2 28/49] blockdev: add helper to get node below throttle node X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Signed-off-by: Fiona Ebner --- Changes in v2: * Rely on QEMU patch that returns file child node name as part of block info. * Add parameter so callers that know they happen for -blockdev only can assert that the top node is indeed a throttle node. src/PVE/QemuServer/Blockdev.pm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/PVE/QemuServer/Blockdev.pm b/src/PVE/QemuServer/Blockdev.pm index 660ad471..87b46eb4 100644 --- a/src/PVE/QemuServer/Blockdev.pm +++ b/src/PVE/QemuServer/Blockdev.pm @@ -139,6 +139,30 @@ sub top_node_name { return "drive-$drive_id"; } +sub get_node_name_below_throttle { + my ($vmid, $device_id, $assert_top_is_throttle) = @_; + + my $block_info = get_block_info($vmid); + my $drive_id = $device_id =~ s/^drive-//r; + my $inserted = $block_info->{$drive_id}->{inserted} + or die "no block node inserted for drive '$drive_id'\n"; + + if ($inserted->{drv} ne 'throttle') { + die "$device_id: unexpected top node $inserted->{'node-name'} ($inserted->{drv})\n" + if $assert_top_is_throttle; + # before the switch to -blockdev, the top node was not throttle + return $inserted->{'node-name'}; + } + + my $children = { map { $_->{'child-name'} => $_ } $inserted->{children}->@* }; + + if (my $node_name = $children->{file}->{'node-name'}) { + return $node_name; + } + + die "$device_id: throttle node without file child node name!\n"; +} + my sub read_only_json_option { my ($drive, $options) = @_; -- 2.47.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel