From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 687AB1FF185 for ; Mon, 17 Nov 2025 12:31:57 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 45F5F15789; Mon, 17 Nov 2025 12:32:00 +0100 (CET) Message-ID: <7d7cabf4-616a-4217-ba7d-3c2c6ba5f948@proxmox.com> Date: Mon, 17 Nov 2025 12:31:56 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Fiona Ebner , Proxmox VE development discussion References: <20251113150342.101933-1-r.obkircher@proxmox.com> <20251113150342.101933-3-r.obkircher@proxmox.com> <6c3edd7e-cf58-4805-a107-3e9c69d86cd5@proxmox.com> Content-Language: en-US, de-AT From: Robert Obkircher In-Reply-To: <6c3edd7e-cf58-4805-a107-3e9c69d86cd5@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1763379088277 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.100 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 Subject: Re: [pve-devel] [PATCH v4 pve-container 2/5] Propagate prestart-hook warnings to task-log. 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: , Reply-To: Proxmox VE development discussion Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" On 11/13/25 17:35, Fiona Ebner wrote: > Am 13.11.25 um 4:04 PM schrieb Robert Obkircher: >> diff --git a/src/lxc-pve-prestart-hook b/src/lxc-pve-prestart-hook >> index 73125e1..f5dd728 100755 >> --- a/src/lxc-pve-prestart-hook >> +++ b/src/lxc-pve-prestart-hook >> @@ -28,17 +28,6 @@ eval { >> $have_sdn = 1; >> }; >> >> -my $WARNFD; >> - >> -sub log_warn { >> - my ($vmid, $message) = @_; >> - >> - if (!defined($WARNFD)) { >> - open($WARNFD, '>', "/run/pve/ct-${vmid}.warnings"); >> - } >> - print $WARNFD "$message\n"; >> -} >> - >> PVE::LXC::Tools::lxc_hook( >> 'pre-start', >> 'lxc', >> @@ -53,6 +42,15 @@ PVE::LXC::Tools::lxc_hook( >> >> PVE::RESTEnvironment->setup_default_cli_env(); >> >> + my $warn_file = "/run/pve/ct-${vmid}.warnings"; >> + # open eagerly so logging works inside the protected_call chroot > Nit: Maybe "early" instead of "eagerly"? I was specifically thinking about eager/lazy evaluation. > >> + open(my $warnfd, '>', $warn_file) or die "Failed to open $warn_file: $!"; >> + my $log_warn = sub { >> + my ($message) = @_; > Nit: I'd add a chomp() so that callers don't need to worry about not > including a newline Makes sense. >> + print $warnfd "$message\n"; >> + $warnfd->flush; # required because protected_call calls POSIX::_exit >> + }; >> + >> return undef if !-f PVE::LXC::Config->config_file($vmid); >> >> my $conf = PVE::LXC::Config->load_config($vmid); >> @@ -155,12 +153,12 @@ PVE::LXC::Tools::lxc_hook( >> >> PVE::LXC::Config->foreach_passthrough_device($conf, $setup_passthrough_device); >> >> - my $lxc_setup = PVE::LXC::Setup->new($conf, $rootdir); >> + my $lxc_setup = PVE::LXC::Setup->new($conf, $rootdir, undef, $log_warn); >> $lxc_setup->pre_start_hook(); >> >> if (PVE::CGroup::cgroup_mode() == 2) { >> if (!$lxc_setup->unified_cgroupv2_support()) { >> - log_warn( >> + $log_warn->( >> $vmid, >> "old systemd (< v232) detected, container won't run in a pure cgroupv2" >> . " environment! Please see documentation -> container -> cgroup version.", > The call here still uses the VMID argument, but the new helper only > takes a single argument. Thanks, good catch! _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel