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 9D0DC8A0A3 for ; Mon, 1 Aug 2022 15:00:13 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 938032FF2B for ; Mon, 1 Aug 2022 14:59: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 ; Mon, 1 Aug 2022 14:59:41 +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 B166A42CE6 for ; Mon, 1 Aug 2022 14:59:41 +0200 (CEST) Date: Mon, 01 Aug 2022 14:59:34 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20220719114639.3035048-1-d.csapak@proxmox.com> <20220719114639.3035048-6-d.csapak@proxmox.com> In-Reply-To: <<20220719114639.3035048-6-d.csapak@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1659357083.eoh05pi6k9.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 1/7] PVE/QemuServer: allow mapped usb devices 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:13 -0000 On July 19, 2022 1:46 pm, Dominik Csapak wrote: > Signed-off-by: Dominik Csapak > --- > PVE/QemuServer.pm | 2 ++ > PVE/QemuServer/USB.pm | 21 ++++++++++++++++++++- > 2 files changed, 22 insertions(+), 1 deletion(-) >=20 > diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm > index 7d9cf22..a6ca80d 100644 > --- a/PVE/QemuServer.pm > +++ b/PVE/QemuServer.pm > @@ -1069,6 +1069,8 @@ The Host USB device or port or the value 'spice'. H= OSTUSBDEVICE syntax is: > =20 > You can use the 'lsusb -t' command to list existing usb devices. > =20 > +Alternatively, you can used an ID of a mapped usb device. > + > NOTE: This option allows direct access to host hardware. So it is no lon= ger possible to migrate such > machines - use with special care. > =20 > diff --git a/PVE/QemuServer/USB.pm b/PVE/QemuServer/USB.pm > index 3c8da2c..279078a 100644 > --- a/PVE/QemuServer/USB.pm > +++ b/PVE/QemuServer/USB.pm > @@ -4,6 +4,7 @@ use strict; > use warnings; > use PVE::QemuServer::PCI qw(print_pci_addr); > use PVE::JSONSchema; > +use PVE::HardwareMap; > use base 'Exporter'; > =20 > our @EXPORT_OK =3D qw( > @@ -27,7 +28,25 @@ sub parse_usb_device { > } elsif ($value =3D~ m/^spice$/i) { > $res->{spice} =3D 1; > } else { > - return; > + # we have no ordinary usb device, must be a mapping > + my $device =3D PVE::HardwareMap::find_device_on_current_node('usb', $va= lue); > + return undef if !defined($device); > + eval { > + PVE::HardwareMap::assert_device_valid('usb', $device); > + }; > + if (my $err =3D $@) { > + warn "USB Mapping invalid (hardware probably changed): $err\n"; > + return; > + } nit: this would also trigger on deleting such an invalid mapping, which is = a=20 bit strange? > + > + if ($device->{path}) { > + $res =3D parse_usb_device($device->{path}); > + } else { > + $res->{vendorid} =3D $device->{vendor}; > + $res->{productid} =3D $device->{device}; > + } > + > + $res->{mapped} =3D 1; > } > =20 > return $res; > --=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