On Thu, 13 Aug 2020 19:29:57 +0200 Philippe Mathieu-Daudé <phi...@redhat.com> wrote:
> Now that our helper is ready for handling multiple IRQs, let > qemu_vfio_open_pci() take an 'irq_count' argument. > > Signed-off-by: Philippe Mathieu-Daudé <phi...@redhat.com> > --- As with patch 2/ tying IRQ setup with the opening of a device seems wrong. Get the device open, then create an interface to configure the interrupt. Thanks, Alex > include/qemu/vfio-helpers.h | 2 +- > block/nvme.c | 5 ++++- > util/vfio-helpers.c | 4 ++-- > 3 files changed, 7 insertions(+), 4 deletions(-) > > diff --git a/include/qemu/vfio-helpers.h b/include/qemu/vfio-helpers.h > index 5c2d8ee5b3..4773b116df 100644 > --- a/include/qemu/vfio-helpers.h > +++ b/include/qemu/vfio-helpers.h > @@ -16,7 +16,7 @@ > typedef struct QEMUVFIOState QEMUVFIOState; > > QEMUVFIOState *qemu_vfio_open_pci(const char *device, int irq_type, > - Error **errp); > + unsigned irq_count, Error **errp); > void qemu_vfio_close(QEMUVFIOState *s); > int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, > bool temporary, uint64_t *iova_list); > diff --git a/block/nvme.c b/block/nvme.c > index a5ef571492..2d7aac3903 100644 > --- a/block/nvme.c > +++ b/block/nvme.c > @@ -106,6 +106,9 @@ QEMU_BUILD_BUG_ON(offsetof(NVMeRegs, doorbells) != > 0x1000); > #define INDEX_ADMIN 0 > #define INDEX_IO(n) (1 + n) > > +/* This driver shares a single MSIX IRQ for the admin and I/O queues */ > +#define MSIX_IRQ_COUNT 1 > + > struct BDRVNVMeState { > AioContext *aio_context; > QEMUVFIOState *vfio; > @@ -712,7 +715,7 @@ static int nvme_init(BlockDriverState *bs, const char > *device, int namespace, > } > > s->vfio = qemu_vfio_open_pci(device, VFIO_PCI_MSIX_IRQ_INDEX, > - errp); > + MSIX_IRQ_COUNT, errp); > if (!s->vfio) { > ret = -EINVAL; > goto out; > diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c > index 7a934d1a1b..36fafef0d3 100644 > --- a/util/vfio-helpers.c > +++ b/util/vfio-helpers.c > @@ -450,12 +450,12 @@ static void qemu_vfio_open_common(QEMUVFIOState *s) > * Open a PCI device, e.g. "0000:00:01.0". > */ > QEMUVFIOState *qemu_vfio_open_pci(const char *device, int irq_type, > - Error **errp) > + unsigned irq_count, Error **errp) > { > int r; > QEMUVFIOState *s = g_new0(QEMUVFIOState, 1); > > - r = qemu_vfio_init_pci(s, device, irq_type, 1, errp); > + r = qemu_vfio_init_pci(s, device, irq_type, irq_count, errp); > if (r) { > g_free(s); > return NULL;