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 0BC308A099 for ; Mon, 1 Aug 2022 15:00:05 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 064BE2FF34 for ; Mon, 1 Aug 2022 15:00:05 +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 ; Mon, 1 Aug 2022 15:00:04 +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 DB09042CE6 for ; Mon, 1 Aug 2022 15:00:03 +0200 (CEST) Date: Mon, 01 Aug 2022 14:59:57 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20220719114639.3035048-1-d.csapak@proxmox.com> <20220719114639.3035048-7-d.csapak@proxmox.com> In-Reply-To: <<20220719114639.3035048-7-d.csapak@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1659357142.dwrndnzw99.astroid@nora.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.161 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: Re: [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, 01 Aug 2022 13:00:05 -0000 On July 19, 2022 1:46 pm, Dominik Csapak wrote: > and get the correct pci device during parsing >=20 > Signed-off-by: Dominik Csapak > --- > PVE/QemuServer/PCI.pm | 20 ++++++++++++++++++-- > 1 file changed, 18 insertions(+), 2 deletions(-) >=20 > 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; > =20 > use PVE::JSONSchema; > +use PVE::HardwareMap; > use PVE::SysFSTools; > use PVE::Tools; > =20 > @@ -23,8 +24,8 @@ my $hostpci_fmt =3D { > host =3D> { > default_key =3D> 1, > type =3D> 'string', > - pattern =3D> qr/$PCIRE(;$PCIRE)*/, > - format_description =3D> 'HOSTPCIID[;HOSTPCIID2...]', > + pattern =3D> qr/(:?$PCIRE(;$PCIRE)*)|(:?$PVE::JSONSchema::CONFIGID_RE)/= , > + format_description =3D> 'HOSTPCIID[;HOSTPCIID2...] or configured mappin= g id', > description =3D> < Host PCI device pass through. The PCI ID of a host's PCI device or a lis= t > of PCI virtual functions of the host. HOSTPCIID syntax is: > @@ -32,6 +33,8 @@ of PCI virtual functions of the host. HOSTPCIID syntax = is: > 'bus:dev.func' (hexadecimal numbers) > =20 > You can us the 'lspci' command to list existing PCI devices. > + > +Alternatively use the ID of a mapped pci device. > EODESCR > }, > rombar =3D> { > @@ -383,6 +386,19 @@ sub parse_hostpci { > =20 > my $res =3D PVE::JSONSchema::parse_property_string($hostpci_fmt, $va= lue); > =20 > + if ($res->{host} !~ m/:/) { > + # we have no ordinary pci id, must be a mapping > + my $device =3D PVE::HardwareMap::find_device_on_current_node('pci', $re= s->{host}); > + die "PCI device mapping not found for '$res->{host}'\n" if !defined($de= vice); > + eval { > + PVE::HardwareMap::assert_device_valid('pci', $device); > + }; > + if (my $err =3D $@) { > + die "PCI device mapping invalid (hardware probably changed): $err\n= "; here we die, with USB we warn.. OTOH this gets called way less than the=20 USB counter part, since we mostly just parse the property string without=20 the extra checks for PCI.. might make sense to unify the approach taken. > + } > + $res->{host} =3D $device->{path}; > + } > + > my @idlist =3D split(/;/, $res->{host}); > delete $res->{host}; > foreach my $id (@idlist) { > --=20 > 2.30.2 >=20 >=20 >=20 > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >=20 >=20 >=20