diff options
author | John Levon <john.levon@nutanix.com> | 2021-02-10 18:26:53 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-10 18:26:53 +0000 |
commit | cf449d6290ddd723a23f0451d0ce18ffc6099e15 (patch) | |
tree | bb59c4564609839ca6281582035068a6ea92ff92 /include | |
parent | aa2157aad1876c3963efe34c694c93eadd309c97 (diff) | |
download | libvfio-user-cf449d6290ddd723a23f0451d0ce18ffc6099e15.zip libvfio-user-cf449d6290ddd723a23f0451d0ce18ffc6099e15.tar.gz libvfio-user-cf449d6290ddd723a23f0451d0ce18ffc6099e15.tar.bz2 |
don't expose -errno in public API (#327)
Regardless of what we do internally, most of our API uses standard mechanisms
for reporting errors. Fix vfu_run_ctx() to do so properly as well, and fix a
couple of other references for user-provided callbacks.
This will require a small fix to SPDK.
Signed-off-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/libvfio-user.h | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/include/libvfio-user.h b/include/libvfio-user.h index 62d4e77..e48514a 100644 --- a/include/libvfio-user.h +++ b/include/libvfio-user.h @@ -140,7 +140,7 @@ vfu_attach_ctx(vfu_ctx_t *vfu_ctx); * * @vfu_ctx: The libvfio-user context to poll * - * @returns 0 on success, -errno on failure. + * @returns 0 on success, -1 on error. Sets errno. */ int vfu_run_ctx(vfu_ctx_t *vfu_ctx); @@ -193,7 +193,7 @@ vfu_setup_log(vfu_ctx_t *vfu_ctx, vfu_log_fn_t *log, int level); * @offset: byte offset within the region * @is_write: whether or not this is a write * - * @returns the number of bytes read or written, or a negative integer on error + * @returns the number of bytes read or written, or -1 on error, setting errno. */ typedef ssize_t (vfu_region_access_cb_t)(vfu_ctx_t *vfu_ctx, char *buf, size_t count, loff_t offset, @@ -400,9 +400,14 @@ typedef struct { */ int version; - /* migration state transition callback */ - /* TODO rename to vfu_migration_state_transition_callback */ - /* FIXME maybe we should create a single callback and pass the state? */ + /* + * Migration state transition callback. + * + * Returns -1 on error, setting errno. + * + * TODO rename to vfu_migration_state_transition_callback + * FIXME maybe we should create a single callback and pass the state? + */ int (*transition)(vfu_ctx_t *vfu_ctx, vfu_migr_state_t state); /* Callbacks for saving device state */ @@ -433,7 +438,9 @@ typedef struct { /* * Function that is called to read migration data. offset and size can be * any subrange on the offset and size previously returned by prepare_data. - * The function must return the amount of data read or -errno on error. + * The function must return the amount of data read or -1 on error, setting + * errno. + * * This function can be called even if the migration data can be memory * mapped. * @@ -446,7 +453,8 @@ typedef struct { /* * Fuction that is called for writing previously stored device state. The - * function must return the amount of data written or -errno on error. + * function must return the amount of data written or -1 on error, setting + * errno. */ ssize_t (*write_data)(vfu_ctx_t *vfu_ctx, void *buf, __u64 count, __u64 offset); |