From: Richard W.M. Jones Date: Fri, 1 Sep 2023 12:38:53 +0000 (+0100) Subject: Attempt RB_POWER_OFF before reboot. X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=8d7e14545801c2341055bda9dfe0239e9279ce10;p=qemu-sanity-check.git Attempt RB_POWER_OFF before reboot. Try a clean power off before using reboot. Also this commit adds a debugging message before each call to reboot(). I wasn't sure if reboot(RB_POWER_OFF) happens synchronously, apparently it does, at least on x86-64. --- diff --git a/src/init.c b/src/init.c index ef7011c..7836158 100644 --- a/src/init.c +++ b/src/init.c @@ -1,5 +1,5 @@ /* init - * Copyright (C) 2013 Red Hat Inc. + * Copyright (C) 2013-2023 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,12 +34,21 @@ main (int argc, char *argv[]) fprintf (stderr, "\n"); fprintf (stderr, "\n"); -#if defined(HAVE_SYS_REBOOT_H) && defined(RB_AUTOBOOT) - /* Try to reboot the system. */ +#if defined(HAVE_SYS_REBOOT_H) +#if defined(RB_POWER_OFF) + /* Try to power off the system. */ + fprintf (stderr, "init: calling reboot RB_POWER_OFF\n"); + reboot (RB_POWER_OFF); + perror ("reboot: RB_POWER_OFF"); +#endif +#if defined(RB_AUTOBOOT) + /* Try to reboot the system (qemu -no-reboot turns this into exit). */ + fprintf (stderr, "init: calling reboot RB_AUTOBOOT\n"); reboot (RB_AUTOBOOT); - perror ("reboot"); - /* Reboot attempt failed, fallthrough below. */ + perror ("reboot: RB_AUTOBOOT"); +#endif #endif + /* Power off or reboot attempt failed, fallthrough below. */ fprintf (stderr, "expect to see a kernel panic below, that is normal\n"); fprintf (stderr, "\n");