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 D69F61FF13B for ; Wed, 25 Mar 2026 22:16:16 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5BBCB35221; Wed, 25 Mar 2026 22:16:36 +0100 (CET) Message-ID: <4f9272f8-dbd1-4bf0-b027-7cbf35683e22@proxmox.com> Date: Wed, 25 Mar 2026 22:16:29 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: [PATCH qemu-server 7/8] agent: fsfreeze: harmonize checks for guest fs freeze To: Fiona Ebner , pve-devel@lists.proxmox.com References: <20260324135325.120749-1-f.ebner@proxmox.com> <20260324135325.120749-8-f.ebner@proxmox.com> Content-Language: en-US From: Thomas Lamprecht In-Reply-To: <20260324135325.120749-8-f.ebner@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1774473341580 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.011 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. 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: P4Z362IBA3XNWOES7BR37DHVWT3VG7CE X-Message-ID-Hash: P4Z362IBA3XNWOES7BR37DHVWT3VG7CE X-MailFrom: t.lamprecht@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: Am 24.03.26 um 14:53 schrieb Fiona Ebner: > Puts the logic inside the agent module, rather than duplicating it in > three different places. > > Signed-off-by: Fiona Ebner > --- > src/PVE/QemuConfig.pm | 14 ++++------- > src/PVE/QemuServer/Agent.pm | 45 ++++++++++++++++++++++++++++++++++ > src/PVE/QemuServer/BlockJob.pm | 13 ++-------- > src/PVE/VZDump/QemuServer.pm | 21 ++++------------ > 4 files changed, 57 insertions(+), 36 deletions(-) > > diff --git a/src/PVE/QemuConfig.pm b/src/PVE/QemuConfig.pm > index 7656134b..240b8bfd 100644 > --- a/src/PVE/QemuConfig.pm > +++ b/src/PVE/QemuConfig.pm > @@ -292,18 +292,14 @@ sub __snapshot_check_running { > sub __snapshot_check_freeze_needed { > my ($class, $vmid, $config, $save_vmstate) = @_; > > + my $freeze_needed = 0; > my $running = $class->__snapshot_check_running($vmid); > + > if (!$save_vmstate) { > - return ( > - $running, > - $running > - && PVE::QemuServer::Agent::get_qga_key($config->{agent}, 'enabled') > - && PVE::QemuServer::Agent::qga_check_running($vmid) > - && (PVE::QemuServer::Agent::get_qga_key($config->{agent}, 'guest-fsfreeze') // 1), > - ); > - } else { > - return ($running, 0); > + $freeze_needed = PVE::QemuServer::Agent::guest_fsfreeze_applicable($config->{agent}, $vmid); > } > + > + return ($running, $freeze_needed); > } > > sub __snapshot_freeze { > diff --git a/src/PVE/QemuServer/Agent.pm b/src/PVE/QemuServer/Agent.pm > index 2c1f580d..12f9f9d5 100644 > --- a/src/PVE/QemuServer/Agent.pm > +++ b/src/PVE/QemuServer/Agent.pm > @@ -289,4 +289,49 @@ sub guest_fsthaw { > return; > } > > +=head3 guest_fsfreeze_applicable > + > + if (guest_fsfreeze_applicable($agent_str, $vmid, $logfunc, $is_backup)) { > + guest_fsfreeze($vmid); > + } > + > +Check if the file systems of the guest C<$vmid> should be frozen according to the guest agent > +property string C<$agent_str> and if freezing is actionable in practice, i.e. guest agent running. > +Logs a message if skipped. Using a custom log function via C<$logfunc> is supported. Otherwise, > +C and C will be used. In the context of backup tasks, C<$is_backup> must be > +specified. > + > +=cut > + > +sub guest_fsfreeze_applicable { > + my ($agent_str, $vmid, $logfunc, $is_backup) = @_; I'm a bit torn here, on one hand I can see where this comes from, but OTOH it also feels a bit overly opaque. Nicest gain here is probably the centralized log method, which I can see the benefits for. So probably fine to have... > + > + $logfunc //= sub { > + my ($level, $msg) = @_; > + chomp($msg); > + $level eq 'info' ? print("$msg\n") : warn("$msg\n"); There's a single use of a level other than 'info' in the next patch and the chomp feels superfluous considering this is a local closure and we fully control the messages and their trailing newlines here? And we probably should start to encourage use v5.36+signature migrations for (smaller) modules soonish, as then we would be able to use (untested): $logfunc //= sub ($msg, $level = 'info') { $level eq 'info' ? print("$msg\n") : warn("$msg\n"); } > + }; > + > + if (!get_qga_key($agent_str, 'enabled')) { > + $logfunc->('info', "skipping guest filesystem freeze - agent not configured in VM options"); > + return; > + } > + > + if (!qga_check_running($vmid, 1)) { > + $logfunc->('info', "skipping guest filesystem freeze - agent configured but not running?"); > + return; > + } > + > + my $freeze = get_qga_key($agent_str, 'guest-fsfreeze'); > + $freeze //= get_qga_key($agent_str, 'freeze-fs-on-backup') if $is_backup; $is_backup could be dropped when aliasing these to mean the same, if something akin to my series [0] gets applied. [0]: https://lore.proxmox.com/all/20260325210021.3789748-1-t.lamprecht@proxmox.com/T/#m837483e3ee5f17e5949485f11c7965367c716b03 > + $freeze //= 1; > + > + if (!$freeze) { > + $logfunc->('info', "skipping guest filesystem freeze - disabled in VM options"); > + return; > + } > + > + return 1; > +} > + > 1;