mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
vfio: add device IO ops vector
For vfio-user, device operations such as IRQ handling and region read/writes are implemented in userspace over the control socket, not ioctl() to the vfio kernel driver; add an ops vector to generalize this, and implement vfio_device_io_ops_ioctl for interacting with the kernel vfio driver. Originally-by: John Johnson <john.g.johnson@oracle.com> Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com> Signed-off-by: Jagannathan Raman <jag.raman@oracle.com> Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Cédric Le Goater <clg@redhat.com> Link: https://lore.kernel.org/qemu-devel/20250507152020.1254632-11-john.levon@nutanix.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
parent
9458d9b4dc
commit
38bf025d0d
5 changed files with 114 additions and 27 deletions
|
@ -381,7 +381,7 @@ static void vfio_msi_interrupt(void *opaque)
|
|||
static int vfio_enable_msix_no_vec(VFIOPCIDevice *vdev)
|
||||
{
|
||||
g_autofree struct vfio_irq_set *irq_set = NULL;
|
||||
int ret = 0, argsz;
|
||||
int argsz;
|
||||
int32_t *fd;
|
||||
|
||||
argsz = sizeof(*irq_set) + sizeof(*fd);
|
||||
|
@ -396,9 +396,7 @@ static int vfio_enable_msix_no_vec(VFIOPCIDevice *vdev)
|
|||
fd = (int32_t *)&irq_set->data;
|
||||
*fd = -1;
|
||||
|
||||
ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_SET_IRQS, irq_set);
|
||||
|
||||
return ret < 0 ? -errno : ret;
|
||||
return vdev->vbasedev.io_ops->set_irqs(&vdev->vbasedev, irq_set);
|
||||
}
|
||||
|
||||
static int vfio_enable_vectors(VFIOPCIDevice *vdev, bool msix)
|
||||
|
@ -455,11 +453,11 @@ static int vfio_enable_vectors(VFIOPCIDevice *vdev, bool msix)
|
|||
fds[i] = fd;
|
||||
}
|
||||
|
||||
ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_SET_IRQS, irq_set);
|
||||
ret = vdev->vbasedev.io_ops->set_irqs(&vdev->vbasedev, irq_set);
|
||||
|
||||
g_free(irq_set);
|
||||
|
||||
return ret < 0 ? -errno : ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void vfio_add_kvm_msi_virq(VFIOPCIDevice *vdev, VFIOMSIVector *vector,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue