From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id C448A1FF0B3 for ; Wed, 14 Oct 2026 15:58:01 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 7265B214FC; Wed, 14 Oct 2026 15:57:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1791917885; x=1792522685; darn=lists.proxmox.com; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=1G3oJoxsIzMB/OXXBJlMwuPjgKM/vzf8PZeNUgUfYkE=; b=PhtmQIAFML/7KYlqU+jyDsnwZCobQnBShUtjGuOuJI0kVoep9QzSBKIpM+ykl9V3xK 133v30Y0G2WOGPWYMIq8jQ8XPrIcGTOggkKHODEjun2u/DYS0YqJjLLhsVDU6ea+Qu4z jNPT74UHrU8K1/iqOUZla97A9zBphLQNEL0bCxqGC+jrXiKBC3nGradzcuNMEIBoMxap zkBmThg3HycqBqt9XsAz2L0O9oGGtzWkX8bxElyFd1eZkPeUHxoZgaueyAbORbI+Q/Bu 2qgIonWrH+sBKGg0m89XcZ+MmXhnOjRnfKlTHfgsshI/rFx4wcKG8jRvdRXyuDkDGSF8 llWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791917885; x=1792522685; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=1G3oJoxsIzMB/OXXBJlMwuPjgKM/vzf8PZeNUgUfYkE=; b=sxi4MpBQL6Rx8tub05BOMXEU1wb3jZSDpPplDULBppuXn2KhLl4JVeRu3YUIMm0llX rq8JQDKBWfDBFBeKxXu6Xu48y/9fihAbomEFVN/w6BL2y7/fOx1nzKBeHbyq8UKtK4eF ja3HzpXqUSbPb99znuVFvZODTrM+pRBdbsJWbvyQTsNRf5h+WLXryFfsK0IGhF9rgpKC pHkkujFxKFXYdLV1afrVp3GHteKMa5dQPNO+spmYTMI35d2i99gMMbbozpL5q4FC/CHc rQeKI84cIsZuACKKUkrShaUJN7Gbl+LEXsAtqlfclaT0rJF8ZZvGiH4REVGuIIXl9CCE UlSg== X-Gm-Message-State: AFq9FYJp2D9kscgv5GMp6z6dhz9OXMT+1gm1JTUnOdzJ4jOE7iCe23Qo TIJDXucErOnPXEiggtPvopRoRLHnkIVwFOL/Lpmh0Ab/iRU/TdQiXDVNSdRflftOL7I= X-Gm-Gg: AYBFou1cPI2fRwNTB1Jpw6s30DdRmu0u5T1QhNx0CC1KLFfHKD0vG9jOhxPwiDW7IQa BaA2mUEZ5YlVWTi4yYiWheBEO1E9qnUzmUjPmk9gbjaIFxxhZlkzwmaQ98WrcvoxZzQ1HH/MxYS ABcFjBBn4+7gcJtipAJl5OzE7YTXoL2qIC6TkPV0RygF3HLozIQQU0Vie+D1nzg3RGNkQ1Akxtf G2lEsdAkn6NH4SSnEvOJVDo/YCT3743aaPz0tE9j6nQTOZF03DOuuetBx9LS32qcQc0eI2bVawg tpwwtB5wTad1Ub0+mZkWLQCRPQ6kByz1+dbQ5ve35qtTv9j2jUSlKtbDqYAM4dw0oMRAyMA/e3I nxCsTNd0jc+UAcfM8h4LvODr1TuxhuPZFrtU0qoLseJITcroUMv7aBAPBJwap2jgv9jUtsicswB Og3STIdttUmpHKc4a/hPTSTLuRNfluNZGS5D3pAOv1gKGjIffh+464VJR8mMdadprEf6J7uXrCj dRF2SekvMWppSs97QQN/9yC+dLK0uuf5zvZLv1TIw== X-Received: by 2002:a17:907:3d4d:b0:c28:599b:7782 with SMTP id a640c23a62f3a-c31aa0120b4mr1238986666b.21.1791917885522; Tue, 13 Oct 2026 11:58:05 -0700 (PDT) From: =?UTF-8?q?Janusz=20Walu=C5=9B?= To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server] fix #2062: agent: add timeout parameter to guest cmd Date: Tue, 13 Oct 2026 20:57:54 +0200 Message-ID: <20261013185754.223502-1-janwalus@gmail.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_PASS -0.1 DMARC pass policy FREEMAIL_FROM 0.001 Sender email is commonly abused enduser mail provider RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record X-MailFrom: janwalus@gmail.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation Message-ID-Hash: 6FOXPEJMXCR657LS6H5UBQXQ2LJJAKHJ X-Message-ID-Hash: 6FOXPEJMXCR657LS6H5UBQXQ2LJJAKHJ X-Mailman-Approved-At: Wed, 14 Oct 2026 15:57:16 +0200 CC: =?UTF-8?q?Janusz=20Walu=C5=9B?= X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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Ċ› 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