diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index 9cdd8d3a4..4ac86e83e 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -1282,7 +1282,8 @@ new_connection(int vid) return -1; } - vsession = spdk_dma_zmalloc(sizeof(struct spdk_vhost_session), + vsession = spdk_dma_zmalloc(sizeof(struct spdk_vhost_session) + + vdev->backend->session_ctx_size, SPDK_CACHE_LINE_SIZE, NULL); if (vsession == NULL) { SPDK_ERRLOG("spdk_dma_zmalloc failed\n"); diff --git a/lib/vhost/vhost_blk.c b/lib/vhost/vhost_blk.c index 90ee633e0..b43fa81bc 100644 --- a/lib/vhost/vhost_blk.c +++ b/lib/vhost/vhost_blk.c @@ -832,6 +832,7 @@ static const struct spdk_vhost_dev_backend vhost_blk_device_backend = { (1ULL << VIRTIO_BLK_F_RO) | (1ULL << VIRTIO_BLK_F_FLUSH) | (1ULL << VIRTIO_BLK_F_CONFIG_WCE) | (1ULL << VIRTIO_BLK_F_BARRIER) | (1ULL << VIRTIO_BLK_F_SCSI) | (1ULL << VIRTIO_BLK_F_DISCARD) | (1ULL << VIRTIO_BLK_F_WRITE_ZEROES), + .session_ctx_size = 0, .start_device = spdk_vhost_blk_start, .stop_device = spdk_vhost_blk_stop, .vhost_get_config = spdk_vhost_blk_get_config, diff --git a/lib/vhost/vhost_internal.h b/lib/vhost/vhost_internal.h index f13346863..b7efdd4e0 100644 --- a/lib/vhost/vhost_internal.h +++ b/lib/vhost/vhost_internal.h @@ -115,6 +115,12 @@ struct spdk_vhost_dev_backend { uint64_t virtio_features; uint64_t disabled_features; + /** + * Size of additional per-session context data + * allocated whenever a new client connects. + */ + size_t session_ctx_size; + /** * Callbacks for starting and pausing the device. * The first param is struct spdk_vhost_dev *. diff --git a/lib/vhost/vhost_nvme.c b/lib/vhost/vhost_nvme.c index c26640c46..d796cdfce 100644 --- a/lib/vhost/vhost_nvme.c +++ b/lib/vhost/vhost_nvme.c @@ -1249,6 +1249,7 @@ spdk_vhost_nvme_write_config_json(struct spdk_vhost_dev *vdev, struct spdk_json_ } static const struct spdk_vhost_dev_backend spdk_vhost_nvme_device_backend = { + .session_ctx_size = 0, .start_device = spdk_vhost_nvme_start_device, .stop_device = spdk_vhost_nvme_stop_device, .dump_info_json = spdk_vhost_nvme_dump_info_json, diff --git a/lib/vhost/vhost_scsi.c b/lib/vhost/vhost_scsi.c index e421605ca..4c1ec29f8 100644 --- a/lib/vhost/vhost_scsi.c +++ b/lib/vhost/vhost_scsi.c @@ -117,6 +117,7 @@ static int spdk_vhost_scsi_dev_remove(struct spdk_vhost_dev *vdev); const struct spdk_vhost_dev_backend spdk_vhost_scsi_device_backend = { .virtio_features = SPDK_VHOST_SCSI_FEATURES, .disabled_features = SPDK_VHOST_SCSI_DISABLED_FEATURES, + .session_ctx_size = 0, .start_device = spdk_vhost_scsi_start, .stop_device = spdk_vhost_scsi_stop, .dump_info_json = spdk_vhost_scsi_dump_info_json,