From 207374c07b90e386462ca6c43405345b84723a8a Mon Sep 17 00:00:00 2001 From: Thanos Makatos Date: Wed, 2 Dec 2020 04:46:28 -0500 Subject: introduce device type Signed-off-by: Thanos Makatos --- lib/libvfio-user.c | 9 ++++++++- lib/private.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c index 964091c..30416a9 100644 --- a/lib/libvfio-user.c +++ b/lib/libvfio-user.c @@ -1278,7 +1278,8 @@ vfu_ctx_try_attach(vfu_ctx_t *vfu_ctx) } vfu_ctx_t * -vfu_create_ctx(vfu_trans_t trans, const char *path, int flags, void *pvt) +vfu_create_ctx(vfu_trans_t trans, const char *path, int flags, void *pvt, + vfu_dev_type_t dev_type) { vfu_ctx_t *vfu_ctx = NULL; int err = 0; @@ -1288,10 +1289,16 @@ vfu_create_ctx(vfu_trans_t trans, const char *path, int flags, void *pvt) return NULL; } + if (dev_type != VFU_DEV_TYPE_PCI) { + errno = EINVAL; + return NULL; + } + vfu_ctx = calloc(1, sizeof(vfu_ctx_t)); if (vfu_ctx == NULL) { return NULL; } + vfu_ctx->dev_type = dev_type; vfu_ctx->trans = &sock_transport_ops; //FIXME: Validate arguments. diff --git a/lib/private.h b/lib/private.h index a2fb3a7..335ceaa 100644 --- a/lib/private.h +++ b/lib/private.h @@ -129,6 +129,7 @@ struct vfu_ctx { uint32_t irq_count[VFU_DEV_NUM_IRQS]; vfu_irqs_t *irqs; int ready; + vfu_dev_type_t dev_type; }; int -- cgit v1.1