From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicholas Piggin Date: Fri, 9 Feb 2024 19:11:27 +1000 Subject: [kvm-unit-tests PATCH v4 1/8] arch-run: Fix TRAP handler recursion to remove temporary files properly In-Reply-To: <20240209091134.600228-1-npiggin@gmail.com> References: <20240209091134.600228-1-npiggin@gmail.com> Message-ID: <20240209091134.600228-2-npiggin@gmail.com> List-Id: To: kvm-riscv@lists.infradead.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 & -- 2.42.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D04BF664C6 for ; Fri, 9 Feb 2024 09:11:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707469915; cv=none; b=QvWq26woV4W4T3X9/oJ/xBb294zzR3iT8dMv2AE3bwkqcpblsBYXGGBnOzP8igAM/c6+Is8WLseqb4cD0iM+FC5fpMdPLarDTmEQHBjrUoVHX9IQXiOxJtABWtu8yIYnFKuKxAOhHzFXd0JCUsJ1gUbidsmpjnxF9f/FMl/EAes= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707469915; c=relaxed/simple; bh=ZAFsihb3M/bAq0syQwiiUvyBvzmIPevskZf5u2erS68=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M0/X6zbV4dCuGKwRL48qUB8UXO42rAR6Qky3f861R6BJfyXPqlUJTvnVb4iJ68A55uR5AaT8FtOVfbNM9RcXyfUikFTmKi3Ap/DNunGhrN4XwMQ8+Pf25/SeoanHRpQ3nNVxdcNzw3pcqhjCR7487SVqoNI1jOZk2FudgKJOI0g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kH9/nqff; arc=none smtp.client-ip=209.85.210.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kH9/nqff" Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-6e2c402a5c2so381565a34.2 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.linux.dev; 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=kH9/nqffYwi9kYGOvMrU1AfS2NNA/zgYNSGtFhfWc/g1/mgxUt9heRojnS9xe5fysc RqZ1YWhiUA00lhlEQ51+JHvohVl999HMJEtM59zOu17C1uxWLLcf9BqisfumdEaaukzH otqDfOZmXSSIsgeTInlhOXeCXufrVyxcIux4Ej0a3HlQkAh+avZlkiRCCSmG9qu17rg2 xfVkD48wxOdR5RAI02tUaaYJyN/fybKbrvySQSU15hoFvtDFRZIL/itNSmxIibf6QtCl 5cBEFZA5crlH+zev1SBF8ipiwqY6eVJylnf1ZDQfY03hQr4xpgSBJKQVDGQQmJMEdDRJ QUYQ== 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=CNLjbFTQ+YtjhvnoKbHAPevm1P6ykHz0xoKlSppdqxs6Ro1+c0thTma9OjZwcNERxe 7Tq6df4gfVccucziQuaCsoeJIAY6nmd7i3sKdrwx12KHAoMsph7moQOpxXovEzaz8IFf fTRDJy2w42Eaz+jn/frYYnQN236iR9FeMtxmm4qga39uJrXnao/DsrJXW10EOvbfo7zO MjSJ52Xdyl0sTNRlJcdAiI96OGmEZR7+VMF9bVolOBNRdr6dUaw95Tyl4FVKXrfBWNuV F04qHHptNhW38RLZoOyeMh/wN3FTrNKbduPUWNzCikRX4xeuSqzy6vsh126mz0S4t0wj 1J8A== X-Forwarded-Encrypted: i=1; AJvYcCVV1PuvbM77ThdQc9vTLAAg4S3QgzkOWoWliKuPshptINf5bjuXPgGKKK6e+fVkBT7OMtsFqL6k+LkC1y4KZnJNIe/6ZM73 X-Gm-Message-State: AOJu0Yx8POPc35sIpAsoa5HR9E00xNJ2gH/WHbF++E0eOUoBc578lniC GxO6p5x/YhLgVbC1JRrrxQBnbHars0bJDvQx1NLnxdSUXHtGEzjR X-Google-Smtp-Source: AGHT+IGcmytfLhFPegBL/6SAtwvaTgnR5fQUFdHgJo6Q2wspsRF4btaANrNXmauM6vRXjX9yxL/gWw== X-Received: by 2002:a9d:7592:0:b0:6e2:b1b8:84c7 with SMTP id s18-20020a9d7592000000b006e2b1b884c7mr748994otk.17.1707469912911; Fri, 09 Feb 2024 01:11:52 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVKEs+ZzHCXAJAGHH6bSzYysqcGhmXYYuO3J7InQHWbz7ru+8zL9FzYLwO9GhlA0tw/acl/lYs3xPiH65/zsxoAQ+vOunmMdeJHj7fwM/7IYXS11Wbs/M5zRz5EFWAit+rW73a2VQG4xCIgTGUjXY82AdiRPTb/BavJVUTQGbV3aId10/C9+rVjQIpd1Sqv+goLw0U2es5OSA3dWuYu5H7d6q1pn6MwjszvCXwnamaxbAuWZvyYWownmRTeOrIzuI/+ZouL6nKh1dRZNCzbkzenpPqIA0lri7eCfEnpLGUSmDhy4bR7gdHEr2MhHc30t+XM2H24jxoeAD/txqPe/zWL8MvUSl69ZVEGcQKNNJ6fDjyFBPGZD7Q2/0JE/myZwW5iFPDzucesGj3v4iUc6Gk/lIsdO/3DaDrVpOb8Tk4ap7x5eab++yF7e1pnQgSA6kNfYSZA7kvMlw+hGoaFgZYDYEkSxXqNBeh1/zUpugm2h2n6a+WOGKyuzbfTM72zw7egy17LNvoMYibovcDaGQ1CqWgMjcNfN+R1vbsgD9BEUgLLhu9mWmXL Received: from wheely.local0.net ([118.208.150.76]) by smtp.gmail.com with ESMTPSA id cb1-20020a056a02070100b005c1ce3c960bsm1101742pgb.50.2024.02.09.01.11.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 01:11:52 -0800 (PST) From: Nicholas Piggin To: Thomas Huth Cc: Nicholas Piggin , kvm@vger.kernel.org, Laurent Vivier , "Shaoqin Huang" , Andrew Jones , Nico Boehr , Paolo Bonzini , Alexandru Elisei , Eric Auger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Marc Hartmayer , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kvmarm@lists.linux.dev, kvm-riscv@lists.infradead.org Subject: [kvm-unit-tests PATCH v4 1/8] arch-run: Fix TRAP handler recursion to remove temporary files properly Date: Fri, 9 Feb 2024 19:11:27 +1000 Message-ID: <20240209091134.600228-2-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240209091134.600228-1-npiggin@gmail.com> References: <20240209091134.600228-1-npiggin@gmail.com> Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 & -- 2.42.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 81130C4828F for ; Fri, 9 Feb 2024 09:13:19 +0000 (UTC) Authentication-Results: lists.ozlabs.org; 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=MaES1m7G; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TWSnV0PV9z3d9t for ; Fri, 9 Feb 2024 20:13:18 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=MaES1m7G; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::32b; helo=mail-ot1-x32b.google.com; envelope-from=npiggin@gmail.com; receiver=lists.ozlabs.org) Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TWSlv67mFz3c56 for ; Fri, 9 Feb 2024 20:11:55 +1100 (AEDT) Received: by mail-ot1-x32b.google.com with SMTP id 46e09a7af769-6e2c402a5c2so381564a34.2 for ; Fri, 09 Feb 2024 01:11:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707469913; x=1708074713; darn=lists.ozlabs.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=MaES1m7GJMltLyQwjApEoxH2e2rg6BaW4PzMIB2zV/LG4GYJlLYo8zbWHbreXhkfF/ TYNzktqPmvxYk+Iv/98sbvZK2ougA61BxamkdXXXc2lm8NkA+8ns+vSYA9MbZi/9AqRl P1QG+5RB2iP9fatRvIqqWfX3Xk14zHxvINSR3IV0EmOF+fb4GG+W6fVdrv3N1GqQfvnW Y7M7PkKSa4svImRyruxXR6knYDRiNZQk88EZkK3tWVC71+tVJYQXVRm8EuF72Hix2fqG 1w2W5v68CslEB4WuNKuH1SSPBt/cgw5eWheguCYXb4cMhhBHYx4sxU1xKr1XsAJw/EKg 0VAw== 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=NA6DejgM0Imi0NHakET0fvfnb+rd8jfKHNZ/Vl7Ka0GL5vkj3nPoZWlPn8//LX3CZo 8sfEr4TIn2ezeySBjbKbg31/nz67Dc+spTXlNFWJEBWCxV4HyXeyHWUVWebyOeiQpMo6 baxf54eBx3A466kEZ0ezbs+Laz4SA3jnrxnrVbb+2uWmaRXQb1agvaecB8PhrARH9g3g s9x0udEKBEJirhj0Wih02pFkkHcYAFNj2ifmt6yeqaCcQlBEaiXpbIsksDC7Fo2E0amu 16CsklNgKLvJBf5nY9WkFBQapPBDEeZiGO9/rQW3z+Z9VUrbLpO9gZTuy64U6ZULOfGx hVGA== X-Forwarded-Encrypted: i=1; AJvYcCXa01xlS+l0aZrNxsDIhmXHNGgUjdVWOiAZ7rj2nU5104/Q1pSZqY2TWgyawn7L2VtQKtTPHX6xlm0PVugvP0qhwLg15Dj240+LzAonZA== X-Gm-Message-State: AOJu0Yy7XEcLVh4pgCcAk7EAfPbSaUaiXrNLowikA/UOR3mLXfsNM/u7 Hg37FYBoAwojCKiyfJKlrN/hBos+xXmmGeNmep+dvHrvavJIHmOc 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 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 Content-Transfer-Encoding: 8bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , linux-s390@vger.kernel.org, Nico Boehr , Janosch Frank , kvm@vger.kernel.org, David Hildenbrand , linuxppc-dev@lists.ozlabs.org, Shaoqin Huang , Nicholas Piggin , Andrew Jones , Eric Auger , Marc Hartmayer , kvm-riscv@lists.infradead.org, kvmarm@lists.linux.dev, Paolo Bonzini , Claudio Imbrenda , Alexandru Elisei Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 & -- 2.42.0