nutanix / libvfio-user

framework for emulating devices in userspace
BSD 3-Clause "New" or "Revised" License
166 stars 51 forks source link

rework PCI capabilities #14

Closed tmakatos closed 4 years ago

tmakatos commented 4 years ago

Currently handling of standard PCI capabilities is left to the device implementation, however that shouldn't be the case as it's the same for all kinds of devices.

tmakatos commented 4 years ago

Ideally we'd like to have a flexible array member at the end of lm_dev_info_t for each capability, where each element of the array would be a union of all possible capability types. However I don't think this is possible as there can be vendor-specific capabillities of unknown size. Therefore the more realistic option would be to introduce a function e.g. lm_pci_cap_add that adds a capability to an existing context. @franciozzy thoughts?

tmakatos commented 4 years ago

Actually I think the current implementation can work, either way the user will be maintaining a pointer to their capability, so all we need to do is to replace the fn field with a buf field in lm_cap_t.

tmakatos commented 4 years ago

I'm looking at the PCI specification and I'm not sure how much of it we can handle in the library we need to go through the spec very thoroughly.

tmakatos commented 4 years ago

I've moved handling of PCI capabilities into MUSER in my vfio-over-socket branch. Capabilities are still maintained in a list which I think need to be replaced by keeping them in a buffer.

tmakatos commented 4 years ago

fixed in vfio-user branch