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 AD70E1FF17C for ; Wed, 23 Jul 2025 13:10:29 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D3180E60A; Wed, 23 Jul 2025 13:11:48 +0200 (CEST) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Wed, 23 Jul 2025 13:10:47 +0200 Message-ID: <20250723111105.72422-2-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250723111105.72422-1-f.ebner@proxmox.com> References: <20250723111105.72422-1-f.ebner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1753269064500 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.027 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [qemuserver.pm] Subject: [pve-devel] [PATCH qemu-server 2/2] fix #6556: vm status: fix querying block stats 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" With the switch to '-blockdev', the 'device' property in the return value of the 'query-blockstats' QMP command is not initialized. This can be seen in the QEMU source code (the device property is the name of the block backend and blk->name is assigned a value only in a code path reached via drive_new()). This was done to avoid confusion/clashes with node names, because they live in the same namespace as block backend names. The node names cannot be relied on either, because an empty CD-ROM drive does not have an associated block node. So use the qdev ID as a fallback. The stats are reported for the block backend, so it does not matter that the block node structure changed with the switch to '-blockdev'. Fixes: aaf48d8e ("command line: switch to blockdev starting with machine version 10.0") Signed-off-by: Fiona Ebner --- src/PVE/QemuServer.pm | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm index d0c537e0..7f42256c 100644 --- a/src/PVE/QemuServer.pm +++ b/src/PVE/QemuServer.pm @@ -2705,8 +2705,20 @@ sub vmstatus { $totalrdbytes = $totalrdbytes + $blockstat->{stats}->{rd_bytes}; $totalwrbytes = $totalwrbytes + $blockstat->{stats}->{wr_bytes}; - $blockstat->{device} =~ s/drive-//; - $res->{$vmid}->{blockstat}->{ $blockstat->{device} } = $blockstat->{stats}; + # With the switch to -blockdev, the block backend in QEMU has no name, so need to also + # consider the qdev ID. Note that empty CD-ROM drives do not have a node name, so that + # cannot be used as a fallback instead of the qdev ID. + my $drive_id; + if ($blockstat->{device}) { + $drive_id = $blockstat->{device} =~ s/drive-//r; + } elsif ($blockstat->{qdev}) { + $drive_id = PVE::QemuServer::Blockdev::qdev_id_to_drive_id($blockstat->{qdev}); + } else { + print "blockstats callback: unexpected missing drive ID\n"; + next; + } + + $res->{$vmid}->{blockstat}->{$drive_id} = $blockstat->{stats}; } $res->{$vmid}->{diskread} = $totalrdbytes; $res->{$vmid}->{diskwrite} = $totalwrbytes; -- 2.47.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel