pci: device reservation: allow one to only free a subset of IDs

Add an optional parameter to the helper that removes PCI reservations
so that we can partially release IDs again. This will be necessary for
NVIDIAs new sysfs api

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Christoph Heiss <c.heiss@proxmox.com>
Reviewed-by: Christoph Heiss <c.heiss@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Dominik Csapak 2024-08-06 14:22:01 +02:00 committed by Thomas Lamprecht
parent fc23c72a42
commit d7fe48e9aa

View File

@ -719,11 +719,12 @@ my $write_pci_reservation_unlocked = sub {
# removes all PCI device reservations held by the `vmid`
sub remove_pci_reservation {
my ($vmid) = @_;
my ($vmid, $pciids) = @_;
PVE::Tools::lock_file($PCIID_RESERVATION_LOCK, 2, sub {
my $reservation_list = $parse_pci_reservation_unlocked->();
for my $id (keys %$reservation_list) {
next if defined($pciids) && !grep { $_ eq $id } $pciids->@*;
my $reservation = $reservation_list->{$id};
next if $reservation->{vmid} != $vmid;
delete $reservation_list->{$id};