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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id BEB468A3C for ; Tue, 22 Aug 2023 14:36:00 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 9E335CC9D for ; Tue, 22 Aug 2023 14:36: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) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Tue, 22 Aug 2023 14:35:59 +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 A2E75432E7 for ; Tue, 22 Aug 2023 14:35:59 +0200 (CEST) Date: Tue, 22 Aug 2023 14:35:58 +0200 From: Christoph Heiss To: Fiona Ebner Cc: Proxmox VE development discussion Message-ID: References: <20230228105911.217085-1-c.heiss@proxmox.com> <324817da-4c12-a98b-62af-eb9333729edc@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <324817da-4c12-a98b-62af-eb9333729edc@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL -0.038 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 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. [nixos.pm, setup.pm] Subject: Re: [pve-devel] [PATCH container] setup: Fix architecture detection for NixOS containers 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, 22 Aug 2023 12:36:00 -0000 Thanks for the review! On Mon, Aug 21, 2023 at 02:50:28PM +0200, Fiona Ebner wrote: > > Am 28.02.23 um 11:59 schrieb Christoph Heiss: > > diff --git a/src/PVE/LXC/Setup.pm b/src/PVE/LXC/Setup.pm > > index 891231f..4346c5e 100644 > > --- a/src/PVE/LXC/Setup.pm > > +++ b/src/PVE/LXC/Setup.pm > > @@ -131,6 +131,20 @@ sub new { > > $plugin->{rootgid} = $rootgid; > > } > > > > + # if arch is unset, we try to autodetect it > > + if (!defined($conf->{arch})) { > > + my $arch = eval { $self->protected_call(sub { $plugin->detect_architecture() }) }; > > + > > The error from the eval should be logged here. Ack, will do. > > > + if (!defined($arch)) { > > + $arch = 'amd64'; > > + print "Falling back to $arch.\nUse `pct set VMID --arch ARCH` to change.\n"; > > + } else { > > + print "Detected container architecture: $arch\n"; > > + } > > + > > (...) > > > diff --git a/src/PVE/LXC/Setup/NixOS.pm b/src/PVE/LXC/Setup/NixOS.pm > > index 845d2d5..4f7b93e 100644 > > --- a/src/PVE/LXC/Setup/NixOS.pm > > +++ b/src/PVE/LXC/Setup/NixOS.pm > > @@ -5,6 +5,7 @@ use warnings; > > > > use File::Path 'make_path'; > > > > +use PVE::LXC::Setup; > > This is a cyclic include, please let us avoid those. We could either use > a new helper module for the detect_architecture() helper or otherwise > move it to pve-guest-common or even pve-common. The detection itself is > pretty generic after all. I will probably go this route and simply move it to another module in pve-container. As long as it is not needed anywhere else, I think it is sensible to letting it stay close it is only user. > > An alternative to that would be to just add a function get_elf_fn() to > the plugin interface and change the existing detect_architecture() to > use that. > > > use PVE::LXC::Setup::Base; > > > > use base qw(PVE::LXC::Setup::Base);