]> git.proxmox.com Git - qemu-server.git/commit
enable cluster mapped PCI devices for guests
authorDominik Csapak <d.csapak@proxmox.com>
Fri, 16 Jun 2023 13:05:23 +0000 (15:05 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 16 Jun 2023 14:24:02 +0000 (16:24 +0200)
commit9b71c34d61f5473f48050f165e126fb3afe55351
tree491fc2f699105ed9f3eef51d971ba534db5649bd
parente3971865b4735a855123d563bf261954be8f529a
enable cluster mapped PCI devices for guests

this patch allows configuring pci devices that are mapped via cluster
resource mapping when the user has 'Resource.Use' on the ACL path
'/mapping/pci/{ID}' (in  addition to the usual required vm config
privileges)

When given multiple mappings in the config, we use them as alternatives
for the passthrough, and will select the first free one on startup.
It is using our regular pci reservation mechanism for regular devices and
we introduce a selection mechanism for mediated devices.

A few changes to the inner workings were required to make this work well:
* parse_hostpci now returns a different structure where we have a list
  of lists (first level is for the different alternatives and second
  level is for the different devices that should be passed through
  together)
* factor out the 'parse_hostpci_devices' which parses each device from
  the config and does some precondition checks
* reserve_pci_usage now behaves slightly different when trying to
  reserve an device with the same VMID that's already reserved for,
  since for checking which alternative we can use, we already must
  reserve one (this means that qm showcmd can actually reserve devices,
  albeit only for up to 10 seconds)
* configuring a mediated device on a multifunction device is not
  supported anymore, and results in failure to start (previously, it
  just chose the first device to do it). This is a breaking change
* configuring a single pci device twice on different hostpci slots now
  fails during commandline generation instead on qemu start, so we had
  to adapt one test where this occurred (it could never have worked
  anyway)
* we now check permissions during clone/restore, meaning raw/real
  devices can only be cloned/restored by root@pam from now on.
  this is a breaking change.

Fixes #3574: Improve SR-IOV usability
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-By:  Markus Frank <m.frank@proxmox.com>
PVE/API2/Qemu.pm
PVE/QemuServer.pm
PVE/QemuServer/PCI.pm
test/cfg2cmd/q35-linux-hostpci.conf
test/cfg2cmd/q35-linux-hostpci.conf.cmd
test/run_config2command_tests.pl