test/vhost: verify cpumask argument for controller creation
`--cpumask` argument for vhost controller creation was
untested. This patch specifies this argument and verifies output
under following conditions:
- no cpumask, resulting in it being equal to the app cpumask
- cpumask equal to app cpumask
- single core
- single non-main core
- two cores
It was motivated by recent changes to reactor code affecting
vhost without it being caught by CI. See commit 7cc83b62
.
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I92c603061619092007bc27a189d3d8787461a16f
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6211
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
710838103b
commit
daab1abc4f
@ -267,28 +267,52 @@ create_controller_test(void)
|
||||
int ret;
|
||||
char long_name[PATH_MAX];
|
||||
|
||||
spdk_cpuset_set_cpu(&g_vhost_core_mask, 0, true);
|
||||
spdk_cpuset_parse(&g_vhost_core_mask, "0xf");
|
||||
|
||||
/* Create device with cpumask implcitly matching whole application */
|
||||
ret = alloc_vdev(&vdev, "vdev_name_0", NULL);
|
||||
SPDK_CU_ASSERT_FATAL(ret == 0 && vdev);
|
||||
SPDK_CU_ASSERT_FATAL(!strcmp(spdk_cpuset_fmt(spdk_thread_get_cpumask(vdev->thread)), "f"));
|
||||
cleanup_vdev(vdev);
|
||||
|
||||
/* Create device with cpumask matching whole application */
|
||||
ret = alloc_vdev(&vdev, "vdev_name_0", "0xf");
|
||||
SPDK_CU_ASSERT_FATAL(ret == 0 && vdev);
|
||||
SPDK_CU_ASSERT_FATAL(!strcmp(spdk_cpuset_fmt(spdk_thread_get_cpumask(vdev->thread)), "f"));
|
||||
cleanup_vdev(vdev);
|
||||
|
||||
/* Create device with single core in cpumask */
|
||||
ret = alloc_vdev(&vdev, "vdev_name_0", "0x2");
|
||||
SPDK_CU_ASSERT_FATAL(ret == 0 && vdev);
|
||||
SPDK_CU_ASSERT_FATAL(!strcmp(spdk_cpuset_fmt(spdk_thread_get_cpumask(vdev->thread)), "2"));
|
||||
cleanup_vdev(vdev);
|
||||
|
||||
/* Create device with cpumask spanning two cores */
|
||||
ret = alloc_vdev(&vdev, "vdev_name_0", "0x3");
|
||||
SPDK_CU_ASSERT_FATAL(ret == 0 && vdev);
|
||||
SPDK_CU_ASSERT_FATAL(!strcmp(spdk_cpuset_fmt(spdk_thread_get_cpumask(vdev->thread)), "3"));
|
||||
cleanup_vdev(vdev);
|
||||
|
||||
/* Create device with incorrect cpumask outside of application cpumask */
|
||||
ret = alloc_vdev(&vdev, "vdev_name_0", "0xf0");
|
||||
SPDK_CU_ASSERT_FATAL(ret != 0);
|
||||
|
||||
/* Create device with no name */
|
||||
ret = alloc_vdev(&vdev, NULL, "0x1");
|
||||
CU_ASSERT(ret != 0);
|
||||
|
||||
/* Create device with incorrect cpumask */
|
||||
ret = alloc_vdev(&vdev, "vdev_name_0", "0x2");
|
||||
ret = alloc_vdev(&vdev, NULL, NULL);
|
||||
CU_ASSERT(ret != 0);
|
||||
|
||||
/* Create device with too long name and path */
|
||||
memset(long_name, 'x', sizeof(long_name));
|
||||
long_name[PATH_MAX - 1] = 0;
|
||||
snprintf(dev_dirname, sizeof(dev_dirname), "some_path/");
|
||||
ret = alloc_vdev(&vdev, long_name, "0x1");
|
||||
ret = alloc_vdev(&vdev, long_name, NULL);
|
||||
CU_ASSERT(ret != 0);
|
||||
dev_dirname[0] = 0;
|
||||
|
||||
/* Create device when device name is already taken */
|
||||
ret = alloc_vdev(&vdev, "vdev_name_0", "0x1");
|
||||
ret = alloc_vdev(&vdev, "vdev_name_0", NULL);
|
||||
SPDK_CU_ASSERT_FATAL(ret == 0 && vdev);
|
||||
ret = alloc_vdev(&vdev2, "vdev_name_0", "0x1");
|
||||
ret = alloc_vdev(&vdev2, "vdev_name_0", NULL);
|
||||
CU_ASSERT(ret != 0);
|
||||
cleanup_vdev(vdev);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ function err_cleanup() {
|
||||
|
||||
# start vhost and configure it
|
||||
trap 'err_cleanup; exit 1' SIGINT SIGTERM EXIT
|
||||
$SPDK_BIN_DIR/vhost &
|
||||
$SPDK_BIN_DIR/vhost -m 0xf &
|
||||
vhost_pid=$!
|
||||
waitforlisten $vhost_pid
|
||||
|
||||
@ -35,17 +35,22 @@ rpc_cmd vhost_scsi_controller_add_target naa.Nvme0n1_scsi0.0 0 Nvme0n1p0
|
||||
rpc_cmd vhost_scsi_controller_add_target naa.Nvme0n1_scsi0.0 1 Nvme0n1p1
|
||||
rpc_cmd vhost_scsi_controller_add_target naa.Nvme0n1_scsi0.0 2 Nvme0n1p2
|
||||
rpc_cmd vhost_scsi_controller_add_target naa.Nvme0n1_scsi0.0 3 Nvme0n1p3
|
||||
[[ "$(rpc_cmd vhost_get_controllers -n naa.Nvme0n1_scsi0.0 | jq -r '.[].cpumask')" == "0xf" ]]
|
||||
|
||||
rpc_cmd vhost_create_blk_controller naa.Nvme0n1_blk0.0 Nvme0n1p4
|
||||
rpc_cmd vhost_create_blk_controller naa.Nvme0n1_blk1.0 Nvme0n1p5
|
||||
rpc_cmd vhost_create_blk_controller naa.Nvme0n1_blk0.0 Nvme0n1p4 --cpumask 0xf
|
||||
[[ "$(rpc_cmd vhost_get_controllers -n naa.Nvme0n1_blk0.0 | jq -r '.[].cpumask')" == "0xf" ]]
|
||||
rpc_cmd vhost_create_blk_controller naa.Nvme0n1_blk1.0 Nvme0n1p5 --cpumask 0x1
|
||||
[[ "$(rpc_cmd vhost_get_controllers -n naa.Nvme0n1_blk1.0 | jq -r '.[].cpumask')" == "0x1" ]]
|
||||
|
||||
rpc_cmd bdev_malloc_create 128 512 --name Malloc0
|
||||
rpc_cmd vhost_create_scsi_controller naa.Malloc0.0
|
||||
rpc_cmd vhost_create_scsi_controller naa.Malloc0.0 --cpumask 0x2
|
||||
rpc_cmd vhost_scsi_controller_add_target naa.Malloc0.0 0 Malloc0
|
||||
[[ "$(rpc_cmd vhost_get_controllers -n naa.Malloc0.0 | jq -r '.[].cpumask')" == "0x2" ]]
|
||||
|
||||
rpc_cmd bdev_malloc_create 128 4096 --name Malloc1
|
||||
rpc_cmd vhost_create_scsi_controller naa.Malloc1.0
|
||||
rpc_cmd vhost_create_scsi_controller naa.Malloc1.0 --cpumask 0xc
|
||||
rpc_cmd vhost_scsi_controller_add_target naa.Malloc1.0 0 Malloc1
|
||||
[[ "$(rpc_cmd vhost_get_controllers -n naa.Malloc1.0 | jq -r '.[].cpumask')" == "0xc" ]]
|
||||
|
||||
# start a dummy app, create vhost bdevs in it, then dump the config for FIO
|
||||
$SPDK_BIN_DIR/spdk_tgt -r /tmp/spdk2.sock -g &
|
||||
|
@ -63,7 +63,7 @@ notice "==============="
|
||||
notice ""
|
||||
notice "running SPDK"
|
||||
notice ""
|
||||
vhost_run 0
|
||||
vhost_run 0 "-m 0xf"
|
||||
notice ""
|
||||
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
|
||||
$rpc_py bdev_malloc_create -b Malloc0 128 4096
|
||||
@ -88,8 +88,8 @@ if $rpc_py vhost_delete_controller unk0 > /dev/null; then
|
||||
fi
|
||||
|
||||
# SCSI
|
||||
notice "Trying to create scsi controller with incorrect cpumask"
|
||||
if $rpc_py vhost_create_scsi_controller vhost.invalid.cpumask --cpumask 0x2; then
|
||||
notice "Trying to create scsi controller with incorrect cpumask outside of application cpumask"
|
||||
if $rpc_py vhost_create_scsi_controller vhost.invalid.cpumask --cpumask 0xf0; then
|
||||
error "Creating scsi controller with incorrect cpumask succeeded, but it shouldn't"
|
||||
fi
|
||||
|
||||
@ -167,8 +167,8 @@ notice "Re-adding device 0 to naa.0"
|
||||
$rpc_py vhost_scsi_controller_add_target naa.0 0 Malloc0
|
||||
|
||||
# BLK
|
||||
notice "Trying to create block controller with incorrect cpumask"
|
||||
if $rpc_py vhost_create_blk_controller vhost.invalid.cpumask Malloc0 --cpumask 0x2; then
|
||||
notice "Trying to create block controller with incorrect cpumask outside of application cpumask"
|
||||
if $rpc_py vhost_create_blk_controller vhost.invalid.cpumask Malloc0 --cpumask 0xf0; then
|
||||
error "Creating block controller with incorrect cpumask succeeded, but it shouldn't"
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user