lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230722130248.GK17311@1wt.eu>
Date:   Sat, 22 Jul 2023 15:02:48 +0200
From:   Willy Tarreau <w@....eu>
To:     Zhangjin Wu <falcon@...ylab.org>
Cc:     thomas@...ch.de, arnd@...db.de, linux-kernel@...r.kernel.org,
        linux-kselftest@...r.kernel.org
Subject: Re: [PATCH v2 09/14] selftests/nolibc: allow quit qemu-system when
 poweroff fails

On Wed, Jul 19, 2023 at 09:27:08PM +0800, Zhangjin Wu wrote:
> The kernel of some architectures can not poweroff qemu-system normally,
> especially for tinyconfig.
> 
> Some architectures may have no kernel poweroff support, the others may
> require more kernel config options and therefore slow down the
> tinyconfig build and test. and also, it's very hard (and some even not
> possible) to find out the exact poweroff related kernel config options
> for every architecture.
> 
> Since the low-level poweroff support is heavily kernel & qemu dependent,
> it is not that critical to both nolibc and nolibc-test, let's simply
> ignore the poweroff required kernel config options for tinyconfig (and
> even for defconfig) and quit qemu-system after a specified timeout or
> with an expected system halt or poweroff string (these strings mean our
> reboot() library routine is perfectly ok).
> 
> QEMU_TIMEOUT value can be configured for every architecture based on
> their time cost requirement of boot+test+poweroff.
> 
> Signed-off-by: Zhangjin Wu <falcon@...ylab.org>
> ---
>  tools/testing/selftests/nolibc/Makefile | 23 +++++++++++++++++++++--
>  1 file changed, 21 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
> index 541f3565e584..a03fab020ebe 100644
> --- a/tools/testing/selftests/nolibc/Makefile
> +++ b/tools/testing/selftests/nolibc/Makefile
> @@ -93,6 +93,9 @@ QEMU_ARGS_s390       = -M s390-ccw-virtio -m 1G -append "console=ttyS0 panic=-1
>  QEMU_ARGS_loongarch  = -M virt -append "console=ttyS0,115200 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
>  QEMU_ARGS            = $(QEMU_ARGS_$(XARCH)) $(QEMU_ARGS_EXTRA)
>  
> +# QEMU_TIMEOUT: some architectures can not poweroff normally, especially for tinyconfig
> +QEMU_TIMEOUT             = $(QEMU_TIMEOUT_$(XARCH))
> +
>  # OUTPUT is only set when run from the main makefile, otherwise
>  # it defaults to this nolibc directory.
>  OUTPUT ?= $(CURDIR)/
> @@ -224,16 +227,32 @@ kernel: extconfig
>  # common macros for qemu run/rerun targets
>  QEMU_SYSTEM_RUN = qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(KERNEL_IMAGE)" -serial stdio $(QEMU_ARGS)
>  
> +ifneq ($(QEMU_TIMEOUT),)
> +TIMEOUT_CMD = t=$(QEMU_TIMEOUT); \
> +	while [ $$t -gt 0 ]; do                                                       \
> +	    sleep 5; t=$$(expr $$t - 5); echo "detecting power off ...";              \
> +	    if grep -qE "reboot: System halted|reboot: Power down" "$(RUN_OUT)"; then \
> +		pkill -9 qemu-system-$(QEMU_ARCH);                                    \
> +		echo "powered off, test finish"; t=1; break;                          \
> +	    fi;                                                                       \
> +	done;                                                                         \
> +	if [ $$t -le 0 ]; then pkill -9 qemu-system-$(QEMU_ARCH); echo "qemu-system-$(QEMU_ARCH) timeout"; fi

Please have a look at the "timeout" command whichi makes all this much
simpler. Also, please get used to never ever use kill -9 first. This
is exactly the way to leave temporary files and IPCs wandering around
while many programs that care about cleanups at least try to do that
upon a regular TERM or INT signal.

Willy

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ