From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 76D351FF16B for ; Tue, 1 Jul 2025 17:48:43 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0ED0FADE9; Tue, 1 Jul 2025 17:49:08 +0200 (CEST) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Tue, 1 Jul 2025 17:40:45 +0200 Message-ID: <20250701154117.434512-26-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.028 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 25/49] blockdev: introduce qdev_id_to_drive_id() helper 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" To be re-used by users of the query-block QMP command. With -blockdev, the 'device' property is not initialized. See also commit 9af3ef69 ("vm devices list: prepare querying block device names for -blockdev") for context. Signed-off-by: Fiona Ebner --- src/PVE/QemuServer.pm | 11 +++-------- src/PVE/QemuServer/Blockdev.pm | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm index e7c98520..a15b4557 100644 --- a/src/PVE/QemuServer.pm +++ b/src/PVE/QemuServer.pm @@ -55,6 +55,7 @@ use PVE::QemuConfig; use PVE::QemuConfig::NoWrite; use PVE::QemuMigrate::Helpers; use PVE::QemuServer::Agent qw(qga_check_running); +use PVE::QemuServer::Blockdev; use PVE::QemuServer::BlockJob; use PVE::QemuServer::Helpers qw(config_aware_timeout get_iscsi_initiator_name min_version kvm_user_version windows_version); @@ -3813,14 +3814,8 @@ sub vm_devices_list { my $resblock = mon_cmd($vmid, 'query-block'); for my $block ($resblock->@*) { my $qdev_id = $block->{qdev} or next; - if ($qdev_id =~ m|^/machine/peripheral/(virtio(\d+))/virtio-backend$|) { - $qdev_id = $1; - } elsif ($qdev_id =~ m|^/machine/system\.flash0$|) { - $qdev_id = 'pflash0'; - } elsif ($qdev_id =~ m|^/machine/system\.flash1$|) { - $qdev_id = 'efidisk0'; - } - $devices->{$qdev_id} = 1; + my $drive_id = PVE::QemuServer::Blockdev::qdev_id_to_drive_id($qdev_id); + $devices->{$drive_id} = 1; } my $resmice = mon_cmd($vmid, 'query-mice'); diff --git a/src/PVE/QemuServer/Blockdev.pm b/src/PVE/QemuServer/Blockdev.pm index 378c9efe..454a6b7d 100644 --- a/src/PVE/QemuServer/Blockdev.pm +++ b/src/PVE/QemuServer/Blockdev.pm @@ -44,6 +44,20 @@ my sub is_fleecing_top_node { return $node_name =~ m/-fleecing$/ ? 1 : 0; } +sub qdev_id_to_drive_id { + my ($qdev_id) = @_; + + if ($qdev_id =~ m|^/machine/peripheral/(virtio(\d+))/virtio-backend$|) { + return $1; + } elsif ($qdev_id =~ m|^/machine/system\.flash0$|) { + return 'pflash0'; + } elsif ($qdev_id =~ m|^/machine/system\.flash1$|) { + return 'efidisk0'; + } + + return $qdev_id; # for SCSI/SATA/IDE it's the same +} + my sub get_node_name { my ($type, $drive_id, $volid, $options) = @_; -- 2.47.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel