[PATCH qemu-server v2 7/7] fix #7383: agent: fsfreeze: skip freeze if already frozen

Fiona Ebner
2026-04-23T12:40:39Z

This avoids the following error message about the command being
disallowed which can be hard to interpret for users:
> Command guest-fsfreeze-freeze has been disabled: the command is not allowed

It's disallowed, because the fs is already frozen, but the error
message does not indicate this. Instead avoid the error by skipping if
already frozen and log it if that is the case.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---

Changes in v2:
* Use subroutine signature.
* Adapt to log function change.

src/PVE/QemuServer/Agent.pm | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/src/PVE/QemuServer/Agent.pm b/src/PVE/QemuServer/Agent.pm
index c8cd334f..be6df443 100644
--- a/src/PVE/QemuServer/Agent.pm
+++ b/src/PVE/QemuServer/Agent.pm
@@ -276,6 +276,23 @@ sub guest_fs_thaw($vmid) {
return;
}

+=head3 guest_fs_is_frozen
+
+ if (guest_fs_is_frozen($vmid)) {
+ print "skipping guest fs freeze - already frozen\n";
+ }
+
+Check if the file systems of the guest C<$vmid> is currently frozen.
+
+=cut
+
+sub guest_fs_is_frozen($vmid) {
+ my $status = PVE::QemuServer::Monitor::mon_cmd($vmid, "guest-fsfreeze-status");
+ check_agent_error($status, "unable to check guest filesystem freeze status");
+
+ return $status eq 'frozen';
+}
+
=head3 guest_fs_freeze_applicable

if (guest_fs_freeze_applicable($agent_str, $vmid, $logfunc)) {
@@ -283,9 +300,9 @@ sub guest_fs_thaw($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.
+property string C<$agent_str> and if freezing is actionable in practice, i.e. guest agent running
+and file system not already frozen. Logs a message if skipped. Using a custom log function via
+C<$logfunc> is supported. Otherwise, C<print()> and C<warn()> will be used.

=cut

@@ -304,6 +321,14 @@ sub guest_fs_freeze_applicable($agent_str, $vmid, $logfunc = undef) {
return;
}

+ my $frozen = eval { PVE::QemuServer::Agent::guest_fs_is_frozen($vmid) };
+ $logfunc->("unable to check guest fs freeze status - $@", 'warn') if $@;
+
+ if ($frozen) {
+ $logfunc->("skipping guest filesystem freeze - already frozen");
+ return;
+ }
+
return 1;
}

--
2.47.3