From patchwork Fri Feb 9 07:01:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13550931 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 1E19A657B0; Fri, 9 Feb 2024 07:02:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707462125; cv=none; b=krcyWccXP9wdu64WEj++O1KgBu3pjQuVsTSjlOhmiQZ+8CbGf3gn+ctj6gcMySPUSTuwqi/TOw2AvmBbAg7fse6poKSDiuPF3dhfbiqpKB1bm9hQc1Tv8onxGoO8gsLjMkhTTSfHwuyo20hRv6kabng05+UJJUpUbUbP3CE6h4E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707462125; c=relaxed/simple; bh=UVP1Wum4p+fkBQmbGH46gx3YuxcNQtb06PxYoUjG2iA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GU4gHi6O7qTtPdffQ341lIydhBK08+mZhtqKeqqnaBql8X59wkNr/TNe35obAe1gtbfQK/vw5VZ3XY7PaC3njqxv7ImQUmWnM0oAN4V2uF5Bss+7ej8mw8s75Y8AsKd23y4lBKWAqC/FTsKco52Suo6vCuLxrwsi6MVVen0Re8U= 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=bNmx02Cf; arc=none smtp.client-ip=209.85.214.176 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="bNmx02Cf" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1d934c8f8f7so5021145ad.2; Thu, 08 Feb 2024 23:02:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707462123; x=1708066923; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eL749GGZxcw+dNDSidA1ZYGeUwGyyiY2EeTAJqo21lY=; b=bNmx02CfRJNlitkHs2t9G92FHSVbAjNtXR971xxiCwKbBrmKPBYWxdDx8u2PYpl9yI WoY1R40CQnwleahHn9vLZS7rxBb/suXujXryjYFF1QQIZkaHoWwp26graGbBgAu+7Uiv rrgcxiRN1PpPonW7a3CUAe986ABH0AuQb+jntriyc4kTyRyMOoZqCq9HDD6R4jhwQseM 781e8DNCaopsOSk3HoArrzpOZnfVFil2vUKaifb/K/7vsyY1fkep58ljC4fSJiL/fHmt aYK8hO1cNfFthelyMDcQcreGEeymOvxxyfV5JE3JUEwHEM95uFzQPwo+5VDTJRHuwsbN qqVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707462123; x=1708066923; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eL749GGZxcw+dNDSidA1ZYGeUwGyyiY2EeTAJqo21lY=; b=X5uQCSaduanfAwatFXOvqIE0zIJLg36n85prOmihoMeGZxVEbANQfoTQC9Fd75JIe4 q6haimu6JY/iWdnzAGsGv9F86MrO0PpR7a9scxKWqOkKJZdKTP2R2H9xyWSZWCoIo7ht Uv6VxSxFtj5ksijop0GGIHJGF4knJmPIwPm1bJIsx3hU0DzU97V0Y1yY+sOpCNwZwT+v 3JHxNEdjNJp+TyDAuc+cM8wA5fv5ZoYfK+FN14i4E8p1ATKn92AxIXAHvh2UgQkVRL/e kY5nWA7ueMUJDfwrJOzADkdxd9YB6kFFTzrcMcO6jF3kDbc05rLCdPPqGLcG1q5x6n0J sZLQ== X-Forwarded-Encrypted: i=1; AJvYcCXMViDzGauYhyRjQ/3KG614IPVwcWm/PDb5qYpjNHGSxBP6H3KvRtBmXHuLEiiLaGJWXIorVX/7TMEVZofuTTyJG4hmIJHdcr17DwaYRNilpzsQ7y9OsmXhnxZ7dYKqyw== X-Gm-Message-State: AOJu0YyMj6lFzezSWwcOwtJhwlPzcfJbZ/ApULPUND8XavVvacK0U06i 9gao5z1ni3Yg/VdUp4H+8o0FIY29dhzO2c7zCBeuV9qRhsuySP8X X-Google-Smtp-Source: AGHT+IEdJEZPg4RmRriNJvZ9ahIM21K97ubmmeCO1CKYdbqQsQThckXb2cLmncRYSvscNc6GGM/MAQ== X-Received: by 2002:a17:90b:18b:b0:28d:1e1b:d73b with SMTP id t11-20020a17090b018b00b0028d1e1bd73bmr549771pjs.19.1707462123256; Thu, 08 Feb 2024 23:02:03 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXAx3a693s2l69Ut2KmKGU4vE2ZC23IXFwaBq60nxdhXQH/wHqINSDRVEggFL83Uw2MwTD9HerALBagZpD8L1eLx4n8TkjqzJ1EGYIMSlHivyd5ypAco80tPfYCz8Hhg34bjv7ya4IYE/HbC0AqAGovAva0WfT4DoOWsO6umPQ+WPMNMsSVVAV6YrXzPXUNjf46OwTbAN+E3I9XhudqgT3G42OFW05p0f0ADTIl6+x+6xpc+BkKnDEuLGaBB/BqUB2jz51hr6LLF3YkHFzD8NghbacfpFpqTB42Io0ldUdysrN7sPlP4VBANUXFnYvnXnoZsg3HXxn21bbqXtbw8r/hLfPNYHjcYLXHdwKUrha44NHYGWm9DIneZWOA5u1atuzSBY0CETd4h9+sxh1mG7owCB0o0+ZXnqlFbAOozjeWyXn9jMGm+jqBMUF7S5W4yc/bzY/sAz8xGDJrLGWUVSy2CPWb1PfsKmTPZNmUM95l6OTokRvOeYdBLQBzEFZzMCIypPS85Ja35rox/gu4ZJdSZ7xbfoYZk4+nYnsWLWrlcarZSyzAyZ9l Received: from wheely.local0.net ([1.146.102.26]) by smtp.gmail.com with ESMTPSA id r10-20020a170903410a00b001d7284b9461sm839285pld.128.2024.02.08.23.01.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 23:02:02 -0800 (PST) From: Nicholas Piggin To: Thomas Huth Cc: Nicholas Piggin , kvm@vger.kernel.org, Laurent Vivier , "Shaoqin Huang" , Andrew Jones , Nico Boehr , Paolo Bonzini , Alexandru Elisei , Eric Auger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Marc Hartmayer , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kvmarm@lists.linux.dev, kvm-riscv@lists.infradead.org Subject: [kvm-unit-tests PATCH v3 1/8] arch-run: Fix TRAP handler recursion to remove temporary files properly Date: Fri, 9 Feb 2024 17:01:34 +1000 Message-ID: <20240209070141.421569-2-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240209070141.421569-1-npiggin@gmail.com> References: <20240209070141.421569-1-npiggin@gmail.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Migration files were not being removed when the QEMU process is interrupted (e.g., with ^C). This is becaus the SIGINT propagates to the bash TRAP handler, which recursively TRAPs due to the 'kill 0' in the handler. This eventually crashes bash. This can be observed by interrupting a long-running test program that is run with MIGRATION=yes, /tmp/mig-helper-* files remain afterwards. Removing TRAP recursion solves this problem and allows the EXIT handler to run and clean up the files. This also moves the trap handler before temp file creation, and expands the name variables at trap-time rather than install-time, which closes the small race between creation trap handler install. Reviewed-by: Thomas Huth Signed-off-by: Nicholas Piggin Reviewed-by: Thomas Huth --- scripts/arch-run.bash | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index d0864360..11d47a85 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -129,6 +129,9 @@ run_migration () return 77 fi + trap 'trap - TERM ; kill 0 ; exit 2' INT TERM + trap 'rm -f ${migout1} ${migsock} ${qmp1} ${qmp2} ${fifo}' RETURN EXIT + migsock=$(mktemp -u -t mig-helper-socket.XXXXXXXXXX) migout1=$(mktemp -t mig-helper-stdout1.XXXXXXXXXX) qmp1=$(mktemp -u -t mig-helper-qmp1.XXXXXXXXXX) @@ -137,9 +140,6 @@ run_migration () qmpout1=/dev/null qmpout2=/dev/null - trap 'kill 0; exit 2' INT TERM - trap 'rm -f ${migout1} ${migsock} ${qmp1} ${qmp2} ${fifo}' RETURN EXIT - eval "$@" -chardev socket,id=mon1,path=${qmp1},server=on,wait=off \ -mon chardev=mon1,mode=control | tee ${migout1} & live_pid=`jobs -l %+ | grep "eval" | awk '{print$2}'` @@ -209,11 +209,11 @@ run_panic () return 77 fi - qmp=$(mktemp -u -t panic-qmp.XXXXXXXXXX) - - trap 'kill 0; exit 2' INT TERM + trap 'trap - TERM ; kill 0 ; exit 2' INT TERM trap 'rm -f ${qmp}' RETURN EXIT + qmp=$(mktemp -u -t panic-qmp.XXXXXXXXXX) + # start VM stopped so we don't miss any events eval "$@" -chardev socket,id=mon1,path=${qmp},server=on,wait=off \ -mon chardev=mon1,mode=control -S & From patchwork Fri Feb 9 07:01:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13550932 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 37EA6657AB; Fri, 9 Feb 2024 07:02:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707462135; cv=none; b=SuynooI5+6kI5+4E8N3DVz7AvkNUfgYZSFsxt/jfPdAE+Se3wkgulGI6sCwlkVHJtpf3f3uQ6KClLc1LgEEeReOefX8fhLPaBbiz1AsIrk07jjyubvi73qKkJ4i2JFiZie8mQPsov0Sh8Oa27Z8RAXyjZq79kI4JaSvH0yNwV80= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707462135; c=relaxed/simple; bh=59F2uXNROyyrYFD80n4UUCXU0uos2PlTu+KS2KayEdk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TOM0ax/CXgtGqmqES8jG7yEsZqMsRdVvMnakC7nxyQzfbaR5SEls4BnWlAcT7r5v9cKQMZ0eVZIiyfiCVRb2EguNWse+8/SkkFPmzrYlXl7prD3xWCstsZJdVfCaO7urKlS8Ek/tYgm+xT3oHCEX88M/yF61C509Tbrmdn8KxIw= 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=Da73FEj5; arc=none smtp.client-ip=209.85.214.180 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="Da73FEj5" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1da0cd9c0e5so5128575ad.0; Thu, 08 Feb 2024 23:02:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707462132; x=1708066932; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PZWJe/FfY+0lZ+B78melC7fte3uc1Gnzj5kPj86WV+c=; b=Da73FEj5OlolUKvvdWUXFDazMDY8iUxI9H3x7JF+MS51S5N7KDVHJ/qteLjaq6V6gB FbAI5XhFH2TibUW8cuCvnEwuOmhxUK+YNpFEB3D0MLJrVXHCe0My6uR0V6EOlDhTXFTk stM2KVQR+brT/8oih/AVIaSwFc9s/kxhyBlH4Vy7e4SHqkwonD3zXb9JWWdiI2jRAC+x cTbgCy59m1n9tlU5MT+nesnj3SiU1nyTte/OuRvfdTloDcyM73YQq4i6NR7Xs8xKawOF QBr99em4xWm6Xdy6ct0Hw9x7teG0GUEpd9KZos3z/lSWHrzkanxUopODtxEurTUtborS Ph1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707462132; x=1708066932; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PZWJe/FfY+0lZ+B78melC7fte3uc1Gnzj5kPj86WV+c=; b=vRJ4Da68mqa5f5cbby+gFcqI09gx/kYcfB/XvDRhvOjL7AxhXK7mBV6RRulxFHnx5i 7mmAfUE8zV3y2x5ZRK1VVWV33T/Quy0phYz6MJCj9ijnoLfRMyN105Om3SwkGtEqAXV6 az6tmmKOvtJ3I4x/htpV2/ZOPHVOEJEBMs21nT1UqDAVTuN4Rx4+7Hf0wdYcL3+eKkXy cnnut4NnxsXp2iLsSVvYpWn69TrpMBWOzLARrNN7VjZ1AWglpLtWdV9uMZD1jF3pzFo5 Q353h+egqA6Qmn4U+CzsXzpAp6WXnRuT3M0JvQ5zo5xSM6AA5X9WfM8mdObPwh8s500M 0rlA== X-Gm-Message-State: AOJu0Yx/uO+cjyJL3i/SgAuMqW/ZFq7VBcyhWBq/tiWWxISj3r6c9C2W OG+s0mQ6FQlMUapafMegqDzUwE+Yx1tvuxzM4Hs0PBMnKOmFKHtt X-Google-Smtp-Source: AGHT+IHOeahmko/f+RwAZAHEJWia2rOHYMfGMz4gCsHP+DywjdnF57Ty4tjhGRk1+lg6vAvd2PgMDA== X-Received: by 2002:a17:903:22cb:b0:1d9:efc7:1c4e with SMTP id y11-20020a17090322cb00b001d9efc71c4emr251590plg.6.1707462132399; Thu, 08 Feb 2024 23:02:12 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUjW0aiDCaCLLFfVUVr5+bjGqa7mzeF+p3ViNkQqbgtcj0Il6d+i/6lELOrZwAv2VLO/QuGkDOmTrZv2VMUIMsKQgyI4X6EJsrbFOqX3EwTBCt77J+G785rbh7UEFgzoGo0MeZTvVYFPZD7/1PJ01abi+YorczJW6k6akDxzxMXt9g2gLdOpy3QIpkuiqBIzAePfI7P128W0t4bkitbTsDbBr98gnEpsMuMgQjuH3Si8ur0dF4cnkyVF7dvAjGhMkLgFQmtXBD6lNkbOeef8ggdt/eBtk2c1xZjUn0zCW6G0TMxpZ+4JWMsZF63nPB1q8lKpmVddNx821u3QU0boOD2tlS8wYCQA3O9JUIEQCCb6Qnpm08pHAbnTmgBswHd5imYUiTh9O2eDynpgwF0mNiaOsqavbRC6Jul2MLacr+aprWRyUDanMygM30mw97u0KHVMszGF2zkWJ9/DGlFbxg4mH+LAJXvpwXsmpY+KkbPjxFdxOPeMt3Fc2yK1BQrEDsG6HaRcQ++jE20RCJF/GmJiLzdCsPsWr8F+BeQeiIe7Yj2y2RZ956a Received: from wheely.local0.net ([1.146.102.26]) by smtp.gmail.com with ESMTPSA id r10-20020a170903410a00b001d7284b9461sm839285pld.128.2024.02.08.23.02.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 23:02:11 -0800 (PST) From: Nicholas Piggin To: Thomas Huth Cc: Nicholas Piggin , kvm@vger.kernel.org, Laurent Vivier , "Shaoqin Huang" , Andrew Jones , Nico Boehr , Paolo Bonzini , Alexandru Elisei , Eric Auger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Marc Hartmayer , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kvmarm@lists.linux.dev, kvm-riscv@lists.infradead.org Subject: [kvm-unit-tests PATCH v3 2/8] arch-run: Clean up initrd cleanup Date: Fri, 9 Feb 2024 17:01:35 +1000 Message-ID: <20240209070141.421569-3-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240209070141.421569-1-npiggin@gmail.com> References: <20240209070141.421569-1-npiggin@gmail.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Rather than put a big script into the trap handler, have it call a function. Signed-off-by: Nicholas Piggin --- scripts/arch-run.bash | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index 11d47a85..1e903e83 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -269,10 +269,21 @@ search_qemu_binary () export PATH=$save_path } +initrd_cleanup () +{ + rm -f $KVM_UNIT_TESTS_ENV + if [ "$KVM_UNIT_TESTS_ENV_OLD" ]; then + export KVM_UNIT_TESTS_ENV="$KVM_UNIT_TESTS_ENV_OLD" + else + unset KVM_UNIT_TESTS_ENV + unset KVM_UNIT_TESTS_ENV_OLD + fi +} + initrd_create () { if [ "$ENVIRON_DEFAULT" = "yes" ]; then - trap_exit_push 'rm -f $KVM_UNIT_TESTS_ENV; [ "$KVM_UNIT_TESTS_ENV_OLD" ] && export KVM_UNIT_TESTS_ENV="$KVM_UNIT_TESTS_ENV_OLD" || unset KVM_UNIT_TESTS_ENV; unset KVM_UNIT_TESTS_ENV_OLD' + trap_exit_push 'initrd_cleanup' [ -f "$KVM_UNIT_TESTS_ENV" ] && export KVM_UNIT_TESTS_ENV_OLD="$KVM_UNIT_TESTS_ENV" export KVM_UNIT_TESTS_ENV=$(mktemp) env_params From patchwork Fri Feb 9 07:01:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13550933 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 709D9651B4; Fri, 9 Feb 2024 07:02:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707462142; cv=none; b=eZuvFUcNckXiTumMeZ+x0LbQxWTbD2m3G4R4vVe8LgWOIfJEb3NJ58SH79UBfRY6LXo9ZuQ/0Dhy30tyJ0WN3NcxRN7yK3UsyNC6Qu0Gf/00NtLjzF8wZlwiK8+VoBj6ZJXxFYejhxoNzoLIruBgmmubOwib3F8pntUZmYWKwao= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707462142; c=relaxed/simple; bh=btWNyJ/RiVRASaF6/39ABlcJIFLw0hx7QpaEdND75ag=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qXWJsDeABUloOHd+2s6NCYKY72ceILWPFKEVKxLtt8o4WJzNyO/+xawbrwTFbC6n1QyRMSUQtSJ/0cyWSqIj+CghDKuFkmyY1YUc0zdjJB1KPrqbheJZU4yTxNO+tGMHq8rBzU7J9+KKpGqbolFeSSzD2k3j44lJVSXES2QTAY8= 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=OibR6Mkt; arc=none smtp.client-ip=209.85.214.179 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="OibR6Mkt" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1d9bd8fa49eso5053325ad.1; Thu, 08 Feb 2024 23:02:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707462141; x=1708066941; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vH3i7c2rdDusoO9l0oYKXVEfYgOTk0BIl82whiOKoAA=; b=OibR6Mkt6HG1SeURSNAdtABpRMttQRcSqYZ87je2RpJMzgrkrnUAVBq8w8xEbIGBaX l4+GoEIyXwpw6etXG0ESQxyTIwdFlXJ6WKZUipIGgn578Dke6a/YizVfFOkb4kBPpEYX UCGEg15MROER+N0i4rwJ19oPzfQheGc8zVsKDIrduPoaR8Le+A80oXMiodtVnow17VrX rcDdzQPMzhzFugeKUsjYN99yrP4uE6Dfqf+D+D/lORc/5n6CjXCrU39ulGqRUeutYBTw aMZhCQreGYFshs+sd8G0nIAOkbFlqkAUz9GX9/ZQy0HjpAnwkEmxkuCcXvsRNsiTySzd Foxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707462141; x=1708066941; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vH3i7c2rdDusoO9l0oYKXVEfYgOTk0BIl82whiOKoAA=; b=Miyuk7xsq2CdBuuGNQEBvG3F8YR9swHk6prCiUUEwzn8Y7n4kXCbmXGV7QfxYokhLg SUB+8IY7OEEKgOzJReGzaiIeOhYrlWRc33smVqmWwhEU2kcOYuHSX2KWDOgSLNq0ghy9 f6UAwPT5y/OeGVu3YlO8eQhTE9Oqt6y5U7JeZg1OK7kOPiNJV66UpUf21P2gMVKHEuhG 8G81Q7rhPmOEz4KuAt/pxovZScFC3PR78J94CU7vjBcLrSGvYPDXu8KUsk9LICgnbrNZ QF3l5rNXRUTb7HGsoz6hOhcshjohEO6utq9W2opNctTDepUvBvvo8YtNhHMo2xGlaB2n 7yGA== X-Forwarded-Encrypted: i=1; AJvYcCW2nmzwclteQQ3Kk//A7R+obNFwBTJYgmNeDrnKw6MBI/f/u5Ul1tJhGPtdcPLalkhXolXvReFUUvFZ/RpZu6DwMIUYV7pfcJL85lqzurVwtfLQTThWHznxUNgCgJuyRA== X-Gm-Message-State: AOJu0YzyoyLyp1+nixZ/RUdsn08IEIckpnLebX9XD2kl4/FHiu4ouAuq G/4Ntz9KTPZglYhgZlJibCWkZ3e7D5o+B+OUg1/1c5iYPqKMZhL8 X-Google-Smtp-Source: AGHT+IFpcSgXgc2Pcdk1s+DGllDRanvp4qFa/hQemAtrKxUbxZjddPhfIOf9iXD5cVWfbfVbrQ/D5w== X-Received: by 2002:a17:903:18e:b0:1d9:d300:a670 with SMTP id z14-20020a170903018e00b001d9d300a670mr877486plg.15.1707462140710; Thu, 08 Feb 2024 23:02:20 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWL7Y2HotGSsYV2teE21T1pi//Ty5QF4kXvFsWSIafNuJsAO3MdpE0xNs70oRHlkPzvlweKPlY/8NnoJ8Rsb8cukQkZw+68Z5QSNfUfNdmODTSgqvFjyszroItLiVTDAdeUhP9LFuIuX+Uju7ap+Lz1EMvexMEjb/B9p2DufbSDyBaJUkktaWqJP9nvgcFqgFg560PLWmmaa23cF6BVopZ1/UmkHIgJFimgDzVO1V7oFGPOVU5ql0AOYjueX9ujRNV4bF12YISbbSmk/s5JGaptqLnfCDz+eCPM31L6Z6qNuLePOq/7LKvdhpz0VQOH0pyizLsTq60z/7V6tTyyIJ9iFcEDCMSN+J823GoIPWzNLvMVtXrv+ua3FVf3eaNryFzlYO6TFJt0ZYrJMrYPX7BCvHnspo+9Pq2LJiNVd8JY3+fKt9h/h+beNkbL1k96JLlFMzGOyPPdfTWHRn88I/eqDVq/JFQkPn+Hll2fiMbqsZ8vDur/NYYW6n3grqy5i9qnk4H1YLx8Dyz+w0oSMAtp43SrwqkEnPDRbrzuPF/nMuSoHqeviQRI Received: from wheely.local0.net ([1.146.102.26]) by smtp.gmail.com with ESMTPSA id r10-20020a170903410a00b001d7284b9461sm839285pld.128.2024.02.08.23.02.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 23:02:20 -0800 (PST) From: Nicholas Piggin To: Thomas Huth Cc: Nicholas Piggin , kvm@vger.kernel.org, Laurent Vivier , "Shaoqin Huang" , Andrew Jones , Nico Boehr , Paolo Bonzini , Alexandru Elisei , Eric Auger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Marc Hartmayer , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kvmarm@lists.linux.dev, kvm-riscv@lists.infradead.org Subject: [kvm-unit-tests PATCH v3 3/8] migration: use a more robust way to wait for background job Date: Fri, 9 Feb 2024 17:01:36 +1000 Message-ID: <20240209070141.421569-4-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240209070141.421569-1-npiggin@gmail.com> References: <20240209070141.421569-1-npiggin@gmail.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Starting a pipeline of jobs in the background does not seem to have a simple way to reliably find the pid of a particular process in the pipeline (because not all processes are started when the shell continues to execute). The way PID of QEMU is derived can result in a failure waiting on a PID that is not running. This is easier to hit with subsequent multiple-migration support. Changing this to use $! by swapping the pipeline for a fifo is more robust. Signed-off-by: Nicholas Piggin Reviewed-by: Thomas Huth --- scripts/arch-run.bash | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index 1e903e83..3689d7c2 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -130,19 +130,22 @@ run_migration () fi trap 'trap - TERM ; kill 0 ; exit 2' INT TERM - trap 'rm -f ${migout1} ${migsock} ${qmp1} ${qmp2} ${fifo}' RETURN EXIT + trap 'rm -f ${migout1} ${migout_fifo1} ${migsock} ${qmp1} ${qmp2} ${fifo}' RETURN EXIT migsock=$(mktemp -u -t mig-helper-socket.XXXXXXXXXX) migout1=$(mktemp -t mig-helper-stdout1.XXXXXXXXXX) + migout_fifo1=$(mktemp -u -t mig-helper-fifo-stdout1.XXXXXXXXXX) qmp1=$(mktemp -u -t mig-helper-qmp1.XXXXXXXXXX) qmp2=$(mktemp -u -t mig-helper-qmp2.XXXXXXXXXX) fifo=$(mktemp -u -t mig-helper-fifo.XXXXXXXXXX) qmpout1=/dev/null qmpout2=/dev/null + mkfifo ${migout_fifo1} eval "$@" -chardev socket,id=mon1,path=${qmp1},server=on,wait=off \ - -mon chardev=mon1,mode=control | tee ${migout1} & - live_pid=`jobs -l %+ | grep "eval" | awk '{print$2}'` + -mon chardev=mon1,mode=control > ${migout_fifo1} & + live_pid=$! + cat ${migout_fifo1} | tee ${migout1} & # We have to use cat to open the named FIFO, because named FIFO's, unlike # pipes, will block on open() until the other end is also opened, and that @@ -150,7 +153,7 @@ run_migration () mkfifo ${fifo} eval "$@" -chardev socket,id=mon2,path=${qmp2},server=on,wait=off \ -mon chardev=mon2,mode=control -incoming unix:${migsock} < <(cat ${fifo}) & - incoming_pid=`jobs -l %+ | awk '{print$2}'` + incoming_pid=$! # The test must prompt the user to migrate, so wait for the "migrate" keyword while ! grep -q -i "Now migrate the VM" < ${migout1} ; do @@ -164,6 +167,10 @@ run_migration () sleep 1 done + # Wait until the destination has created the incoming and qmp sockets + while ! [ -S ${migsock} ] ; do sleep 0.1 ; done + while ! [ -S ${qmp2} ] ; do sleep 0.1 ; done + qmp ${qmp1} '"migrate", "arguments": { "uri": "unix:'${migsock}'" }' > ${qmpout1} # Wait for the migration to complete From patchwork Fri Feb 9 07:01:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13550934 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 38FFE651B4; Fri, 9 Feb 2024 07:02:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707462151; cv=none; b=sN+cdkaSfjEoG/88KiPEo0BxDCgsrKZ5zVqpjx57WQ5K/Xqe/Cz/H9vouh9pm7rslfxkNyuFgkks5vmMRsZrWZhopSNcOFcmHRkBneTlot/nyGRlN/6bZ9XEoXMd6WOxZMK1Ux3aZliOLFVduIDSRiIG8qsAdJhKrtzqS2nm1sI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707462151; c=relaxed/simple; bh=Gg7afgpKgLqxRrIVkPZ3CNm/sV/oLsSSBPr/dtBKVug=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gUrT/VV4m9FreD27F1N4QOGmVPQhQAhiihhTNc07yZY+T4/ygHLyaI0IMp4IfQ5TRXPiC8vH4LPWqpznM4RYMTBj3b6jj1ZGr50pswCc/WAP+lIEwv31gitXjpOil6DkY7vBv4LYFdvgXhfEhyTqeOx78QeYbDhjogD5dxPLvnY= 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=kNHTyj4R; arc=none smtp.client-ip=209.85.214.174 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="kNHTyj4R" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1d934c8f8f7so5023505ad.2; Thu, 08 Feb 2024 23:02:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707462149; x=1708066949; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DpqZHmKQT++Y4YOLTxyI6uDILUR5f0/cqNvHxqH8mFw=; b=kNHTyj4RSMAxYU/5DDb05KClcOi4Y35A0oCM/WYNH444Z4l9rV+P0tuBrx7UfWY9Ki 6VWNtrZ/oVhhLHkEX6b8h8MSjdzMYZeNq7ZX8sgGIGHWx/cS2P5fIEIth5MhvbtE7l3+ TAk0urTDVt9AbiFRDO9bE1IL1VJcSv3IQxp+gqrKlrDmfdnnHT4/TLmxhMjWzmlvSLS/ YjlhIILNV0GGEfbrLm5+IZSRX53GyJGUjsf9bbBF9+1op+HtZ10zNC21mvUNOQazy3yu mdaatUWemPszH8dk3R4xBHVQQQ4in6t3JaXdEEDv+LSc0R1FqfVhDVLHtGLqzR0BFyPX SfIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707462149; x=1708066949; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DpqZHmKQT++Y4YOLTxyI6uDILUR5f0/cqNvHxqH8mFw=; b=IixueKTF6C3j1y6S3aCyaLDvs5zFLzf235foQdKJ/KlUqQyFlf2ldSuPcKNNdtIiU9 /1XgSYN6MrEROC1pkxCPQEtkOSwAjkT4XfvOClvoKpi3tJwbxwwdBkQPOZFDCb0Xvuye WBHMK9xKUshHioO2AWMaYvfiLd6AZ5RIdLN28JLrtykGKhxZ8pTHjdl1+uk21wv1pZZy /lS+o0yneyOxRha+lozHvxEiok9B/VzvfjqKmvjAL+Ul6WRWtleNbyj8f8Z3verbDImt fv5u0PTAufmpykqZWgrP3qcICp7PjtaN74/OHRZ+io2AL7GEB2ON7K3Gg5Ao0SPQKtbL a/3w== X-Gm-Message-State: AOJu0YxKpsABMss5lWsJOYZsrGSIacnafuMiau6T3HIJOi8aymigOY9U DLF/oT1nFvz3inNk0/UoRyUSDBwcHUJRAgjU9OMaSknKwa+e5iqOnR11DpZi X-Google-Smtp-Source: AGHT+IE2tIcOzUjaHbEFDbBS5ugMbCwQY5qSy1ZC290ksdvjYfnwFlD/RrP/ga59ZKlW8QV7r/wUFg== X-Received: by 2002:a17:902:c40e:b0:1d9:d444:313 with SMTP id k14-20020a170902c40e00b001d9d4440313mr904753plk.43.1707462149502; Thu, 08 Feb 2024 23:02:29 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUgb6TKnUtHNlr8ipsjz4i1op2gc+f7F4d9VegZaGXA20hmCD99A/dslBGtMaI+Pav04qe5ou2LwgxvwZgseJGgy1Bc+fZw2A7XsD994oakvysOOyE6btj4338nDFtq65ODbJmey8AYyYSVi8+QTbf/HosjEZNzpJKHOJCb7p8rz06sgGaRYpSfN/8/RzcoJzWeMTXp7tjovHRok7nk1ir4/AO2QuMZNX9dp2ydB3YMDWkwfcmYqG17aismMgV98MEYGLrqOpBk8X5WIRDMeSzhyehmrhjPs36Z59IsMuscXZAbEuxNdEzRMTc5ZBbnVQEgwrvwJYzTirPHlYjKaWLBjA8BvA4zZM1kzBYiFJkf5ADxFJYFA+ZIh1b9720ojImzI7dMfJ5m6DfOENpqMniqONd4fMi/hcfDojYzuqw4vGoxWqztQSFRq4+YerCfnohjOwdEt/NOf3nJSlLeOn8Ts+3SMRcGAWXFVT55/R7vfNhjALDmO9h6pELO2lCPwBrLSJQyswnNvJkwHiNJ+V3aIgfULqC+y3zBD4YNmrhZYKrRBETlwpN3 Received: from wheely.local0.net ([1.146.102.26]) by smtp.gmail.com with ESMTPSA id r10-20020a170903410a00b001d7284b9461sm839285pld.128.2024.02.08.23.02.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 23:02:29 -0800 (PST) From: Nicholas Piggin To: Thomas Huth Cc: Nicholas Piggin , kvm@vger.kernel.org, Laurent Vivier , "Shaoqin Huang" , Andrew Jones , Nico Boehr , Paolo Bonzini , Alexandru Elisei , Eric Auger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Marc Hartmayer , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kvmarm@lists.linux.dev, kvm-riscv@lists.infradead.org Subject: [kvm-unit-tests PATCH v3 4/8] migration: Support multiple migrations Date: Fri, 9 Feb 2024 17:01:37 +1000 Message-ID: <20240209070141.421569-5-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240209070141.421569-1-npiggin@gmail.com> References: <20240209070141.421569-1-npiggin@gmail.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Support multiple migrations by flipping dest file/socket variables to source after the migration is complete, ready to start again. A new destination is created if the test outputs the migrate line again. Test cases may now switch to calling migrate() one or more times. Signed-off-by: Nicholas Piggin --- lib/migrate.c | 8 ++-- lib/migrate.h | 1 + scripts/arch-run.bash | 93 +++++++++++++++++++++++++++++++++++++------ 3 files changed, 85 insertions(+), 17 deletions(-) diff --git a/lib/migrate.c b/lib/migrate.c index 527e63ae..b7721659 100644 --- a/lib/migrate.c +++ b/lib/migrate.c @@ -8,8 +8,10 @@ #include #include "migrate.h" -/* static for now since we only support migrating exactly once per test. */ -static void migrate(void) +/* + * Initiate migration and wait for it to complete. + */ +void migrate(void) { puts("Now migrate the VM, then press a key to continue...\n"); (void)getchar(); @@ -19,8 +21,6 @@ static void migrate(void) /* * Initiate migration and wait for it to complete. * If this function is called more than once, it is a no-op. - * Since migrate_cmd can only migrate exactly once this function can - * simplify the control flow, especially when skipping tests. */ void migrate_once(void) { diff --git a/lib/migrate.h b/lib/migrate.h index 3c94e6af..2af06a72 100644 --- a/lib/migrate.h +++ b/lib/migrate.h @@ -6,4 +6,5 @@ * Author: Nico Boehr */ +void migrate(void); void migrate_once(void); diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index 3689d7c2..a914ba17 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -129,12 +129,16 @@ run_migration () return 77 fi + migcmdline=$@ + trap 'trap - TERM ; kill 0 ; exit 2' INT TERM - trap 'rm -f ${migout1} ${migout_fifo1} ${migsock} ${qmp1} ${qmp2} ${fifo}' RETURN EXIT + trap 'rm -f ${migout1} ${migout2} ${migout_fifo1} ${migout_fifo2} ${migsock} ${qmp1} ${qmp2} ${fifo}' RETURN EXIT migsock=$(mktemp -u -t mig-helper-socket.XXXXXXXXXX) migout1=$(mktemp -t mig-helper-stdout1.XXXXXXXXXX) migout_fifo1=$(mktemp -u -t mig-helper-fifo-stdout1.XXXXXXXXXX) + migout2=$(mktemp -t mig-helper-stdout2.XXXXXXXXXX) + migout_fifo2=$(mktemp -u -t mig-helper-fifo-stdout2.XXXXXXXXXX) qmp1=$(mktemp -u -t mig-helper-qmp1.XXXXXXXXXX) qmp2=$(mktemp -u -t mig-helper-qmp2.XXXXXXXXXX) fifo=$(mktemp -u -t mig-helper-fifo.XXXXXXXXXX) @@ -142,18 +146,61 @@ run_migration () qmpout2=/dev/null mkfifo ${migout_fifo1} - eval "$@" -chardev socket,id=mon1,path=${qmp1},server=on,wait=off \ + mkfifo ${migout_fifo2} + + eval "$migcmdline" \ + -chardev socket,id=mon1,path=${qmp1},server=on,wait=off \ -mon chardev=mon1,mode=control > ${migout_fifo1} & live_pid=$! cat ${migout_fifo1} | tee ${migout1} & - # We have to use cat to open the named FIFO, because named FIFO's, unlike - # pipes, will block on open() until the other end is also opened, and that - # totally breaks QEMU... + # The test must prompt the user to migrate, so wait for the "migrate" + # keyword + while ! grep -q -i "Now migrate the VM" < ${migout1} ; do + if ! ps -p ${live_pid} > /dev/null ; then + echo "ERROR: Test exit before migration point." >&2 + qmp ${qmp1} '"quit"'> ${qmpout1} 2>/dev/null + return 3 + fi + sleep 0.1 + done + + # This starts the first source QEMU in advance of the test reaching the + # migration point, since we expect at least one migration. Subsequent + # sources are started as the test hits migrate keywords. + do_migration || return $? + + while ps -p ${live_pid} > /dev/null ; do + # Wait for EXIT or further migrations + if ! grep -q -i "Now migrate the VM" < ${migout1} ; then + sleep 0.1 + else + do_migration || return $? + fi + done + + wait ${live_pid} + ret=$? + + while (( $(jobs -r | wc -l) > 0 )); do + sleep 0.1 + done + + return $ret +} + +do_migration () +{ + # We have to use cat to open the named FIFO, because named FIFO's, + # unlike pipes, will block on open() until the other end is also + # opened, and that totally breaks QEMU... mkfifo ${fifo} - eval "$@" -chardev socket,id=mon2,path=${qmp2},server=on,wait=off \ - -mon chardev=mon2,mode=control -incoming unix:${migsock} < <(cat ${fifo}) & + eval "$migcmdline" \ + -chardev socket,id=mon2,path=${qmp2},server=on,wait=off \ + -mon chardev=mon2,mode=control -incoming unix:${migsock} \ + < <(cat ${fifo}) > ${migout_fifo2} & incoming_pid=$! + cat ${migout_fifo2} | tee ${migout2} & # The test must prompt the user to migrate, so wait for the "migrate" keyword while ! grep -q -i "Now migrate the VM" < ${migout1} ; do @@ -164,7 +211,7 @@ run_migration () qmp ${qmp2} '"quit"'> ${qmpout2} 2>/dev/null return 3 fi - sleep 1 + sleep 0.1 done # Wait until the destination has created the incoming and qmp sockets @@ -176,7 +223,7 @@ run_migration () # Wait for the migration to complete migstatus=`qmp ${qmp1} '"query-migrate"' | grep return` while ! grep -q '"completed"' <<<"$migstatus" ; do - sleep 1 + sleep 0.1 if ! migstatus=`qmp ${qmp1} '"query-migrate"'`; then echo "ERROR: Querying migration state failed." >&2 echo > ${fifo} @@ -192,14 +239,34 @@ run_migration () return 2 fi done + qmp ${qmp1} '"quit"'> ${qmpout1} 2>/dev/null + + # keypress to dst so getchar completes and test continues echo > ${fifo} - wait $incoming_pid + rm ${fifo} + + # Ensure the incoming socket is removed, ready for next destination + if [ -S ${migsock} ] ; then + echo "ERROR: Incoming migration socket not removed after migration." >& 2 + qmp ${qmp2} '"quit"'> ${qmpout2} 2>/dev/null + return 2 + fi + + wait ${live_pid} ret=$? - while (( $(jobs -r | wc -l) > 0 )); do - sleep 0.5 - done + # Now flip the variables because dest becomes source + live_pid=${incoming_pid} + tmp=${migout1} + migout1=${migout2} + migout2=${tmp} + tmp=${migout_fifo1} + migout_fifo1=${migout_fifo2} + migout_fifo2=${tmp} + tmp=${qmp1} + qmp1=${qmp2} + qmp2=${tmp} return $ret } From patchwork Fri Feb 9 07:01:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13550935 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (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 7023B56B7B; Fri, 9 Feb 2024 07:02:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707462161; cv=none; b=h1E1Ww4A4GAmnmllZareuoMGytrg2qZXSQ2zLWZuhszTyaQa0b556P6qkEe3n7GnHapR5DLdvgmpkbsqhkEuQVP4Hxv79ReHuhHPVHw+WB2cH1EMEFebiT+DSGkcSicr4hgyBeGmEt5LqV8MYrqbzSEO8leFYk+kFJJTf6UygR0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707462161; c=relaxed/simple; bh=Ggiy/j+eNNquv7fJGl0mDomtLALKGr93XSs0exwN1fM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YfT2GYkfKVXO6ny+6aREiFBO3HbeVt8X4NnEY/e70fUz61+YAVZoWg+vyzZ3lRnnSi7gPNLBGJuRXACciVwoT/GATUCc/dnlFRilWsMuXfm760C0+bb8lDn2JgW+HKM/5xGZdaycdqyycXUE6zVqfAa6hl6nt6j8kAmtY6vwyrs= 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=H2BRQGJR; arc=none smtp.client-ip=209.85.210.181 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="H2BRQGJR" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-6e0518c83c6so417428b3a.0; Thu, 08 Feb 2024 23:02:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707462158; x=1708066958; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cy1X5Ca29tArtn0NovkNFsMlSyreo5G7UR6M9QUaMzw=; b=H2BRQGJR9nSxNmyVy2lYqe/CTpcmu1R1WvRVm6c62JdD+hE3pHPxlvpOA8PYCS2IeG adtU596ZdRy6v+pkoqEmeMbPFyAkZjEMXm1+o6isDJMDEPA409byBOqRtcOrMRHeOtpM uNW+JLuwPWW/Ug4F233vkBuQZflM1cj6NIO8wF2hWnCgaC6u2zkKtOUeKeiAQrcf0uQB ABxhgOwB3+PoKddpoUTZSuiYHa7o4JdPTZ1Dmk2oYORhVvP3+6G2zOx2dXY6eS8BTPa1 VMRITpCR3BXVrbcOzhvBfz1dclujeMt+8RTSexyNRLRCdSb9wm2mjAPMvngwJPQnLWx6 g+jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707462158; x=1708066958; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cy1X5Ca29tArtn0NovkNFsMlSyreo5G7UR6M9QUaMzw=; b=ZOXE7RPunRQ8FvWr7AKmPj5IeHivTESQ/nWUG211zwutpzbyEg0EF+asq4w3w1FkTi 7+6hVk/gmndhwNjIIWlzowP04xU+8xMGde9bt54abCy3EOPIkMrl/njO41adsyAwuwFZ NFEhB2q3LvMxM084A/uGEyHO7+bog4p19nBsi4D7hx4IzXKDDfhlFi8REobSMUMdLDeB sLb6HrJXuXqB1H4kdtQ9vaE4KfFgV8bWYSODuMfmCuoyDRDjijJQAuE6qq5MKjjo1IRs S3uXy8UnEuO3NlJBp+P7j+XpigQthgU1QQ5wUBLAyLMK8vrBg2CmrUK7e8Mxgm0nTFP+ d6DA== X-Forwarded-Encrypted: i=1; AJvYcCV8oJcMEjF8wbIRAAVcZf6vsdosG8A1GtnB8En1176fegMWEdKWg8PxovCefOi/wRZBnO1Ib6Uo7ScMxn45EmoqoVSvUQO5J+ffELQ6K0rTMFybhPjT6L1mfELeFgtR/Q== X-Gm-Message-State: AOJu0YyRHGHNXa4hbeofWno5VnyhFsvImnaY1Uu6SFJS0w6vu+liKQjP HQTcCJXDHDdePvz7XyR66Jjl1Kd+EuLKRID3Jo8+3Jc5EV+4j8WO X-Google-Smtp-Source: AGHT+IGyObXJhAJtuRZSnotzajDKS6+1BQXtukEa0pBvdlsdU+rx6fNsJtri4ZZ4yQH/wfN6q/qLvQ== X-Received: by 2002:a05:6a20:d70f:b0:19b:e91c:1a42 with SMTP id iz15-20020a056a20d70f00b0019be91c1a42mr981104pzb.55.1707462157792; Thu, 08 Feb 2024 23:02:37 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXWAILiGdtpXRUr7E9L3EvTMs439ia4KHvSemZiVQD134LyHPDF51alZyQePs8N9GRrcv2AonRJWQNOwMDtxtn3q3aTo/z1z/1lOobjPcC+hT2oAdS03H9B8USvSh5E9qGsoPDGEAIT0SU5K5yg06Po55yRrSO4l/yTxbYGYB5jXZ9L9WNdutQlL/QgEh8eakjz5RV9/hGjx7h3s9sdIHQuwOpgUFvBrzZch1nv1GZABrPHBTc1qygJTH6Nv1aOaqIQxgF+1FcdRntS2/d/qozZ5R1zNRrQRGIcIajEQAvDmSkqHxe0arg/kmH7bpWUCT1fSWlmNaLr47aFKLM7iiSMRjjO5ZivAISeehm0pZKHjGMJNNG5M5C4brt+iKrPi3tznROuJQkTzZ4p6DeDNRinOFXEPuGX3NIdGS750TrUF/qxsWQKR/7EpNNB95FJ+51yG/5MpD7ahY1HxfxbaEueCD6sQ4VoTS8abizpSc8NwIpy7YWlwXpl67SbLDmSGAC7dTX4YzCB7N1lSBsAEHYh9s4FVZNEcJ/a5nV2LVkwRC+NUxcHEs0j Received: from wheely.local0.net ([1.146.102.26]) by smtp.gmail.com with ESMTPSA id r10-20020a170903410a00b001d7284b9461sm839285pld.128.2024.02.08.23.02.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 23:02:37 -0800 (PST) From: Nicholas Piggin To: Thomas Huth Cc: Nicholas Piggin , kvm@vger.kernel.org, Laurent Vivier , "Shaoqin Huang" , Andrew Jones , Nico Boehr , Paolo Bonzini , Alexandru Elisei , Eric Auger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Marc Hartmayer , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kvmarm@lists.linux.dev, kvm-riscv@lists.infradead.org Subject: [kvm-unit-tests PATCH v3 5/8] arch-run: rename migration variables Date: Fri, 9 Feb 2024 17:01:38 +1000 Message-ID: <20240209070141.421569-6-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240209070141.421569-1-npiggin@gmail.com> References: <20240209070141.421569-1-npiggin@gmail.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Using 1 and 2 for source and destination is confusing, particularly now with multiple migrations that flip between them. Do a rename pass to tidy things up. Signed-off-by: Nicholas Piggin Acked-by: Thomas Huth --- scripts/arch-run.bash | 115 +++++++++++++++++++++--------------------- 1 file changed, 58 insertions(+), 57 deletions(-) diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index a914ba17..0b45eb61 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -132,34 +132,34 @@ run_migration () migcmdline=$@ trap 'trap - TERM ; kill 0 ; exit 2' INT TERM - trap 'rm -f ${migout1} ${migout2} ${migout_fifo1} ${migout_fifo2} ${migsock} ${qmp1} ${qmp2} ${fifo}' RETURN EXIT - - migsock=$(mktemp -u -t mig-helper-socket.XXXXXXXXXX) - migout1=$(mktemp -t mig-helper-stdout1.XXXXXXXXXX) - migout_fifo1=$(mktemp -u -t mig-helper-fifo-stdout1.XXXXXXXXXX) - migout2=$(mktemp -t mig-helper-stdout2.XXXXXXXXXX) - migout_fifo2=$(mktemp -u -t mig-helper-fifo-stdout2.XXXXXXXXXX) - qmp1=$(mktemp -u -t mig-helper-qmp1.XXXXXXXXXX) - qmp2=$(mktemp -u -t mig-helper-qmp2.XXXXXXXXXX) - fifo=$(mktemp -u -t mig-helper-fifo.XXXXXXXXXX) - qmpout1=/dev/null - qmpout2=/dev/null - - mkfifo ${migout_fifo1} - mkfifo ${migout_fifo2} + trap 'rm -f ${src_out} ${dst_out} ${src_outfifo} ${dst_outfifo} ${dst_incoming} ${src_qmp} ${dst_qmp} ${dst_infifo}' RETURN EXIT + + dst_incoming=$(mktemp -u -t mig-helper-socket-incoming.XXXXXXXXXX) + src_out=$(mktemp -t mig-helper-stdout1.XXXXXXXXXX) + src_outfifo=$(mktemp -u -t mig-helper-fifo-stdout1.XXXXXXXXXX) + dst_out=$(mktemp -t mig-helper-stdout2.XXXXXXXXXX) + dst_outfifo=$(mktemp -u -t mig-helper-fifo-stdout2.XXXXXXXXXX) + src_qmp=$(mktemp -u -t mig-helper-qmp1.XXXXXXXXXX) + dst_qmp=$(mktemp -u -t mig-helper-qmp2.XXXXXXXXXX) + dst_infifo=$(mktemp -u -t mig-helper-fifo-stdin.XXXXXXXXXX) + src_qmpout=/dev/null + dst_qmpout=/dev/null + + mkfifo ${src_outfifo} + mkfifo ${dst_outfifo} eval "$migcmdline" \ - -chardev socket,id=mon1,path=${qmp1},server=on,wait=off \ - -mon chardev=mon1,mode=control > ${migout_fifo1} & + -chardev socket,id=mon,path=${src_qmp},server=on,wait=off \ + -mon chardev=mon,mode=control > ${src_outfifo} & live_pid=$! - cat ${migout_fifo1} | tee ${migout1} & + cat ${src_outfifo} | tee ${src_out} & # The test must prompt the user to migrate, so wait for the "migrate" # keyword - while ! grep -q -i "Now migrate the VM" < ${migout1} ; do + while ! grep -q -i "Now migrate the VM" < ${src_out} ; do if ! ps -p ${live_pid} > /dev/null ; then echo "ERROR: Test exit before migration point." >&2 - qmp ${qmp1} '"quit"'> ${qmpout1} 2>/dev/null + qmp ${src_qmp} '"quit"'> ${src_qmpout} 2>/dev/null return 3 fi sleep 0.1 @@ -172,7 +172,7 @@ run_migration () while ps -p ${live_pid} > /dev/null ; do # Wait for EXIT or further migrations - if ! grep -q -i "Now migrate the VM" < ${migout1} ; then + if ! grep -q -i "Now migrate the VM" < ${src_out} ; then sleep 0.1 else do_migration || return $? @@ -194,79 +194,80 @@ do_migration () # We have to use cat to open the named FIFO, because named FIFO's, # unlike pipes, will block on open() until the other end is also # opened, and that totally breaks QEMU... - mkfifo ${fifo} + mkfifo ${dst_infifo} eval "$migcmdline" \ - -chardev socket,id=mon2,path=${qmp2},server=on,wait=off \ - -mon chardev=mon2,mode=control -incoming unix:${migsock} \ - < <(cat ${fifo}) > ${migout_fifo2} & + -chardev socket,id=mon,path=${dst_qmp},server=on,wait=off \ + -mon chardev=mon,mode=control -incoming unix:${dst_incoming} \ + < <(cat ${dst_infifo}) > ${dst_outfifo} & incoming_pid=$! - cat ${migout_fifo2} | tee ${migout2} & + cat ${dst_outfifo} | tee ${dst_out} & # The test must prompt the user to migrate, so wait for the "migrate" keyword - while ! grep -q -i "Now migrate the VM" < ${migout1} ; do + while ! grep -q -i "Now migrate the VM" < ${src_out} ; do if ! ps -p ${live_pid} > /dev/null ; then echo "ERROR: Test exit before migration point." >&2 - echo > ${fifo} - qmp ${qmp1} '"quit"'> ${qmpout1} 2>/dev/null - qmp ${qmp2} '"quit"'> ${qmpout2} 2>/dev/null + echo > ${dst_infifo} + qmp ${src_qmp} '"quit"'> ${src_qmpout} 2>/dev/null + qmp ${dst_qmp} '"quit"'> ${dst_qmpout} 2>/dev/null return 3 fi sleep 0.1 done # Wait until the destination has created the incoming and qmp sockets - while ! [ -S ${migsock} ] ; do sleep 0.1 ; done - while ! [ -S ${qmp2} ] ; do sleep 0.1 ; done + while ! [ -S ${dst_incoming} ] ; do sleep 0.1 ; done + while ! [ -S ${dst_qmp} ] ; do sleep 0.1 ; done - qmp ${qmp1} '"migrate", "arguments": { "uri": "unix:'${migsock}'" }' > ${qmpout1} + qmp ${src_qmp} '"migrate", "arguments": { "uri": "unix:'${dst_incoming}'" }' > ${src_qmpout} # Wait for the migration to complete - migstatus=`qmp ${qmp1} '"query-migrate"' | grep return` + migstatus=`qmp ${src_qmp} '"query-migrate"' | grep return` while ! grep -q '"completed"' <<<"$migstatus" ; do sleep 0.1 - if ! migstatus=`qmp ${qmp1} '"query-migrate"'`; then + if ! migstatus=`qmp ${src_qmp} '"query-migrate"'`; then echo "ERROR: Querying migration state failed." >&2 - echo > ${fifo} - qmp ${qmp2} '"quit"'> ${qmpout2} 2>/dev/null + echo > ${dst_infifo} + qmp ${dst_qmp} '"quit"'> ${dst_qmpout} 2>/dev/null return 2 fi migstatus=`grep return <<<"$migstatus"` if grep -q '"failed"' <<<"$migstatus"; then echo "ERROR: Migration failed." >&2 - echo > ${fifo} - qmp ${qmp1} '"quit"'> ${qmpout1} 2>/dev/null - qmp ${qmp2} '"quit"'> ${qmpout2} 2>/dev/null + echo > ${dst_infifo} + qmp ${src_qmp} '"quit"'> ${src_qmpout} 2>/dev/null + qmp ${dst_qmp} '"quit"'> ${dst_qmpout} 2>/dev/null return 2 fi done - qmp ${qmp1} '"quit"'> ${qmpout1} 2>/dev/null + qmp ${src_qmp} '"quit"'> ${src_qmpout} 2>/dev/null # keypress to dst so getchar completes and test continues - echo > ${fifo} - rm ${fifo} + echo > ${dst_infifo} + rm ${dst_infifo} # Ensure the incoming socket is removed, ready for next destination - if [ -S ${migsock} ] ; then + if [ -S ${dst_incoming} ] ; then echo "ERROR: Incoming migration socket not removed after migration." >& 2 - qmp ${qmp2} '"quit"'> ${qmpout2} 2>/dev/null + qmp ${dst_qmp} '"quit"'> ${dst_qmpout} 2>/dev/null return 2 fi wait ${live_pid} ret=$? - # Now flip the variables because dest becomes source + # Now flip the variables because destination machine becomes source + # for the next migration. live_pid=${incoming_pid} - tmp=${migout1} - migout1=${migout2} - migout2=${tmp} - tmp=${migout_fifo1} - migout_fifo1=${migout_fifo2} - migout_fifo2=${tmp} - tmp=${qmp1} - qmp1=${qmp2} - qmp2=${tmp} + tmp=${src_out} + src_out=${dst_out} + dst_out=${tmp} + tmp=${src_outfifo} + src_outfifo=${dst_outfifo} + dst_outfifo=${tmp} + tmp=${src_qmp} + src_qmp=${dst_qmp} + dst_qmp=${tmp} return $ret } @@ -289,8 +290,8 @@ run_panic () qmp=$(mktemp -u -t panic-qmp.XXXXXXXXXX) # start VM stopped so we don't miss any events - eval "$@" -chardev socket,id=mon1,path=${qmp},server=on,wait=off \ - -mon chardev=mon1,mode=control -S & + eval "$@" -chardev socket,id=mon,path=${qmp},server=on,wait=off \ + -mon chardev=mon,mode=control -S & panic_event_count=$(qmp_events ${qmp} | jq -c 'select(.event == "GUEST_PANICKED")' | wc -l) if [ "$panic_event_count" -lt 1 ]; then From patchwork Fri Feb 9 07:01:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13550936 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 0E060651B0; Fri, 9 Feb 2024 07:02:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707462168; cv=none; b=b09eQvUnV5GJjN35Q5+G2LmHyykHofK1PofUNhvMslbkKj8UntoVaoN0Up383mGX+fhQMkbSlgc7CoL/DzOcWEy1FtMgP8eofqENf+AEdHJ6uzED2hFfT4DICmnhMVKTSWy0tZ4S7u4nK02Q7fxe/gMYkWQVDA/+h8kQtlunVuE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707462168; c=relaxed/simple; bh=2We+TY3TrSFlAYJp9qjCOG7hr8bE3hpOyLxv0thXofA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dG0y74AL6knFrumvaUE0M5qUna96btytcLRCbMvBv9oRNpMDQgCYg724uUgZylswjox3goIdt3+O9xhTxRU88OdCTsJh4NDzbOCHdmDfBGYs52ClkzuuURN5EvW0nEUVxckyMc8mKKgxOTYgIQ1VLLjOhn4vAR0yM7B02u9Y9DM= 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=jKVnlqNN; arc=none smtp.client-ip=209.85.214.179 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="jKVnlqNN" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1d9b2400910so4794045ad.0; Thu, 08 Feb 2024 23:02:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707462166; x=1708066966; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Qsb66D3Bdnju/B4wMjZRE5sQcB0Os6ZjxNoeFhHSgYI=; b=jKVnlqNN03rQqi+6Dbmcbm333+62bJBH5AEbQGJtzlPZKjfKM2QLD+dJg49kVfDaYZ 7shon5X0WhMrEew3g2TLFhruTcRJo0X/y0Vq6heNxbhr2TKPtGtpGeLVLZ5atc4LsD5f KU1Ds5HrT9MgLE4CcG1v57lCVd6bRln1u8E5w55z8kicC2pLdzUH+q2zEuEapFZkV1fb vq7g1ABKUNoxXnzIB3FlJ5TPCd+Ymy1D+0bmVjMwmyfaE/iascLGTVWlQd/5lBUiXNCL gZYWKQtRo4ITXrNNUq2u1wA0VVYesSpNS81W9N9JYIt5prTQZnHUERamc3F9npmjSO12 b5xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707462166; x=1708066966; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Qsb66D3Bdnju/B4wMjZRE5sQcB0Os6ZjxNoeFhHSgYI=; b=RrfPqDkmqIe0/H7eeNo6UA2s18sNtwVmvHunX6/Lg5BPeupCK/wH5W9ZXx22FHzU3i supFPdecCTINJGf7LXs5ZqgNKLPPTBmBP1fAO+Z0JQxBkPT7JTUDHAYz0alfsMXgIRF1 DGY69JFFgh//aA0GsHh5bwjoLxSpAFDcL3N7cOxLI3rS8XJMzRftkVHqhOhPcK7Ki5P/ YosB3D3HThMC9zfBpWKwUq55c0TXByQmstyVaTLdCkqJjJdOlgWY8+3vQuDhYkyZTFD7 9LsqgEOHUarOnvFE8haB51xwNGIv1o95diz75yalSZGJO9AWK1XhcH+26p1QiClMGB+Y q5vA== X-Forwarded-Encrypted: i=1; AJvYcCXLV69ADRmIa0PYXu84035Kykh+YR5L4ozyZTCpa9yzhe9zupOn2T7MoQtzvx0ZTFMKIOMqJkjWTwsiVq/OQDeyEoNp3lTxTYS62+CKburfDeoTS4Vh2y+WGjx/51DbuA== X-Gm-Message-State: AOJu0Yxcwg1ihOpmx+ZjaukCvbTMpotk8xLWJI7UnEuUMoc78qpokeHF VoXWPVo6nz+oDlJdD5NCW4OR7R8muIbj6a5UVVkbP9tCmeP8s7iP X-Google-Smtp-Source: AGHT+IHU0yLvmoVA6RKCQ6uyd2pMX3xvxjI2eIt3+EkdLZ4rFtP2o0Kv2c+t5MKAEvXWGxoEJoqkhA== X-Received: by 2002:a17:902:dac4:b0:1d8:ff72:eef8 with SMTP id q4-20020a170902dac400b001d8ff72eef8mr252746plx.18.1707462166439; Thu, 08 Feb 2024 23:02:46 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWUS07VqJtp8QffWN3zhicRM8LYt8elB5iTOnmCfZ9yy015fREDprJMZMviRnS98UcXQ/VxQw5ldSNprvJDhbVvdZ2iTvfcBiAjIzZfqX58zO6C8/i7isMINudyqNMaFxktdnnzLNazq6uh+2kKcYxmW4vZDXt8HbVI8+QYEcbcIRlCYgMvivyCqBZ6LkfiVKkaqRVhOnH1HSaJkFlOP64LphaRgHUHEniYyVPhgJ2cftwYq3LZ8hQtH3X4i94sQ1NmT12Uu39pJiWkIUij9SP4kCLNt41SD0xaEIECmybtiFoq1h7Fkr3ziDK8J0m7NyoAcZ9UwSVZivUHtCuYCt6i6nZMHfN2FIL+UC4mt/7Vt9FQ4OftEaUD4g0Uj75ilOzRkKQiRzXv2CJAB7cV7goDUn40aKB6FotefYlzCEHOwttpUYJdMEU+iksnfmeV0C1WAhxVF6EOkXiv/2qUsbmlWT/TJBT5tupgBrXLQc4X/zjmDQsWKW/5uB/n2l1aRYc2ChurcIcQZOSF9H1AL/ldjQ168IPS9m45kha/V5LyIKKwVJYZc17j Received: from wheely.local0.net ([1.146.102.26]) by smtp.gmail.com with ESMTPSA id r10-20020a170903410a00b001d7284b9461sm839285pld.128.2024.02.08.23.02.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 23:02:46 -0800 (PST) From: Nicholas Piggin To: Thomas Huth Cc: Nicholas Piggin , kvm@vger.kernel.org, Laurent Vivier , "Shaoqin Huang" , Andrew Jones , Nico Boehr , Paolo Bonzini , Alexandru Elisei , Eric Auger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Marc Hartmayer , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kvmarm@lists.linux.dev, kvm-riscv@lists.infradead.org Subject: [kvm-unit-tests PATCH v3 6/8] migration: Add quiet migration support Date: Fri, 9 Feb 2024 17:01:39 +1000 Message-ID: <20240209070141.421569-7-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240209070141.421569-1-npiggin@gmail.com> References: <20240209070141.421569-1-npiggin@gmail.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Console output required to support migration becomes quite noisy when doing lots of migrations. Provide a migrate_quiet() call that suppresses console output and doesn't log a message. Signed-off-by: Nicholas Piggin --- lib/migrate.c | 12 ++++++++++++ lib/migrate.h | 1 + scripts/arch-run.bash | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/migrate.c b/lib/migrate.c index b7721659..4e0ab516 100644 --- a/lib/migrate.c +++ b/lib/migrate.c @@ -18,6 +18,18 @@ void migrate(void) report_info("Migration complete"); } +/* + * Like migrate() but supporess output and logs, useful for intensive + * migration stress testing without polluting logs. Test cases should + * provide relevant information about migration in failure reports. + */ +void migrate_quiet(void) +{ + puts("Now migrate the VM (quiet)\n"); + (void)getchar(); +} + + /* * Initiate migration and wait for it to complete. * If this function is called more than once, it is a no-op. diff --git a/lib/migrate.h b/lib/migrate.h index 2af06a72..95b9102b 100644 --- a/lib/migrate.h +++ b/lib/migrate.h @@ -7,4 +7,5 @@ */ void migrate(void); +void migrate_quiet(void); void migrate_once(void); diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index 0b45eb61..29cf9b0c 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -152,7 +152,7 @@ run_migration () -chardev socket,id=mon,path=${src_qmp},server=on,wait=off \ -mon chardev=mon,mode=control > ${src_outfifo} & live_pid=$! - cat ${src_outfifo} | tee ${src_out} & + cat ${src_outfifo} | tee ${src_out} | grep -v "Now migrate the VM (quiet)" & # The test must prompt the user to migrate, so wait for the "migrate" # keyword @@ -200,7 +200,7 @@ do_migration () -mon chardev=mon,mode=control -incoming unix:${dst_incoming} \ < <(cat ${dst_infifo}) > ${dst_outfifo} & incoming_pid=$! - cat ${dst_outfifo} | tee ${dst_out} & + cat ${dst_outfifo} | tee ${dst_out} | grep -v "Now migrate the VM (quiet)" & # The test must prompt the user to migrate, so wait for the "migrate" keyword while ! grep -q -i "Now migrate the VM" < ${src_out} ; do From patchwork Fri Feb 9 07:01:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13550937 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 A0962657A8; Fri, 9 Feb 2024 07:02:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707462177; cv=none; b=tSilg/t/7BXwQD45tsCwdhk+/8Xox0Tte4+nd16SzSQtbzsTBcsTB3FUhirrvfUsVnbJSMFejekUaR9ONIkvE/JLHOdjTUehEVIh/04AaJ6K7FvXwVaBLA9fw2TbaFJ7EEZpH5JrJWiMP3mFLnxOoy6IxpHJKOOGVngzzh+gLoM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707462177; c=relaxed/simple; bh=IcS62kZkPfcgyZsoiOU+CF/aNai6/xamvdNLtmZr0zI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MCoLB7TzuABXB3bXY65XGn6mDjN5WSQD/llQK2GbXwyu81+I5IqUhHLe6QrBLpxKQU5RzXzUuuI6g13JMt4Q85jJC1LoV3RxtoSYRd8r/LsGgCoTZJ4xbYwz0FhIvNAom1DpAHSHcFvGtjIcOIduWlPv63H2PIj6k7eLW/H7RGE= 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=CMbeCU3a; arc=none smtp.client-ip=209.85.214.181 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="CMbeCU3a" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1d911c2103aso3920205ad.0; Thu, 08 Feb 2024 23:02:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707462175; x=1708066975; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OVEm/pYZkdeEDIy5KjMBW2u/cmIIhledzwTk6k6esVw=; b=CMbeCU3aUrxO6hnWcJ/tr6bds8dMPrLl1X3kQ8QyieMR/T91MFHb1KsSPqtFkAf8NW ftGbMDZT+ZnJ13cya3jAp194uKMmgIgbsGH2yrBKC28beXZo3Il6FfteGEHBjUsqT6lm JXSu7yhGLCDOkoH7i3o03SWunVMKvKOd7YosKOmWZBKMA8TkHsMW0GpJCwLkmkYUesXU fHRl78wXoj3RpdjC8NobOVpCf/+W23Hx2b9ViKRRwo3Cneeqcl8T/gy3iMrl3OP5TIwr 7WWpUD/DTXgv7ZYf225awz6iHW5mbSzXrBtjGo3juH3ps1Bi+5Yp7Yya4BVoIzbsr1Ch /Evg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707462175; x=1708066975; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OVEm/pYZkdeEDIy5KjMBW2u/cmIIhledzwTk6k6esVw=; b=YYMTpR3v6zU6I6ZpmgU/VORWnnEAtvk6ISNlRI/GIcCkeHuZ5xxX/xVWFrssN6vsav rQfCjatzeK1bK1pdg4a7wYxEFNf/pglCSPRojqguIyGMTuMZ5NElCj3ns2by+GDkWb5n +O5nkYdj7uTjpl6Qhoz0vsEBoosU+RkivQtoTnkFnEI9K9BepvFT2eEtC5HbkIrV0an3 du+PZibA8k9+uVOfqc9AfbVSz7o+7XudgBJACh+PXjkGQd7i9OtsDMWR4Yr7QOJmsn+u gBxBcA2qrb7myPazu7U9aCp4dgNf9aSCJOcCQqCzQzZx04cXdEFeJ3upswdn1HyAoUb6 aB1Q== X-Forwarded-Encrypted: i=1; AJvYcCVlI47chCmZcQcTSirKJYJUN0ZK8CpHoKsOaCWtrtwykhUQ1YqnOAgJ0T2WsuHYf0tkx0kYd2188X6WTE48iBswa9PuLwUe3U0tLN3vbWWCLIWSvf3WAABCuM+SLL+YhQ== X-Gm-Message-State: AOJu0YzEIvDMtRmEnD+kzgXWAOrXFt5kb9kb5Z359qzdcH4u6U0cqJyP iWEcNcGRo1s2wuhnmKu/mVBr6+xY6apOOimKoW6qHSRX2RJIhoJJ X-Google-Smtp-Source: AGHT+IEQnwNqYZV7NMmdpTLfryCzZT99JVrOcx1KoOE4uHx45cY4W8kkhKefaUBVdiD8mo8fym4z7Q== X-Received: by 2002:a17:902:fe0c:b0:1d9:7e40:6c2b with SMTP id g12-20020a170902fe0c00b001d97e406c2bmr719014plj.32.1707462174901; Thu, 08 Feb 2024 23:02:54 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVX4sftCfg4C1MSLp4Dd5cmlgcIFACd8suRXWy8FwyF/WhEh7XciVerXpPJy64oDODvV3AucCySya4eOUXdlcnXqW+f/Id3bqxOHfAkc+qYtY0JcJ0r9GRjOgjodKtFXzX2/2iNQDiL0P3bRbv0/FF8hTGhuR9RNSD9qHJ82fJ2SCmMmWU8UyOSROZG7EQWwQy0iT6waqxES1rsQOsaN0OtZh5CRa8kOqdx0M+hXPlx5UZPr4TSN3t3eiVb2EpVEXPtk1aAsNwP4jCOVqu6NBIojn5EWj3VU8oYvzq6Caotl3E5FoGRoxPWZA351D+KCGvV+iSyRuf5PPLAQUxJEmbCPTsaDqSIzscWMulQwIeMokUgpeubCaxA/5DZUEOhZKNUt7QYuKqidmO66aa+vVj0ylBNnLiouvSSLSVExjuBvKlaM/P/LrbzkNvcWllv4FCLaVJYzveyqGyuO6HZKGT5kLYI+rWXwPH822UknKvlMB5sXYgG90c+9zXk2cHUVIcdzl2g4VtKtRKhJoJSIzVseqGfETA72fyXW1hZoxqSk8Ix3QS7RI1x Received: from wheely.local0.net ([1.146.102.26]) by smtp.gmail.com with ESMTPSA id r10-20020a170903410a00b001d7284b9461sm839285pld.128.2024.02.08.23.02.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 23:02:54 -0800 (PST) From: Nicholas Piggin To: Thomas Huth Cc: Nicholas Piggin , kvm@vger.kernel.org, Laurent Vivier , "Shaoqin Huang" , Andrew Jones , Nico Boehr , Paolo Bonzini , Alexandru Elisei , Eric Auger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Marc Hartmayer , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kvmarm@lists.linux.dev, kvm-riscv@lists.infradead.org Subject: [kvm-unit-tests PATCH v3 7/8] Add common/ directory for architecture-independent tests Date: Fri, 9 Feb 2024 17:01:40 +1000 Message-ID: <20240209070141.421569-8-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240209070141.421569-1-npiggin@gmail.com> References: <20240209070141.421569-1-npiggin@gmail.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 x86/sieve.c is used by s390x, arm, and riscv via symbolic link. Make a new directory common/ for architecture-independent tests and move sieve.c here. Signed-off-by: Nicholas Piggin Reviewed-by: Thomas Huth --- arm/sieve.c | 2 +- common/sieve.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ riscv/sieve.c | 2 +- s390x/sieve.c | 2 +- x86/sieve.c | 52 +------------------------------------------------- 5 files changed, 55 insertions(+), 54 deletions(-) create mode 100644 common/sieve.c mode change 100644 => 120000 x86/sieve.c diff --git a/arm/sieve.c b/arm/sieve.c index 8f14a5c3..fe299f30 120000 --- a/arm/sieve.c +++ b/arm/sieve.c @@ -1 +1 @@ -../x86/sieve.c \ No newline at end of file +../common/sieve.c \ No newline at end of file diff --git a/common/sieve.c b/common/sieve.c new file mode 100644 index 00000000..8150f2d9 --- /dev/null +++ b/common/sieve.c @@ -0,0 +1,51 @@ +#include "alloc.h" +#include "libcflat.h" + +static int sieve(char* data, int size) +{ + int i, j, r = 0; + + for (i = 0; i < size; ++i) + data[i] = 1; + + data[0] = data[1] = 0; + + for (i = 2; i < size; ++i) + if (data[i]) { + ++r; + for (j = i*2; j < size; j += i) + data[j] = 0; + } + return r; +} + +static void test_sieve(const char *msg, char *data, int size) +{ + int r; + + printf("%s:", msg); + r = sieve(data, size); + printf("%d out of %d\n", r, size); +} + +#define STATIC_SIZE 1000000 +#define VSIZE 100000000 +char static_data[STATIC_SIZE]; + +int main(void) +{ + void *v; + int i; + + printf("starting sieve\n"); + test_sieve("static", static_data, STATIC_SIZE); + setup_vm(); + test_sieve("mapped", static_data, STATIC_SIZE); + for (i = 0; i < 3; ++i) { + v = malloc(VSIZE); + test_sieve("virtual", v, VSIZE); + free(v); + } + + return 0; +} diff --git a/riscv/sieve.c b/riscv/sieve.c index 8f14a5c3..fe299f30 120000 --- a/riscv/sieve.c +++ b/riscv/sieve.c @@ -1 +1 @@ -../x86/sieve.c \ No newline at end of file +../common/sieve.c \ No newline at end of file diff --git a/s390x/sieve.c b/s390x/sieve.c index 8f14a5c3..fe299f30 120000 --- a/s390x/sieve.c +++ b/s390x/sieve.c @@ -1 +1 @@ -../x86/sieve.c \ No newline at end of file +../common/sieve.c \ No newline at end of file diff --git a/x86/sieve.c b/x86/sieve.c deleted file mode 100644 index 8150f2d9..00000000 --- a/x86/sieve.c +++ /dev/null @@ -1,51 +0,0 @@ -#include "alloc.h" -#include "libcflat.h" - -static int sieve(char* data, int size) -{ - int i, j, r = 0; - - for (i = 0; i < size; ++i) - data[i] = 1; - - data[0] = data[1] = 0; - - for (i = 2; i < size; ++i) - if (data[i]) { - ++r; - for (j = i*2; j < size; j += i) - data[j] = 0; - } - return r; -} - -static void test_sieve(const char *msg, char *data, int size) -{ - int r; - - printf("%s:", msg); - r = sieve(data, size); - printf("%d out of %d\n", r, size); -} - -#define STATIC_SIZE 1000000 -#define VSIZE 100000000 -char static_data[STATIC_SIZE]; - -int main(void) -{ - void *v; - int i; - - printf("starting sieve\n"); - test_sieve("static", static_data, STATIC_SIZE); - setup_vm(); - test_sieve("mapped", static_data, STATIC_SIZE); - for (i = 0; i < 3; ++i) { - v = malloc(VSIZE); - test_sieve("virtual", v, VSIZE); - free(v); - } - - return 0; -} diff --git a/x86/sieve.c b/x86/sieve.c new file mode 120000 index 00000000..fe299f30 --- /dev/null +++ b/x86/sieve.c @@ -0,0 +1 @@ +../common/sieve.c \ No newline at end of file From patchwork Fri Feb 9 07:01:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13550938 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 707D056B7B; Fri, 9 Feb 2024 07:03:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707462184; cv=none; b=jvtP7hkHcx8ZONSssYZNEZIjRuK19XAtMcTSj/w1G/Q0YhujKYwwK54u3klFRfielSx4dRuxhqfaJTWIvHQMtisi+9zjyIhvuZx7DM4aWI8YuEpqi8KJuT1C64nQSEZ+6Fuz8h/8sgxb68OOep7XiVHJAx+REXPgLsWqYDEAKGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707462184; c=relaxed/simple; bh=0RH/PiOeHXzMf2Ch1cJmwhhhXF+PGIoUjEBesR0lss4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CTzHxpgep4R7lUiIhZyAVkmAsKGndNZj8Sj5XeDIijvR7j4sYY3erIiWplNJDvQ6z+QA1STb0L9/o1ImHJOuJ/f+c6XmQQGOsZ7pZR16MleHwsqnPBwolk03GwpLi00k00II04I1fNNwaEDah9uoGMt5IaZTKLze/MTQCvexyQs= 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=a8izTpHC; arc=none smtp.client-ip=209.85.210.174 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="a8izTpHC" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-6e053b272b0so406506b3a.1; Thu, 08 Feb 2024 23:03:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707462183; x=1708066983; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nLcEDOFfXRm4asPXfN/h/emKx6nM9DLWqis1Tw2BV0c=; b=a8izTpHCLGfdQevzbcnhDSDQ39krTIw/CI2EMvviQkt5AKtcN++MQirpCajwG9XNLq 8t63Drp+/FYeWMItWXiGj6Ykect8gaGIgq2H0G8jKyiQsGRYNedhYbdJerr4BUlyL5gX WfktNV6yzC369ln02+xXCotsFNn1SRSN2mIfc5aMqzmvVjlfHZrxWX5HwlPflI3Tdme/ QEw58FfUjk9zJhDQ4Krw45Ljz2FGqzs/V7ZcQSznqRf5SF7M3gLe+NHcJdtTn8vufOGE 5HNaH1z5JWX1Qp+yMF8l+PE7wp1lc6KAgnS6ANvv4uovyZ4wUKJx3ixTkoMtBYIivT6H v65Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707462183; x=1708066983; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nLcEDOFfXRm4asPXfN/h/emKx6nM9DLWqis1Tw2BV0c=; b=vJhJukJIbwdaQZn8Ftw2XDzBAFTEM7tg4ItE2naczrSuVxRpEuRxYa7lSQLW3LK/GD aizAUhm/AM9yBVejaKRrpgzK44n/zPY8dUeOlmB+1RquZGCSSRVoo18msVXfvB8/IGZz s7XT7g7xSgqy2oPDvLUWzlMsAGT0H+QQrmIRe+0z8W/ADiDKrTtFoD7vNxoKk+F0SExf COYoG1+W9lWXfRKznj3IKHgw8mWBgP33Tsd1uxCPpcs5GWZkCOGqVhkqSpUgYovNMamY kgCKsEZmAFMgebiL8wn09S4iL3pi020JYaYIR3XIcLAnmQskbMim4+xD9QLFxpYDgn7N rpkg== X-Forwarded-Encrypted: i=1; AJvYcCUcSnyNr0xhRXTPwfvwX3kwF3+W+lj4OxCugJcGIXZ2txpQ0QKrtRfXYZ0ils5DPirhtBVBRfdbZDUzoMsQv5nJwXgC7PUiCQXNl5HlmUS5DpgV2SAW8U7vrtgODGwQhg== X-Gm-Message-State: AOJu0YyuWQohY4UmW/QjiW/TVvbaeYQzQ7W7B+PKBElkyBgvEmyh0oz1 yaNISg58a/7upxhfYxXaMqAf19QPmY3ET51prjqw6Z3O64WoXa9S X-Google-Smtp-Source: AGHT+IHCDQmhvrErtDNERE9RrkYau41AxB4oBcYKBUMctdPXanPruVPXCMJmeFh2pOIguDwPif262w== X-Received: by 2002:a05:6a20:94ce:b0:19e:99fd:3f5c with SMTP id ht14-20020a056a2094ce00b0019e99fd3f5cmr1013600pzb.25.1707462182771; Thu, 08 Feb 2024 23:03:02 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUXjVIucCvEhqf7rvEFHTsNvZRp6jchNyZ+VPMsRdJDMsygxun8hUVxG2Y9mmn+X1wF20AwZkwuxOqKvnmXHpi9Ya7qdy/vQC1E8gcH8PMc7eRyxEQ8mxGRUcypUXdhMh5JNVzlCEUQn8zSJY5XWu7q9rUVLSdJRbAApVO3gxxx1wTOt9T5wuHIddoEFJ/CkUbe+ZaSr2EMUqb7uSZ9BG5yLWDyPSq0hBIjYZBEECml7FVaVkrV/Zuv+Mh+iVhI9fyn6tIai8lu4zaiajlWuaOLax7bDifk3TcJ0450njTgSSaMih51NGiRSQTbt5GfxXki6u5W+6T1MlF5lfjdZBtkNKW30gvRDaC0z0USNqRdKSFUhhngff5ouSHO68CgNwA1BOK4njt4vZ8qETP2fDsDhU2vgvMMeZdOGNcjIJtVNrDga/XQyaVyKUnraQN1U7rTY3mqC6Q8dAu5li30gvg7lhS31t1VyOq2ib3S6QOqL3A6gvEgf+d9zZjbG/M1dacZipocfeTU0ghXUdrosLA70IEtXqxgRi2+jQQjc25jY6VBoqWsSQQp Received: from wheely.local0.net ([1.146.102.26]) by smtp.gmail.com with ESMTPSA id r10-20020a170903410a00b001d7284b9461sm839285pld.128.2024.02.08.23.02.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 23:03:02 -0800 (PST) From: Nicholas Piggin To: Thomas Huth Cc: Nicholas Piggin , kvm@vger.kernel.org, Laurent Vivier , "Shaoqin Huang" , Andrew Jones , Nico Boehr , Paolo Bonzini , Alexandru Elisei , Eric Auger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Marc Hartmayer , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kvmarm@lists.linux.dev, kvm-riscv@lists.infradead.org Subject: [kvm-unit-tests PATCH v3 8/8] migration: add a migration selftest Date: Fri, 9 Feb 2024 17:01:41 +1000 Message-ID: <20240209070141.421569-9-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240209070141.421569-1-npiggin@gmail.com> References: <20240209070141.421569-1-npiggin@gmail.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a selftest for migration support in guest library and test harness code. It performs migrations a tight loop to irritate races and bugs in the test harness code. Include the test in arm, s390, powerpc. Acked-by: Claudio Imbrenda (s390x) Signed-off-by: Nicholas Piggin Reviewed-by: Thomas Huth --- This has flushed out several bugs in developing the multi migration test harness code already. Thanks, Nick arm/Makefile.common | 1 + arm/selftest-migration.c | 1 + arm/unittests.cfg | 6 ++++++ common/selftest-migration.c | 34 ++++++++++++++++++++++++++++++++++ powerpc/Makefile.common | 1 + powerpc/selftest-migration.c | 1 + powerpc/unittests.cfg | 4 ++++ s390x/Makefile | 1 + s390x/selftest-migration.c | 1 + s390x/unittests.cfg | 4 ++++ 10 files changed, 54 insertions(+) create mode 120000 arm/selftest-migration.c create mode 100644 common/selftest-migration.c create mode 120000 powerpc/selftest-migration.c create mode 120000 s390x/selftest-migration.c diff --git a/arm/Makefile.common b/arm/Makefile.common index f828dbe0..f107c478 100644 --- a/arm/Makefile.common +++ b/arm/Makefile.common @@ -5,6 +5,7 @@ # tests-common = $(TEST_DIR)/selftest.$(exe) +tests-common += $(TEST_DIR)/selftest-migration.$(exe) tests-common += $(TEST_DIR)/spinlock-test.$(exe) tests-common += $(TEST_DIR)/pci-test.$(exe) tests-common += $(TEST_DIR)/pmu.$(exe) diff --git a/arm/selftest-migration.c b/arm/selftest-migration.c new file mode 120000 index 00000000..bd1eb266 --- /dev/null +++ b/arm/selftest-migration.c @@ -0,0 +1 @@ +../common/selftest-migration.c \ No newline at end of file diff --git a/arm/unittests.cfg b/arm/unittests.cfg index fe601cbb..1ffd9a82 100644 --- a/arm/unittests.cfg +++ b/arm/unittests.cfg @@ -55,6 +55,12 @@ smp = $MAX_SMP extra_params = -append 'smp' groups = selftest +# Test migration +[selftest-migration] +file = selftest-migration.flat +groups = selftest migration + +arch = arm64 # Test PCI emulation [pci-test] file = pci-test.flat diff --git a/common/selftest-migration.c b/common/selftest-migration.c new file mode 100644 index 00000000..f70c505f --- /dev/null +++ b/common/selftest-migration.c @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Machine independent migration tests + * + * This is just a very simple test that is intended to stress the migration + * support in the test harness. This could be expanded to test more guest + * library code, but architecture-specific tests should be used to test + * migration of tricky machine state. + */ +#include +#include + +#if defined(__arm__) || defined(__aarch64__) +/* arm can only call getchar 15 times */ +#define NR_MIGRATIONS 15 +#else +#define NR_MIGRATIONS 100 +#endif + +int main(int argc, char **argv) +{ + int i = 0; + + report_prefix_push("migration"); + + for (i = 0; i < NR_MIGRATIONS; i++) + migrate_quiet(); + + report(true, "simple harness stress test"); + + report_prefix_pop(); + + return report_summary(); +} diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common index eb88398d..da4a7bbb 100644 --- a/powerpc/Makefile.common +++ b/powerpc/Makefile.common @@ -6,6 +6,7 @@ tests-common = \ $(TEST_DIR)/selftest.elf \ + $(TEST_DIR)/selftest-migration.elf \ $(TEST_DIR)/spapr_hcall.elf \ $(TEST_DIR)/rtas.elf \ $(TEST_DIR)/emulator.elf \ diff --git a/powerpc/selftest-migration.c b/powerpc/selftest-migration.c new file mode 120000 index 00000000..bd1eb266 --- /dev/null +++ b/powerpc/selftest-migration.c @@ -0,0 +1 @@ +../common/selftest-migration.c \ No newline at end of file diff --git a/powerpc/unittests.cfg b/powerpc/unittests.cfg index e71140aa..7ce57de0 100644 --- a/powerpc/unittests.cfg +++ b/powerpc/unittests.cfg @@ -36,6 +36,10 @@ smp = 2 extra_params = -m 256 -append 'setup smp=2 mem=256' groups = selftest +[selftest-migration] +file = selftest-migration.elf +groups = selftest migration + [spapr_hcall] file = spapr_hcall.elf diff --git a/s390x/Makefile b/s390x/Makefile index b72f7578..344d46d6 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -1,4 +1,5 @@ tests = $(TEST_DIR)/selftest.elf +tests += $(TEST_DIR)/selftest-migration.elf tests += $(TEST_DIR)/intercept.elf tests += $(TEST_DIR)/emulator.elf tests += $(TEST_DIR)/sieve.elf diff --git a/s390x/selftest-migration.c b/s390x/selftest-migration.c new file mode 120000 index 00000000..bd1eb266 --- /dev/null +++ b/s390x/selftest-migration.c @@ -0,0 +1 @@ +../common/selftest-migration.c \ No newline at end of file diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index f5024b6e..a7ad522c 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -24,6 +24,10 @@ groups = selftest # please keep the kernel cmdline in sync with $(TEST_DIR)/selftest.parmfile extra_params = -append 'test 123' +[selftest-migration] +file = selftest-migration.elf +groups = selftest migration + [intercept] file = intercept.elf