vhost: introduce session names

We currently don't have any way to differentiate different
sessions e.g. in error messages. Whenever there's an error
in some session, we just print the device name.

We now introduce vsession->name with the following format:
<device name>s<dpdk connection id>

Note that it's still impossible to know exactly which
qemu process corresponds to which session in spdk, but
there's not much we could do in that matter right now.
In spdk we don't even have the accepted connection fd.

Change-Id: I666aa60c5e36bf3d56f68133042af2afc8cc5e85
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466039
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@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:
Darek Stojaczyk 2019-07-20 11:55:19 +02:00 committed by Jim Harris
parent 0ce883cef0
commit e5d7a44581
2 changed files with 11 additions and 1 deletions

View File

@ -1373,8 +1373,15 @@ new_connection(int vid)
memset(vsession, 0, sizeof(*vsession) + vdev->backend->session_ctx_size);
vsession->vdev = vdev;
vsession->id = vdev->vsessions_num++;
vsession->vid = vid;
vsession->id = vdev->vsessions_num++;
vsession->name = spdk_sprintf_alloc("%ss%u", vdev->name, vsession->vid);
if (vsession->name == NULL) {
SPDK_ERRLOG("vsession alloc failed\n");
pthread_mutex_unlock(&g_spdk_vhost_mutex);
free(vsession);
return -1;
}
vsession->poll_group = NULL;
vsession->started = false;
vsession->initialized = false;
@ -1406,6 +1413,7 @@ destroy_connection(int vid)
}
TAILQ_REMOVE(&vsession->vdev->vsessions, vsession, tailq);
free(vsession->name);
free(vsession);
pthread_mutex_unlock(&g_spdk_vhost_mutex);
}

View File

@ -127,6 +127,8 @@ struct spdk_vhost_session {
/* Unique session ID. */
uint64_t id;
/* Unique session name. */
char *name;
struct vhost_poll_group *poll_group;