public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Erik Fastermann <e.fastermann@proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Erik Fastermann <e.fastermann@proxmox.com>
Subject: [PATCH pve-guest-common] tunnel: websocket: prepend api token name when missing
Date: Thu, 18 Jun 2026 13:04:33 +0200	[thread overview]
Message-ID: <20260618110433.124789-1-e.fastermann@proxmox.com> (raw)

Ensure that the API token used in `fork_websocket_tunnel` is properly
prefixed with 'PVEAPIToken=' if it isn't already.

Previously, if a token was supplied without this explicit prefix,
initial API checks would pass successfully, but QEMU and LXC
migrations would abruptly fail midway with the error "server didn't
upgrade: 401 Unauthorized" when attempting to establish the websocket
tunnel. This inconsistency created a confusing user experience, as the
migration appeared to work fine initially.

The early API checks succeeded because `PVE::APIClient::LWP` already
automatically handles the missing prefix. This change brings the
websocket tunnel setup in line with that behavior, preventing mid-
migration failures when the prefix is omitted.

Signed-off-by: Erik Fastermann <e.fastermann@proxmox.com>
---
 src/PVE/Tunnel.pm | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/PVE/Tunnel.pm b/src/PVE/Tunnel.pm
index 791b465..10f2bd6 100644
--- a/src/PVE/Tunnel.pm
+++ b/src/PVE/Tunnel.pm
@@ -234,6 +234,9 @@ sub fork_websocket_tunnel {
     my ($conn, $url, $req_params, $tunnel_params, $log) = @_;
 
     if (my $apitoken = $conn->{apitoken}) {
+        if ($apitoken !~ /^\w+(?:=| )/) {
+            $apitoken = "PVEAPIToken=${apitoken}";
+        }
         $tunnel_params->{headers} = [["Authorization", "$apitoken"]];
     } else {
         die "can't connect to remote host without credentials\n";
-- 
2.47.3




                 reply	other threads:[~2026-06-18 11:05 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=20260618110433.124789-1-e.fastermann@proxmox.com \
    --to=e.fastermann@proxmox.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