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: 1896874 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=I/+wSWMO; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=k47E9Aod; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TWSm066WGz23hn for ; Fri, 9 Feb 2024 20:12:00 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7Uoku562aRwfnF/LX+TKTqwby7yeABXuyRO9Smb5mA4=; b=I/+wSWMOP4SnQE PGGIyjfnPDJXZNnmketq1opzRYXfTmaBAs/GiTKWmlAF+wQTnXXKGlrdz77ziWQ16edzXG1eVUz5j GFk5jBVKauSK4TX2PrJX7egCBhELJcCwwrxzx1hRfNIDhvIdxZmU+wPsEKPnISAm7oQmVdK6ZAGR2 CRd9ZtoWj/2dKJtPtKsg2RroydSByG95MiSVAWJ7xYJqnJvJku2EWZb+jKtwwnHIQTSzvFQMyW7qW Rx3uAF3fucHzqddycSaoLDiZnCd5zTFI5U3robe0m3k2Lvje5klRbQ6fecv26LNnQp4Xw/pnIhAXJ 4lvKC3pBVUNlFgFuuL5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rYMvP-0000000GXl1-25BY; Fri, 09 Feb 2024 09:11:59 +0000 Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rYMvN-0000000GXj7-0hh8 for kvm-riscv@lists.infradead.org; Fri, 09 Feb 2024 09:11:58 +0000 Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-6e14b858785so361487a34.0 for ; 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=lists.infradead.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=k47E9AodhRm7pFi5pAfjmARlutkQsBD0XG/oKrxTDRNg87gxjT1TQ35E8P9k8UzXRL BiBDkX015W7ZJWWgf7mLhhb9z/vLOJ6FsTYPt6c3MNS06NAt50TB5zD/kRwBw1bHJAkU fUEECxKHQ2zYH9JWNwihXH98+T7hxIdpWTKY4mFKnHmxlf71A1Ttx0DQhJ7nFivxni/M aAt/mk71VJrwa7n2gZlHbsmYP84b11pRbFCtErb+FzSt42u3en4TJIKmbsq+f+LIiJLk d8BD1dgqVVCY6EAv84dG3Vmn04Pnek6dRqrYzrwRaMHZbLOK4kRHhxEL6V2oZRUXQxUj cynA== 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=KO9k/27xidaKyZaooOMYuskksn/nzimA7TZbm10dzEYntw97OcHQVPZOqXqaS7oy7P I+PhwyaTc4kVsYTbOuKnpp1itRslCxXAt3YgjgHUHY300HrzQgFgJICy90s7Aneqvt1I FE8rfS5WFZ968poe10g9w+0H95WlnaAPFNV4uTESD6kBAoVCdG/zXAIIjPjtX099aOHx 2i7NlZp/7VYu5ZN04URyT/FH8Dp9v+NWjPaDvQbZlX4EBZJHsbxMmOkS29Tl0aKJiLmw BW8FOUh3bFXZLyfnrDsUlhxpB1zblLhNAqW0Aa6xeBpLBooFhbZxatBgU3ZXhq0gSi7r vdxw== X-Forwarded-Encrypted: i=1; AJvYcCVc1m9qoNKodRndQQcHbJv7hVWKTZi0VA3P1wz0o1ia7JZuICCzL39wTQgf0rNuC2i2J1N3X6z2HxaI7tPbFHoqM1jmF71XAgvx6miLuQ== X-Gm-Message-State: AOJu0YySqidKrcbUSnSu3oXGDZ/FbDIrhl3krH7DyVWtTxo4rPp6+S+/ cYkjmwmdbtTKAUjvGHOPgyQdvgRMhsL2h3MHSYMlCxYOmm0/ScRC 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240209_011157_241360_36617EDF X-CRM114-Status: GOOD ( 10.55 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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' [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:32f listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [npiggin(at)gmail.com] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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: 1896875 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=IF5Kd//I; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=ggXX5LZr; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TWSm84YTPz23hn for ; Fri, 9 Feb 2024 20:12:08 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MJWq4ssfoSECfFUJlrWr0UcifG3TNGXzfpW6mbKaIz8=; b=IF5Kd//Imkmuq1 64fdfDyT8XMeeM89D7E4tQQOUBcN8h22HzXO2UuMHSD2nB8jDDBhjZgpDSblGuCez2hQDoIUGdRFj QhJZTIXV+zAHE5T1IckQI7hnuaMnVAv15OkEnZE7+7Fy3YYe3opz+TitToMX4ukgkd62NcX0cE3WQ vYFemj9p8EQNPFhCnESIcbz8wi6Jb9XoFwXZtFmUkKtZSMVNjVRdaiRIrkSta8qzx3Gwue3KbHRqa CBQ/8o3neOD61BFHuLCU9gaRdYCd/EReyaEtyRbTxu51+44P4xYYE2D4atSQgmVXwqxEg5Dog05i9 cd0SYu0MdeGHyQJtOqDA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rYMvX-0000000GXoG-1AS2; Fri, 09 Feb 2024 09:12:07 +0000 Received: from mail-il1-x12f.google.com ([2607:f8b0:4864:20::12f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rYMvU-0000000GXlY-1rIR for kvm-riscv@lists.infradead.org; Fri, 09 Feb 2024 09:12:05 +0000 Received: by mail-il1-x12f.google.com with SMTP id e9e14a558f8ab-363dd27c082so2107285ab.0 for ; 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=lists.infradead.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=ggXX5LZrhpAS7raDaCxhxH0qZVEhpMxsjh9pufH7xLqa7JKuWUZly1NWe9ekkmjKKk MeJreGNpU3C0iRbrBy3HksKL7fLhdFM4CASrx5ppP/U8n7+rtR8clOmnIoD6Bm36kQIz cGhEWPNVel8wm1uC56OExmQY4C64W8mTmfQBnoGQxLF3QyzXPHThkLHDhjWcX8nXnbBa wfYW9R+yXRBgq3/wXZ4jOhnAo8Eg1GbIJP8HjPYHISM34MQ/uEbFfGPFLSdG7lTz5/Cd pxlNs7ZE89bp4fOUziuaXBh5ZisEC/TEUd6RguY4Drm3z9Bfj2bh51o9BxAgxOQdAbQO dWbQ== 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=aUPjGzLheJME5OVaAC2D3vQJZ/uDm9WBLjV5K2Ke4h6+Cvtw7SvH82tG0bunvGXBVD H3XjePcKIyJ0o5qeXNZ+N1/BMi1ZO8R6s9uZ120Ov+Q7AWXiyey3JXRji5OoDxQ10VXH Fz2sD93BshLqHwVanY3VndyaFm+sr8kj47vCb6l2J0ulN1/yyth3unO79I2epV7DRQjh hRZgN9iqcALNMI6GKggGXhWii5qUgYMtYW/4KkHPI5PoT+mOv0RypcoZzrf1M7utt6vd e2gsK+UkC/Zk2rdFPP3ZLS8fqBx76SWzeDfRny+z+0WUaJuw4ydAl/IP5taR699D15NT FK6A== X-Forwarded-Encrypted: i=1; AJvYcCUPfxLHQ5FYhFEY6rCjKc4xu8ByIVts6q4OjYnQ3fCj9jmOyFBdAugU5T464uZ8OMkqOzBEYeJSBSXMxyYRX98T33OTNfhVWqKJGvsODg== X-Gm-Message-State: AOJu0YxEJJqgCTMB9RnoXtWSmCQhwe1fw03Osg9nwlVuDHSpfH4gcNFC nHOtuqRiufksPV++48uZero9E0d+/NeCB7l3zCuGrvW4UyMcv4Cf 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240209_011204_510136_D2657776 X-CRM114-Status: UNSURE ( 8.96 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:12f listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [npiggin(at)gmail.com] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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: 1896877 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=w5GgQOvH; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=YF70V/uY; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TWSmF14S3z23hn for ; Fri, 9 Feb 2024 20:12:13 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=f0kcD12bjAU//TpVuKfT+pN8jIpi0zX7tE7E6W4m3Ak=; b=w5GgQOvHfJSKUd yhZ9yukz4xiS9KJQAGs2aTgqVHDPNc45K8EHcH3gcfZ7g8M8sr1zFcJvXvWpaT/0K6wJbLC3kUD7B UEqqeX6J7dagCg/wisDNs2p7JLmNxRZ+hcnlp8bB95hA+YebPhzKjZsNOjj071ikZdQHvQzZM4lTQ VRY10QQri/OY/++6NnP+Sdrh/3FV6FpGRdSTzJyofOPxj6vX/p+/eDfKK6pDh8672MwACQCL3y/Dv 6VfhPjei7fEjxqGSGvup6YB1qBvQJlxqKt7Uxt9Y66xQJuZU4YdEpkHTXlz3NdWLDqgmgQRx7DE3R X9hs83q0O4YrOg3ZIJzQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rYMvb-0000000GXqx-36rU; Fri, 09 Feb 2024 09:12:11 +0000 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rYMvZ-0000000GXoU-2Tbz for kvm-riscv@lists.infradead.org; Fri, 09 Feb 2024 09:12:10 +0000 Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-6e0f43074edso387941a34.1 for ; 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=lists.infradead.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=YF70V/uYOTT8K1mTahMymerULYYOCaySdCcjsxuPCrVBtRnv+BeMoxArpUMaenScQ7 CQBSVEAmW3DuwKBPYNYIIWm9CVa1IFSZZhL42KGZElPVJ9jMrgt2+O81hJqrEEkuWuj5 64MM9iypdoX4c0X85zdoQ0HPSoUFCZedOL3dFUw6crDBJGEA2CFcmLPwIXJsVEfjuyNV DJuGdzjoZIhy4bNDP0B+9jMgqgVRdyj5V0WfSVpZcBrTDLcUV//LQRJ3oyQdaN2/Tvn/ teN8jRBNuHB3UEPeqogiNMt5l4cXrqYO1str5B80OoMJ3YkGmU6A2dkEiVAT2hJvscZs 823w== 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=d0y0KJDQgDbZCdUP3oL0NX7jiPnWJ6pcOK+3rQt6vYS5H9y4yHpy5aWMMOho9KxKlk VU3jGY2+3/xTu8wAzqG15AA42Rzsnp8sSh7B6nPaz80E1dZtqySKbYPb5Ty5RXRr8Acg GdF6kgbI7N07p2quRx1TZG4//UfJmE5TIbkAXPG4OcGAgWiVmITK1yZ8JWgVg4Co94x2 IZ9PaX5q+xBHxIkygok4rn/LYNgzEp4ytlweM6gwg5FjhRb2vgXxiZWtCzdcMAEugNVb x+IQtpKaM9OwofY+lhCZJYsI8Smp0sFBXYAryXCp52T1PPH2eAg9omeFR1tV1oUnHfXF vHzA== X-Forwarded-Encrypted: i=1; AJvYcCXK/6FbaxQSmXyHDD2mVVRcRtFJfjcLYHXqtrKWz+izE0EjY+r6ScoTZN0e7lYSOPRlxXEFA9O8a3oYZXMhSmvga+0/bHoO0ZYFiy4Z5A== X-Gm-Message-State: AOJu0Yztz4tgJcBTCLyCZkJyo2eY5Mxm1OOYtbOrF1XPmFzpxVf0sSwn ReZZnporw+FPprqrYMVsO7A22RHfXl6UGN8z992x0VHDJnYIKSVl 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240209_011209_677369_F9901EDD X-CRM114-Status: GOOD ( 11.72 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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 [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:329 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [npiggin(at)gmail.com] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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: 1896878 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=ccGWbShc; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=W97zBSpj; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TWSmN5MPPz23hn for ; Fri, 9 Feb 2024 20:12:20 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HdB1Hj6QkIS/HZsP6l+6f3YaBGVI/fU/aIObdVriggo=; b=ccGWbShc+P1oTh km2nzKY/G/J8Q00+vajXiAmQFJaKpvVRSeczQ6YJCr9BCDuLYK5+k5RY8yTGFNQAd0MyQgSNtsfWN r0YCbwnXOsh8raYZlT9RGt6SDaSwuq/snIofeooALnD0F2sJdOaZmkvAUu//3FZqE79uVzMQxmiBi UlT4q/SAhPHokNh1OR3jz+oyCtswEsIeJ6EPt9UPH8TsOQFlgkgVIFutBqSJdtERFznV9yunsn3ci 4vl4IwIaunQL6nGcRamXzzEBJrC0WJzcvZ1RF4ydIsi/R/0ovc7rzx+ickCwWLPGUv+0ez+c0K+vq b9qtjJWZsdn/OiZ9Xxag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rYMvj-0000000GXuY-1CtC; Fri, 09 Feb 2024 09:12:19 +0000 Received: from mail-io1-xd2c.google.com ([2607:f8b0:4864:20::d2c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rYMvg-0000000GXsc-1Ysl for kvm-riscv@lists.infradead.org; Fri, 09 Feb 2024 09:12:17 +0000 Received: by mail-io1-xd2c.google.com with SMTP id ca18e2360f4ac-7c40863de70so27893939f.0 for ; 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=lists.infradead.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=W97zBSpjsAMrfTXFiJ/D5583mDpEg3p1weG45GNdD3OGDCH5EFUcZzDBZit6oArRe/ 15Fdk7ygm49+DkajSbEgcUN2enDbcmLwLF0qk8HUBMUYHfihbuJd8bEWZaQPj2R24ONv jqp0RSbBoX4HK5xlz0tuIcLjUmSWT1HjxH3mqLRQbERbHFvju57wqy0J7wFCYDrJ6fKa 1WuG0VBRSNYOn3Rb6A26jjZ160JwvfcXN/Qvnx3I8CPzMxwmOWSsgeXaaQCdGd637Pka 6J3JyfqgIrApzF+l1VNtXiTG7kiZj6+Xlpv7ccryNTi7BgGqcddsho45yyT+jqXnUEIT j/ZA== 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=Ln6uTyWeq+deHrHHrLpJ4j4zCjGPlJE3pj0gKw7Mcb6+w5MbhUy8t1g3rjbTdV9Ge1 wCDGjW3tKm+sjD1/myv7ZsPGkR7AwUhiB462x9oD+HwWcFuEV5zivoGKn0lFFi7mbjRZ 24AF3aVswFLf/7uG/rEshle71Jh9InHP4k4+lktGLu8cwr0KeTDkJFnypfUNrL6hywLw PrwMZuWmCJpkpjF6s73iO4P5CBjdyeyp8Aphhq6xP0+ZH5vdfBc71F9FTMQiMuzlDvHD MwKAMBMSRy7ww2amShb/YO5MDBrlAZpLYC90SyeAz/rT8KlFL95WrGVS/qu4AD6RhQeV O4ig== X-Gm-Message-State: AOJu0YzZ0H2lz6zcxKBdYYan7zZMH21X/xAqpTIAsOzZPKdcw8Pfj1tN 55roqo4mkF3lPzRflp1AfdyaYhRbNSNbTdzcNEA8r7QPOBvvXYze 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240209_011216_443653_49B2E5DB X-CRM114-Status: GOOD ( 18.40 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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 ag [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:d2c listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [npiggin(at)gmail.com] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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: 1896879 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=aL1axWcU; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=PwxgayaV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TWSmb2hmZz23hn for ; Fri, 9 Feb 2024 20:12:31 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RqGZ801BXLLhrihQHAichCd0V/EZNvkC7MjeMQcZ4TM=; b=aL1axWcUOCUGMt e1uysDVtp0PYRVIVDxyBe00X8ZO6fYr+7zOApFsFoKe+M7XkY2ao8lORFh9SzBkyHvjuY/jO8RxWO 2RyxUujCSXLNY/tjsUEZOOl/sN/AmXcW5z4vCBkKqTiW+grXRhCE/DucyvjZ3MbazGbX27OKqxru+ 4wA3Z6VjsbEDiOguBZIU/masFZz7IGEV8wcj0EY5ULezBT4D9sVS8CxS5wGk37qX0uAl4SNaI2zEW kz+w+r7NRx7yMXWjy0E9JX5OE186TXlTXDkNSDdV0XSWrIoxAbhMxJv9wrmkoeXBhYqQgDslR/zxl W0nEgQ2lH6junMACEZOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rYMvt-0000000GXzf-47Yr; Fri, 09 Feb 2024 09:12:29 +0000 Received: from mail-ot1-x334.google.com ([2607:f8b0:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rYMvo-0000000GXwK-10Tw for kvm-riscv@lists.infradead.org; Fri, 09 Feb 2024 09:12:28 +0000 Received: by mail-ot1-x334.google.com with SMTP id 46e09a7af769-6e1214ae9d4so233148a34.3 for ; Fri, 09 Feb 2024 01:12:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707469942; x=1708074742; darn=lists.infradead.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=PwxgayaV9YZaQua64GTmyO0uZl8ae8CLmjkTVmuLH9NkalcdfDbZtFGz09oVMjqNm9 sohwbIfOX8emBP3DeU+Y9r0xALo80+oHizboEWBhVEZEDBGiVSaBwgBYxV0id92iTRWZ +wcyxO7QiEm0+yisc/s8uCGTfSQA+vUIVOG3BQOMxJUN8QAf/q30hQNFqeS0gBKD2+im pN7yZzRuIkETWUYneFMmzlvKAexq6cv6Kl7AfY01biKEtzHpd34DdTkAo2vkwfr42QD+ g0c6lb2kyekBK0XhspIlPcp8gukv8SObTNBn5X/AizDXVbsz9Lx8AIWLAhjDl3iIt2WQ kXXg== 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=Gyea39DvADnXGgJGHYT/9ut6T1LcZQoOeGsm6neEMO6MZnAxsLPcCOQwsLEL07Czck ck8/kitbMhHjkuR4e7L5vAPSaEmhB2FZz+u86sPG7laTgJh0hfur3wBCAVj1GeOiw9zu xPZLN3HR6oFVEHXe+O5/wKrDV0citsnEIXgl2zeS26ttT+bWI5N82AAmWHVaGGulDIFj U86G4/tzlGZKchkKwEN7wpgcP9BVpL0QFTEkk6POBEr5tc2fypqANeENWyqBeTXlpjv1 cKTWuY4uQxokA8Pi92e4JRae5WRsGPvmKuJJvKx/4cMJEi46+JwVHZTNRaDxTOPGwyvo R+rg== X-Forwarded-Encrypted: i=1; AJvYcCXRymGU0o2XZ4T3q+YIVhBOSero/GNkmO5PMUDUK3mBa4qdgXUTIx+7oj9x0hgWj5mlyufHX0AbfTxCHruOkiAC9A0CbRrZ6j9pNCYNdg== X-Gm-Message-State: AOJu0Yzi3YfKTOS3UI3eGNz9BOZqSr/6VcReZ0d4/zFgHfk0jco8eNO+ 1w0KcQp2JezRZCcqhigtSYAxfuAH8i20KLAxV1dGp9mQ8OSXjNyu 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240209_011225_084499_28E967BC X-CRM114-Status: GOOD ( 11.82 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:334 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [npiggin(at)gmail.com] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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: 1896880 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=HUQiDRow; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=P5iummuT; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TWSmg31prz23hn for ; Fri, 9 Feb 2024 20:12:35 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DRMU3SS/6SkIpl0Xqq00r+oC2VsjTovUnssGx0hkUMc=; b=HUQiDRowDD72Ho tWv5JiHorqW5bigqu0yB7+/KDoWheDlYbSav+f0YBEA7AFzYTehOddsHf7o3O3/LA7bmtX1VCizU7 AsJ7L6WZ7iVUkpx455KXXrkTda17y5+ABu+eF4EwpwWWKPgcXj9YGi8k4EV/jdvwk+ZgMS8JaPSlb MCa0wdfQbsP46B7m7+y5zTfCgBGXOpNR5K/PN2n77Eeyl13BaNkIydc3/FmaizIGMZ+Ba7sUg92KG 85cETwLAocaUBbttcVQkZGRSMae1fhTc2pHtQIP2xlWKbOiQGuHWKiWXadIax99E+kCF0BaN6/RIq UaKRL1PJs5MB/HEquWKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rYMvx-0000000GY1S-3eOI; Fri, 09 Feb 2024 09:12:33 +0000 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rYMvv-0000000GXze-0w9J for kvm-riscv@lists.infradead.org; Fri, 09 Feb 2024 09:12:32 +0000 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-6e04f29c7bcso518615b3a.0 for ; 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=lists.infradead.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=P5iummuT5cQ3aft09Yt5FkiFOHIUDGwmqxLCDYdVAci/DUpU/g4+PBJOUQ5qeamUgN saSjrLrZiM/P6hg8d7Cm0dPCwotZhBkECq3WxBrP2MZXtOdLQspGaXHwhe77OpkWD/AM oJ9Hn4mgdK04ZQvOf/c7RvLni+Mx74ddi180UrNx8fOppRBfmm5o/vELuecjVRJBHvb0 hNUmjEP4hul77KzkgRxCp3yixEWynSuzlRTI2kbfz4nX1byzwGo6vDAfMHxN25+tx4u7 IM6waSlwCXW0RyoKNGC7Fyiix+wvBR+yqW82262Yhe0mUtnayfDUEIq1GG9jyet4xhTX gbVg== 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=wpjsWrAGJWZ9HGoVqdBmurRo+74+ZvHt5Fj2vcUXVEG8eZ5IDq+tGFDqH9JaESD6Mo UQtvklWf2aqm7PyexMzIrRuxwZjjsGvlOgFDDXAT7SN0b3p4GM1TQZwZyp2g7Y5XJGyA ghGbpfU3mNNyF1B/Yu+ZcPfJyDFHG5BVY4AbiWt8Q+kz/iokD82HUfRnNQjg7rVGlVAQ X1Sf7SwaMKnSu+iPklcZx0mTlxV3h5qqUn43FCb4MoiYw8UriXBYkXj7xnpxHKKwKpkQ bE9pOSPI1arP3rcF8MmEs8hrIwKUK8yTPPJteJMlrN8d7w6JFo8jfMFcmiI0iAOJc5BO svcw== X-Forwarded-Encrypted: i=1; AJvYcCXCCyP6oOhccFZU/WBsA5AsNnqx/c66XnZUc16h+vzw7damaPBKCVxWedlEcs0yBQ4vUhFB1Z49IJHAHcetK1eqFRyZPZfCijnIUf+Mxw== X-Gm-Message-State: AOJu0Yyy9IDL7HvV6rsz4KR9MYpFyMnK6cEUUScCrgf+dub15KJNLpI7 oGHJeOIZnhlJ8eoBdKTMyDfD9zRzNUjNcNoafIfRMNr52DnYMBip 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240209_011231_337665_8B86F2DF X-CRM114-Status: GOOD ( 12.60 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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 | 11 +++++++++++ lib/migrate.h | 1 + scripts/arch-run.bash | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:42b listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [npiggin(at)gmail.com] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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: 1896883 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=pZYtfvuk; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=gTVfSGlM; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TWSnN1ldLz23j0 for ; Fri, 9 Feb 2024 20:13:12 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Uk7UwvMHAIzXTgTebnFh7hmOFqvjlXHnOsKqWzRu7e8=; b=pZYtfvukzI9QbO EtgW/r0Hqnto7mwhjNKoeS8Y2SIPtZkiPpCcV2hy7/cxtpVtXJqSlqzcRzv3+x2/ubo6lCQdyk3Qu VPi+bIcodbbm5A20ArrGhLCvM6uq1HRNr9nOb6k20QN1WMSdfhFE/q8LxK/DcdrnszTsM30b2kAzC kxp1AYS0kSx7LSJUDbkI0xynKOrAdvo33QTlnW7nFYUeAmAPbpZrUyUDGJj5A9HKacLICNXxhFXey PEBdIWik8eU+UHDY49zRFB3Lv8vswYTMUcRZx317cfwdqwyDYyqMizL88gNlXBZfzwS3SZCKHnp60 uX/v3sCtG/yP1dA5rKdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rYMwY-0000000GYFE-3Tj3; Fri, 09 Feb 2024 09:13:10 +0000 Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rYMwV-0000000GY37-3EzZ for kvm-riscv@lists.infradead.org; Fri, 09 Feb 2024 09:13:09 +0000 Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-3be9e11ee59so291337b6e.1 for ; 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=lists.infradead.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=gTVfSGlM2QY4g1KMadiGWki4kDsKj8T4IyMZqGMoujI0qmKXrhT+iRI3ULz+vs5DEd sB78iq5FmVA6ibIeShr4YBIecfhIvwplAN+5cTdujY+vDBV9atqL3kQNRbX4wPtvsjNw Lj5MUJLGscgh8WdYAZquEPmRr6oE+tpaaGUo06pCZfgYfgbMwYZNRtL9IfmV81oJnz0J y3mucYLWndT8jP7bOCmfmq+MoSwRbYdAgAiw45VxXy2hgzo1WPUC/ItZuU/vXZ5jrAiE Un/4Ego8q6FwpttzMpNoYteiP8vdLNbnLhSfFNINHNxXBzoPWCtIf54OY+yCcVxM1mwq 73Cw== 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=dlLlR8Hxxy66c1I0fSSIjIfFHJ7ZHzPVNfzM80fjNcr6p7RwPgrLGlJh2IikKTxhPY xkTX8ignxsUrYb7FsypY/1iIG1IH9R6bv2vRrX4mlXbUhFkpgeDAS3IJJ90Suedn7Xfh 0nkfmjSiaz4yxfdzrUXoQeo0xMCI6jN6w7QLwwoDtogw5hXDjEuAy3gNShouK9mQ0Fof CIrutoU7xunX5xf4fHBW0spH34BU7v7WmWxnDzhhblw2/83DsZ3WvKS0MpBCCTYWCnqO HvW0/Mv/ausE0b4FMTc7my1a1DbrJVj8lGxS/5ygGDRHV62HYyrQP1MHCySzxpOw+7If 16Nw== X-Gm-Message-State: AOJu0Yz55EiWi6z7U70HvsY6aV5kSQKfpoU/aHA8Us6MdYbV9f4xHuh0 scsZaw6/4y0ih8oIuJnaI3yykQMIS5J7S4Nmj0fLeV2MvgVSF344 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240209_011307_838688_82B4F3CF X-CRM114-Status: GOOD ( 14.60 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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/s [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:231 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [npiggin(at)gmail.com] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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: 1896882 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=dqd6E9EQ; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=QWbVykxX; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TWSnM6Dhgz23hn for ; Fri, 9 Feb 2024 20:13:11 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JU/Q94vZbsEG6vMeHQxbpbYyjgWTUk1Z2kIfekbnxPQ=; b=dqd6E9EQnBJv9e 1bnad8L75G+R8M1GPZAIk0mOGwSBTbZK+jx02NqermbUcNjT2tob4/Z82IunLj+f24od3YrGax19l 3IlVE+aixXU1ENPFkRaTMcVMRE2rEyJLu4J6dfAGFPnCor9hVjgXefJFDDrsfmWWtDYS12MkTTIRh +SDgeFaRXAiN4LuQp0CIRaR+NyOL2jaoeq2Z4dXyYjr4bdrg4vjhpbbRPDQyKj0iY63P9cNAgdH8d 9JpFNhSxZyQ6LL+uzLiKrOtevYl5+2g0bGRWsanylnE83KCMyAHW7sX/pk3cdRyvJXYrXd0imlX7a gVcvZsh7FyVXVrkErNAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rYMwY-0000000GYEl-1p4q; Fri, 09 Feb 2024 09:13:10 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rYMwV-0000000GY5f-3F2q for kvm-riscv@lists.infradead.org; Fri, 09 Feb 2024 09:13:09 +0000 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6e04f29c7bcso518706b3a.0 for ; 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=lists.infradead.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=QWbVykxXL6BnWRStirIDfbywiIoj4GGnZkoKmbwdysTAdvOYp60rpz/Ppxd57TYZeu Dj7bdGph9+YrXF9vl1RtphuhupOeMM3lRSvPwiOjAAjIoSXtQ+Le56Qj2Ua25rwALsS5 JFaRwybkv5B9F95/qdz9E0oNKjFPw8AaO0zNPBleSefYaVqEPmJM1Jzp1FZYICftHPLZ q4LIaZPkQIVaGaD0+3c5o27u2jLVzFoj/mDeV5AKvgCjgGSZ4EdjPa+hH/xhN6WI9CUi 9S+pAGrF759Kxw+/TZWl0SCq95mD0yp62c6m9WOh0//9FPn9W91NVFbO+9FYuTs1pcfX 4pig== 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=f5s3hNmjCnqm6UHGFwPE9oqDUZtuZ18oVo/Kd4vWZ4IkW/MGTUzPOiP44BJYs0Jdwh jQbEoo412ApBMwyDyQmFHY15dRn+feLkAwrmNAcgOrhFce+1CQlCx0BI2AteVmaueXap Py+lc199AF63SuYaaXLGk48hRtjGW4Rzy0L2Ozx8QFyoTane1VuF4ZeJJSc80B8gWuZZ SV4VuEXZcKy5i5BR56ivRBBM7BvAUrdF9KYXypTbeMvfyp7iOVmMDDE5gpWm8mp0KfPs ZQ9bgnGBr7YfjbZOMT5XbohpYlj+x+JvXkKm97urT/jz/vpRuylqOcX5WItmOx5g28s5 Ur4w== X-Gm-Message-State: AOJu0YwmeF22Sw0RFrcHb/NxhjGM8tj/7YuL2m6UCEz5sSfURrvkQmzB UUgVLBiC5IdZF9XtQGCxRU8SytJ3OAq2JO6wBt2x6wYyar7myvEB 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240209_011307_827905_4EC26315 X-CRM114-Status: GOOD ( 16.91 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:42f listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [npiggin(at)gmail.com] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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