From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 168071FF0AB for ; Wed, 07 Oct 2026 10:37:45 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id A5081213BC; Wed, 07 Oct 2026 10:37:41 +0200 (CEST) From: Elias Huhsovitz To: pve-devel@lists.proxmox.com Subject: [PATCH container/manager 0/2] fix #8093: console: bind console sessions to container lifetime via systemd scopes Date: Wed, 7 Oct 2026 10:37:24 +0200 Message-ID: <20261007083726.26067-1-e.huhsovitz@proxmox.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-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1791362257267 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.547 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: FLHMOSDWZ27OYMVDT3TXU5BH6UX52RY7 X-Message-ID-Hash: FLHMOSDWZ27OYMVDT3TXU5BH6UX52RY7 X-MailFrom: e.huhsovitz@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Elias Huhsovitz X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The current Problem ------------------- Console session processes can outlive their container when it stops or is destroyed. The cleanup currently runs in pvestatd every 10 seconds. It calls vmstatus() and kills stale processes by PID. The killing of the process can result in a race condition: If the console gets closed by something else, just before the kill command is executed, a different process can reuse the PID and we kill a completely unrelated process. Also checking this every 10s is too much unnecessary overhead IMO. My understanding of a "better" architecture ------------------------------------------- IMO console deletion should be tied to the state of the underlying container. Also I was unable to find a "convenient" time/event for a cleanup job to run. Proposed implementation ----------------------- Wrap console commands in transient systemd scopes and bind them to the container service via the PartOf= property. When the container stops, systemd stops the scope, terminating the console session and the dtach session. This allows removing the pvestatd periodic cleanup entirely. Summary of Changes ------------------ pve-manager: Elias Huhsovitz (1): fix #8093: pvestatd: remove cleanup of stale lxc consoles PVE/Service/pvestatd.pm | 18 ------------------ 1 file changed, 18 deletions(-) pve-container: Elias Huhsovitz (1): fix #8093: console: bind console sessions to container lifetime via systemd scopes src/PVE/API2/LXC.pm | 6 +++--- src/PVE/CLI/pct.pm | 10 +++++++--- src/PVE/LXC.pm | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 6 deletions(-) Summary over all repositories: 4 files changed, 51 insertions(+), 24 deletions(-) -- Generated by murpp 0.12.0