all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH qemu-server] fix #2062: agent: add timeout parameter to guest cmd
@ 2026-10-13 18:57 Janusz Waluś
  0 siblings, 0 replies; only message in thread
From: Janusz Waluś @ 2026-10-13 18:57 UTC (permalink / raw)
  To: pve-devel; +Cc: Janusz Waluś

This adds timeout parameter to QGA commands, allowing override of the hardcoded 3-second limit.
Timeout applies for initial checking if QGA is working as well as the actual command.
This resolves timeout false positives in environments with high I/O load.

Suggested-by: Tim Marx
Signed-off-by: Janusz Waluś <janwalus@gmail.com>
Buglink: https://bugzilla.proxmox.com/show_bug.cgi?id=2062
---
 src/PVE/API2/Qemu/Agent.pm  | 18 +++++++++++++++---
 src/PVE/QemuServer/Agent.pm |  8 ++++----
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/PVE/API2/Qemu/Agent.pm b/src/PVE/API2/Qemu/Agent.pm
index f826fc27..7fbc2791 100644
--- a/src/PVE/API2/Qemu/Agent.pm
+++ b/src/PVE/API2/Qemu/Agent.pm
@@ -201,6 +201,14 @@ sub register_command {
                 description => "The QGA command.",
                 enum => [sort keys %$guest_agent_commands],
             },
+            timeout => {
+                type => 'integer',
+                description =>
+                    "Timeout for the command in seconds. If not specified, the default"
+                        . " timeout for each command is used.",
+                minimum => 1,
+                optional => 1,
+            },
         },
     };
 
@@ -233,10 +241,14 @@ sub register_command {
 
             my $conf = PVE::QemuConfig->load_config($vmid); # check if VM exists
 
-            PVE::QemuServer::Agent::assert_agent_available($vmid, $conf);
-
             my $cmd = $param->{command} // $command;
-            my $res = mon_cmd($vmid, "guest-$cmd");
+            my $timeout = $param->{timeout} // 3;
+            PVE::QemuServer::Agent::assert_agent_available($vmid, $conf, $timeout);
+
+            my %cmd_params;
+            $cmd_params{timeout} = $param->{timeout} if defined($param->{timeout});
+
+            my $res = mon_cmd($vmid, "guest-$cmd", %cmd_params);
 
             return { result => $res };
         },
diff --git a/src/PVE/QemuServer/Agent.pm b/src/PVE/QemuServer/Agent.pm
index be6df443..08288d00 100644
--- a/src/PVE/QemuServer/Agent.pm
+++ b/src/PVE/QemuServer/Agent.pm
@@ -79,8 +79,8 @@ sub get_qga_key($conf, $key) {
     return $agent->{$key};
 }
 
-sub qga_check_running($vmid, $nowarn = 0) {
-    eval { PVE::QemuServer::Monitor::mon_cmd($vmid, "guest-ping", timeout => 3); };
+sub qga_check_running($vmid, $nowarn = 0, $timeout = 3) {
+    eval { PVE::QemuServer::Monitor::mon_cmd($vmid, "guest-ping", timeout => $timeout); };
     if ($@) {
         warn "QEMU Guest Agent is not running - $@" if !$nowarn;
         return 0;
@@ -106,10 +106,10 @@ sub check_agent_error($result, $errmsg, $noerr = 0) {
     return 1;
 }
 
-sub assert_agent_available($vmid, $conf) {
+sub assert_agent_available($vmid, $conf, $timeout = 3) {
     die "No QEMU guest agent configured\n" if !defined($conf->{agent});
     die "VM $vmid is not running\n" if !PVE::QemuServer::Helpers::vm_running_locally($vmid);
-    die "QEMU guest agent is not running\n" if !qga_check_running($vmid, 1);
+    die "QEMU guest agent is not running\n" if !qga_check_running($vmid, 1, $timeout);
 }
 
 # loads config, checks if available, executes command, checks for errors
-- 
Hi everyone,

This is my first patch to Proxmox project. Please let me know if any adjustments are needed regarding code and submittion process itself.

Best regards,
Janusz




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-14 13:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-13 18:57 [PATCH qemu-server] fix #2062: agent: add timeout parameter to guest cmd Janusz Waluś

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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal