Commit d9d58ba3 authored by Tomasz Zawadzki's avatar Tomasz Zawadzki Committed by Jim Harris
Browse files

lib/vhost: use spdk_vhost_dev_next() iterator



In later patches rte_vhost functions will be moved
to rte_vhost_user.c. To prepare for this,
iterator is used in place of accessing g_vhost_devices.

While here, followed the same style of iterating in
spdk_vhost_config_json().

Signed-off-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I1b73c00dfe1391f359421d044686e49a8c6c9176
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11022


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
parent b077e6e0
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -781,7 +781,8 @@ vhost_session_find_by_vid(int vid)
	struct spdk_vhost_dev *vdev;
	struct spdk_vhost_session *vsession;

	TAILQ_FOREACH(vdev, &g_vhost_devices, tailq) {
	for (vdev = spdk_vhost_dev_next(NULL); vdev != NULL;
	     vdev = spdk_vhost_dev_next(vdev)) {
		TAILQ_FOREACH(vsession, &vdev->vsessions, tailq) {
			if (vsession->vid == vid) {
				return vsession;
@@ -1578,7 +1579,8 @@ session_shutdown(void *arg)
	struct spdk_vhost_dev *vdev = NULL;
	struct spdk_vhost_session *vsession;

	TAILQ_FOREACH(vdev, &g_vhost_devices, tailq) {
	for (vdev = spdk_vhost_dev_next(NULL); vdev != NULL;
	     vdev = spdk_vhost_dev_next(vdev)) {
		spdk_vhost_lock();
		TAILQ_FOREACH(vsession, &vdev->vsessions, tailq) {
			if (vsession->started) {
@@ -1626,8 +1628,8 @@ spdk_vhost_config_json(struct spdk_json_write_ctx *w)
	spdk_json_write_array_begin(w);

	spdk_vhost_lock();
	vdev = spdk_vhost_dev_next(NULL);
	while (vdev != NULL) {
	for (vdev = spdk_vhost_dev_next(NULL); vdev != NULL;
	     vdev = spdk_vhost_dev_next(vdev)) {
		vdev->backend->write_config_json(vdev, w);

		spdk_vhost_get_coalescing(vdev, &delay_base_us, &iops_threshold);
@@ -1643,7 +1645,6 @@ spdk_vhost_config_json(struct spdk_json_write_ctx *w)

			spdk_json_write_object_end(w);
		}
		vdev = spdk_vhost_dev_next(vdev);
	}
	spdk_vhost_unlock();