use PVE::Tools qw(file_read_firstline dir_glob_foreach);
my $pcisysfs = "/sys/bus/pci";
-my $pciregex = "([a-f0-9]{4}):([a-f0-9]{2}):([a-f0-9]{2})\.([a-f0-9])";
+my $pciregex = "([a-f0-9]{4,}):([a-f0-9]{2}):([a-f0-9]{2})\.([a-f0-9])";
my $parse_pci_ids = sub {
my $ids = {};
my ($id) = @_;
my $fullid = $id;
- if ($id !~ m/^[0-9a-fA-f]{4}:/) {
+ if ($id !~ m/^[0-9a-fA-f]{4,}:/) {
$fullid = "0000:$id";
}
}
die "Cannot find vfio-pci module!\n" if !-d $vfio_basedir;
- $pciid = "0000:$pciid" if $pciid !~ m/^[0-9a-f]{4}:/;
+ $pciid = "0000:$pciid" if $pciid !~ m/^[0-9a-f]{4,}:/;
# get IOMMU group devices
opendir(my $D, "$pcisysfs/devices/$pciid/iommu_group/devices/") || die "Cannot open iommu_group: $!\n";
- my @devs = grep /^[0-9a-f]{4}:/, readdir($D);
+ my @devs = grep /^[0-9a-f]{4,}:/, readdir($D);
closedir($D);
foreach my $pciid (@devs) {
sub pci_create_mdev_device {
my ($pciid, $uuid, $type) = @_;
- $pciid = "0000:$pciid" if $pciid !~ m/^[0-9a-f]{4}:/;
+ $pciid = "0000:$pciid" if $pciid !~ m/^[0-9a-f]{4,}:/;
my $basedir = "$pcisysfs/devices/$pciid";
my $mdev_dir = "$basedir/mdev_supported_types";
sub pci_cleanup_mdev_device {
my ($pciid, $uuid) = @_;
- $pciid = "0000:$pciid" if $pciid !~ m/^[0-9a-f]{4}:/;
+ $pciid = "0000:$pciid" if $pciid !~ m/^[0-9a-f]{4,}:/;
my $basedir = "$pcisysfs/devices/$pciid/$uuid";