vhost: don't operate on partially-initialized vdev
Make the vdev initialization happen before calling any vdev related functions. This is mostly needed for an upcomming patch where additional step is required after initializing the vdev and before starting rte vhost. On the other hand, this patch also fixes a technically possible scenario where rte vhost starts processing vhost-user messages and calling our ops before the related vdev was initialized. Change-Id: I8fbc7e7bc0b364327cfcec60faa74d4f64d6fad8 Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/447024 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
1ecbb6a8da
commit
aa5f129f57
@ -752,6 +752,17 @@ spdk_vhost_dev_register(struct spdk_vhost_dev *vdev, const char *name, const cha
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vdev->name = strdup(name);
|
||||||
|
vdev->path = strdup(path);
|
||||||
|
vdev->cpumask = cpumask;
|
||||||
|
vdev->registered = true;
|
||||||
|
vdev->backend = backend;
|
||||||
|
TAILQ_INIT(&vdev->vsessions);
|
||||||
|
TAILQ_INSERT_TAIL(&g_spdk_vhost_devices, vdev, tailq);
|
||||||
|
|
||||||
|
spdk_vhost_set_coalescing(vdev, SPDK_VHOST_COALESCING_DELAY_BASE_US,
|
||||||
|
SPDK_VHOST_VQ_IOPS_COALESCING_THRESHOLD);
|
||||||
|
|
||||||
/* The following might start a POSIX thread that polls for incoming
|
/* The following might start a POSIX thread that polls for incoming
|
||||||
* socket connections and calls backend->start/stop_device. These backend
|
* socket connections and calls backend->start/stop_device. These backend
|
||||||
* callbacks are also protected by the global SPDK vhost mutex, so we're
|
* callbacks are also protected by the global SPDK vhost mutex, so we're
|
||||||
@ -761,21 +772,13 @@ spdk_vhost_dev_register(struct spdk_vhost_dev *vdev, const char *name, const cha
|
|||||||
SPDK_ERRLOG("Failed to start vhost driver for controller %s (%d): %s\n",
|
SPDK_ERRLOG("Failed to start vhost driver for controller %s (%d): %s\n",
|
||||||
name, errno, spdk_strerror(errno));
|
name, errno, spdk_strerror(errno));
|
||||||
rte_vhost_driver_unregister(path);
|
rte_vhost_driver_unregister(path);
|
||||||
|
TAILQ_REMOVE(&g_spdk_vhost_devices, vdev, tailq);
|
||||||
|
free(vdev->name);
|
||||||
|
free(vdev->path);
|
||||||
rc = -EIO;
|
rc = -EIO;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
vdev->name = strdup(name);
|
|
||||||
vdev->path = strdup(path);
|
|
||||||
vdev->cpumask = cpumask;
|
|
||||||
vdev->registered = true;
|
|
||||||
vdev->backend = backend;
|
|
||||||
TAILQ_INIT(&vdev->vsessions);
|
|
||||||
spdk_vhost_set_coalescing(vdev, SPDK_VHOST_COALESCING_DELAY_BASE_US,
|
|
||||||
SPDK_VHOST_VQ_IOPS_COALESCING_THRESHOLD);
|
|
||||||
|
|
||||||
TAILQ_INSERT_TAIL(&g_spdk_vhost_devices, vdev, tailq);
|
|
||||||
|
|
||||||
SPDK_INFOLOG(SPDK_LOG_VHOST, "Controller %s: new controller added\n", vdev->name);
|
SPDK_INFOLOG(SPDK_LOG_VHOST, "Controller %s: new controller added\n", vdev->name);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user