public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
	Christoph Heiss <c.heiss@proxmox.com>
Subject: Re: [pve-devel] [PATCH container] setup: Fix architecture detection for NixOS containers
Date: Mon, 21 Aug 2023 14:50:28 +0200	[thread overview]
Message-ID: <324817da-4c12-a98b-62af-eb9333729edc@proxmox.com> (raw)
In-Reply-To: <20230228105911.217085-1-c.heiss@proxmox.com>

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.

> +	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.

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);




  parent reply	other threads:[~2023-08-21 12:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-28 10:59 Christoph Heiss
2023-07-03 10:00 ` Christoph Heiss
2023-08-21 12:50 ` Fiona Ebner [this message]
2023-08-22 12:35   ` Christoph Heiss

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=324817da-4c12-a98b-62af-eb9333729edc@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=c.heiss@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal