public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
	Matthieu Malvache <matthieu@ma2t.com>
Subject: Re: [pve-devel] [PATCH container 1/1] vnc: Allow custom timeout value in vncproxy method
Date: Fri, 3 Mar 2023 15:50:07 +0100	[thread overview]
Message-ID: <fae9059c-5c15-dca8-a140-a61170664fb3@proxmox.com> (raw)
In-Reply-To: <20230303111604.2043-2-matthieu@ma2t.com>

one additional comment inline:

On 3/3/23 12:16, Matthieu Malvache wrote:
> This commit adds support for a custom timeout value in the 'vncproxy'
> method of the Proxmox PVE REST API. The timeout can be specified using
> the 'timeout' parameter and defaults to 10 seconds if not set.
> 
> 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..4ca5842 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};

that has actually a bug ;)

the 'default' option in the parameter definition is not set anywhere, it's just
used for the documentation generation


to actually make it use the default of 10 you should do:

my $timeout = $param->{timeout} // 10;


this way it is set to 10 when the parameter is not set

>   
>   	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;
>   





      parent reply	other threads:[~2023-03-03 14:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-03 11:16 [pve-devel] [PATCH container 0/1] Add support for custom timeout " Matthieu Malvache
2023-03-03 11:16 ` [pve-devel] [PATCH container 1/1] vnc: Allow custom timeout value " Matthieu Malvache
2023-03-03 12:06   ` Matthias Heiserer
2023-03-03 13:43     ` Matthieu Malvache
2023-03-03 15:07       ` Matthias Heiserer
2023-03-03 14:50   ` Dominik Csapak [this message]

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=fae9059c-5c15-dca8-a140-a61170664fb3@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=matthieu@ma2t.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 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