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 386A8744AC for ; Mon, 21 Jun 2021 15:56:22 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2A3C11C41C for ; Mon, 21 Jun 2021 15:55:41 +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 id 43F1B1C305 for ; Mon, 21 Jun 2021 15:55:36 +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 03ADB42FEC for ; Mon, 21 Jun 2021 15:55:36 +0200 (CEST) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Mon, 21 Jun 2021 15:55:21 +0200 Message-Id: <20210621135534.14807-9-d.csapak@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210621135534.14807-1-d.csapak@proxmox.com> References: <20210621135534.14807-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.833 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 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: Mon, 21 Jun 2021 13:56:22 -0000 and get the correct pci device during parsing Signed-off-by: Dominik Csapak --- PVE/QemuServer/PCI.pm | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/PVE/QemuServer/PCI.pm b/PVE/QemuServer/PCI.pm index 2ee142f..26bad63 100644 --- a/PVE/QemuServer/PCI.pm +++ b/PVE/QemuServer/PCI.pm @@ -4,6 +4,8 @@ use warnings; use strict; use PVE::JSONSchema; +use PVE::HardwareMap; +use PVE::HardwareMap::PCIPlugin; use PVE::SysFSTools; use base 'Exporter'; @@ -18,12 +20,13 @@ parse_hostpci our $MAX_HOSTPCI_DEVICES = 16; my $PCIRE = qr/([a-f0-9]{4}:)?[a-f0-9]{2}:[a-f0-9]{2}(?:\.[a-f0-9])?/; + 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 => < { @@ -349,6 +354,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::PCIPlugin->assert_device_valid($device); + }; + if (my $err = $@) { + die "PCI device mapping invalid (hardware probably changed): $err\n"; + } + $res->{host} = $device->{pcipath}; + } + my @idlist = split(/;/, $res->{host}); delete $res->{host}; foreach my $id (@idlist) { -- 2.20.1