aboutsummaryrefslogtreecommitdiff
path: root/lib/libvfio-user.c
diff options
context:
space:
mode:
authorJohn Levon <john.levon@nutanix.com>2021-03-10 10:37:59 +0000
committerGitHub <noreply@github.com>2021-03-10 10:37:59 +0000
commit052d709d0cfd77c36f5b31402c3cc1c3d868d618 (patch)
tree29f6fbba5fa94e80e7c53bbc2fdde474ae16a1b0 /lib/libvfio-user.c
parent997536eee6609827b5053afef497f94bc6f6dbf4 (diff)
downloadlibvfio-user-052d709d0cfd77c36f5b31402c3cc1c3d868d618.zip
libvfio-user-052d709d0cfd77c36f5b31402c3cc1c3d868d618.tar.gz
libvfio-user-052d709d0cfd77c36f5b31402c3cc1c3d868d618.tar.bz2
fix IRQ disable path (#386)
Properly fix IRQ disabling: Allow count == 0 to mean "disable all IRQS of the given type". On our side, disabling an IRQ means forgetting about the eventfd that was previously passed over the socket. Allow individual IRQs to be disabled, by means of a VFIO_IRQ_SET_DATA_EVENTFD message with no file descriptors passed. In vfio, this is done via setting "-1" in the fd slots; which isn't possible via auxiliary data. Thus, only one IRQ can be disabled a a time in vfio-user. Clean up "->type": this is never set, so wasn't having any effect. Follow up changes will likely re-introduce this in some form. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'lib/libvfio-user.c')
-rw-r--r--lib/libvfio-user.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c
index 77c9f0c..8df125f 100644
--- a/lib/libvfio-user.c
+++ b/lib/libvfio-user.c
@@ -1037,7 +1037,7 @@ vfu_realize_ctx(vfu_ctx_t *vfu_ctx)
}
}
- //FIXME: assert(max_ivs > 0)?
+ // FIXME: assert(max_ivs > 0)?
size = sizeof(int) * max_ivs;
vfu_ctx->irqs = calloc(1, sizeof(vfu_irqs_t) + size);
if (vfu_ctx->irqs == NULL) {
@@ -1051,7 +1051,6 @@ vfu_realize_ctx(vfu_ctx_t *vfu_ctx)
}
vfu_ctx->irqs->err_efd = -1;
vfu_ctx->irqs->req_efd = -1;
- vfu_ctx->irqs->type = IRQ_NONE;
vfu_ctx->irqs->max_ivs = max_ivs;
// Reflect on the config space whether INTX is available.
@@ -1423,10 +1422,8 @@ vfu_setup_device_nr_irqs(vfu_ctx_t *vfu_ctx, enum vfu_dev_irq_type type,
assert(vfu_ctx != NULL);
- if (type < VFU_DEV_INTX_IRQ || type > VFU_DEV_REQ_IRQ) {
- vfu_log(vfu_ctx, LOG_ERR, "Invalid IRQ index %d, should be between "
- "(%d to %d)", type, VFU_DEV_INTX_IRQ,
- VFU_DEV_REQ_IRQ);
+ if (type >= VFU_DEV_NUM_IRQS) {
+ vfu_log(vfu_ctx, LOG_ERR, "Invalid IRQ type index %u", type);
return ERROR_INT(EINVAL);
}