From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson To: passt-dev@passt.top Subject: [PATCH 10/10] test: Kill qemu by pidfile rather than ^C Date: Thu, 18 Aug 2022 16:13:58 +1000 Message-ID: <20220818061358.1775944-11-david@gibson.dropbear.id.au> In-Reply-To: <20220818061358.1775944-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7989716867654463717==" --===============7989716867654463717== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Currently in at least some of the testcases we kill qemu processes we're done with by issuing a Control-C to the tmux panel it's running in. That makes things harder as we try to move towards allowing "headless" testing without tmux. So, instead always use an explicit kill on a pid derived from a pidfile for killing qemu. Note that we don't need to remove the pidfiles afterwards, because qemu does that itself when terminated. Signed-off-by: David Gibson --- test/lib/setup | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/test/lib/setup b/test/lib/setup index 450b68a..42f03c1 100755 --- a/test/lib/setup +++ b/test/lib/setup @@ -60,7 +60,8 @@ setup_passt() { ' -append "console=3DttyS0 mitigations=3Doff apparmor=3D0 ' \ 'virtio-net.napi_tx=3D1"' \ " -device virtio-net-pci,netdev=3Dhostnet0,x-txburst=3D16384" \ - " -netdev socket,fd=3D5,id=3Dhostnet0" + " -netdev socket,fd=3D5,id=3Dhostnet0" \ + ' -pidfile passt_qemu.pid' pane_status GUEST =20 # Set things up to reduce problems parsing host command output @@ -178,7 +179,8 @@ setup_passt_in_ns() { ' -append "console=3DttyS0 mitigations=3Doff apparmor=3D0 ' \ 'virtio-net.napi_tx=3D1"' \ " -device virtio-net-pci,netdev=3Dhostnet0,x-txburst=3D524288" \ - " -netdev socket,fd=3D5,id=3Dhostnet0" + " -netdev socket,fd=3D5,id=3Dhostnet0" \ + ' -pidfile passt_in_ns_qemu.pid' pane_status GUEST =20 # Set things up to reduce problems parsing host command output @@ -271,7 +273,8 @@ setup_two_guests() { ' -append "console=3DttyS0 mitigations=3Doff apparmor=3D0 ' \ 'virtio-net.napi_tx=3D1"' \ " -device virtio-net-pci,netdev=3Dhostnet0,x-txburst=3D16384" \ - " -netdev socket,fd=3D5,id=3Dhostnet0" + " -netdev socket,fd=3D5,id=3Dhostnet0" \ + ' -pidfile two_guests_qemu_1.pid' pane_run GUEST_2 './qrap 5 qemu-system-$(uname -m)' \ ' -M accel=3Dkvm:tcg' \ ' -m '${VMEM}' -cpu host -smp '${VCPUS} \ @@ -281,7 +284,8 @@ setup_two_guests() { ' -append "console=3DttyS0 mitigations=3Doff apparmor=3D0 ' \ 'virtio-net.napi_tx=3D1"' \ " -device virtio-net-pci,netdev=3Dhostnet0,x-txburst=3D16384" \ - " -netdev socket,fd=3D5,id=3Dhostnet0" + " -netdev socket,fd=3D5,id=3Dhostnet0" \ + ' -pidfile two_guests_qemu_2.pid' pane_status GUEST_1 pane_status GUEST_2 } @@ -298,7 +302,7 @@ teardown_distro() { =20 # teardown_passt() - Kill qemu, remove passt PID file teardown_passt() { - tmux send-keys -t ${PANE_GUEST} "C-c" + kill $(cat passt_qemu.pid) pane_wait GUEST rm passt.pid } @@ -311,7 +315,7 @@ teardown_pasta() { =20 # teardown_passt_in_ns() - Exit namespace, kill qemu and pasta, remove pid f= ile teardown_passt_in_ns() { - tmux send-keys -t ${PANE_GUEST} "C-c" + kill $(cat passt_in_ns_qemu.pid) pane_wait GUEST tmux send-keys -t ${PANE_GUEST} "C-d" =20 @@ -326,11 +330,11 @@ teardown_passt_in_ns() { =20 # teardown_two_guests() - Exit namespaces, kill qemu processes, passt and pa= sta teardown_two_guests() { - tmux send-keys -t ${PANE_GUEST_1} "C-c" + kill $(cat two_guests_qemu_1.pid) pane_wait GUEST_1 tmux send-keys -t ${PANE_GUEST_1} "C-d" =20 - tmux send-keys -t ${PANE_GUEST_2} "C-c" + kill $(cat two_guests_qemu_2.pid) pane_wait GUEST_2 tmux send-keys -t ${PANE_GUEST_2} "C-d" =20 --=20 2.37.2 --===============7989716867654463717==--