diff options
author | swapnili <swapnil.ingle@nutanix.com> | 2020-12-10 12:50:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-10 12:50:54 +0100 |
commit | b40603643660299dd4ba0fd9521e282a0af98f81 (patch) | |
tree | f410cc58b448cbbb64d1f27dbd5ee06527c18b5f /lib | |
parent | becb165b321b66fa3465d0d4a6d74316044188b4 (diff) | |
download | libvfio-user-b40603643660299dd4ba0fd9521e282a0af98f81.zip libvfio-user-b40603643660299dd4ba0fd9521e282a0af98f81.tar.gz libvfio-user-b40603643660299dd4ba0fd9521e282a0af98f81.tar.bz2 |
Drop vfu_ctx_drive() and use vfu_ctx_poll() (#178)
* Drop vfu_ctx_drive() and use vfu_run_ctx()
Renamed vfu_ctx_poll() to vfu_run_ctx().
Updated vfu_run_ctx() to also handle blocking ctx.
Instead of having separate functions for blocking and
non-blocking ctx, better to have one.
This way user can call same set of functions for both cases.
Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libvfio-user.c | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c index 5e04794..082ac7c 100644 --- a/lib/libvfio-user.c +++ b/lib/libvfio-user.c @@ -1079,6 +1079,8 @@ process_request(vfu_ctx_t *vfu_ctx) return ret; } +UNIT_TEST_SYMBOL(process_request); +#define process_request __wrap_process_request int vfu_realize_ctx(vfu_ctx_t *vfu_ctx) @@ -1162,34 +1164,21 @@ vfu_realize_ctx(vfu_ctx_t *vfu_ctx) } int -vfu_ctx_drive(vfu_ctx_t *vfu_ctx) +vfu_run_ctx(vfu_ctx_t *vfu_ctx) { int err; + bool blocking; - if (vfu_ctx == NULL || !vfu_ctx->realized) { + assert(vfu_ctx != NULL); + + if (!vfu_ctx->realized) { return ERROR(EINVAL); } + blocking = !(vfu_ctx->flags & LIBVFIO_USER_FLAG_ATTACH_NB); do { err = process_request(vfu_ctx); - } while (err >= 0); - - return err; -} - -int -vfu_ctx_poll(vfu_ctx_t *vfu_ctx) -{ - int err; - - if (unlikely((vfu_ctx->flags & LIBVFIO_USER_FLAG_ATTACH_NB) == 0)) { - return -ENOTSUP; - } - - if (!vfu_ctx->realized) { - return ERROR(EINVAL); - } - err = process_request(vfu_ctx); + } while (err >= 0 && blocking); return err >= 0 ? 0 : err; } |