[PATCH qemu-server v2 3/7] agent: parse: change signature to take property string rather than full VM config

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

Better encapsulation and in preparation to harmonize checks for freeze
while avoiding the need to pass the full config to block jobs.

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

Changes in v2:
* Also adapt new should_fs_freeze() caller.

src/PVE/QemuServer.pm | 6 +++---
src/PVE/QemuServer/Agent.pm | 10 +++++-----
2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 2a469fff..ec311160 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -3426,7 +3426,7 @@ sub config_to_command {

push @$cmd, '-k', $conf->{keyboard} if defined($conf->{keyboard});

- my $guest_agent = parse_guest_agent($conf);
+ my $guest_agent = parse_guest_agent($conf->{agent});

if ($guest_agent->{enabled}) {
my $qgasocket = PVE::QemuServer::Helpers::qmp_socket(
@@ -5163,8 +5163,8 @@ sub vmconfig_update_agent {

my $hotplug_options = { fstrim_cloned_disks => 1 };

- my $old_agent = parse_guest_agent($conf);
- my $agent = parse_guest_agent({ $opt => $value });
+ my $old_agent = parse_guest_agent($conf->{agent});
+ my $agent = parse_guest_agent($value);

for my $option (keys %$agent) { # added/changed options
next if defined($hotplug_options->{$option});
diff --git a/src/PVE/QemuServer/Agent.pm b/src/PVE/QemuServer/Agent.pm
index a68dd8d7..8b814edd 100644
--- a/src/PVE/QemuServer/Agent.pm
+++ b/src/PVE/QemuServer/Agent.pm
@@ -61,10 +61,10 @@ our $agent_fmt = {
},
};

-sub parse_guest_agent($conf) {
- return {} if !defined($conf->{agent});
+sub parse_guest_agent($value) {
+ return {} if !defined($value);

- my $res = eval { PVE::JSONSchema::parse_property_string($agent_fmt, $conf->{agent}) };
+ my $res = eval { PVE::JSONSchema::parse_property_string($agent_fmt, $value) };
warn $@ if $@;

# if the agent is disabled ignore the other potentially set properties
@@ -75,7 +75,7 @@ sub parse_guest_agent($conf) {
sub get_qga_key($conf, $key) {
return undef if !defined($conf->{agent});

- my $agent = parse_guest_agent($conf);
+ my $agent = parse_guest_agent($conf->{agent});
return $agent->{$key};
}

@@ -188,7 +188,7 @@ Does B<not> check whether the agent is actually running.
=cut

sub should_fs_freeze($conf) {
- my $agent = parse_guest_agent($conf);
+ my $agent = parse_guest_agent($conf->{agent});
return 0 if !$agent->{enabled};