1+ From 6c3157c3324c5e47cb0a8c3df0aaa59b753a2f2f Mon Sep 17 00:00:00 2001
2+ From: jiangcuo <jiangcuo@bingsin.com>
3+ Date: Thu, 5 Dec 2024 11:31:29 +0800
4+ Subject: [PATCH] Add loongarch support
5+
6+ ---
7+ src/PVE/LXC/Config.pm | 2 +-
8+ src/PVE/LXC/Setup.pm | 11 ----------
9+ src/PVE/LXC/Setup/Plugin.pm | 44 ++++++++++++++++++++++++++++++++++++-
10+ src/PVE/LXC/Tools.pm | 1 +
11+ 4 files changed, 45 insertions(+), 13 deletions(-)
12+
113diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
2- index 1664a35..73f60f0 100644
14+ index 5cc37f7..0452d4a 100644
315--- a/src/PVE/LXC/Config.pm
416+++ b/src/PVE/LXC/Config.pm
517@@ -473,7 +473,7 @@ my $confdesc = {
@@ -12,10 +24,10 @@ index 1664a35..73f60f0 100644
1224 default => 'amd64',
1325 },
1426diff --git a/src/PVE/LXC/Setup.pm b/src/PVE/LXC/Setup.pm
15- index 5c9114c..cae55b1 100644
27+ index dc58990..78272be 100644
1628--- a/src/PVE/LXC/Setup.pm
1729+++ b/src/PVE/LXC/Setup.pm
18- @@ -135 ,17 +135 ,6 @@ sub new {
30+ @@ -141 ,17 +141 ,6 @@ sub new {
1931 if (!defined($conf->{arch})) {
2032 my $arch = eval { $self->protected_call(sub { $plugin->detect_architecture() }) };
2133
@@ -34,14 +46,14 @@ index 5c9114c..cae55b1 100644
3446 }
3547
3648diff --git a/src/PVE/LXC/Setup/Plugin.pm b/src/PVE/LXC/Setup/Plugin.pm
37- index b9d9c2d..533afe0 100644
49+ index b9d9c2d..f413d91 100644
3850--- a/src/PVE/LXC/Setup/Plugin.pm
3951+++ b/src/PVE/LXC/Setup/Plugin.pm
4052@@ -6,6 +6,7 @@ use strict;
4153 use warnings;
4254
4355 use Carp;
44- + use PVE::Tools;
56+ + use PVE::Tools qw(get_host_arch) ;
4557
4658 sub new {
4759 my ($class, $conf, $rootdir, $os_release) = @_;
@@ -84,8 +96,8 @@ index b9d9c2d..533afe0 100644
8496+
8597+ my $arch = eval { PVE::Tools::run_fork_with_timeout(5, $detect_arch) };
8698+ if (my $err = $@) {
87- + $arch = 'arm64' ;
88- + print "Architecture detection failed: $err\nFalling back to loongarch64 .\n" .
99+ + $arch = get_host_arch() ;
100+ + print "Architecture detection failed: $err\nFalling back to $arch .\n" .
89101+ "Use `pct set VMID --arch ARCH` to change.\n";
90102+ } else {
91103+ print "Detected container architecture: $arch\n";
@@ -96,7 +108,7 @@ index b9d9c2d..533afe0 100644
96108
97109 # hooks
98110diff --git a/src/PVE/LXC/Tools.pm b/src/PVE/LXC/Tools.pm
99- index 7e3e530..838327f 100644
111+ index 3380c62..a9aa942 100644
100112--- a/src/PVE/LXC/Tools.pm
101113+++ b/src/PVE/LXC/Tools.pm
102114@@ -179,6 +179,7 @@ sub detect_elf_architecture {
0 commit comments