fix intel debug
This commit is contained in:
parent
ac007f5f38
commit
6f7c5bf545
@ -5,7 +5,7 @@ use warnings;
|
|||||||
use Exporter 'import';
|
use Exporter 'import';
|
||||||
|
|
||||||
use PVE::PVEMod::Config qw(%config $process_type $pve_mod_working_dir);
|
use PVE::PVEMod::Config qw(%config $process_type $pve_mod_working_dir);
|
||||||
use PVE::PVEMod::Utils qw(debug check_executable setup_collector_signals safe_read_json safe_write_json);
|
use PVE::PVEMod::Utils qw(debug check_executable setup_collector_signals safe_write_json);
|
||||||
use PVE::PVEMod::Store qw(update_intel_gpu_rrd);
|
use PVE::PVEMod::Store qw(update_intel_gpu_rrd);
|
||||||
|
|
||||||
our @EXPORT_OK = qw(
|
our @EXPORT_OK = qw(
|
||||||
@ -19,30 +19,28 @@ our @EXPORT_OK = qw(
|
|||||||
|
|
||||||
sub get_intel_gpu_devices {
|
sub get_intel_gpu_devices {
|
||||||
my @devices = ();
|
my @devices = ();
|
||||||
|
my $fh;
|
||||||
|
|
||||||
|
# Parse: "card0 Intel Alderlake_n (Gen12) pci:vendor=8086,device=46D0,card=0"
|
||||||
|
# or: "card0 Intel Alderlake_n (Gen12) pci:0000:00:02.0"
|
||||||
|
|
||||||
if ($config{debug}{intel_mode} && -f $config{debug}{intel_devices_file}) {
|
if ($config{debug}{intel_mode} && -f $config{debug}{intel_devices_file}) {
|
||||||
debug(__LINE__, "Debug mode: reading Intel GPU devices from $config{debug}{intel_devices_file}");
|
my $file = $config{debug}{intel_devices_file};
|
||||||
my $data = safe_read_json($config{debug}{intel_devices_file});
|
debug(__LINE__, "Debug mode: reading Intel GPU devices from $file");
|
||||||
if ($data && ref $data eq 'ARRAY') {
|
unless (open $fh, '<', $file) {
|
||||||
for my $dev (@$data) {
|
debug(__LINE__, "Failed to open debug file $file: $!");
|
||||||
push @devices, {
|
return @devices;
|
||||||
card => $dev->{card},
|
|
||||||
name => $dev->{name},
|
|
||||||
path => $dev->{path},
|
|
||||||
drm_path => $dev->{drm_path},
|
|
||||||
};
|
|
||||||
debug(__LINE__, "Found Intel device (debug): $dev->{card} -> $dev->{name} ($dev->{path})");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
debug(__LINE__, "Failed to parse debug file $config{debug}{intel_devices_file}");
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debug(__LINE__, "Getting Intel GPU devices");
|
debug(__LINE__, "Getting Intel GPU devices");
|
||||||
if (open my $fh, '-|', 'intel_gpu_top -L') {
|
unless (open $fh, '-|', 'intel_gpu_top -L') {
|
||||||
|
debug(__LINE__, "Failed to run intel_gpu_top -L: $!");
|
||||||
|
return @devices;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (<$fh>) {
|
while (<$fh>) {
|
||||||
chomp;
|
chomp;
|
||||||
# Parse: "card0 Intel Alderlake_n (Gen12) pci:vendor=8086,device=46D0,card=0"
|
|
||||||
# or: "card0 Intel Alderlake_n (Gen12) pci:0000:00:02.0"
|
|
||||||
if (/^(card\d+)\s+(.+?)\s+(pci:[^\s]+)/) {
|
if (/^(card\d+)\s+(.+?)\s+(pci:[^\s]+)/) {
|
||||||
my ($card, $name, $path) = ($1, $2, $3);
|
my ($card, $name, $path) = ($1, $2, $3);
|
||||||
push @devices, {
|
push @devices, {
|
||||||
@ -55,10 +53,6 @@ sub get_intel_gpu_devices {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
close $fh;
|
close $fh;
|
||||||
} else {
|
|
||||||
debug(__LINE__, "Failed to run intel_gpu_top -L: $!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return @devices;
|
return @devices;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user