From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	by lore.proxmox.com (Postfix) with ESMTPS id CCA2C1FF15F
	for <inbox@lore.proxmox.com>; Mon,  2 Dec 2024 09:47:39 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 4D05B11A7F;
	Mon,  2 Dec 2024 09:47:43 +0100 (CET)
Message-ID: <a830b1a1-1fe8-4329-b2eb-9525ff54aa25@proxmox.com>
Date: Mon, 2 Dec 2024 09:47:39 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird Beta
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
 Hannes Duerr <h.duerr@proxmox.com>
References: <20241120112610.160234-1-h.duerr@proxmox.com>
 <20241120112610.160234-3-h.duerr@proxmox.com>
Content-Language: en-US
From: Dominik Csapak <d.csapak@proxmox.com>
In-Reply-To: <20241120112610.160234-3-h.duerr@proxmox.com>
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.014 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 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 proxmx-nvidia-vgpu-helper 2/2] add script to
 help with the installation of the nvidia vgpu dependencies
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

high level comments first:

* the script is actually not installed with the package, because it's not
installed anywhere and not in any .install file

(you'd either have to use an 'install' target in the makefile to install it to some folder
or use a .install file in the debian folder for the package to specify
which files should be installed
(see most of our other packages how they do it exactly)

* i'd like to go a bit further than this script.

What I'd have imagined is more like our 'pveceph' tool that can
include multiple commands, even if we might only have one or two for now

so e.g.

pve-nvidia-vgpu-helper install-prerequisites
pve-nvidia-vgpu-helper gpus list
pve-nvidia-vgpu-helper gpus enable-sriov
etc..

some of these (e.g. the sriov enablement) could even be interactive, but something
like that could be done in the future.

thir

* not sure about that, but couldn't this be a rust binary?
i think we have everything we need already there.
It is not a requirement for this IMHO, but personally i tend to write new things
in rust these days.

* it would be very nice to also have some general prerequisites checked, maybe
as a separate command or all-in-one (does not matter much imo). For example
if iommu/vt-d/etc. is turned on and the cards are separated, if there are even
nvidia cards installed, etc.

one comment inline

On 11/20/24 12:26, Hannes Duerr wrote:
> The script should help with the dependency installation for the nvidia
> vgpu driver, also if the driver is already installed but the system has
> been updated
> 
> Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
> ---
>   pve-install-nvidia-vgpu-deps | 66 ++++++++++++++++++++++++++++++++++++
>   1 file changed, 66 insertions(+)
>   create mode 100755 pve-install-nvidia-vgpu-deps
> 
> diff --git a/pve-install-nvidia-vgpu-deps b/pve-install-nvidia-vgpu-deps
> new file mode 100755
> index 0000000..fc0856e
> --- /dev/null
> +++ b/pve-install-nvidia-vgpu-deps
> @@ -0,0 +1,66 @@
> +#!/usr/bin/perl
> +
> +use strict;
> +use warnings;
> +
> +use PVE::Tools qw(run_command);
> +use AptPkg::Cache;
> +
> +my @apt_install = qw(apt-get --no-install-recommends -o Dpkg:Options::=--force-confnew install --);

imho i find that line a bit dangerous, because it'll overwrite user configs with new default configs
AFAIU

Our approach to installs is that they can be interactive, so adding '--force-confnew' is not a good idea

> +my @dependencies = qw(dkms libc6-dev);
> +my @missing_packages;
> +
> +die "Please execute the script with root privileges\n" if $>;
> +
> +my $apt_cache = AptPkg::Cache->new();
> +die "unable to initialize AptPkg::Cache\n" if !$apt_cache;
> +
> +sub package_is_installed {
> +    my ($package) = @_;
> +    my $p = $apt_cache->{$package};
> +    if (!defined($p->{CurrentState}) || $p->{CurrentState} ne "Installed") {
> +	push(@missing_packages, $package);
> +    }
> +}
> +
> +foreach my $dependency (@dependencies) {
> +    package_is_installed($dependency);
> +}
> +
> +
> +my $running_kernel;
> +run_command( ['/usr/bin/uname', '-r' ],
> +    outfunc => sub { $running_kernel = shift } );
> +
> +my $default_major_minor_version;
> +run_command(['/usr/bin/dpkg-query', '-f', '${Depends}', '-W', 'proxmox-default-kernel'],
> +    outfunc => sub { $default_major_minor_version = shift } );
> +
> +my $default_full_version;
> +run_command(['/usr/bin/dpkg-query', '-f', '${Version}', '-W', $default_major_minor_version],
> +    outfunc => sub { $default_full_version = shift } );
> +
> +if ($running_kernel =~ /$default_full_version-pve/) {
> +    print "You are running the proxmox default kernel `proxmox-kernel-$running_kernel`\n";
> +    package_is_installed("proxmox-default-headers");
> +} elsif ($running_kernel =~ /pve/) {
> +    print "You are running the non default proxmox kernel `proxmox-kernel-$running_kernel`\n";
> +    package_is_installed("proxmox-headers-$running_kernel");
> +} else {
> +    die "You are not using a proxmox-kernel, please make sure that the appropriate header package is installed.\n";
> +}
> +
> +if (!@missing_packages){
> +    print "All required packages are installed, you can continue with the Nvidia vGPU driver installation.\n";
> +    exit;
> +} else {
> +    print "The following packages are missing:\n" . join("\n", @missing_packages) ."\n";
> +    print "Would you like to install them now (y/n)?\n";
> +}
> +
> +my $answer = <STDIN>;
> +if (defined($answer) && $answer =~ m/^\s*y(?:es)?\s*$/i) {
> +    if (system(@apt_install, @missing_packages) != 0) {
> +	die "apt failed during the installation: ($?)\n";
> +    }
> +}



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel