From: "Janusz Waluś" <janwalus@gmail.com>
To: pve-devel@lists.proxmox.com
Cc: "Janusz Waluś" <janwalus@gmail.com>
Subject: [PATCH qemu-server] fix #2062: agent: add timeout parameter to guest cmd
Date: Tue, 13 Oct 2026 20:57:54 +0200 [thread overview]
Message-ID: <20261013185754.223502-1-janwalus@gmail.com> (raw)
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
reply other threads:[~2026-10-14 13:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261013185754.223502-1-janwalus@gmail.com \
--to=janwalus@gmail.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.