From d7fe48e9aa79311248201f62c59e0d76bd3a74e3 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Tue, 6 Aug 2024 14:22:01 +0200 Subject: [PATCH] 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 Tested-by: Christoph Heiss Reviewed-by: Christoph Heiss Signed-off-by: Thomas Lamprecht --- PVE/QemuServer/PCI.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PVE/QemuServer/PCI.pm b/PVE/QemuServer/PCI.pm index 3aa260d6..ae24980a 100644 --- a/PVE/QemuServer/PCI.pm +++ b/PVE/QemuServer/PCI.pm @@ -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};