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 E8D9793C9B for ; Tue, 20 Sep 2022 14:51:19 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A3E891BF9B for ; Tue, 20 Sep 2022 14:51:00 +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, 20 Sep 2022 14:50:54 +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 34C7C4447E for ; Tue, 20 Sep 2022 14:50:45 +0200 (CEST) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Tue, 20 Sep 2022 14:50:21 +0200 Message-Id: <20220920125041.3636561-16-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220920125041.3636561-1-d.csapak@proxmox.com> References: <20220920125041.3636561-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.079 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 v3 06/13] 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, 20 Sep 2022 12:51:19 -0000 and get the correct pci device during parsing Signed-off-by: Dominik Csapak --- PVE/QemuServer/PCI.pm | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/PVE/QemuServer/PCI.pm b/PVE/QemuServer/PCI.pm index b5284ef..08244c1 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,10 +386,27 @@ sub parse_hostpci { my $res = PVE::JSONSchema::parse_property_string($hostpci_fmt, $value); + my $mapping = 0; + if ($res->{host} !~ m/:/) { + # we have no ordinary pci id, must be a mapping + $mapping = 1; + 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) { my $devs = PVE::SysFSTools::lspci($id); + die "cannot use mediated device with multifuntion device\n" + if $mapping && $res->{mdev} && scalar(@$devs) > 1; die "no PCI device found for '$id'\n" if !scalar(@$devs); push @{$res->{pciid}}, @$devs; } -- 2.30.2