]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/SysFSTools.pm
bump version to 8.2.1
[pve-common.git] / src / PVE / SysFSTools.pm
index 4038eed83dbf7501d58dc43310ef68c302791f62..57f0ac832b41ce15f7043ec2f7322e8337115620 100644 (file)
@@ -34,11 +34,9 @@ my $parse_pci_ids = sub {
     return $ids;
 };
 
-my $fixup_missing_domain = sub {
+my sub normalize_pci_id {
     my ($id) = @_;
-
     $id = "0000:$id" if $id !~ m/^${domainregex}:/;
-
     return $id;
 };
 
@@ -157,7 +155,7 @@ sub lspci {
 sub get_mdev_types {
     my ($id) = @_;
 
-    $id = $fixup_missing_domain->($id);
+    $id = normalize_pci_id($id);
 
     my $types = [];
 
@@ -174,11 +172,16 @@ sub get_mdev_types {
        my $available = int(file_read_firstline("$type_path/available_instances"));
        my $description = PVE::Tools::file_get_contents("$type_path/description");
 
-       push @$types, {
+       my $entry = {
            type => $type,
            description => $description,
            available => $available,
        };
+
+       my $name = file_read_firstline("$type_path/name");
+       $entry->{name} = $name if defined($name);
+
+       push @$types, $entry;
     });
 
     return $types;
@@ -306,7 +309,7 @@ sub pci_dev_group_bind_to_vfio {
     }
     die "Cannot find vfio-pci module!\n" if !-d $vfio_basedir;
 
-    $pciid = $fixup_missing_domain->($pciid);
+    $pciid = normalize_pci_id($pciid);
 
     # get IOMMU group devices
     opendir(my $D, "$pcisysfs/devices/$pciid/iommu_group/devices/") || die "Cannot open iommu_group: $!\n";
@@ -329,7 +332,7 @@ sub pci_dev_group_bind_to_vfio {
 sub pci_create_mdev_device {
     my ($pciid, $uuid, $type) = @_;
 
-    $pciid = $fixup_missing_domain->($pciid);
+    $pciid = normalize_pci_id($pciid);
 
     my $basedir = "$pcisysfs/devices/$pciid";
     my $mdev_dir = "$basedir/mdev_supported_types";
@@ -363,20 +366,6 @@ sub pci_create_mdev_device {
     return undef;
 }
 
-sub pci_cleanup_mdev_device {
-    my ($pciid, $uuid) = @_;
-
-    $pciid = $fixup_missing_domain->($pciid);
-
-    my $basedir = "$pcisysfs/devices/$pciid/$uuid";
-
-    if (! -e $basedir) {
-       return 1; # no cleanup necessary if it does not exist
-    }
-
-    return file_write("$basedir/remove", "1");
-}
-
 # encode the hostpci index and vmid into the uuid
 sub generate_mdev_uuid {
     my ($vmid, $index) = @_;