* [PATCH container] fix #7667: prevent stale errno from breaking device passthrough
@ 2026-06-03 12:36 Filip Schauer
0 siblings, 0 replies; only message in thread
From: Filip Schauer @ 2026-06-03 12:36 UTC (permalink / raw)
To: pve-devel
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-06-03 12:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-03 12:36 [PATCH container] fix #7667: prevent stale errno from breaking device passthrough Filip Schauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox