all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Filip Schauer <f.schauer@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH container] fix #7667: prevent stale errno from breaking device passthrough
Date: Wed,  3 Jun 2026 14:36:01 +0200	[thread overview]
Message-ID: <20260603123603.109373-1-f.schauer@proxmox.com> (raw)

Since a successful stat() call does not reset $!, unconditionally
checking it afterward can cause a false error when $! was set earlier.

This causes device passthrough to always fail with "Device $path does
not exist" for privileged containers with an ostype that doesn't have a
matching config in /usr/share/lxc/config/<ostype>.common.conf.

Fix this by checking $! only when stat() actually fails. Also switch to
the $!{ENOENT} syntax, allowing the POSIX ENOENT import to be dropped.

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
---
 src/PVE/LXC/Tools.pm | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/PVE/LXC/Tools.pm b/src/PVE/LXC/Tools.pm
index 40dd270..ce2467e 100644
--- a/src/PVE/LXC/Tools.pm
+++ b/src/PVE/LXC/Tools.pm
@@ -4,7 +4,7 @@ package PVE::LXC::Tools;
 use strict;
 use warnings;
 
-use POSIX qw(ENOENT S_ISBLK S_ISCHR);
+use POSIX qw(S_ISBLK S_ISCHR);
 
 use PVE::SafeSyslog;
 
@@ -159,9 +159,8 @@ sub get_device_mode_and_rdev($) {
 
     die "Path is not defined\n" if !defined($path);
 
-    my ($mode, $rdev) = (stat($path))[2, 6];
-    die "Device $path does not exist\n" if $! == ENOENT;
-    die "Error accessing device $path\n" if !defined($mode) || !defined($rdev);
+    my ($mode, $rdev) = (stat($path))[2, 6]
+        or die($!{ENOENT} ? "Device $path does not exist\n" : "Error accessing device $path: $!\n");
     die "$path is not a device\n" if !S_ISBLK($mode) && !S_ISCHR($mode);
 
     return ($mode, $rdev);
-- 
2.47.3





                 reply	other threads:[~2026-06-03 12:36 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=20260603123603.109373-1-f.schauer@proxmox.com \
    --to=f.schauer@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal