From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 81DDA1FF0B3 for ; Wed, 14 Oct 2026 10:54:11 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 0596B2141B; Wed, 14 Oct 2026 10:54:09 +0200 (CEST) From: Hannes Laimer To: pve-devel@lists.proxmox.com Subject: [PATCH lxc] d/patches: print a failing hook's last output along with its exit code Date: Wed, 14 Oct 2026 10:54:00 +0200 Message-ID: <20261014085400.551471-1-h.laimer@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1791968044085 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.505 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: QWZIEK7Q2K55GOBNFH3OSHK6TBGC5XMB X-Message-ID-Hash: QWZIEK7Q2K55GOBNFH3OSHK6TBGC5XMB X-MailFrom: h.laimer@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This makes the output of a failed LXC start task way more useful when diagnosing a problem. So far the reason a container could not start was only in the lxc debug log, so one had to start it again with the debug flag, which can't be done through the UI and dumps lxc's whole debug output into the task log. Signed-off-by: Hannes Laimer --- some example outputs: * typo in mp ``` run_buffer: 569 Script exited with status 2 lxc_init: 1037 Failed to run lxc.hook.pre-start for container "100" __lxc_start: 2208 Failed to initialize container "100" TASK ERROR: startup for container '100' failed run_buffer: 580 Script output: directory '/mnt/nope' does not exist run_buffer: 583 Script exited with status 2 lxc_init: 1037 Failed to run lxc.hook.pre-start for container "100" __lxc_start: 2208 Failed to initialize container "100" TASK ERROR: startup for container '100' failed ``` * problem with rootfs ``` run_buffer: 569 Script exited with status 32 lxc_init: 1037 Failed to run lxc.hook.pre-start for container "100" __lxc_start: 2208 Failed to initialize container "100" TASK ERROR: startup for container '100' failed run_buffer: 580 Script output: command 'mount /dev/dm-6 /var/lib/lxc/.pve-staged-mounts/rootfs' failed: exit code 32 run_buffer: 583 Script exited with status 32 lxc_init: 1037 Failed to run lxc.hook.pre-start for container "100" __lxc_start: 2208 Failed to initialize container "100" TASK ERROR: startup for container '100' failed ``` ...output-of-a-failing-hook-as-an-error.patch | 38 +++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 39 insertions(+) create mode 100644 debian/patches/pve/0004-utils-log-last-output-of-a-failing-hook-as-an-error.patch diff --git a/debian/patches/pve/0004-utils-log-last-output-of-a-failing-hook-as-an-error.patch b/debian/patches/pve/0004-utils-log-last-output-of-a-failing-hook-as-an-error.patch new file mode 100644 index 0000000..be72316 --- /dev/null +++ b/debian/patches/pve/0004-utils-log-last-output-of-a-failing-hook-as-an-error.patch @@ -0,0 +1,38 @@ +From eb3906204eb9ae822e6ab4d85f0d5e3dacc916d3 Mon Sep 17 00:00:00 2001 +From: Hannes Laimer +Date: Wed, 14 Oct 2026 09:06:48 +0200 +Subject: [PATCH] utils: log last output of a failing hook as an error + +The exit code of a failing hook is logged as an error, and the code +alone is usually not enough to locate the problem. Log the last output +of the hook as an error as well. + +Signed-off-by: Hannes Laimer +--- + src/lxc/utils.c | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/src/lxc/utils.c b/src/lxc/utils.c +index cab8e893b..17249ab9f 100644 +--- a/src/lxc/utils.c ++++ b/src/lxc/utils.c +@@ -565,7 +565,15 @@ static int run_buffer(char *buffer) + ret = lxc_pclose(move_ptr(f)); + if (ret == -1) + return log_error_errno(-1, errno, "Script exited with error"); +- else if (WIFEXITED(ret) && WEXITSTATUS(ret) != 0) ++ ++ if (WIFEXITED(ret) && WEXITSTATUS(ret) == 0) ++ return 0; ++ ++ remove_trailing_newlines(output); ++ if (*output) ++ ERROR("Script output: %s", output); ++ ++ if (WIFEXITED(ret)) + return log_error(-1, "Script exited with status %d", WEXITSTATUS(ret)); + else if (WIFSIGNALED(ret)) + return log_error(-1, "Script terminated by signal %d", WTERMSIG(ret)); +-- +2.47.3 + diff --git a/debian/patches/series b/debian/patches/series index 8a37d9b..8b9baac 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -3,5 +3,6 @@ apparmor/0002-apparmor-use-abi-directive-in-apparmor-profiles.patch pve/0001-PVE-Config-deny-rw-mounting-of-sys-and-proc.patch pve/0002-PVE-Config-attach-always-use-getent.patch pve/0003-dhclient-script-set-RFC3442-classless-routes.patch +pve/0004-utils-log-last-output-of-a-failing-hook-as-an-error.patch cgroupv1-warnings/0001-PVE-Revert-lxc-conf-drop-cgroup1-config-options-lxc..patch cgroupv1-warnings/0002-PVE-ignore-cgroupv1-settings-with-a-warning.patch -- 2.47.3