[pve-devel] [PATCH v4 pve-container 2/5] Propagate prestart-hook warnings to task-log.
Robert Obkircher
r.obkircher at proxmox.com
Mon Nov 17 12:31:56 CET 2025
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!
More information about the pve-devel
mailing list