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 8FEAD8965B for ; Fri, 12 Aug 2022 09:33:20 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7F892270C3 for ; Fri, 12 Aug 2022 09:32:50 +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 ; Fri, 12 Aug 2022 09:32:49 +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 AD88F43549 for ; Fri, 12 Aug 2022 09:32:49 +0200 (CEST) Date: Fri, 12 Aug 2022 09:32:48 +0200 From: Wolfgang Bumiller To: Dominik Csapak Cc: pve-devel@lists.proxmox.com Message-ID: <20220812073248.2nlw53xwa4danl3e@casey.proxmox.com> References: <20220726065559.674547-1-d.csapak@proxmox.com> <20220726065559.674547-3-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220726065559.674547-3-d.csapak@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.278 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 T_SCC_BODY_TEXT_LINE -0.01 - 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, qemuserver.pm] Subject: Re: [pve-devel] [PATCH qemu-server 1/1] automatically add 'uuid' parameter when passing through NVIDIA vGPU 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: Fri, 12 Aug 2022 07:33:20 -0000 On Tue, Jul 26, 2022 at 08:55:58AM +0200, Dominik Csapak wrote: > When passing through an NVIDIA vGPU via mediated devices, their > software needs the qemu process to have the 'uuid' parameter set to the > one of the vGPU. Since it's currently not possible to pass through multiple > vGPUs to one VM (seems to be an NVIDIA driver limitation at the moment), > we don't have to take care about that. > > Sadly, the place we do this, it does not show up in 'qm showcmd' as we > don't (want to) query the pci devices in that case, and then we don't > have a way of knowing if it's an NVIDIA card or not. But since this > is informational with QEMU anyway, i'd say we can ignore that. > > Signed-off-by: Dominik Csapak > --- > PVE/QemuServer.pm | 8 +++++++- > PVE/QemuServer/PCI.pm | 4 +++- > 2 files changed, 10 insertions(+), 2 deletions(-) > > diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm > index 7d9cf22..c4eb031 100644 > --- a/PVE/QemuServer.pm > +++ b/PVE/QemuServer.pm > @@ -5597,7 +5597,13 @@ sub vm_start_nolock { > for my $id (sort keys %$pci_devices) { > my $d = $pci_devices->{$id}; > for my $dev ($d->{pciid}->@*) { > - PVE::QemuServer::PCI::prepare_pci_device($vmid, $dev->{id}, $id, $d->{mdev}); > + my $info = PVE::QemuServer::PCI::prepare_pci_device($vmid, $dev->{id}, $id, $d->{mdev}); > + > + # nvidia grid needs the uuid of the mdev as qemu parameter > + if ($d->{mdev} && $info->{vendor} eq '10de') { > + my $uuid = PVE::QemuServer::PCI::generate_mdev_uuid($vmid, $id); > + push @$cmd, '-uuid', $uuid; You mention you can only pass through one device, but I'd still prefer the code to make sure we only pass a single `-uuid` parameter here, since this is not at all clear when just reading the code. Otherwise this seems fine. > + } > } > } > }; > diff --git a/PVE/QemuServer/PCI.pm b/PVE/QemuServer/PCI.pm > index 23fe508..3d0e70e 100644 > --- a/PVE/QemuServer/PCI.pm > +++ b/PVE/QemuServer/PCI.pm > @@ -253,7 +253,7 @@ sub get_pci_addr_map { > return $pci_addr_map; > } > > -my sub generate_mdev_uuid { > +sub generate_mdev_uuid { > my ($vmid, $index) = @_; > return sprintf("%08d-0000-0000-0000-%012d", $index, $vmid); > } > @@ -514,6 +514,8 @@ sub prepare_pci_device { > die "can't reset PCI device '$pciid'\n" > if $info->{has_fl_reset} && !PVE::SysFSTools::pci_dev_reset($info); > } > + > + return $info; > } > > my $RUNDIR = '/run/qemu-server'; > -- > 2.30.2