diff options
author | John Levon <john.levon@nutanix.com> | 2021-04-15 10:42:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-15 10:42:07 +0100 |
commit | f7e9ff4496cc53caf8217b6210e29628ec60561d (patch) | |
tree | c3f652ca18b02bde8bfae80c62f386f70ed880bf /lib/libvfio-user.c | |
parent | 2e50c5667ce8724b0b7963255d3016efbb1f568a (diff) | |
download | libvfio-user-f7e9ff4496cc53caf8217b6210e29628ec60561d.zip libvfio-user-f7e9ff4496cc53caf8217b6210e29628ec60561d.tar.gz libvfio-user-f7e9ff4496cc53caf8217b6210e29628ec60561d.tar.bz2 |
vfu_ctx_create(): validate flags argument (#442)
In addition, return ENOTSUP for unknown device types, and add some unit tests.
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.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c index e6b79f2..03ef6da 100644 --- a/lib/libvfio-user.c +++ b/lib/libvfio-user.c @@ -1187,14 +1187,16 @@ vfu_create_ctx(vfu_trans_t trans, const char *path, int flags, void *pvt, int err = 0; size_t i; - //FIXME: Validate arguments. + if ((flags & ~(LIBVFIO_USER_FLAG_ATTACH_NB)) != 0) { + return ERROR_PTR(EINVAL); + } if (trans != VFU_TRANS_SOCK) { return ERROR_PTR(ENOTSUP); } if (dev_type != VFU_DEV_TYPE_PCI) { - return ERROR_PTR(EINVAL); + return ERROR_PTR(ENOTSUP); } vfu_ctx = calloc(1, sizeof(vfu_ctx_t)); |