From patchwork Thu Jun 27 09:10:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13714013 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 893A513C67D for ; Thu, 27 Jun 2024 09:10:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719479435; cv=none; b=Tn9jSL7N66WzBb9SLppYf+4/SjNHP591hVOpiBAt6v5+yQUlO03NnhhuCT+TwyndLyghnE17jSQ03WkOENwgFNjkoeDkSThJTsplWq1OBTa5GFLAR/f+Ybv3SroIn83+/VEG0yauZYgJvtZcBeEELGhbmdBJTO2mzsAWRFg2/DA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719479435; c=relaxed/simple; bh=pGeGgzHyUr4f92IxFN78mhlUFH/1qaLv7MOvrdi5TQQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RiXQKkuLutgaY69SJCZwnIOubkx4c0AB/WSpg8VloAnKbYVkKqkQ3e99jnqIqBGriQbP3e0JyWJ3EeSRoaza91eDXZ/AqaO8xyrWOGAoVT6V4IbVkJYzJVPzv+Fxms7MHZV3VTNcU0yfi+MvZb2t7d5P2VXXfcuiOE27bnuxOf0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=lHoy3bOv; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=GtnQSqfe; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=lHoy3bOv; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=GtnQSqfe; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="lHoy3bOv"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="GtnQSqfe"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="lHoy3bOv"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="GtnQSqfe" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A3100219B8; Thu, 27 Jun 2024 09:10:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1719479431; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vO3mLwiht/6bxAJcfiCnSj/vjI0rh0zJmWK/xqVj/fg=; b=lHoy3bOvUYHxQ8fQ5HGrGD3MN55s5W85PjTkcoYyqLinZ7PNv51yL4NtQt3ySgOi9g82my +mNjXLe/1soQycMg/jFsBBitFO5s8Gq0HuRktW+GJlG1OVjAbRqR51fXwl8uyNureL3Efa x9tErSBNBvckuHT5Dk7dDnK2pVIII9Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1719479431; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vO3mLwiht/6bxAJcfiCnSj/vjI0rh0zJmWK/xqVj/fg=; b=GtnQSqfeCUdYQ6+Fm9+6CO/MFv1Jp0JPAlqzDOCo6L4HLzoJBaRI99+D0Um28NlpW0N/DQ sOEykrGxS7QzBlAA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1719479431; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vO3mLwiht/6bxAJcfiCnSj/vjI0rh0zJmWK/xqVj/fg=; b=lHoy3bOvUYHxQ8fQ5HGrGD3MN55s5W85PjTkcoYyqLinZ7PNv51yL4NtQt3ySgOi9g82my +mNjXLe/1soQycMg/jFsBBitFO5s8Gq0HuRktW+GJlG1OVjAbRqR51fXwl8uyNureL3Efa x9tErSBNBvckuHT5Dk7dDnK2pVIII9Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1719479431; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vO3mLwiht/6bxAJcfiCnSj/vjI0rh0zJmWK/xqVj/fg=; b=GtnQSqfeCUdYQ6+Fm9+6CO/MFv1Jp0JPAlqzDOCo6L4HLzoJBaRI99+D0Um28NlpW0N/DQ sOEykrGxS7QzBlAA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 943401384C; Thu, 27 Jun 2024 09:10:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id a6FrI4csfWa9FgAAD6G6ig (envelope-from ); Thu, 27 Jun 2024 09:10:31 +0000 From: Daniel Wagner To: Shin'ichiro Kawasaki Cc: Chaitanya Kulkarni , Hannes Reinecke , linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, Daniel Wagner Subject: [PATCH blktests v3 1/3] nvme/rc: introduce remote target support Date: Thu, 27 Jun 2024 11:10:14 +0200 Message-ID: <20240627091016.12752-2-dwagner@suse.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627091016.12752-1-dwagner@suse.de> References: <20240627091016.12752-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Score: -6.80 X-Spam-Level: X-Spam-Flag: NO X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,imap1.dmz-prg2.suse.org:helo] Most of the NVMEeoF tests are exercising the host code of the nvme subsystem. There is no real reason not to run these against a real target. We just have to skip the soft target setup and make it possible to setup a remote target. Because all tests use now the common setup/cleanup helpers we just need to intercept this call and forward it to an external component. As we already have various nvme variables to setup the target which we should allow to overwrite. Also introduce a NVME_TARGET_CONTROL variable which points to a script which gets executed whenever a targets needs to be created/destroyed. Signed-off-by: Daniel Wagner --- Documentation/running-tests.md | 33 ++++++++++++++++++++ check | 4 +++ tests/nvme/rc | 57 ++++++++++++++++++++++++++++++++-- 3 files changed, 92 insertions(+), 2 deletions(-) diff --git a/Documentation/running-tests.md b/Documentation/running-tests.md index 968702e76bb5..fe4f729bd037 100644 --- a/Documentation/running-tests.md +++ b/Documentation/running-tests.md @@ -120,6 +120,9 @@ The NVMe tests can be additionally parameterized via environment variables. - NVME_NUM_ITER: 1000 (default) The number of iterations a test should do. This parameter had an old name 'nvme_num_iter'. The old name is still usable, but not recommended. +- NVME_TARGET_CONTROL: When defined, the generic target setup/cleanup code will + be skipped and this script gets called. This makes it possible to run + the fabric nvme tests against a real target. ### Running nvme-rdma and SRP tests @@ -167,3 +170,33 @@ if ! findmnt -t configfs /sys/kernel/config > /dev/null; then mount -t configfs configfs /sys/kernel/config fi ``` +### NVME_TARGET_CONTROL + +When NVME_TARGET_CONTROL is set, blktests will call the script which the +environment variable points to, to fetch the configuration values to be used for +the runs, e.g subsysnqn or hostnqn. This allows the blktest to be run against +external configured/setup targets. + +The blktests expects that the script interface implements following +commands: + +config: + --show-blkdev-type + --show-trtype + --show-hostnqn + --show-hostid + --show-host-traddr + --show-traddr + --show-trsvid + --show-subsys-uuid + --show-subsysnqn + +setup: + --subsysnqn SUBSYSNQN + --subsys-uuid SUBSYS_UUID + --hostnqn HOSTNQN + --ctrlkey CTRLKEY + --hostkey HOSTKEY + +cleanup: + --subsysnqn SUBSYSNQN diff --git a/check b/check index 3ed4510f3f40..d0475629773d 100755 --- a/check +++ b/check @@ -603,6 +603,10 @@ _run_group() { # shellcheck disable=SC1090 . "tests/${group}/rc" + if declare -fF group_setup >/dev/null; then + group_setup + fi + if declare -fF group_requires >/dev/null; then group_requires if [[ -v SKIP_REASONS ]]; then diff --git a/tests/nvme/rc b/tests/nvme/rc index c1ddf412033b..4465dea0370b 100644 --- a/tests/nvme/rc +++ b/tests/nvme/rc @@ -23,6 +23,7 @@ _check_conflict_and_set_default NVME_IMG_SIZE nvme_img_size 1G _check_conflict_and_set_default NVME_NUM_ITER nvme_num_iter 1000 nvmet_blkdev_type=${nvmet_blkdev_type:-"device"} NVMET_BLKDEV_TYPES=${NVMET_BLKDEV_TYPES:-"device file"} +nvme_target_control="${NVME_TARGET_CONTROL:-}" _NVMET_TRTYPES_is_valid() { local type @@ -135,6 +136,13 @@ _nvme_requires() { return 0 } +group_setup() { + if [[ -n "${nvme_target_control}" ]]; then + NVMET_TRTYPES="$(${nvme_target_control} config --show-trtype)" + NVMET_BLKDEV_TYPES="$(${nvme_target_control} config --show-blkdev-type)" + fi +} + group_requires() { _have_root _NVMET_TRTYPES_is_valid @@ -359,6 +367,10 @@ _cleanup_nvmet() { fi done + if [[ -n "${nvme_target_control}" ]]; then + return + fi + for port in "${NVMET_CFS}"/ports/*; do name=$(basename "${port}") echo "WARNING: Test did not clean up port: ${name}" @@ -403,11 +415,26 @@ _cleanup_nvmet() { _setup_nvmet() { _register_test_cleanup _cleanup_nvmet + + if [[ -n "${nvme_target_control}" ]]; then + def_hostnqn="$(${nvme_target_control} config --show-hostnqn)" + def_hostid="$(${nvme_target_control} config --show-hostid)" + def_host_traddr="$(${nvme_target_control} config --show-host-traddr)" + def_traddr="$(${nvme_target_control} config --show-traddr)" + def_trsvcid="$(${nvme_target_control} config --show-trsvid)" + def_subsys_uuid="$(${nvme_target_control} config --show-subsys-uuid)" + def_subsysnqn="$(${nvme_target_control} config --show-subsysnqn)" + return + fi + modprobe -q nvmet + if [[ "${nvme_trtype}" != "loop" ]]; then modprobe -q nvmet-"${nvme_trtype}" fi + modprobe -q nvme-"${nvme_trtype}" + if [[ "${nvme_trtype}" == "rdma" ]]; then start_soft_rdma for i in $(rdma_network_interfaces) @@ -425,6 +452,7 @@ _setup_nvmet() { fi done fi + if [[ "${nvme_trtype}" = "fc" ]]; then modprobe -q nvme-fcloop _setup_fcloop "${def_local_wwnn}" "${def_local_wwpn}" \ @@ -873,11 +901,13 @@ _find_nvme_passthru_loop_dev() { _nvmet_target_setup() { local blkdev_type="${nvmet_blkdev_type}" + local subsys_uuid="${def_subsys_uuid}" + local subsysnqn="${def_subsysnqn}" local blkdev + local ARGS=() local ctrlkey="" local hostkey="" - local subsysnqn="${def_subsysnqn}" - local subsys_uuid="${def_subsys_uuid}" + local blkdev local port while [[ $# -gt 0 ]]; do @@ -909,6 +939,22 @@ _nvmet_target_setup() { esac done + if [[ -n "${hostkey}" ]]; then + ARGS+=(--hostkey "${hostkey}") + fi + if [[ -n "${ctrlkey}" ]]; then + ARGS+=(--ctrkey "${ctrlkey}") + fi + + if [[ -n "${nvme_target_control}" ]]; then + eval "${nvme_target_control}" setup \ + --subsysnqn "${subsysnqn}" \ + --subsys-uuid "${subsys_uuid}" \ + --hostnqn "${def_hostnqn}" \ + "${ARGS[@]}" &> /dev/null + return + fi + truncate -s "${NVME_IMG_SIZE}" "$(_nvme_def_file_path)" if [[ "${blkdev_type}" == "device" ]]; then blkdev="$(losetup -f --show "$(_nvme_def_file_path)")" @@ -948,6 +994,13 @@ _nvmet_target_cleanup() { esac done + if [[ -n "${nvme_target_control}" ]]; then + eval "${nvme_target_control}" cleanup \ + --subsysnqn "${subsysnqn}" \ + > /dev/null + return + fi + _get_nvmet_ports "${subsysnqn}" ports for port in "${ports[@]}"; do From patchwork Thu Jun 27 09:10:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13714014 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0ABD413C69A for ; Thu, 27 Jun 2024 09:10:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719479435; cv=none; b=K01xQqSJkwyUpyJLme6ZuQwhQmWyATaHO96Qd8p+MNQrZBJQDyKCKkw6/sejxdGmu13zFBLclCSNgP7LbtNDkiyHiKT4hfwFRsjTfTA61DCSPL8qMPgZojkxmrmet3cMk6Df5MXv8Fbfm9qT/IuCCPDd5JB+aDVM3Wp5igitGj4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719479435; c=relaxed/simple; bh=AR6zqvdAKOqbvcSCNdVoIrsVo814XjFKli0AhWq7oaQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OpzjQv8tCjbgpwpyTqnGbHgZw1yR6hbPknwWc0ElQKS89nLd60WWyUzUdWm77MDYq95dxgi3DMKK2mucqHXWWyMtEysY3jUS2FfdNfglaWmrIcXYF2kBtJ9ZEP5ocPBIhb3LSEKGoOp/kTG70OcEoJEaRLpyf1Ypi+xSGl6yN8s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=nEIuchUc; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=pzKpR2xX; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=nEIuchUc; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=pzKpR2xX; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="nEIuchUc"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="pzKpR2xX"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="nEIuchUc"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="pzKpR2xX" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 415D01FBB2; Thu, 27 Jun 2024 09:10:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1719479432; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2/2zxRrftkm3PhLdkZY5e2sc9YCePDPdk4+R6WJPSbI=; b=nEIuchUcGD43EelAryCcNYc66hdkWHRb6BlptaF1wVKvBXO4dh9KLMlMw13dB4af9v9EQr jvL+ta1W4mlKmYKBX6ie9DuyBPrXd4o5iC0NZeInQ5z+c+TpG7Fjhokka7dKWLIRl5kuQv GRypWCJt/qrUlL9XXq1bOUwDjPzofgA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1719479432; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2/2zxRrftkm3PhLdkZY5e2sc9YCePDPdk4+R6WJPSbI=; b=pzKpR2xX8wEsHtb49chnzo95DW1vchReri9mlar9zEzd9ojEg9ho6CurNFtIXkw2TzOVTo MzLzI9omNGZjvUCA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1719479432; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2/2zxRrftkm3PhLdkZY5e2sc9YCePDPdk4+R6WJPSbI=; b=nEIuchUcGD43EelAryCcNYc66hdkWHRb6BlptaF1wVKvBXO4dh9KLMlMw13dB4af9v9EQr jvL+ta1W4mlKmYKBX6ie9DuyBPrXd4o5iC0NZeInQ5z+c+TpG7Fjhokka7dKWLIRl5kuQv GRypWCJt/qrUlL9XXq1bOUwDjPzofgA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1719479432; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2/2zxRrftkm3PhLdkZY5e2sc9YCePDPdk4+R6WJPSbI=; b=pzKpR2xX8wEsHtb49chnzo95DW1vchReri9mlar9zEzd9ojEg9ho6CurNFtIXkw2TzOVTo MzLzI9omNGZjvUCA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 3289D1384C; Thu, 27 Jun 2024 09:10:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id hQt0C4gsfWbAFgAAD6G6ig (envelope-from ); Thu, 27 Jun 2024 09:10:32 +0000 From: Daniel Wagner To: Shin'ichiro Kawasaki Cc: Chaitanya Kulkarni , Hannes Reinecke , linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, Daniel Wagner Subject: [PATCH blktests v3 2/3] nvme/030: only run against kernel soft target Date: Thu, 27 Jun 2024 11:10:15 +0200 Message-ID: <20240627091016.12752-3-dwagner@suse.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627091016.12752-1-dwagner@suse.de> References: <20240627091016.12752-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[99.98%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Score: -6.80 X-Spam-Level: This tests is exercising the target code and not so much the host side. The problem with nvme/030 is that it depends on interface to interact with the target which is not covered by the standard. Thus we can't run it against a real target. Just skip it when we run against a real target. Signed-off-by: Daniel Wagner --- tests/nvme/030 | 1 + tests/nvme/rc | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/tests/nvme/030 b/tests/nvme/030 index b1ed8bc20908..ae7081d55354 100755 --- a/tests/nvme/030 +++ b/tests/nvme/030 @@ -13,6 +13,7 @@ requires() { _nvme_requires _have_loop _require_nvme_trtype_is_fabrics + _require_kernel_nvme_target } set_conditions() { diff --git a/tests/nvme/rc b/tests/nvme/rc index 4465dea0370b..5e2e440ccd47 100644 --- a/tests/nvme/rc +++ b/tests/nvme/rc @@ -225,6 +225,14 @@ _require_kernel_nvme_fabrics_feature() { return 0 } +_require_kernel_nvme_target() { + if [[ -n "${nvme_target_control}" ]]; then + SKIP_REASONS+=("Linux kernel soft target not available") + return 1; + fi + return 0 +} + _test_dev_nvme_ctrl() { echo "/dev/char/$(cat "${TEST_DEV_SYSFS}/device/dev")" } From patchwork Thu Jun 27 09:10:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13714015 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF53913C806 for ; Thu, 27 Jun 2024 09:10:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719479436; cv=none; b=ImnbNDAy9O+Jf38AoyDj5Z2plR6twqkEE/KIyj+tW2xT3roqsyKsZJuUkQsmlEsej1w/CchpxsLpoTPb+WlXiNi+U/5+NIpM5P0Mz2azp0kxQCrX0YLLo03EMldN5EbVySpvPBe4uXqOjpwdaQ9O7lhdIjk9kLEadifvVnwSZ7A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719479436; c=relaxed/simple; bh=GAjQ5Gp1E+qG3N/w5nf9yJQaGonahU5gRXtb6/YYmN0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DkgC/17CzbVv+tfPs25qDNq7s13MOBPvkJ5FWgSkCLK7EmDKDpGBCFetiKUYoffeWJ79MCFrThr05rx0rczVNltid3DBjOid5rWue377NoeumZ6aFK1ToKcYy2757UcRNdUOqiR/lCZoV8dcx3cTtuKP4weP+SmnJzXG7U8R2Q0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CEC7A1FBB3; Thu, 27 Jun 2024 09:10:32 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id C02851384C; Thu, 27 Jun 2024 09:10:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id DZjxLYgsfWbCFgAAD6G6ig (envelope-from ); Thu, 27 Jun 2024 09:10:32 +0000 From: Daniel Wagner To: Shin'ichiro Kawasaki Cc: Chaitanya Kulkarni , Hannes Reinecke , linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, Daniel Wagner Subject: [PATCH blktests v3 3/3] contrib: add remote target setup/cleanup script Date: Thu, 27 Jun 2024 11:10:16 +0200 Message-ID: <20240627091016.12752-4-dwagner@suse.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627091016.12752-1-dwagner@suse.de> References: <20240627091016.12752-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: CEC7A1FBB3 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -4.00 X-Spam-Level: Use nvmetcli to setup/cleanup a remote soft target. Signed-off-by: Daniel Wagner --- contrib/nvme_target_control.py | 181 +++++++++++++++++++++++++++++++++ contrib/nvmet-subsys.jinja2 | 71 +++++++++++++ 2 files changed, 252 insertions(+) create mode 100755 contrib/nvme_target_control.py create mode 100644 contrib/nvmet-subsys.jinja2 diff --git a/contrib/nvme_target_control.py b/contrib/nvme_target_control.py new file mode 100755 index 000000000000..0a34a5a85a66 --- /dev/null +++ b/contrib/nvme_target_control.py @@ -0,0 +1,181 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-3.0+ + +# blktests calls this script to setup/teardown remote targets. blktests passes +# all relevant information via the command line, e.g. --hostnqn. +# +# This script uses nvmetcli to setup the remote target (it depends on the REST +# API feature [1]). There is not technical need for nvmetcli to use but it makes +# it simple to setup a remote Linux box. If you want to setup someting else +# you should to replace this part. +# +# There are couple of global configuration options which need to be set. +# Add ~/.config/blktests/nvme_target_control.toml file with something like: +# +# [main] +# skip_setup_cleanup=false +# nvmetcli='/usr/bin/nvmetcli' +# remote='http://nvmet.local:5000' +# +# [host] +# blkdev_type='device' +# trtype='tcp' +# hostnqn='nqn.2014-08.org.nvmexpress:uuid:0f01fb42-9f7f-4856-b0b3-51e60b8de349' +# hostid='0f01fb42-9f7f-4856-b0b3-51e60b8de349' +# host_traddr='192.168.154.187' +# +# [subsys_0] +# traddr='192.168.19.189' +# trsvid='4420' +# subsysnqn='blktests-subsystem-1' +# subsys_uuid='91fdba0d-f87b-4c25-b80f-db7be1418b9e' +# +# This expects nvmetcli with the restapi service running on target. +# +# Alternatively, you can skip the the target setup/cleanup completely +# (skip_setup_cleanup) and run against a previously configured target. +# +# [main] +# skip_setup_cleanup=true +# nvmetcli='/usr/bin/nvmetcli' +# remote='http://nvmet.local:5000' +# +# [host] +# blkdev_type='device' +# trtype='tcp' +# hostnqn='nqn.2014-08.org.nvmexpress:uuid:1a9e23dd-466e-45ca-9f43-a29aaf47cb21' +# hostid='1a9e23dd-466e-45ca-9f43-a29aaf47cb21' +# host_traddr='10.161.16.48' +# +# [subsys_0] +# traddr='10.162.198.45' +# trsvid='4420' +# subsysnqn='nqn.1988-11.com.dell:powerstore:00:f03028e73ef7D032D81E' +# subsys_uuid='3a5c104c-ee41-38a1-8ccf-0968003d54e7' +# +# nvmetcli uses JSON configuration, thus this script creates a JSON configuration +# using a jinja2 template. After this step we simple have to set the blktests +# variable correctly and start blktests. +# +# NVME_TARGET_CONTROL=~/blktests/contrib/nvme_target_control.py ./check nvme +# +# [1] https://github.com/hreinecke/nvmetcli/tree/restapi + +import os +import tomllib +import argparse +import subprocess +from jinja2 import Environment, FileSystemLoader + + +XDG_CONFIG_HOME = os.environ.get("XDG_CONFIG_HOME") +if not XDG_CONFIG_HOME: + XDG_CONFIG_HOME = os.environ.get('HOME') + '/.config' + + +with open(f'{XDG_CONFIG_HOME}/blktests/nvme_target_control.toml', 'rb') as f: + config = tomllib.load(f) + nvmetcli = config['main']['nvmetcli'] + remote = config['main']['remote'] + + +def gen_conf(conf): + basepath = os.path.dirname(__file__) + environment = Environment(loader=FileSystemLoader(basepath)) + template = environment.get_template('nvmet-subsys.jinja2') + filename = f'{conf["subsysnqn"]}.json' + content = template.render(conf) + with open(filename, mode='w', encoding='utf-8') as outfile: + outfile.write(content) + + +def target_setup(args): + if config['main']['skip_setup_cleanup']: + return + + conf = { + 'subsysnqn': args.subsysnqn, + 'subsys_uuid': args.subsys_uuid, + 'hostnqn': args.hostnqn, + 'allowed_hosts': args.hostnqn, + 'ctrlkey': args.ctrlkey, + 'hostkey': args.hostkey, + 'blkdev': '/dev/vdc' + } + + gen_conf(conf) + + subprocess.call(['python3', nvmetcli, '--remote=' + remote, + 'restore', args.subsysnqn + '.json']) + + +def target_cleanup(args): + if config['main']['skip_setup_cleanup']: + return + + subprocess.call(['python3', nvmetcli, '--remote=' + remote, + 'clear', args.subsysnqn + '.json']) + + +def target_config(args): + if args.show_blkdev_type: + print(config['host']['blkdev_type']) + elif args.show_trtype: + print(config['host']['trtype']) + elif args.show_hostnqn: + print(config['host']['hostnqn']) + elif args.show_hostid: + print(config['host']['hostid']) + elif args.show_host_traddr: + print(config['host']['host_traddr']) + elif args.show_traddr: + print(config['subsys_0']['traddr']) + elif args.show_trsvid: + print(config['subsys_0']['trsvid']) + elif args.show_subsysnqn: + print(config['subsys_0']['subsysnqn']) + elif args.show_subsys_uuid: + print(config['subsys_0']['subsys_uuid']) + + +def build_parser(): + parser = argparse.ArgumentParser() + sub = parser.add_subparsers(required=True) + + setup = sub.add_parser('setup') + setup.add_argument('--subsysnqn', required=True) + setup.add_argument('--subsys-uuid', required=True) + setup.add_argument('--hostnqn', required=True) + setup.add_argument('--ctrlkey', default='') + setup.add_argument('--hostkey', default='') + setup.set_defaults(func=target_setup) + + cleanup = sub.add_parser('cleanup') + cleanup.add_argument('--subsysnqn', required=True) + cleanup.set_defaults(func=target_cleanup) + + config = sub.add_parser('config') + config.add_argument('--show-blkdev-type', action='store_true') + config.add_argument('--show-trtype', action='store_true') + config.add_argument('--show-hostnqn', action='store_true') + config.add_argument('--show-hostid', action='store_true') + config.add_argument('--show-host-traddr', action='store_true') + config.add_argument('--show-traddr', action='store_true') + config.add_argument('--show-trsvid', action='store_true') + config.add_argument('--show-subsys-uuid', action='store_true') + config.add_argument('--show-subsysnqn', action='store_true') + config.set_defaults(func=target_config) + + return parser + + +def main(): + import sys + + parser = build_parser() + args = parser.parse_args() + args.func(args) + + +if __name__ == '__main__': + main() diff --git a/contrib/nvmet-subsys.jinja2 b/contrib/nvmet-subsys.jinja2 new file mode 100644 index 000000000000..a446fbd9b784 --- /dev/null +++ b/contrib/nvmet-subsys.jinja2 @@ -0,0 +1,71 @@ +{ + "hosts": [ + { + "nqn": "{{ hostnqn }}" + } + ], + "ports": [ + { + "addr": { + "adrfam": "ipv4", + "traddr": "0.0.0.0", + "treq": "not specified", + "trsvcid": "4420", + "trtype": "tcp", + "tsas": "none" + }, + "ana_groups": [ + { + "ana": { + "state": "optimized" + }, + "grpid": 1 + } + ], + "param": { + "inline_data_size": "16384", + "pi_enable": "0" + }, + "portid": 0, + "referrals": [], + "subsystems": [ + "{{ subsysnqn }}" + ] + } + ], + "subsystems": [ + { + "allowed_hosts": [ + "{{ allowed_hosts }}" + ], + "attr": { + "allow_any_host": "0", + "cntlid_max": "65519", + "cntlid_min": "1", + "firmware": "yada", + "ieee_oui": "0x000000", + "model": "Linux", + "pi_enable": "0", + "qid_max": "128", + "serial": "0c74361069d9db6c65ef", + "version": "1.3" + }, + "namespaces": [ + { + "ana": { + "grpid": "1" + }, + "ana_grpid": 1, + "device": { + "nguid": "00000000-0000-0000-0000-000000000000", + "path": "{{ blkdev }}", + "uuid": "{{ subsys_uuid }}" + }, + "enable": 1, + "nsid": 1 + } + ], + "nqn": "{{ subsysnqn }}" + } + ] +}