public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH v2 qemu-server 1/1] vnc: Allow custom timeout value in vncproxy method
@ 2023-03-03 18:48 Matthieu Malvache
  0 siblings, 0 replies; only message in thread
From: Matthieu Malvache @ 2023-03-03 18:48 UTC (permalink / raw)
  To: pve-devel

This commit adds support for a custom timeout value in the 'vncproxy'
method of the Proxmox PVE REST API. The timeout can now be specified 
using the 'timeout' parameter and defaults to 10 seconds if not set.

This will help users to better tailor the timeout based on factors
such as network latency.

The code change was implemented in the 'vncproxy' method of the
'PVE::API2::Qemu' package. The 'timeout' parameter was added to the
'parameters' section of the method and was used to set the timeout
duration in the 'realcmd' sub.

Signed-off-by: Matthieu Malvache <matthieu@ma2t.com>
---
 PVE/API2/Qemu.pm | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 587bb22..bb20273 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -2164,6 +2164,13 @@ __PACKAGE__->register_method({
 		default => 0,
 		description => "Generates a random password to be used as ticket instead of the API ticket.",
 	    },
+	    timeout => {
+		optional => 1,
+		type => 'integer',
+		minimum => 5,
+		default => 10,
+		description => "Timeout in seconds for the vnc proxy connection.",
+	    },
 	},
     },
     returns => {
@@ -2192,6 +2199,7 @@ __PACKAGE__->register_method({
 	my $vmid = $param->{vmid};
 	my $node = $param->{node};
 	my $websocket = $param->{websocket};
+	my $timeout = $param->{timeout} // 10;
 
 	my $conf = PVE::QemuConfig->load_config($vmid, $node); # check if VM exists
 
@@ -2226,8 +2234,6 @@ __PACKAGE__->register_method({
 
 	my $port = PVE::Tools::next_vnc_port($family);
 
-	my $timeout = 10;
-
 	my $realcmd = sub {
 	    my $upid = shift;
 
-- 
2.30.2




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

only message in thread, other threads:[~2023-03-03 18:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-03 18:48 [pve-devel] [PATCH v2 qemu-server 1/1] vnc: Allow custom timeout value in vncproxy method Matthieu Malvache

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal