[dpdk-dev] [PATCH v3 4/4] vfio: enable vfio hotplug by req notifier handler
Jeff Guo
jia.guo at intel.com
Thu Oct 4 07:05:30 CEST 2018
On 10/2/2018 10:15 PM, Burakov, Anatoly wrote:
> On 02-Oct-18 1:58 PM, Jeff Guo wrote:
>> When device is be hot-unplugged, the vfio kernel module will sent req
>> notifier to request user space to release the allocated resources at
>> first. After that, vfio kernel module will detect the device disappear,
>> and then delete the device in kernel.
>>
>> This patch aim to add req notifier processing to enable hotplug for
>> vfio.
>> By enable the req notifier monitoring and register the notifier
>> callback,
>> when device be hot-unplugged, the hot-unplug handler will be called to
>> process hotplug for vfio.
>>
>> Signed-off-by: Jeff Guo <jia.guo at intel.com>
>> ---
>> v3->v2:
>> change some code style and typo.
>> ---
>
> <snip>
>
>> +/* enable notifier (only enable req now) */
>> +static int
>> +pci_vfio_enable_notifier(struct rte_pci_device *dev, int vfio_dev_fd)
>> +{
>> + int ret;
>> + int fd = -1;
>> +
>> + /* set up an eventfd for req notifier */
>> + fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
>> + if (fd < 0) {
>> + RTE_LOG(ERR, EAL, "Cannot set up eventfd, error %i (%s)\n",
>> + errno, strerror(errno));
>> + return -1;
>> + }
>> +
>> + dev->req_notifier_handler.fd = fd;
>> + dev->req_notifier_handler.type = RTE_INTR_HANDLE_VFIO_REQ;
>> + dev->req_notifier_handler.vfio_dev_fd = vfio_dev_fd;
>> + ret = rte_intr_callback_register(&dev->req_notifier_handler,
>> + pci_vfio_req_handler,
>> + (void *)&dev->device);
>> + if (ret) {
>> + RTE_LOG(ERR, EAL, "Fail to register req notifier handler.\n");
>> + goto error;
>
> At this point (and further down as well), if we go to error, we've
> already modified the req_notifier_handler data. Do we need to
> overwrite it? Maybe just do these operations on a local struct, and
> then do a memcpy into dev->req_notifier_handler on success?
>
I think just overwrite it in error process should be clear and simple.
More information about the dev
mailing list