From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH qemu-server 1/4] agent: add should_fs_freeze helper
Date: Wed, 25 Mar 2026 21:49:15 +0100 [thread overview]
Message-ID: <20260325210021.3789748-2-t.lamprecht@proxmox.com> (raw)
In-Reply-To: <20260325210021.3789748-1-t.lamprecht@proxmox.com>
Add a centralized helper that checks whether guest filesystem
freeze/thaw should be attempted, combining the agent-enabled and
guest-fsfreeze setting checks. This replaces duplicated inline logic
and the scattered '// 1' default fallback across call sites.
No behavioral change intended, the helper returns the same result as
the previous inline expressions.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
src/PVE/API2/Qemu.pm | 10 ++++------
src/PVE/QemuConfig.pm | 5 ++---
src/PVE/QemuServer/Agent.pm | 15 +++++++++++++++
3 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm
index b409610c..020c68b2 100644
--- a/src/PVE/API2/Qemu.pm
+++ b/src/PVE/API2/Qemu.pm
@@ -374,8 +374,7 @@ my $import_from_volid = sub {
my ($src_storeid) = PVE::Storage::parse_volume_id($src_volid);
- my $qga = $src_conf->{agent}
- && (PVE::QemuServer::Agent::get_qga_key($src_conf, 'guest-fsfreeze') // 1);
+ my $fs_freeze = PVE::QemuServer::Agent::should_fs_freeze($src_conf);
return PVE::QemuServer::clone_disk(
$storecfg,
@@ -385,7 +384,7 @@ my $import_from_volid = sub {
$vollist,
undef,
undef,
- $qga,
+ $fs_freeze,
PVE::Storage::get_bandwidth_limit('clone', [$src_storeid, $dest_info->{storage}]),
);
};
@@ -4562,8 +4561,7 @@ __PACKAGE__->register_method({
$dest_info->{efisize} = PVE::QemuServer::get_efivars_size($oldconf)
if $opt eq 'efidisk0';
- my $qga = $oldconf->{agent}
- && (PVE::QemuServer::Agent::get_qga_key($oldconf, 'guest-fsfreeze') // 1);
+ my $fs_freeze = PVE::QemuServer::Agent::should_fs_freeze($oldconf);
my $newdrive = PVE::QemuServer::clone_disk(
$storecfg,
@@ -4573,7 +4571,7 @@ __PACKAGE__->register_method({
$newvollist,
$jobs,
$completion,
- $qga,
+ $fs_freeze,
$clonelimit,
);
diff --git a/src/PVE/QemuConfig.pm b/src/PVE/QemuConfig.pm
index 462d1d6d..839b6cd0 100644
--- a/src/PVE/QemuConfig.pm
+++ b/src/PVE/QemuConfig.pm
@@ -297,9 +297,8 @@ sub __snapshot_check_freeze_needed {
return (
$running,
$running
- && PVE::QemuServer::Agent::get_qga_key($config, 'enabled')
- && PVE::QemuServer::Agent::qga_check_running($vmid)
- && (PVE::QemuServer::Agent::get_qga_key($config, 'guest-fsfreeze') // 1),
+ && PVE::QemuServer::Agent::should_fs_freeze($config)
+ && PVE::QemuServer::Agent::qga_check_running($vmid),
);
} else {
return ($running, 0);
diff --git a/src/PVE/QemuServer/Agent.pm b/src/PVE/QemuServer/Agent.pm
index fb3e1835..4bc7cfa1 100644
--- a/src/PVE/QemuServer/Agent.pm
+++ b/src/PVE/QemuServer/Agent.pm
@@ -202,6 +202,21 @@ sub qemu_exec_status {
return $res;
}
+=head3 should_fs_freeze
+
+Returns whether guest filesystem freeze/thaw should be attempted based on the agent configuration.
+Does B<not> check whether the agent is actually running.
+
+=cut
+
+sub should_fs_freeze {
+ my ($conf) = @_;
+
+ my $agent = parse_guest_agent($conf);
+ return 0 if !$agent->{enabled};
+ return $agent->{'guest-fsfreeze'} // 1;
+}
+
=head3 guest_fsfreeze
guest_fsfreeze($vmid);
--
2.47.3
next prev parent reply other threads:[~2026-03-25 21:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-25 20:49 [PATCH qemu-server 0/4] rework fs-freeze agent property Thomas Lamprecht
2026-03-25 20:49 ` Thomas Lamprecht [this message]
2026-03-25 20:49 ` [PATCH qemu-server 2/4] agent: treat freeze-fs-on-backup as alias for guest-fsfreeze Thomas Lamprecht
2026-03-25 20:49 ` [PATCH qemu-server 3/4] tests: cfg2cmd: add agent guest-fsfreeze config tests Thomas Lamprecht
2026-03-25 20:49 ` [PATCH qemu-server 4/4] qga: rename guest-fsfreeze to freeze-fs Thomas Lamprecht
2026-03-25 21:35 ` superseded: [PATCH qemu-server 0/4] rework fs-freeze agent property Thomas Lamprecht
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=20260325210021.3789748-2-t.lamprecht@proxmox.com \
--to=t.lamprecht@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox