From nobody Fri Dec 19 12:29:06 2025 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (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 CBBB720E334 for ; Sat, 8 Nov 2025 16:01:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762617714; cv=none; b=B/g6q5xZuvEodo4XX50ZfgzK1mqhHZ7+j3+LayWcB4PsQd1Uuwv8pZnZ1g6QXIvjUBuwpgaoZpL9TgcDGFRUZLsO9tfAGS/wm3IlCI4bEaoN2lqLqNSJElGp6fto6pRBi4lPZ6bjYXFqUr4kXncVBmuf2o7IQ4IJ7BWN03o1N58= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762617714; c=relaxed/simple; bh=KaZPXYApVo3gzuCQZxOqqdj7Oefz16QZ4HcopRgoUyE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SgMJqlulPgcRc47h8fjDZPSPWd2pFUHO0ZLcSg0HgTb+7zuQ8w0nECrQbVZ4vVoQ1OUMbQspJ837MOSXHhKl0MtiAW28dgo1BTI8h4wkIHKVnSkFdpuZZLrTAqvjJln1WfArlStDenoUKj0acHU6bhH643s2ZWJbv4P4tWtre8A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=W2nYmmAi; arc=none smtp.client-ip=209.85.216.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W2nYmmAi" Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-340ba29d518so1088694a91.3 for ; Sat, 08 Nov 2025 08:01:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762617712; x=1763222512; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=KuFcuN4dciZC8eK8448U1zaLcwyfmGMtaq+xAMSDgTg=; b=W2nYmmAiA/Ru3TG/OkEGb4o7wuwewiw8M/MCOegkyCdB7IoXzVcJqZiMi0W18+3REV Oic4WsypsL5oZmUtDYoZOBoEYkTNo38GCLY73dOmrtSK/DPyZayF56ZEkpEsVbv6eHfX +gnXjpJT3di0TZFNH42qb9UUUwgcUGgyw7q8WjEDr+hkDGm497YgNJhgGGDrzgNvyfQb JTnGMvFVf7bFjTGyQCImuABdUZ9TaQCXkVYXjVn/qbi7vPRgunSYFkTDznkGpjeKJjRu pP1pa4U+mkfRe/BQ9ugslOiWzEBU4XteDFCKHmkUjTu6O25eIOcFTXUyr6SCLVghz1rm h7xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762617712; x=1763222512; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=KuFcuN4dciZC8eK8448U1zaLcwyfmGMtaq+xAMSDgTg=; b=pvAWbL5G2xaiHxXMSy7LYJ4hqy5ICBSfE+0apgz3WX/iVNlE9UTmRFoMfoxSNr0h7+ isqiVCWUWlAuFfIWDCZ+pWnRAUoFjkuCeMsHkk9+JznD6w2730F1NuRuoLpG/aY9TGWs ff8SlEye5l1ASm1nX0pXvXpuprsY9LqJY8ZBf5jhhJtOoL+jY+TFG/eKa+3Hh7q9CA5L v/oeUDthNgr/eD2Qr9EwmvgR7WBzR9ym6jTQt7MdnJnbsYZELCU2X2izJjHOIubyDjG/ 74Pkg9YvrxwURT9nNJ8Kydr4JnXZcKGqRRrzL9gH/fFQLYXKUClckoH+9aH1LD0nO0qF qqhw== X-Forwarded-Encrypted: i=1; AJvYcCWXvA5GtLpZKmrLPIY+M+N8maskVBRCb3x3LvIUQmphFwmD57NzO6yIDn7Vul5iCQhwmoDpoFir/imioNc=@vger.kernel.org X-Gm-Message-State: AOJu0YysTKEG9gWGkfJetLYt/Qe8kC9eI4nIu38ID3SHuqB6gaH80nim nZmfEvINwgz1LE0+oz2OgHtJLP63QaZltQI8xZche0oUBXXerCOBLo5F X-Gm-Gg: ASbGncs78pbhNWu+orVZE0jbVaZ9yjJqqGtld2xRWLkcrqxGQxtytYOZXwI1Qq1mEM8 TqIg0j8kaB28HP1U+tc6C9W0NEj6kBH6smvIlpBjOu/T/G0Wg96IwUT1xNjnIeWTqSM98EHXRU6 MM5XcdEdte3wayAiHeLQVz/DfCYpJRmYa00Oa+l/LZsJp3sQaIeVvhW8z7iFx1c+1cvNXwG2dNE 4308UDtkJ0EkhANzuBnSBwp8bYomciYDQsGiiKbpAZbgHmRuC7eY0T2eiF46ACHnT8bvw/01GzL hM3OCkyGD4CIePokBZliHewPnxtkXD2Kvd5TN04SJhAPin5tMZBCNDB/iqCaW4/Bgj4XYSc3GzR Y+RXAkcql354/Us1py0a1/NdUtMmcKao2YNTvBSK+Sg4zahS7V8qvny6EXbICi7FCWXdR2zXdgA == X-Google-Smtp-Source: AGHT+IFfAGmgLKI4wsdRP449UjnWCEHQ8HjRd06GWOlMDD2Oh5K2oGmSXaRp75cZh2HiCmppgc3Cvw== X-Received: by 2002:a17:90b:4a8d:b0:340:f05a:3ed1 with SMTP id 98e67ed59e1d1-3436cced91fmr3307290a91.21.1762617711672; Sat, 08 Nov 2025 08:01:51 -0800 (PST) Received: from localhost ([2a03:2880:2ff:71::]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3434c30b96dsm5767493a91.5.2025.11.08.08.01.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Nov 2025 08:01:51 -0800 (PST) From: Bobby Eshleman Date: Sat, 08 Nov 2025 08:00:52 -0800 Subject: [PATCH net-next v4 01/12] selftests/vsock: improve logging in vmtest.sh Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251108-vsock-selftests-fixes-and-improvements-v4-1-d5e8d6c87289@meta.com> References: <20251108-vsock-selftests-fixes-and-improvements-v4-0-d5e8d6c87289@meta.com> In-Reply-To: <20251108-vsock-selftests-fixes-and-improvements-v4-0-d5e8d6c87289@meta.com> To: Stefano Garzarella , Shuah Khan Cc: virtualization@lists.linux.dev, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Simon Horman , Bobby Eshleman X-Mailer: b4 0.14.3 From: Bobby Eshleman Improve usability of logging functions. Remove the test name prefix from logging functions so that logging calls can be made deeper into the call stack without passing down the test name or setting some global. Teach log function to accept a LOG_PREFIX variable to avoid unnecessary argument shifting. Remove log_setup() and instead use log_host(). The host/guest prefixes are useful to show whether a failure happened on the guest or host side, but "setup" doesn't really give additional useful information. Since all log_setup() calls happen on the host, lets just use log_host() instead. Signed-off-by: Bobby Eshleman Reviewed-by: Stefano Garzarella --- Changes in v4: - add quotes to "${redirect}" for consistency Changes in v2: - add quotes around $@ in log_{host,guest} (Simon) - remove unnecessary cat for piping into awk (Simon) Changes from previous series: - do not use log levels, keep as on/off switch, after revising the other patch series the levels became unnecessary. --- tools/testing/selftests/vsock/vmtest.sh | 69 ++++++++++++++---------------= ---- 1 file changed, 29 insertions(+), 40 deletions(-) diff --git a/tools/testing/selftests/vsock/vmtest.sh b/tools/testing/selfte= sts/vsock/vmtest.sh index 8ceeb8a7894f..bc16b13cdbe3 100755 --- a/tools/testing/selftests/vsock/vmtest.sh +++ b/tools/testing/selftests/vsock/vmtest.sh @@ -271,60 +271,51 @@ EOF =20 host_wait_for_listener() { wait_for_listener "${TEST_HOST_PORT_LISTENER}" "${WAIT_PERIOD}" "${WAIT_P= ERIOD_MAX}" -} - -__log_stdin() { - cat | awk '{ printf "%s:\t%s\n","'"${prefix}"'", $0 }' -} =20 -__log_args() { - echo "$*" | awk '{ printf "%s:\t%s\n","'"${prefix}"'", $0 }' } =20 log() { - local prefix=3D"$1" + local redirect + local prefix =20 - shift - local redirect=3D if [[ ${VERBOSE} -eq 0 ]]; then redirect=3D/dev/null else redirect=3D/dev/stdout fi =20 + prefix=3D"${LOG_PREFIX:-}" + if [[ "$#" -eq 0 ]]; then - __log_stdin | tee -a "${LOG}" > ${redirect} + if [[ -n "${prefix}" ]]; then + awk -v prefix=3D"${prefix}" '{printf "%s: %s\n", prefix, $0}' + else + cat + fi else - __log_args "$@" | tee -a "${LOG}" > ${redirect} - fi -} - -log_setup() { - log "setup" "$@" + if [[ -n "${prefix}" ]]; then + echo "${prefix}: " "$@" + else + echo "$@" + fi + fi | tee -a "${LOG}" > "${redirect}" } =20 log_host() { - local testname=3D$1 - - shift - log "test:${testname}:host" "$@" + LOG_PREFIX=3Dhost log "$@" } =20 log_guest() { - local testname=3D$1 - - shift - log "test:${testname}:guest" "$@" + LOG_PREFIX=3Dguest log "$@" } =20 test_vm_server_host_client() { - local testname=3D"${FUNCNAME[0]#test_}" =20 vm_ssh -- "${VSOCK_TEST}" \ --mode=3Dserver \ --control-port=3D"${TEST_GUEST_PORT}" \ --peer-cid=3D2 \ - 2>&1 | log_guest "${testname}" & + 2>&1 | log_guest & =20 vm_wait_for_listener "${TEST_GUEST_PORT}" =20 @@ -332,18 +323,17 @@ test_vm_server_host_client() { --mode=3Dclient \ --control-host=3D127.0.0.1 \ --peer-cid=3D"${VSOCK_CID}" \ - --control-port=3D"${TEST_HOST_PORT}" 2>&1 | log_host "${testname}" + --control-port=3D"${TEST_HOST_PORT}" 2>&1 | log_host =20 return $? } =20 test_vm_client_host_server() { - local testname=3D"${FUNCNAME[0]#test_}" =20 ${VSOCK_TEST} \ --mode "server" \ --control-port "${TEST_HOST_PORT_LISTENER}" \ - --peer-cid "${VSOCK_CID}" 2>&1 | log_host "${testname}" & + --peer-cid "${VSOCK_CID}" 2>&1 | log_host & =20 host_wait_for_listener =20 @@ -351,19 +341,18 @@ test_vm_client_host_server() { --mode=3Dclient \ --control-host=3D10.0.2.2 \ --peer-cid=3D2 \ - --control-port=3D"${TEST_HOST_PORT_LISTENER}" 2>&1 | log_guest "${testna= me}" + --control-port=3D"${TEST_HOST_PORT_LISTENER}" 2>&1 | log_guest =20 return $? } =20 test_vm_loopback() { - local testname=3D"${FUNCNAME[0]#test_}" local port=3D60000 # non-forwarded local port =20 vm_ssh -- "${VSOCK_TEST}" \ --mode=3Dserver \ --control-port=3D"${port}" \ - --peer-cid=3D1 2>&1 | log_guest "${testname}" & + --peer-cid=3D1 2>&1 | log_guest & =20 vm_wait_for_listener "${port}" =20 @@ -371,7 +360,7 @@ test_vm_loopback() { --mode=3Dclient \ --control-host=3D"127.0.0.1" \ --control-port=3D"${port}" \ - --peer-cid=3D1 2>&1 | log_guest "${testname}" + --peer-cid=3D1 2>&1 | log_guest =20 return $? } @@ -399,25 +388,25 @@ run_test() { =20 host_oops_cnt_after=3D$(dmesg | grep -i 'Oops' | wc -l) if [[ ${host_oops_cnt_after} -gt ${host_oops_cnt_before} ]]; then - echo "FAIL: kernel oops detected on host" | log_host "${name}" + echo "FAIL: kernel oops detected on host" | log_host rc=3D$KSFT_FAIL fi =20 host_warn_cnt_after=3D$(dmesg --level=3Dwarn | grep -c -i 'vsock') if [[ ${host_warn_cnt_after} -gt ${host_warn_cnt_before} ]]; then - echo "FAIL: kernel warning detected on host" | log_host "${name}" + echo "FAIL: kernel warning detected on host" | log_host rc=3D$KSFT_FAIL fi =20 vm_oops_cnt_after=3D$(vm_ssh -- dmesg | grep -i 'Oops' | wc -l) if [[ ${vm_oops_cnt_after} -gt ${vm_oops_cnt_before} ]]; then - echo "FAIL: kernel oops detected on vm" | log_host "${name}" + echo "FAIL: kernel oops detected on vm" | log_host rc=3D$KSFT_FAIL fi =20 vm_warn_cnt_after=3D$(vm_ssh -- dmesg --level=3Dwarn | grep -c -i 'vsock') if [[ ${vm_warn_cnt_after} -gt ${vm_warn_cnt_before} ]]; then - echo "FAIL: kernel warning detected on vm" | log_host "${name}" + echo "FAIL: kernel warning detected on vm" | log_host rc=3D$KSFT_FAIL fi =20 @@ -452,10 +441,10 @@ handle_build =20 echo "1..${#ARGS[@]}" =20 -log_setup "Booting up VM" +log_host "Booting up VM" vm_start vm_wait_for_ssh -log_setup "VM booted up" +log_host "VM booted up" =20 cnt_pass=3D0 cnt_fail=3D0 --=20 2.47.3