lib/vhost: remove session initialized flag

Session in vhost means an active socket connection from
client(e.g: QEMU or SPDK vhost initiator), but the device
state could be `started` or `stopped` because users may
remove the driver of the device in VM, so in
`foreach_session` we can always call the callback function
without checking the session state, and the callback function
may check the device state if necessary.

Change-Id: Id0fc8c7f6f0915a55a738f0c87ebe6539f7fb2db
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15038
Community-CI: Mellanox Build Bot
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Changpeng Liu 2022-10-19 11:19:33 +08:00 committed by Tomasz Zawadzki
parent 9da4e15c5c
commit fabf6a83cc
2 changed files with 3 additions and 8 deletions

View File

@ -964,7 +964,6 @@ new_connection(int vid)
return -1;
}
vsession->started = false;
vsession->initialized = false;
vsession->next_stats_check_time = 0;
vsession->stats_check_interval = SPDK_VHOST_STATS_CHECK_INTERVAL_MS *
spdk_get_ticks_hz() / 1000UL;
@ -1144,7 +1143,6 @@ start_device(int vid)
vdev = vsession->vdev;
vhost_user_session_set_coalescing(vdev, vsession, NULL);
vsession->initialized = true;
spdk_thread_send_msg(vdev->thread, vhost_user_session_start, vsession);
out:
@ -1362,11 +1360,9 @@ foreach_session(void *arg1)
}
TAILQ_FOREACH(vsession, &to_user_dev(vdev)->vsessions, tailq) {
if (vsession->initialized) {
rc = ev_ctx->cb_fn(vdev, vsession, ev_ctx->user_ctx);
if (rc < 0) {
goto out;
}
rc = ev_ctx->cb_fn(vdev, vsession, ev_ctx->user_ctx);
if (rc < 0) {
goto out;
}
}

View File

@ -114,7 +114,6 @@ struct spdk_vhost_session {
/* Unique session name. */
char *name;
bool initialized;
bool started;
bool interrupt_mode;