diff options
author | Thanos Makatos <thanos.makatos@nutanix.com> | 2020-12-16 12:16:45 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-16 12:16:45 +0000 |
commit | 545a268510c270ec537134f8050fe7ec5a1f0f51 (patch) | |
tree | 30ba271b10a43dc8ebacfd6405bcd0c1f7531850 | |
parent | 0502943fb1ce6f24aff1f3086e55f7ceff86bd68 (diff) | |
download | libvfio-user-545a268510c270ec537134f8050fe7ec5a1f0f51.zip libvfio-user-545a268510c270ec537134f8050fe7ec5a1f0f51.tar.gz libvfio-user-545a268510c270ec537134f8050fe7ec5a1f0f51.tar.bz2 |
enable ERR and REQ IRQs by default (#209)
enable ERR and REQ IRQs by default
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
Reviewed-by: John Levon <john.levon@nutanix.com>
-rw-r--r-- | include/libvfio-user.h | 3 | ||||
-rw-r--r-- | lib/libvfio-user.c | 9 | ||||
-rw-r--r-- | test/unit-tests.c | 2 |
3 files changed, 13 insertions, 1 deletions
diff --git a/include/libvfio-user.h b/include/libvfio-user.h index d5a8c6a..1a336374 100644 --- a/include/libvfio-user.h +++ b/include/libvfio-user.h @@ -88,7 +88,8 @@ typedef enum { } vfu_dev_type_t; /** - * Creates libvfio-user context. + * Creates libvfio-user context. By default one ERR and one REQ IRQs are + * initialized, this can be overridden with vfu_setup_device_nr_irqs. * * @trans: transport type * @path: path to socket file. diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c index c5cd3c3..87ecbfa 100644 --- a/lib/libvfio-user.c +++ b/lib/libvfio-user.c @@ -1349,6 +1349,15 @@ vfu_create_ctx(vfu_trans_t trans, const char *path, int flags, void *pvt, goto out; } + if (vfu_setup_device_nr_irqs(vfu_ctx, VFU_DEV_ERR_IRQ, 1) == -1) { + err = -errno; + goto out; + } + if (vfu_setup_device_nr_irqs(vfu_ctx, VFU_DEV_REQ_IRQ, 1) == -1) { + err = -errno; + goto out; + } + if (vfu_ctx->trans->init != NULL) { err = vfu_ctx->trans->init(vfu_ctx); if (err < 0) { diff --git a/test/unit-tests.c b/test/unit-tests.c index 7de11ac..a983f3d 100644 --- a/test/unit-tests.c +++ b/test/unit-tests.c @@ -525,6 +525,8 @@ test_vfu_ctx_create(void **state __attribute__((unused))) vfu_ctx = vfu_create_ctx(VFU_TRANS_SOCK, "", LIBVFIO_USER_FLAG_ATTACH_NB, NULL, VFU_DEV_TYPE_PCI); assert_non_null(vfu_ctx); + assert_int_equal(1, vfu_ctx->irq_count[VFU_DEV_ERR_IRQ]); + assert_int_equal(1, vfu_ctx->irq_count[VFU_DEV_REQ_IRQ]); assert_int_equal(0, vfu_pci_setup_config_hdr(vfu_ctx, id, ss, cc, VFU_PCI_TYPE_CONVENTIONAL, 0)); |