mirror of
https://github.com/torvalds/linux.git
synced 2026-08-02 13:22:02 +02:00
Merge branch 'selftests-vsock-support-nested-vm-runner-for-vmtest-sh'
Bobby Eshleman says: ==================== selftests/vsock: support nested VM runner for vmtest.sh This series fixes a few issues trying to launch vmtest.sh in a nested VM environment and were discovered when trying to prepare the tests for netdev CI/CD. When taken together these patches make vmtest.sh work both on bare metal and in nested VMs, regardless of the outer VM's user, coincidental path overlaps, or filesystem settings. ==================== Link: https://patch.msgid.link/20260317-vsock-vmtest-nested-fixes-v2-0-0b3f53b80a0f@meta.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
64cf4b95de
|
|
@ -42,6 +42,8 @@ readonly KERNEL_CMDLINE="\
|
|||
virtme.ssh virtme_ssh_channel=tcp virtme_ssh_user=$USER \
|
||||
"
|
||||
readonly LOG=$(mktemp /tmp/vsock_vmtest_XXXX.log)
|
||||
readonly TEST_HOME="$(mktemp -d /tmp/vmtest_home_XXXX)"
|
||||
readonly SSH_KEY_PATH="${TEST_HOME}"/.ssh/id_ed25519
|
||||
|
||||
# Namespace tests must use the ns_ prefix. This is checked in check_netns() and
|
||||
# is used to determine if a test needs namespace setup before test execution.
|
||||
|
|
@ -257,7 +259,12 @@ vm_ssh() {
|
|||
|
||||
shift
|
||||
|
||||
${ns_exec} ssh -q -o UserKnownHostsFile=/dev/null -p "${SSH_HOST_PORT}" localhost "$@"
|
||||
${ns_exec} ssh -q \
|
||||
-i "${SSH_KEY_PATH}" \
|
||||
-o UserKnownHostsFile=/dev/null \
|
||||
-o StrictHostKeyChecking=no \
|
||||
-p "${SSH_HOST_PORT}" \
|
||||
localhost "$@"
|
||||
|
||||
return $?
|
||||
}
|
||||
|
|
@ -265,6 +272,7 @@ vm_ssh() {
|
|||
cleanup() {
|
||||
terminate_pidfiles "${!PIDFILES[@]}"
|
||||
del_namespaces
|
||||
rm -rf "${TEST_HOME}"
|
||||
}
|
||||
|
||||
check_args() {
|
||||
|
|
@ -382,6 +390,12 @@ handle_build() {
|
|||
popd &>/dev/null
|
||||
}
|
||||
|
||||
setup_home() {
|
||||
mkdir -p "$(dirname "${SSH_KEY_PATH}")"
|
||||
ssh-keygen -t ed25519 -f "${SSH_KEY_PATH}" -N "" -q
|
||||
cp "${VSOCK_TEST}" "${TEST_HOME}"/vsock_test
|
||||
}
|
||||
|
||||
create_pidfile() {
|
||||
local pidfile
|
||||
|
||||
|
|
@ -470,11 +484,14 @@ vm_start() {
|
|||
--run \
|
||||
${kernel_opt} \
|
||||
${verbose_opt} \
|
||||
--rwdir=/root="${TEST_HOME}" \
|
||||
--force-9p \
|
||||
--cwd /root \
|
||||
--qemu-opts="${qemu_opts}" \
|
||||
--qemu="${qemu}" \
|
||||
--user root \
|
||||
--append "${KERNEL_CMDLINE}" \
|
||||
--rw &> ${logfile} &
|
||||
&> ${logfile} &
|
||||
|
||||
timeout "${WAIT_QEMU}" \
|
||||
bash -c 'while [[ ! -s '"${pidfile}"' ]]; do sleep 1; done; exit 0'
|
||||
|
|
@ -604,7 +621,7 @@ vm_vsock_test() {
|
|||
# log output and use pipefail to respect vsock_test errors
|
||||
set -o pipefail
|
||||
if [[ "${host}" != server ]]; then
|
||||
vm_ssh "${ns}" -- "${VSOCK_TEST}" \
|
||||
vm_ssh "${ns}" -- ./vsock_test \
|
||||
--mode=client \
|
||||
--control-host="${host}" \
|
||||
--peer-cid="${cid}" \
|
||||
|
|
@ -612,7 +629,7 @@ vm_vsock_test() {
|
|||
2>&1 | log_guest
|
||||
rc=$?
|
||||
else
|
||||
vm_ssh "${ns}" -- "${VSOCK_TEST}" \
|
||||
vm_ssh "${ns}" -- ./vsock_test \
|
||||
--mode=server \
|
||||
--peer-cid="${cid}" \
|
||||
--control-port="${port}" \
|
||||
|
|
@ -1551,6 +1568,7 @@ check_deps
|
|||
check_vng
|
||||
check_socat
|
||||
handle_build
|
||||
setup_home
|
||||
|
||||
echo "1..${#ARGS[@]}"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user