diff options
author | John Levon <john.levon@nutanix.com> | 2021-05-26 12:23:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-26 12:23:29 +0100 |
commit | 7aca16a2cf2b00b11fbdb51829b47c3838eeb151 (patch) | |
tree | 1c95ed1f49c1fbaa2fcf21eaa523ca5d71bada35 /test/mocks.c | |
parent | 03edc3a44e635377ac238a009c5c76b90af3c970 (diff) | |
download | libvfio-user-7aca16a2cf2b00b11fbdb51829b47c3838eeb151.zip libvfio-user-7aca16a2cf2b00b11fbdb51829b47c3838eeb151.tar.gz libvfio-user-7aca16a2cf2b00b11fbdb51829b47c3838eeb151.tar.bz2 |
improve request header handling
We should require a non-empty payload for every command type except
VFIO_USER_DEVICE_RESET.
We should also reply to the caller with such failures.
Add some testing for is_valid_header(), and move the fd handling test over to it
too.
Signed-off-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'test/mocks.c')
-rw-r--r-- | test/mocks.c | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/test/mocks.c b/test/mocks.c index 5a2b55f..4f202d5 100644 --- a/test/mocks.c +++ b/test/mocks.c @@ -62,12 +62,9 @@ static struct function funcs[] = { { .name = "dma_controller_add_region" }, { .name = "dma_controller_remove_region" }, { .name = "dma_controller_unmap_region" }, - { .name = "exec_command" }, - { .name = "get_request_header" }, { .name = "handle_dirty_pages" }, { .name = "process_request" }, { .name = "should_exec_command" }, - { .name = "tran_sock_send_iovec" }, { .name = "migration_region_access_registers" }, { .name = "handle_dirty_pages_get" }, { .name = "handle_device_state" }, @@ -164,24 +161,6 @@ dma_controller_unmap_region(dma_controller_t *dma, check_expected(region); } -int -tran_sock_send_iovec(int sock, uint16_t msg_id, bool is_reply, - enum vfio_user_command cmd, - struct iovec *iovecs, size_t nr_iovecs, - int *fds, int count, int err) -{ - check_expected(sock); - check_expected(msg_id); - check_expected(is_reply); - check_expected(cmd); - check_expected(iovecs); - check_expected(nr_iovecs); - check_expected(fds); - check_expected(count); - check_expected(err); - return mock(); -} - bool device_is_stopped(struct migration *migration) { @@ -193,26 +172,6 @@ device_is_stopped(struct migration *migration) } int -get_request_header(vfu_ctx_t *vfu_ctx, vfu_msg_t **msgp) -{ - check_expected(vfu_ctx); - check_expected(msgp); - return mock(); -} - -int -exec_command(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg) -{ - if (!is_patched("exec_command")) { - return __real_exec_command(vfu_ctx, msg); - } - check_expected(vfu_ctx); - check_expected(msg); - errno = mock(); - return mock(); -} - -int process_request(vfu_ctx_t *vfu_ctx) { |