vhost: wrap some of rte_vhost functions

This patch introduces indirection layer for session management
functions that makes it possible to switch their underlying implementation
if we want to (in unit tests for example).

Change-Id: I563c97bc65d55cc42fecbd1b7eb6679e394784a2
Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470459
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Vitaliy Mysak 2019-10-03 18:36:30 +02:00 committed by Tomasz Zawadzki
parent 0a089121f6
commit 506a90a90b
4 changed files with 26 additions and 6 deletions

View File

@ -385,3 +385,21 @@ vhost_register_unix_socket(const char *path, const char *ctrl_name,
return 0;
}
int
vhost_get_mem_table(int vid, struct rte_vhost_memory **mem)
{
return rte_vhost_get_mem_table(vid, mem);
}
int
vhost_driver_unregister(const char *path)
{
return rte_vhost_driver_unregister(path);
}
int
vhost_get_negotiated_features(int vid, uint64_t *negotiated_features)
{
return rte_vhost_get_negotiated_features(vid, negotiated_features);
}

View File

@ -664,7 +664,7 @@ vhost_dev_unregister(struct spdk_vhost_dev *vdev)
return -EBUSY;
}
if (vdev->registered && rte_vhost_driver_unregister(vdev->path) != 0) {
if (vdev->registered && vhost_driver_unregister(vdev->path) != 0) {
SPDK_ERRLOG("Could not unregister controller %s with vhost library\n"
"Check if domain socket %s still exists\n",
vdev->name, vdev->path);
@ -1074,12 +1074,12 @@ vhost_start_device_cb(int vid)
vsession->max_queues = i + 1;
}
if (rte_vhost_get_negotiated_features(vid, &vsession->negotiated_features) != 0) {
if (vhost_get_negotiated_features(vid, &vsession->negotiated_features) != 0) {
SPDK_ERRLOG("vhost device %d: Failed to get negotiated driver features\n", vid);
goto out;
}
if (rte_vhost_get_mem_table(vid, &vsession->mem) != 0) {
if (vhost_get_mem_table(vid, &vsession->mem) != 0) {
SPDK_ERRLOG("vhost device %d: Failed to get guest memory table\n", vid);
goto out;
}
@ -1436,7 +1436,7 @@ session_shutdown(void *arg)
struct spdk_vhost_dev *vdev = NULL;
TAILQ_FOREACH(vdev, &g_vhost_devices, tailq) {
rte_vhost_driver_unregister(vdev->path);
vhost_driver_unregister(vdev->path);
vdev->registered = false;
}

View File

@ -406,9 +406,11 @@ void vhost_session_stop_done(struct spdk_vhost_session *vsession, int response);
struct spdk_vhost_session *vhost_session_find_by_vid(int vid);
void vhost_session_install_rte_compat_hooks(struct spdk_vhost_session *vsession);
int vhost_register_unix_socket(const char *path, const char *ctrl_name,
uint64_t virtio_features, uint64_t disabled_features);
int vhost_driver_unregister(const char *path);
int vhost_get_mem_table(int vid, struct rte_vhost_memory **mem);
int vhost_get_negotiated_features(int vid, uint64_t *negotiated_features);
struct vhost_poll_group *vhost_get_poll_group(struct spdk_cpuset *cpumask);

View File

@ -50,7 +50,7 @@ DEFINE_STUB_V(vhost_session_install_rte_compat_hooks,
(struct spdk_vhost_session *vsession));
DEFINE_STUB(vhost_register_unix_socket, int, (const char *path, const char *name,
uint64_t virtio_features, uint64_t disabled_features), 0);
DEFINE_STUB(rte_vhost_driver_unregister, int, (const char *path), 0);
DEFINE_STUB(vhost_driver_unregister, int, (const char *path), 0);
DEFINE_STUB(spdk_mem_register, int, (void *vaddr, size_t len), 0);
DEFINE_STUB(spdk_mem_unregister, int, (void *vaddr, size_t len), 0);
DEFINE_STUB(rte_vhost_vring_call, int, (int vid, uint16_t vring_idx), 0);