lib/vfio-user: add spdk_vfio_user_dev_send_request as public function

Fuzzing vfio-user require access to send request api

Signed-off-by: Sebastian Brzezinka <sebastian.brzezinka@intel.com>
Change-Id: I6c58b8ab4fd3394150bbb3e64b4f95bff93dae6e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13881
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Sebastian Brzezinka 2022-08-04 22:47:45 +02:00 committed by Tomasz Zawadzki
parent ef73f559e6
commit 5fb57441ec
6 changed files with 22 additions and 2 deletions

View File

@ -6,6 +6,7 @@
#define _SPDK_VFIO_USER_PCI_H #define _SPDK_VFIO_USER_PCI_H
#include "spdk/stdinc.h" #include "spdk/stdinc.h"
#include "spdk/vfio_user_spec.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -24,6 +25,11 @@ struct vfio_device *spdk_vfio_user_setup(const char *path);
void spdk_vfio_user_release(struct vfio_device *dev); void spdk_vfio_user_release(struct vfio_device *dev);
/* For fuzzing only */
int spdk_vfio_user_dev_send_request(struct vfio_device *dev, enum vfio_user_command command,
void *arg, size_t arg_len, size_t buf_len, int *fds,
int max_fds);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -7,7 +7,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
SO_VER := 3 SO_VER := 3
SO_MINOR := 0 SO_MINOR := 1
C_SRCS = vfio_user_pci.c vfio_user.c C_SRCS = vfio_user_pci.c vfio_user.c
LIBNAME = vfio_user LIBNAME = vfio_user

View File

@ -6,6 +6,7 @@
spdk_vfio_user_get_bar_addr; spdk_vfio_user_get_bar_addr;
spdk_vfio_user_setup; spdk_vfio_user_setup;
spdk_vfio_user_release; spdk_vfio_user_release;
spdk_vfio_user_dev_send_request;
local: *; local: *;
}; };

View File

@ -157,7 +157,7 @@ vfio_user_read(int fd, struct vfio_user_request *req)
return 0; return 0;
} }
static int int
vfio_user_dev_send_request(struct vfio_device *dev, enum vfio_user_command command, vfio_user_dev_send_request(struct vfio_device *dev, enum vfio_user_command command,
void *arg, size_t arg_len, size_t buf_len, int *fds, int max_fds) void *arg, size_t arg_len, size_t buf_len, int *fds, int max_fds)
{ {

View File

@ -65,5 +65,9 @@ int vfio_user_get_dev_region_info(struct vfio_device *dev, struct vfio_region_in
int vfio_user_dev_dma_map_unmap(struct vfio_device *dev, struct vfio_memory_region *mr, bool map); int vfio_user_dev_dma_map_unmap(struct vfio_device *dev, struct vfio_memory_region *mr, bool map);
int vfio_user_dev_mmio_access(struct vfio_device *dev, uint32_t index, uint64_t offset, size_t len, int vfio_user_dev_mmio_access(struct vfio_device *dev, uint32_t index, uint64_t offset, size_t len,
void *buf, bool is_write); void *buf, bool is_write);
/* For fuzzing only */
int vfio_user_dev_send_request(struct vfio_device *dev, enum vfio_user_command command,
void *arg, size_t arg_len, size_t buf_len, int *fds,
int max_fds);
#endif #endif

View File

@ -421,4 +421,13 @@ spdk_vfio_user_get_bar_addr(struct vfio_device *dev, uint32_t index, uint64_t of
return NULL; return NULL;
} }
/* For fuzzing only */
int
spdk_vfio_user_dev_send_request(struct vfio_device *dev, enum vfio_user_command command,
void *arg, size_t arg_len, size_t buf_len, int *fds,
int max_fds)
{
return vfio_user_dev_send_request(dev, command, arg, arg_len, buf_len, fds, max_fds);
}
SPDK_LOG_REGISTER_COMPONENT(vfio_pci) SPDK_LOG_REGISTER_COMPONENT(vfio_pci)