From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 68D717CCB0 for ; Tue, 19 Jul 2022 13:47:15 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 30EEA28D9F for ; Tue, 19 Jul 2022 13:46:43 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Tue, 19 Jul 2022 13:46:40 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id A2BFF423B2 for ; Tue, 19 Jul 2022 13:46:40 +0200 (CEST) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Tue, 19 Jul 2022 13:46:22 +0200 Message-Id: <20220719114639.3035048-7-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220719114639.3035048-1-d.csapak@proxmox.com> References: <20220719114639.3035048-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.092 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [pci.pm] Subject: [pve-devel] [PATCH qemu-server 2/7] PVE/QemuServer: allow mapped pci deviced in config 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: , X-List-Received-Date: Tue, 19 Jul 2022 11:47:15 -0000 and get the correct pci device during parsing Signed-off-by: Dominik Csapak --- PVE/QemuServer/PCI.pm | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/PVE/QemuServer/PCI.pm b/PVE/QemuServer/PCI.pm index 23fe508..1ff4bce 100644 --- a/PVE/QemuServer/PCI.pm +++ b/PVE/QemuServer/PCI.pm @@ -4,6 +4,7 @@ use warnings; use strict; use PVE::JSONSchema; +use PVE::HardwareMap; use PVE::SysFSTools; use PVE::Tools; @@ -23,8 +24,8 @@ my $hostpci_fmt = { host => { default_key => 1, type => 'string', - pattern => qr/$PCIRE(;$PCIRE)*/, - format_description => 'HOSTPCIID[;HOSTPCIID2...]', + pattern => qr/(:?$PCIRE(;$PCIRE)*)|(:?$PVE::JSONSchema::CONFIGID_RE)/, + format_description => 'HOSTPCIID[;HOSTPCIID2...] or configured mapping id', description => < { @@ -383,6 +386,19 @@ sub parse_hostpci { my $res = PVE::JSONSchema::parse_property_string($hostpci_fmt, $value); + if ($res->{host} !~ m/:/) { + # we have no ordinary pci id, must be a mapping + my $device = PVE::HardwareMap::find_device_on_current_node('pci', $res->{host}); + die "PCI device mapping not found for '$res->{host}'\n" if !defined($device); + eval { + PVE::HardwareMap::assert_device_valid('pci', $device); + }; + if (my $err = $@) { + die "PCI device mapping invalid (hardware probably changed): $err\n"; + } + $res->{host} = $device->{path}; + } + my @idlist = split(/;/, $res->{host}); delete $res->{host}; foreach my $id (@idlist) { -- 2.30.2