From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Fiona Ebner <f.ebner@proxmox.com>, pve-devel@lists.proxmox.com
Subject: Re: [PATCH qemu-server 7/8] agent: fsfreeze: harmonize checks for guest fs freeze
Date: Wed, 25 Mar 2026 22:16:29 +0100 [thread overview]
Message-ID: <4f9272f8-dbd1-4bf0-b027-7cbf35683e22@proxmox.com> (raw)
In-Reply-To: <20260324135325.120749-8-f.ebner@proxmox.com>
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 <f.ebner@proxmox.com>
> ---
> 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<print()> and C<warn()> 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;
next prev parent reply other threads:[~2026-03-25 21:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-24 13:50 [PATCH-SERIES qemu-server 0/8] fix #7383: agent: fsfreeze: skip freeze if already frozen Fiona Ebner
2026-03-24 13:50 ` [PATCH qemu-server 1/8] agent: fs thaw: check command result Fiona Ebner
2026-03-25 21:20 ` applied: " Thomas Lamprecht
2026-03-24 13:50 ` [PATCH qemu-server 2/8] api: clone/import: fix check if agent is enabled Fiona Ebner
2026-03-25 21:20 ` applied: " Thomas Lamprecht
2026-03-24 13:50 ` [PATCH qemu-server 3/8] backup: freeze: " Fiona Ebner
2026-03-25 21:20 ` applied: " Thomas Lamprecht
2026-03-24 13:50 ` [PATCH qemu-server 4/8] agent: parse: change signature to take property string rather than full VM config Fiona Ebner
2026-03-24 13:50 ` [PATCH qemu-server 5/8] agent: get qga key: " Fiona Ebner
2026-03-24 13:50 ` [PATCH qemu-server 6/8] clone disk/block jobs: change signatures to take guest agent property string Fiona Ebner
2026-03-24 13:50 ` [PATCH qemu-server 7/8] agent: fsfreeze: harmonize checks for guest fs freeze Fiona Ebner
2026-03-25 21:16 ` Thomas Lamprecht [this message]
2026-03-24 13:50 ` [PATCH qemu-server 8/8] fix #7383: agent: fsfreeze: skip freeze if already frozen Fiona Ebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4f9272f8-dbd1-4bf0-b027-7cbf35683e22@proxmox.com \
--to=t.lamprecht@proxmox.com \
--cc=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.