From patchwork Fri Feb 9 09:11:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13550995 Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (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 D0CC2664D8; Fri, 9 Feb 2024 09:11:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707469915; cv=none; b=hib+/HbrLtjUtZ0RizzWtGZib20shVawyJVyu/kTv+6I6ZJRrttWMblPqDLSrOq6ghFW4XdJqFbvLIfPOwV9JImvwjMaB4KE+E7jwiNvi0N0BZwLMVIrt+npNUIgFGxYVHujYrMc7Chpb2CPUmopqjv7WfhdRotypzhEur2Vw+Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707469915; c=relaxed/simple; bh=ZAFsihb3M/bAq0syQwiiUvyBvzmIPevskZf5u2erS68=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M0/X6zbV4dCuGKwRL48qUB8UXO42rAR6Qky3f861R6BJfyXPqlUJTvnVb4iJ68A55uR5AaT8FtOVfbNM9RcXyfUikFTmKi3Ap/DNunGhrN4XwMQ8+Pf25/SeoanHRpQ3nNVxdcNzw3pcqhjCR7487SVqoNI1jOZk2FudgKJOI0g= 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=BwErevDm; arc=none smtp.client-ip=209.85.210.41 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="BwErevDm" Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-6e2c402a5c2so381563a34.2; Fri, 09 Feb 2024 01:11:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707469913; x=1708074713; 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=LxyXAGgGrfeNy34o4rw1jwmZjpNeqct9+4wIMTyRvKI=; b=BwErevDmrXANUobgswkyW/90s2LxY123fZQMEwuv6noJekzQe8oz9E0VeaWxakNtWi ive+AWxLS0l+7AbzphAX36oGCUnj+kItC8efoSQ19Sj+GbItKJmKL4nk4kog8EzOvvr9 DpmDfn1WVuiGFWDrWMqOkBUYam7BP+AJaN6qKbpWmBwysrlAxxYcL1z4Ta2jkdzyhgwn klsZl99U/zamNxWsc2SkCDS79H67+9LYGxS1H3e8y6xNqiPdjLEbhgDFloVv9dWLP3Lv Wf5auZh7N4NxXgnFyac/wgJ6wfa5t2m43a5rNzf/o3USvVQ2gvDzkLgcQ9OLaEA7ode0 inwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707469913; x=1708074713; 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=LxyXAGgGrfeNy34o4rw1jwmZjpNeqct9+4wIMTyRvKI=; b=m0UuzvcZh/s952uAi52ec8OjWaDb9o543CfODQZaneldA3ojvtUwE4+ZEBTmYpXcw8 GNBF185FHo5kgNP6OKaQnDCKRftqCJ3vhyenR0Yz2ovNrzVxZQZ84xaLEYjhdN8mxazw e1S7UUWSIqiCBzitolKxj2+e4mo+ddso8UUP4chfIzVJOrDUVy70BZOVkJliFn9uGdgB 9JAkVSu8UkhFoG/JreJSeR0+fYcTdv2bu05tq1v5xRdsz4YInCcXtdlxh4ZJZ2hQebLT VGIG3P9kDlwqSuRyV6Rtqh1yyS2sITgHSoDQnhRHh7uu1Zz8ktxIB/8PDllLkOWTGbPG wMAA== X-Forwarded-Encrypted: i=1; AJvYcCVDHjwTFtjH45Dj0bivjzJDuir8h8ScT+EDU+1ufGAP2mziy6cYCzl+MM/FC9BU497QtxEnur8Wu4E/94x+04ZO0+8TFj8BDFfcRPvK0aNT7q02h0V+EMWkpCiLvzVlQA== X-Gm-Message-State: AOJu0Ywp9PDaRBjYyKxGQACFvbxLVfriccIVYDObAUDWL0zKumoQBUoX rOyUzZelj+Mc+mw5cWUkIJMX/iiZMmK5UKP6UN8XIar6HAB2cIBz X-Google-Smtp-Source: AGHT+IGcmytfLhFPegBL/6SAtwvaTgnR5fQUFdHgJo6Q2wspsRF4btaANrNXmauM6vRXjX9yxL/gWw== X-Received: by 2002:a9d:7592:0:b0:6e2:b1b8:84c7 with SMTP id s18-20020a9d7592000000b006e2b1b884c7mr748994otk.17.1707469912911; Fri, 09 Feb 2024 01:11:52 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVKEs+ZzHCXAJAGHH6bSzYysqcGhmXYYuO3J7InQHWbz7ru+8zL9FzYLwO9GhlA0tw/acl/lYs3xPiH65/zsxoAQ+vOunmMdeJHj7fwM/7IYXS11Wbs/M5zRz5EFWAit+rW73a2VQG4xCIgTGUjXY82AdiRPTb/BavJVUTQGbV3aId10/C9+rVjQIpd1Sqv+goLw0U2es5OSA3dWuYu5H7d6q1pn6MwjszvCXwnamaxbAuWZvyYWownmRTeOrIzuI/+ZouL6nKh1dRZNCzbkzenpPqIA0lri7eCfEnpLGUSmDhy4bR7gdHEr2MhHc30t+XM2H24jxoeAD/txqPe/zWL8MvUSl69ZVEGcQKNNJ6fDjyFBPGZD7Q2/0JE/myZwW5iFPDzucesGj3v4iUc6Gk/lIsdO/3DaDrVpOb8Tk4ap7x5eab++yF7e1pnQgSA6kNfYSZA7kvMlw+hGoaFgZYDYEkSxXqNBeh1/zUpugm2h2n6a+WOGKyuzbfTM72zw7egy17LNvoMYibovcDaGQ1CqWgMjcNfN+R1vbsgD9BEUgLLhu9mWmXL Received: from wheely.local0.net ([118.208.150.76]) by smtp.gmail.com with ESMTPSA id cb1-20020a056a02070100b005c1ce3c960bsm1101742pgb.50.2024.02.09.01.11.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 01:11:52 -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 v4 1/8] arch-run: Fix TRAP handler recursion to remove temporary files properly Date: Fri, 9 Feb 2024 19:11:27 +1000 Message-ID: <20240209091134.600228-2-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240209091134.600228-1-npiggin@gmail.com> References: <20240209091134.600228-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, which closes the small race between creation trap handler install. Reviewed-by: Thomas Huth Signed-off-by: Nicholas Piggin --- 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 09:11:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13550996 Received: from mail-il1-f181.google.com (mail-il1-f181.google.com [209.85.166.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 12375664CA; Fri, 9 Feb 2024 09:12:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707469922; cv=none; b=JUsZqBhbC9f02rNgVNHfo04qr41uw2CPc38hB9l+ExkzjfGXCrZtgxPxCHudFzjwozKkkCXWu/pztWry/snsX6mDkoZ0UUxKPMBCrUqjrUeoMyupaTaS9P+in31Pp6rukTHm+/avdFcKrYwxLFrrKtciUadWHeP81+Ab48xotgE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707469922; c=relaxed/simple; bh=XkWbXJiup8BsE99nEBZlkdOg//43UMa/HAUJAsLv3zw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C1xXpLv39uWDHLrutKHXk7wTF5R/H7E2RO93uVRx4gUzRq6/wiIexzisYeurSw7k3gkiGnFRFuU/KI0qiZE3lvkGOJM1s7vfMwAovnWlROQu7FNZQ755GyEYWTo4v8cVl2gh1+EYpUd9W4sHqtrYepfsmLSrzzEdcXFDSZUpoiE= 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=D+REB+hO; arc=none smtp.client-ip=209.85.166.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="D+REB+hO" Received: by mail-il1-f181.google.com with SMTP id e9e14a558f8ab-363da712713so2073805ab.1; Fri, 09 Feb 2024 01:12:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707469920; x=1708074720; 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=yS+ul2b/NpaGNmT4nHQYQeP0IrroORjWUgFq1DiJtuk=; b=D+REB+hOXikjHTzrTPFQ2Y7RagnTD/8NxkUVR/KPVhERIi3DVpMku9eIbTrVuovZs2 g8wl7yRt8DadYdnPPSNkqLhHLAp7CsEa4qh1MC72l5LHvwOLZHN6NjjCTuFPGnoVN5Mi Kk34TVtWsad/By/FqerKztAPDTFSBFAGnrG1peRYqb68mQL5TLcq6YOw8A+qNdjnYk5U oA431pxGYD1I14P4slq1IsFl/c5fpTpNP23vcUEa3q56i3YjppcjSOUjxiNHUed+Oz5u q08zqXj8QpVnhhAggGSEtgMQY5J77Lq0cTzJCZB/OJRV6UF9M0rzkkgWXTTli5PnyLw1 1Psw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707469920; x=1708074720; 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=yS+ul2b/NpaGNmT4nHQYQeP0IrroORjWUgFq1DiJtuk=; b=poObnCu2GAp/yjCBR0cAikppl08lj4reALo4PXZmBMOvWQ6UY5ZRlcPWLJ3jfws/US bASfn0skru8ARVGAevbXARo9IekZeSgIqS49rGb99oUGPa6DQW2Wd0yDicMOTPm7Z49e FpFW45I7uLwDIUbfahNQuNbVqYey5/pHyUDYk6VZPOGflAyq0uIoFHHaDBpZ9p2rgLJI 7KkQFYRjTRVI7Olafy+6eiuwx56MdT50/YcbM1DS9IJSvquv1ZYn1MLgLmaxX9fE+gI0 QYvSY6mLhD+JlsYbPbqeECdEPtD9cFA1ISTpfa5798bbdtJe3knkUEfPFQIyUU6avJ+i NT+g== X-Forwarded-Encrypted: i=1; AJvYcCXN0qurKvlw5jqVhMYH37X7omPhDVBfZr4pFoU7Rd/MU+3G7HLR3I8gMSS6sdsRbJx/euQfyMQEH5ToHKP8Sl15DTIUXtGP1HVFK/WkgQ/mqzhdC54pO6GfXYLb+Fgvhg== X-Gm-Message-State: AOJu0YxTOUZMitP70BnX/0D/0O8vQi28F+xmZawRJitY7XK1SZNzm6Re esFGKHshJsDgWriM5mZL3jmtCjEn5j1QMYzfBB7Zf4PmV06dwyWK X-Google-Smtp-Source: AGHT+IFRG49LrsMALjwaw/QQGV3P6t7iqzINaidenzf+7nkJ/oR5JUoQayo972KhNecT03FbRR4u3A== X-Received: by 2002:a05:6e02:12a6:b0:363:c5c9:deb4 with SMTP id f6-20020a056e0212a600b00363c5c9deb4mr1134765ilr.14.1707469920181; Fri, 09 Feb 2024 01:12:00 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWDopPltMDOD/Zc+PObLBIP1nne3PAHsVM6zRZWO1HpORlibOckT/gTcQ19PG5LdBYjTnCRcjHTqOD87qjEXIJ1Cw7vJKBTxRxvlbtduv1eAO8QEC3zvdE/JG45h1/hySgdnu4sHEuXGV6jdeujTVLoH6eqLOSPODhCWZI/0SPP3ZkdBudUiSkYqEz1CH99b0O99Nhv5N9EuQELW/E6kWEb6PyvGtdAXrgaVAXE/TeAkLARmmyO0zgbKZglUUiiDGXR28i7Prujn5UHTgY96rYxQNCAhONw7ZbmBCGszMHcWZlZ2hqwhT/hzy/4gSW65TNy5kHI8BBZUl11FY31xxTtnsGu5DOcr/0dGsTqplINJ0f00gj+4/Qf/JWNCKfUWmeheIRgqAZM/KeBUcgdkSTFXIItBmlR7IQSTajuDXKUEEqzQJANuFk2VqKEAoJ+hJhIzPltXqVq2CgQBb28tG4SNO6NsoSINmz0faIh18GbVw52Y1je6CsC9xx/zd8vtsYtwnRkF9tDoHCe77ZgebF4irBc+bEu3Iq91jwtK3kjmKiFN6wxQBWX Received: from wheely.local0.net ([118.208.150.76]) by smtp.gmail.com with ESMTPSA id cb1-20020a056a02070100b005c1ce3c960bsm1101742pgb.50.2024.02.09.01.11.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 01:11:59 -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 v4 2/8] arch-run: Clean up initrd cleanup Date: Fri, 9 Feb 2024 19:11:28 +1000 Message-ID: <20240209091134.600228-3-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240209091134.600228-1-npiggin@gmail.com> References: <20240209091134.600228-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 Reviewed-by: Thomas Huth --- 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..c1dd67ab 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 + fi + unset KVM_UNIT_TESTS_ENV_OLD +} + 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 09:11:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13550997 Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) (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 10379679E7; Fri, 9 Feb 2024 09:12:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707469929; cv=none; b=BJcBB9oKYh6e84EERdS4z7j6xGqbcrMqEQcHMAXgN6xLjO+rh9VQcY2uU3PPVualM3jUMPSDBrHu/Unyb4yCqsmck8XJVX+H6ZWOsmmfAVTGnipLxyVX+SdqZGwEkAHMJMvmSQsZu9FC7ox1UK3W/9mjA39CyujpZyutXYkb+Pc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707469929; c=relaxed/simple; bh=skjZjXlI8C38ruEi2hlhX93rLEO4EIwDk56z9yMwflU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kj4smQTNQL4WHxqB1IzpUQkk9ZHYmx45nRw/TXLGG1XqcC3r4lccLlD9HK0+38SaD32jV9YWH5miSI9kcxTmR+Fbc1n0nyvkkbDKme/nEYPZsUGa8dH7vDGxiNiOSJ3IZ3DET761RetITEjbYVbge9j5r0pGH+/bSSXOI0F1M3s= 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=d7qP7dF+; arc=none smtp.client-ip=209.85.210.49 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="d7qP7dF+" Received: by mail-ot1-f49.google.com with SMTP id 46e09a7af769-6e12f8506ccso323272a34.2; Fri, 09 Feb 2024 01:12:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707469927; x=1708074727; 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=ueRelljhUpFIYjZZj8MkfM076AFkfPtPKMcEp6Rqelo=; b=d7qP7dF+u8IwTOyydCkGZvBDyNNM8SRX5tywoGLxMFb7P6ysAtgLIlC2pi3kbHvQKC wyyN+iE3FtCo1uzb3IMyVzflaMkO/eTkpZHIWz3azn9+73nIhwyIA7NlkCsUTtTcUvOT MTCIsqLFGHBpWgfWQmNssIdR8WmdHcJLDPdP57LWPicdr9hij5zUEzDM8ZHNZpASdWiq 1Sht84ybEQK8F6tsKP3TyK3I6FCHpL+a8vAW/NdzCJYRl827ExY4QIy4D9J+rS7pRy6z 7fn7ggMrciPsdll1N/C5CIX2qnzIAAH19xprb3OaFjQ4vc8M/FJ1vs/OJLAgkSWI+mlW n28w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707469927; x=1708074727; 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=ueRelljhUpFIYjZZj8MkfM076AFkfPtPKMcEp6Rqelo=; b=fOEl0bjxmUEnKO9KCjkfyNk14m2e3tEuRXt1sI2p+0cQbILrnzhWqVP0s4GM/xzAeH IQj8yM5p28llvXIWPDyfiA332iXkD/tYKV+VNqPCokX4gl4DSLR/qPKmShCDvQTmy28H G7BcogYu57ymSM7H828fDuvJKwF0xl8mDuNLiEmAIU4+x2YKPMUr8xJgGzbuGnNallOm fCv2EiVQycak4Z128glUXD84Qr7xngwzG0Wg6vjg6p93yVk+ecKWh/EPPttO2ETBP5QW kvPwt315ZpIvUaYLNQJcvGL2QALjXFGi3vVJKvpgUHHzRfwmQxv9OLlbV7h+Ij+va/b/ wWqw== X-Forwarded-Encrypted: i=1; AJvYcCVky8Txeg1euH0Qit753h/D2JDFVvXkxX7wU3OMMn+zOxBcEPmbwSNIgf1rawiPACptEuCDnrJXvZmovfIxr57Clfli0YKlIeBzpr6TswOl6RV5reNvixD1NfVib+1TDg== X-Gm-Message-State: AOJu0Yz+CUi01XeV/0HPOYVRUUMsLOTfercq2o+94qCTs7RUDVsOYm/X RzZ1oPK2Ta8VbhwkEi8Io7CuyWVpTZsrQiGEpGlIGB3ekLb8edoA X-Google-Smtp-Source: AGHT+IG+uF1AVKltLLT/Mxy+BTg+RrPJAlXJIq8b820qvd3G5/GdkhJ+6IWxpDYFMlAC1NwZY+uNog== X-Received: by 2002:a05:6830:2646:b0:6dc:9cb:bd76 with SMTP id f6-20020a056830264600b006dc09cbbd76mr792620otu.4.1707469927219; Fri, 09 Feb 2024 01:12:07 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWzWA83VkewDTZfCMZdk6G5YgheMq3t4JNWJCTTx5tmNSX/1gsPYIiH3qmJJq/ijinLpb3xeiH2zs443nSPQUpC0/Em/eeE7RoY4CHLfiXosNuS/3XgeKdOWIC5vELsZJATbQJwpPKfQrAO6jTEODObtJTizbk7H/mPboAdVVqcEZXaUUJ1i35iJVQQ8TdtU37SY4l4vA/HecyN0hGa4ZQftCxlT82HavH0PWHaEow8h9L//3jq2ViO6p3heq9tcsCsGDGWifqycdAeJ+NG+ZZJJKMPQtmF2rgY2/VimIYYSsdsigD8uaLiwOPw7UmRAKWGnWc5vZmpNzTmQfLXihvaHpkTSfTh7yoa65zAimrjVwsQgHs0YjUoUUWuAj9uMmBmpX3UuPk6qu6f5FgJpKJvRVgAcyzBf4Rodf1M7Cd2pAfF5wAiVnR5IDVF6VF4H+eehWMNzS3VqYzuE5TlrklgZg9CX4fK4r7Ikjgvg4oznWMvy/CcF4gKGTZUQi3spCoNRwXFsT1963QqFGp43gEXpqK/iBwlMrv+ntA9/McSpbkv+Y4icgFi Received: from wheely.local0.net ([118.208.150.76]) by smtp.gmail.com with ESMTPSA id cb1-20020a056a02070100b005c1ce3c960bsm1101742pgb.50.2024.02.09.01.12.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 01:12:06 -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 v4 3/8] migration: use a more robust way to wait for background job Date: Fri, 9 Feb 2024 19:11:29 +1000 Message-ID: <20240209091134.600228-4-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240209091134.600228-1-npiggin@gmail.com> References: <20240209091134.600228-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. Reviewed-by: Thomas Huth Signed-off-by: Nicholas Piggin --- 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 c1dd67ab..9a5aaddc 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 09:11:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13550998 Received: from mail-il1-f176.google.com (mail-il1-f176.google.com [209.85.166.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 4EB99664C9; Fri, 9 Feb 2024 09:12:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707469937; cv=none; b=iox1wdQuqP2ov1f/RkKGpQmsYqrgVSff188qLNtY1YlVchiGj1NNmv3zTsKEa0YSlnuHf2+uBQRoeQgW2PlgurjMu0zGUt/mEeOGUYimlYDUhwDxHRWt6XUFV8BZS1G88oypE+iPr3fc7yee9vV8X6qjNmICEROlaRVKHKlMLIs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707469937; c=relaxed/simple; bh=/BWxHdbgtJmDCBbNGut75HtAqp/5+5sSfL8SAdWk/SU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ThWGrc0BxZq377CFE9vphNliO/f520YZw4xyztzGCb7KcARDPLBNwuh4qtyU9uk970bGB3P3mdKC6Brljt2WdyF995FybBvmTJiGt92YrwEnxx31UvDnkdEPm3gdJosbizEwK+hpEfnRw5qxOnCtF3T9Faa5np1qN6moeYwrFM4= 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=dDm1EluY; arc=none smtp.client-ip=209.85.166.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="dDm1EluY" Received: by mail-il1-f176.google.com with SMTP id e9e14a558f8ab-363dde86f0bso1927345ab.3; Fri, 09 Feb 2024 01:12:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707469934; x=1708074734; 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=fT6qMRC+pw0S3IxnByVmt3CuBvluv9Wtp5vBNNErLSM=; b=dDm1EluYObNvEVCeZFeS7pvRbRHIGJw1Pj0Xu8XAVHWyCVnMr8DJI9q2oJWjh12Ccq DgPq/YEWQYbBcTEzBps0Ux5ptdrjqMb+zXnjlPTgk+qfhJqnOkZxneXldaLMexZa1bDJ 26BR2EbQr70yYecJThy8527BTfWMR2MF1JqvvGD4a9EaFscSBR0GB9izmClKTvC4HaIs +yJyigpbnzPgDinXyfTFKWwIo7mdc1tKS9Vp4giDyFt7LWwstmdsQQbZJPgW6iy5mz+x XiQDoeIemlSZNlHeosUiFye39ulCzgYa27ftH7ya5Fg+dAO//jJayST1ostCRQwuhRox OHQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707469934; x=1708074734; 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=fT6qMRC+pw0S3IxnByVmt3CuBvluv9Wtp5vBNNErLSM=; b=gi9BXQSxOcehCDW84SXaqB1GE8k1b1N6raKWD8nwJNOJD/5j4tt2mJz2rA+cubfEFM dpjYBWx7M9sKL5C33500JJg/onamEhMUiDBqQIYTHPobMjvpea6fvO5vo/ngYYa4G70w i21MMewCWSHEWMiTiYmY2CHi+JSANrKPaxpFB2eY01dSYped827NDfoSzSMh0UPvr5Lz erp8Acukn8BE90BSgCavXfvfL9uuxnmzYkXwkBng/WPfr+/Ct2jeY9u6djsKERkDKMRE SS/2AZYwfy5T1wYs/sBGneHego7JGwHMd3J/uTxpCNzmEDHzYHSaS/+lShdPdleW20pS 1+Mg== X-Gm-Message-State: AOJu0YzTnAkD4i91qSFeilRoY8U7ux2/+pH/LxHp2hnIW+WnErrtraDF 809NoNkysrBgMsnXmkxdlKBPYRDVCys6XwVlf5WnpZ6g9FYQAX2tD5/sqkyN X-Google-Smtp-Source: AGHT+IHibsT0DSntKBcN9RYYZqiACNyhgKRW2VVt94qySfQqZmMFZ504tD+p+VBnJx+v68Q4gh04Fg== X-Received: by 2002:a92:b74e:0:b0:363:c664:cfed with SMTP id c14-20020a92b74e000000b00363c664cfedmr1118904ilm.32.1707469934457; Fri, 09 Feb 2024 01:12:14 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUVYUB37apMvQ3VGs+5Ws3Gf62dyGZo9vthw/uz2L8OaqTwDVzG54ysbUP990pgHiF+QNtoyOA03eNjx1V+XPOOE9bPSzjN43HzQNvLlrAC9EAgh47UXkUot0FXDfz9bYAWPqelgBgje2D8EMT5PUnZGIl+6zCs7aIg3+ZGh/7zewiyD1ugr9cR3Ec3QFOGVtoTxgGaa0mco2m36Gc37syL5HxoDl8tB7OUqiiwCs73+Ag2Lt3vx/yDxMcfmIzSFRPihipEKRuVJH1AypJqKPjCUu28AGG6v534t8byoP2pY8YAy8QkPbGM+d+AaywgPttwLbA19VlO0PFkRzhUw4hI8Cj7EOQ8R/MnpLdZrgyWTzY/O0kidqUV9XJE3B7Ju0OampFZD00XE6Msn/CHG2OmecmFiFyY5M4pv1zwbh+LAtrk8zIzClmGUq/8ArY+g0DyeHn9H/bgFP7SA0cpfLUH3hKHqDsTEri1+o1FQzMuKvgpkWukjEm+chYWmmmo3dU5nf8NhrTVyoNDows/v56C+GpToh/abzr/uRsw+gG/UMq1QvVLg3Pf Received: from wheely.local0.net ([118.208.150.76]) by smtp.gmail.com with ESMTPSA id cb1-20020a056a02070100b005c1ce3c960bsm1101742pgb.50.2024.02.09.01.12.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 01:12:14 -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 v4 4/8] migration: Support multiple migrations Date: Fri, 9 Feb 2024 19:11:30 +1000 Message-ID: <20240209091134.600228-5-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240209091134.600228-1-npiggin@gmail.com> References: <20240209091134.600228-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 Reviewed-by: Thomas Huth --- lib/migrate.c | 8 ++-- lib/migrate.h | 1 + scripts/arch-run.bash | 86 ++++++++++++++++++++++++++++++++++++------- 3 files changed, 77 insertions(+), 18 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 9a5aaddc..c2002d7a 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,20 +146,54 @@ 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... + # Start the first destination QEMU machine in advance of the test + # reaching the migration point, since we expect at least one migration. + # Then destination machines are started after the test outputs + # subsequent "Now migrate the VM" messages. + do_migration || return $? + + while ps -p ${live_pid} > /dev/null ; do + # Wait for test exit or further migration messages. + 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 + # The test must prompt the user to migrate, so wait for the + # "Now migrate VM" console message. 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 @@ -164,7 +202,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 +214,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 +230,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 09:11:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13550999 Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) (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 24BF1664C6; Fri, 9 Feb 2024 09:12:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707469944; cv=none; b=kCyAntGzSMkITwKCW8KUnpbSxsGJ7mblWFF9gbaxGgvZCnAxE85+53enhrE09gwpp331RvioVTX+ZqFPfGALL998enmu9nbbiw4pxYgGXwmb8MmP8XtGU9TQPRCqxyTsTM4ovISXbKo5Z13TOLX7xe4sFRU+xkCzyZ+GI7H24zk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707469944; c=relaxed/simple; bh=hFQmAXGuXJzsU+D6+fezDb5bPNLYd+sNQribc7Q6YxQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p+yCIeKdOg0gpS4VS7PcTz9a5TH7QxiZy/PdUOJmU6mUJ0tOivqxoBRXWXBJM7KPkHfKQgH4JQNfA8idegpPxLsWmOYM9uxt0aGVv62MX4um8qTN3Ph3Xe9R0o6vCVh3q67mbh7+uOvftiJJMoPY7uW4vse/sPVZrww3iBwbq4A= 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=Z7xeAvSD; arc=none smtp.client-ip=209.85.167.173 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="Z7xeAvSD" Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-3bbb4806f67so451503b6e.3; Fri, 09 Feb 2024 01:12:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707469942; x=1708074742; 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=X4s6FdHef7vHJmaayGa/KenEMFLkhsTB2Fe0/1F6SbM=; b=Z7xeAvSDJkrttKIlB85D3aTzrdzXXwo3/bpnExbO3d/sMbJhsR7vcZZr4GtZTwqIEi CfdTZhkfB2fOxDZfPTfw1EiHFZPb3wmqVI9HhfgxF4qRRrS8JWRFZK5Y6HOfCBYS3RnD BCrkbG/ez2iJEFs6eeh6XwdOYCp91/s80yn7iJO2LpGjvqN+l6KM0bbQgQz9gWziWu8K jUyo+CHgwOi6/86+Bd0gVAT85J+KREt5PgBWPkqypYZukRLCOwkXMJHtny2hBA/LlYR5 Xw+rgWC6Li5ivoweJk5NgtPlXnuXCBzACFYfAUEQHiKXbyc+GbXLuja453HNpP0xJRWq zwgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707469942; x=1708074742; 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=X4s6FdHef7vHJmaayGa/KenEMFLkhsTB2Fe0/1F6SbM=; b=Wchhnft+ifYfgsekvJx/MBRjvQn+uflb5LX5k3qYvnckWNyv8N6h+/s4o3LHl5nti+ gAAdwrLGmSImGOPHsVDJIwf4r1Bgg55uYe8XlmpliFE6A/8r2Iad6t8lKvKjgHn1bUMW DZVzwY7a8ntlmOHTeoWjbMlHYTrRRGzdAVOqDEMsxM2JCF8qpDlfrqiwgbfI1XuQdI7P k6DYry9op4Dp2e9J5JNL6VUvSrSTu4AE2+/cllss3SsLR8WPLtc7Be900xoB7llKW1IU ZTHsZEnopp4G/X7djaY8jOPGE/gp/S0AzqoA2sCFpQylt5IibtkpiJILDToEw7h9EpF9 Pt2w== X-Forwarded-Encrypted: i=1; AJvYcCV8E15gzNLgweCnCw2LCznqNHdj2ffCloYJiXEcp3UPvr/SlfyzC+5MQDXG6gLdwF4GALtQ63ktyucUA5Zel8+kzF9Et+V1wfisUp31JmVEtbG6h3W3ap6FLbMWWMJxZA== X-Gm-Message-State: AOJu0YwXFDger/j9z7+UfAPF4n1cztw9EXCNbRPzMD5a7Y4wvnUlWEDy Tvq9Fa/w7R5QNWwlRJ6XkPvk+Y+BaTsgqYInd/zco5C1Jio1/6iS X-Google-Smtp-Source: AGHT+IHzygceGEjkPjUx0xiCajopPxJC7oryA1WqG+A/YiVXTpAlz8lhX39kYbGZTCk+iygcpAOZSw== X-Received: by 2002:a05:6871:888:b0:210:b468:6a5d with SMTP id r8-20020a056871088800b00210b4686a5dmr982709oaq.16.1707469942286; Fri, 09 Feb 2024 01:12:22 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXKIzIOsROoCCo0GMYrwniUaZ4ECGCXrpd7nSeCWNDa7srXa24kJgicmOyaUEtvuC5H7ZuHqBX5XyVdmtQMrrH9+TJka+KvnEJG9BWBrL9jZQ9qVBJCOx5XZrM5C9NJtyoub16ywUB116Nk8aLVO+1LoLpqVZinTA8vznJM/LHt3o8kjpKjABgq7JhubrCdpM3DG05g7uzZ7yQni1/ln6w8NNVGWnCGmX7uvKUncNnqFbjEeNi/i6hKLl7wD729SMiITlNt9nEFJX4IE94OHsj1NLNXoSBdiw2cMGvcqi2nHWFgpkZY0CG5WqxtfYVyJsIXGqWfV9H2YaAy2HJpU1N74m8fRiRRtqukEbUw1p/bx9avPGME1U3BMu7ukU6Vf/yXwzquYMae78uUG6nTwxozOB7rddS+71+Y+YtIkx2xPOrMbnce7EtAi9OFs7SiwqpH7Nt948WvbtxL4qkPmOYQ80srRVLRA4io+LPSffMsLiN/N6vz7R96DH7+B8gSNPc7iS98UUCpxXl6HIqB8JsDqN7lU0+gL+vYk0mj9WvT2GerrLzpQxi4 Received: from wheely.local0.net ([118.208.150.76]) by smtp.gmail.com with ESMTPSA id cb1-20020a056a02070100b005c1ce3c960bsm1101742pgb.50.2024.02.09.01.12.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 01:12:21 -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 v4 5/8] arch-run: rename migration variables Date: Fri, 9 Feb 2024 19:11:31 +1000 Message-ID: <20240209091134.600228-6-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240209091134.600228-1-npiggin@gmail.com> References: <20240209091134.600228-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 'src' and 'dst' to tidy things up. Acked-by: Thomas Huth Signed-off-by: Nicholas Piggin --- scripts/arch-run.bash | 111 +++++++++++++++++++++--------------------- 1 file changed, 56 insertions(+), 55 deletions(-) diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index c2002d7a..c98429e8 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -132,27 +132,27 @@ 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} & # Start the first destination QEMU machine in advance of the test # reaching the migration point, since we expect at least one migration. @@ -162,7 +162,7 @@ run_migration () while ps -p ${live_pid} > /dev/null ; do # Wait for test exit or further migration messages. - 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 $? @@ -184,80 +184,81 @@ 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 # "Now migrate VM" console message. - 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 } @@ -280,8 +281,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 09:11:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13551000 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (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 37232664C5; Fri, 9 Feb 2024 09:12:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707469951; cv=none; b=Fb82At//J5JvawtaV4A/GBZbzVknGKmwvs7FX+hS1+qE+DRWUVo4ZkZDCrF/EoDsV8mxS/VHdx3SlhKcTBTHmwHUUrwkdarixI4HHLHEbJ1hUwIjqIbzn7CJugtbQLwy2mhDzdvrMmihkRfTGn7CaMxIVBEhYNS3G/a3DwUNyIE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707469951; c=relaxed/simple; bh=H5zOkFsThYHS+CIs/f4GLylAaVSi5mDx3GgSSHbQBfc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Jsm8YeROWpaXeLNr82J//pe6jV1Tt2p1eDZT5gIGNuYaBD2VTxX/CJgHDPjpsXWpMgcN1LShqOksS+ij5UlIH30tUESDYHe104OAw7KHlC4Zz5/EI5Gz6FXpOU10xknpkgeznt+kjoxi63HpxLYqnspxFccnrYaCe2MkKlAteJw= 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=IU85r9dy; arc=none smtp.client-ip=209.85.210.177 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="IU85r9dy" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-6e04f29c7bcso518614b3a.0; Fri, 09 Feb 2024 01:12:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707469949; x=1708074749; 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=J+sqr3M98Kde9sdnxslUPSokF3Ng1Usn2pZLKUoX5aU=; b=IU85r9dyBnZs0lrDqnKzjKYbvOjXNsINz5m3L48C9x8Tl8NhRFBjVfs7dOc64dS581 tZjtDT3FPe1xJ0C7OBQbwYjdgsevH8kViKg2qHcgfRaj+H4WrpHApvBpJcDj6sNEEWgJ aE9Q6xxTmFz04Q75MuwI/r19LymBialarYw+NgFSKDnxijsBygDCgHnvD2MwYu5+Qa2f +0LABTzVvO3QGeC6ldb42p9HitbFrHEnvAyJMzD0choSvK5/rMFCBQiM5LBpQCT+VtA6 +cpn3AaTrHx51lsRyfi2qZQRwBr0GJHlR5XjMHmsQj6Pv+s/lecmf5fK2AYsZIkV0eo+ ySzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707469949; x=1708074749; 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=J+sqr3M98Kde9sdnxslUPSokF3Ng1Usn2pZLKUoX5aU=; b=Bb/VWW0Lp5xisz+S49oi0c2iDBN6Kyr2AuatL4SLwVE2EYx5/TgNYGpI1wIdQJkRDg t5kmvrb8uJfg8BXGPtPtr69B0zEDAA3OxXDX37iOe3NE0U8nPUIw5tz7sUkU0Gf/w+U2 OxugGj8HeIGKQ/jC/I/Hw6Pc/CV2NF/vP61FQznlVkVTxVyhh/PJysMJrceG+e1EF1+J Gc++yCglQzjRuB1sYS8nkp1QjKb5WUre0dcKdZ6WFy01XnN1mPh2elMrOu2Cj1HTRm7B FUbmExcdLY+whngMJIEzRdNreQx6wx08UQhQzKqdrIOwDk/1u7NV/T3MaAGGJJ27JfHt MlyA== X-Forwarded-Encrypted: i=1; AJvYcCXmPDQP9fKMsfhWv31bb4ATznYniv8uRbKnLBpbpSo5TvXxUMFshZWeE0BBcQyKfm3e1a6F7uEJ4JjvTXnZoW82kcOUP9rVPFbhxXcb/pRXsO4ySiLlVn4qdfI96rHLVQ== X-Gm-Message-State: AOJu0Yxr5xGslrFHAIDJAeekHJOVly7gxQ+RtFYGBTQ8kgrqp2DGQSkP KYgubdDERwc7ZCjO0bvkDz7yiAeWN9EFpN9QvjTROJFkgA5fy/Fs X-Google-Smtp-Source: AGHT+IGZiCLeAGHQEeXZBPf6iULKQpILOZ0yiXZFxdekf6snAicAqOXMJ5tAAJqWOoJoPAenpSfyfA== X-Received: by 2002:a05:6a20:9e47:b0:19e:3a9f:f925 with SMTP id mt7-20020a056a209e4700b0019e3a9ff925mr1379427pzb.14.1707469949311; Fri, 09 Feb 2024 01:12:29 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVzluO77dA063QfZWhHREA8V27IxpTe9fFgjzHmlT7bplmWFF152odg1GY/Slh6d8UPJTMANFSrITjUQ0ZsVqx+spgRQEVJ+SXxTdj5OfvWG+QyNpKU9ojdeobZTJuurl6QEnqzJRn8ypfSc7USux7m6h7xZIg7cohLhOljnsjBWtwgpByMWvWzkO0mdnEY3SWfG3gwAL4H+xgDUxWM8QW45cQdlEv09vFEnxijUHiMTGFLxivLp13tBWO76S87z7kfj5i5flJj7daI57LyoDUeCGACU0VoFibaf5To0doTdDkoHOHRoXm4+EJWraVJ4Ds7QDbk+DbyQtdPgekRLpc8g2sjQ1pg9DWaX3y0a0r4zsA/Yd1bs+KTkH9jh/ruwgLzmm+RqM9n+MKClAnuNel5pMLNrqL7lJTegkrgd0nxN30CMzv8ZF62Kmvmcaj5ENlPByFuO4bgJYcuJFcH0GKBZP7EqW6fsS7i0hLhK9gNM0eIdKi1J+4btINqVsA1oz8hCafDKYNlQZ3riVPWLHUfmS1tJdMfZfjOWB6XLSjgK2AJ2HR/qIXT Received: from wheely.local0.net ([118.208.150.76]) by smtp.gmail.com with ESMTPSA id cb1-20020a056a02070100b005c1ce3c960bsm1101742pgb.50.2024.02.09.01.12.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 01:12: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 v4 6/8] migration: Add quiet migration support Date: Fri, 9 Feb 2024 19:11:32 +1000 Message-ID: <20240209091134.600228-7-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240209091134.600228-1-npiggin@gmail.com> References: <20240209091134.600228-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 Reviewed-by: Thomas Huth --- lib/migrate.c | 11 +++++++++++ lib/migrate.h | 1 + scripts/arch-run.bash | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/migrate.c b/lib/migrate.c index b7721659..92d1d957 100644 --- a/lib/migrate.c +++ b/lib/migrate.c @@ -18,6 +18,17 @@ void migrate(void) report_info("Migration complete"); } +/* + * Like migrate() but suppress 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 c98429e8..0a98e512 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)" & # Start the first destination QEMU machine in advance of the test # reaching the migration point, since we expect at least one migration. @@ -190,7 +190,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 # "Now migrate VM" console message. From patchwork Fri Feb 9 09:11:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13551001 Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) (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 AF272664D3; Fri, 9 Feb 2024 09:12:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707469959; cv=none; b=kOS4b6Mok6pXqxvPSz9jhtdZCef3d5RivzqL9WPTvwBrI6GoU5SIQTttwB9v2FRsYlbD88HHVrZz8XdsfTKQy7IIC3f/vYEwVcHtOAb13uikC+Jj0uRxkQIyYOzRgcPUia64JWuoMbCetfx7Uq3hjdpDzOm+xxiGWxajTMzPQ5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707469959; c=relaxed/simple; bh=3h89rZxZOC2oNaGXb+xtrg1aGJu/Sq2hVnRS+W6GlNE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cRgnDjEX2G1hh+uxgtyBGk0A1notuXu2ak/7jqLYH8AMS4twE0DsEsPmm5QufsKBMVPupeNy9nKCurk+tHGagmFju2lxL8BinDopoo0Q60djZeVfBh3XAIEln0ZJiHnFHMXoNNkEKXFQ4ItZpGinOSFkgy4tF61NHHH3d6g4Avk= 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=idgRyKcC; arc=none smtp.client-ip=209.85.167.172 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="idgRyKcC" Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-3bfd3db19baso270108b6e.0; Fri, 09 Feb 2024 01:12:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707469957; x=1708074757; 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=+AksW/xWOBo9VmX/69t4hhS8qRPramQT9Z7Ypigl0WA=; b=idgRyKcCFnOIMcQWAfZCNeprlsd4cGcBIjLfr6UISwYr3l8Vc0V4XkQexFTj1kzdW6 uvLci0NI+H0V3kaD7jYyDrH1MxJhgir+umg0F6I4cQqQt7MQALy08h6jjp0kOHKfyUw+ bVj7u3RmhqOQPtzHzGEdR7fiF3p/awAo0rvcLG8qftADBbDQTPSj34XfkhtS8PiNcYkW 4nS3b+AWxJJ4F1Wu/p1Tm3BsUniCpAnq40i9ElHkPgBrG1wE6JojrQ/lHshwDMV38lp3 suhsrgByeSS3wPKtpzeb9mCtH7EEbMvM6+Gc9d2krO5J73nfmuCtOerwH7Dm+1tpxshd aWKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707469957; x=1708074757; 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=+AksW/xWOBo9VmX/69t4hhS8qRPramQT9Z7Ypigl0WA=; b=n3hXh9SA5DWndBqDVsLegKvH8mTNB0fu6bTX/kn6R6lsrIUsSFcIvWdSsoEMvaT1uM sqarNs4IFB5SCHQmSt3CGe/1i6jablheGFTlj+jEsR94lB4/eBPEB8G5+EuR7L8uyBRY vQNkteY1U3okAQTxYRwYhTVoDb4LwJWpBIFzrzva9VX0Ahi8b/E3JKLgzlevaEhkey1z EhbCHA0qtDgr48a0qMRRfRMxWUu8FGuiKkUMumYVuVVChi2Y4H4nMzxBENQIuDqDE3d0 6IJvnWgueMTVp8rExvR49OUl42xvGv1MejLuZYSomZujFRia/0pPT4SA9R44qXGSnXVh KO5A== X-Gm-Message-State: AOJu0YzNMG3GwSugVB96sG2ea6fcUgiIFktSJw0R0y0hy5ntEiZcxPQW wOYCTvzJwVg4VfvEoMr9vnWU428zs5nTJih18FZY90dFl54MhVAI X-Google-Smtp-Source: AGHT+IEIHO/U6QjmJfygHFclXfxV0lUCeX5heQt+eUUVJ/hovB7xrXAgLx955AGicKrmFgk9n+BoKA== X-Received: by 2002:a05:6808:2817:b0:3be:cdbd:5dd7 with SMTP id et23-20020a056808281700b003becdbd5dd7mr1020153oib.22.1707469956625; Fri, 09 Feb 2024 01:12:36 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVs4qVmLOg72KKuZcMy0BE7Ki258JyQKnchF94kWsJQhod9hUbwO0sAGfTmMkyPrrASwCq0D7tUe5yFIAgzO0TOZ3vHCBifsKHRhuln+uNTcU+E45AxYikhLN7WqNQA6kX0nJ1Mbk27Y3aPc8w0m3399xZKJKl4XgbLyCLXV6jdDt1jpJ1QrPjWfyx7OqDsM6kaSBg0zg6uHz/XNevzHcASmYePg5PlIFEqNew4wpWP4qHByjifIlUvbHfyZuHQdH8bcMLApowIbtbCpx9aSZ+2XpUdMAK3R/0FOQDsioy1JOYXZ8uQWSP5cJsmKg2QeSOfnxGt0iLNh0TcbTptf/op/dJkSilKsNT+sTB7czY0E+VkAViH4lfRfms072VbOoZ+zZXmVSsj0FCbqa7W7fO04f0u4e3GXuVizAvcjV/vKj3EMfWKOYbqKYB4z7wgxtwuqc1PrAMTIBhE09BejP9g6tlkYJzaPnRlSfJ5KHqlbElD0nn7ErsWzL+IhYYP3BHs6vh1wM+5kKO9rzOxxxnaqzwvTSJ1ZDtr4fqczCevhxa41nBzhKqi Received: from wheely.local0.net ([118.208.150.76]) by smtp.gmail.com with ESMTPSA id cb1-20020a056a02070100b005c1ce3c960bsm1101742pgb.50.2024.02.09.01.12.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 01:12:36 -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 v4 7/8] Add common/ directory for architecture-independent tests Date: Fri, 9 Feb 2024 19:11:33 +1000 Message-ID: <20240209091134.600228-8-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240209091134.600228-1-npiggin@gmail.com> References: <20240209091134.600228-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. Reviewed-by: Thomas Huth Signed-off-by: Nicholas Piggin --- 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 09:11: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: 13551002 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (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 D551F664CD; Fri, 9 Feb 2024 09:12:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707469966; cv=none; b=Xk+uESTz2LpHMiIbd5CK0oCko/5k6ZNTxALbNs2U0kYnZwNgrMl+m609LfMhMjO+kUZh4C6LeeYxX0GrVjk2wNxiq2vcXBYJQxMQ4wi7QZd2CB59UHTACZ8p09BrWPVBoQxBFCOYaPlke5Z6M0put0VMg5xNJ5i2cpm8q6sY+R0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707469966; c=relaxed/simple; bh=YDiPhKCwA8NLGHrJJZAVTr3FIYsWlbq0GjshdSQahwo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JQS50ZFMjqpuDjAOp7oUKtoNeh2Ua1oR4NK9YeruAeMhnfgTWnqRAfAfDwVbhB9MRPraqXQbAu4A+Mv+Z+HLDcnUc9EKjxQHy8vR1K92Z1SnUjpEuFBLu8+4xjHMpJCSk32RixuSxz6Lh2Zj1VRxUr0lFP28PPpAigM+bRl8BKU= 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=G0p1pUH/; arc=none smtp.client-ip=209.85.210.182 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="G0p1pUH/" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-6e06725a08dso511818b3a.3; Fri, 09 Feb 2024 01:12:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707469964; x=1708074764; 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=xUi8tWoV7y43d8/rADxcJNoz7Om9vKHwuVyyk4R4P/0=; b=G0p1pUH/B71XJ6sqw5XHv9bqcEWjp95IIGBSaUx6pS5VI6+eBTvyeCIg2YF36brfJH 0lyGUxJDkFAxBQiNH7KsjLXCG2Q5dd84E3fG8ZtP4Y5GDmnXACZh7p6+utlcFLNiy1sL C7o4Nb6xbVfizEFbMJRXySKb31CpeI7gGTfATIqGmNNSDBLbwSj5zfzFMg1u48arCYsf fdZM3kw6up7UT6UqR1FVwG1pVWNeix2lELwB9bm465GOjJGGPM/RxGi9lI/CTCKz7K9K SKGgBE5VltrkeMbFm86jX6quTeDvxcg8CAVK1koyGG6KYBlXudEC8qDkWd2wwDyprCnE AZFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707469964; x=1708074764; 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=xUi8tWoV7y43d8/rADxcJNoz7Om9vKHwuVyyk4R4P/0=; b=o9JF84yCwAcEdgyVuHrI7As1nLvTsWVYmZsJYKnMFyrump56S6WrDS/nTNbVRDBEm0 gHty1+P2ae4HaaHLygg8DkjI85azY6A9+oQBE1Ps3pmO0Ow0qhkQW4ypkBsQl5/Mct7M 2oLGM18BPigk7p3qUNdrO48fAIWz/YOEC+sROJUpzPTnaVsxlmRiMpUU1Px/oGtBwbte xx0mGr+9aqhasiBgZG4Nu6FrwpbzbaOfMR/h3MJLcFJd03HyeigEXX1vtrI154htnKlY QzaGVxRcqj714kLuwSy4H+dBckgF6qsg+arkCIcC8M9YSwRqkYAx3v7vVLTR5hdZDjrw J9uA== X-Gm-Message-State: AOJu0YyX2yaO6K7UykltVYBPMPKbcLNW1HWSUZsQhynrBaiLlI3Cmt1n ykBOcFfNud6OY7ZEyjwI0GOLGkuAhtHKieBPfoQPTak8eP3TGNg4 X-Google-Smtp-Source: AGHT+IEU4SjDeB439gZ1v+vHOsu9gIns1aZMUMmovHkP67opmUKwsDY5/bROOCbrnRZ9ZxCiwcuKiA== X-Received: by 2002:a05:6a00:80e0:b0:6dd:db87:6356 with SMTP id ei32-20020a056a0080e000b006dddb876356mr897226pfb.7.1707469964083; Fri, 09 Feb 2024 01:12:44 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXrwZjktcf61HetSLBq6YFmOCC03GE86GQEfIt7eieexAYX156hMSSPKOXp7y3e12XVLDSW4UuAQGUhgwTKyp0ERxQ+7FDd0Rvk9hb7ibp1h+V4KNfsR7GMwMXcPYGUsH//ZAt/n7cxghZKwqfsahSlqC1uLBO1NNvZMNa/9LUNtk98M/3JSP4eg6VwJL325/HPcjWWfm8UwurysoUGcBNBOGnpdqlwPXk6p3YuDXbKNk0mI3Ea400fweEVt0bzLpG+dsqWnZ2yjR3Er3jtBi14nN6pC6rZP/dJ7l5sxSAtbkq+ya/AxRx1Ntrl5UjE9TdUB5qL27ZAMTaEiMb2Wiohr42TS9qrRI0j6M5X1TVVoxnBEwVOGBabsSIGDjYgLb3VA2aXN27xfXXDByohtjQtJ4qHk+KMPAS1B/Y23na7l0wbcRJnJJBXyqdmmhESa3FrkiW5DXrRneZjTbBAGkXfeFi5LQ1B2kvdOSqzLTaC0oZkKQPJDWhGjTZPXMliWp1tirt027OA3K5bSh2Tkk24RrjmC21CBtlObJ/PL1sw+jY+ky4qfTwb Received: from wheely.local0.net ([118.208.150.76]) by smtp.gmail.com with ESMTPSA id cb1-20020a056a02070100b005c1ce3c960bsm1101742pgb.50.2024.02.09.01.12.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 01:12:43 -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 v4 8/8] migration: add a migration selftest Date: Fri, 9 Feb 2024 19:11:34 +1000 Message-ID: <20240209091134.600228-9-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240209091134.600228-1-npiggin@gmail.com> References: <20240209091134.600228-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 in 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) Reviewed-by: Thomas Huth Signed-off-by: Nicholas Piggin --- 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..db0e4c9b 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