changeset 10574:c8621ef15d56

6855522 Happyface boot and Fast Reboot don't get along
author Sherry Moore <Sherry.Moore@Sun.COM>
date Thu, 17 Sep 2009 11:03:46 -0700
parents a950fee27362
children 2a8816c5173b
files usr/src/cmd/halt/halt.c usr/src/lib/libgrubmgmt/common/libgrub_cmd.def usr/src/uts/i86pc/boot/boot_console.c usr/src/uts/i86pc/os/fakebop.c usr/src/uts/i86pc/os/mlsetup.c
diffstat 5 files changed, 111 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/halt/halt.c	Thu Sep 17 10:27:14 2009 -0700
+++ b/usr/src/cmd/halt/halt.c	Thu Sep 17 11:03:46 2009 -0700
@@ -379,6 +379,42 @@
 		(void) sigsend(P_CTID, next->ctid, SIGCONT);
 }
 
+#define	FMRI_GDM "svc:/application/graphical-login/gdm:default"
+
+/*
+ * If gdm is running, try to stop gdm.
+ * Returns  0 on success, -1 on failure.
+ */
+static int
+stop_gdm()
+{
+	char *gdm_state = NULL;
+	int retry = 0;
+
+	/*
+	 * If gdm is running, try to stop gdm.
+	 */
+	while ((gdm_state = smf_get_state(FMRI_GDM)) != NULL &&
+	    strcmp(gdm_state, SCF_STATE_STRING_ONLINE) == 0 && retry++ < 5) {
+		if (smf_disable_instance(FMRI_GDM, SMF_TEMPORARY) != 0) {
+			(void) fprintf(stderr,
+			    gettext("%s: Failed to stop %s: %s.\n"),
+			    cmdname, FMRI_GDM, scf_strerror(scf_error()));
+			return (-1);
+		}
+		(void) sleep(1);
+	}
+
+	if (retry >= 5) {
+		(void) fprintf(stderr, gettext("%s: Failed to stop %s.\n"),
+		    cmdname, FMRI_GDM);
+		return (-1);
+	}
+
+	return (0);
+}
+
+
 static void
 stop_restarters()
 {
@@ -1480,7 +1516,29 @@
 			(void) fprintf(stderr,
 			    gettext("%s: could not create %s.\n"),
 			    cmdname, resetting);
+	}
 
+	/*
+	 * Make sure we don't get stopped by a jobcontrol shell
+	 * once we start killing everybody.
+	 */
+	(void) signal(SIGTSTP, SIG_IGN);
+	(void) signal(SIGTTIN, SIG_IGN);
+	(void) signal(SIGTTOU, SIG_IGN);
+	(void) signal(SIGPIPE, SIG_IGN);
+	(void) signal(SIGTERM, SIG_IGN);
+
+	/*
+	 * Try to stop gdm so X has a chance to return the screen and
+	 * keyboard to a sane state.
+	 */
+	if (fast_reboot && stop_gdm() != 0) {
+		(void) fprintf(stderr,
+		    gettext("%s: Falling back to regular reboot.\n"), cmdname);
+		fast_reboot = 0;
+	}
+
+	if (cmd != A_DUMP) {
 		/*
 		 * Stop all restarters so they do not try to restart services
 		 * that are terminated.
@@ -1500,16 +1558,6 @@
 	}
 
 	/*
-	 * Make sure we don't get stopped by a jobcontrol shell
-	 * once we start killing everybody.
-	 */
-	(void) signal(SIGTSTP, SIG_IGN);
-	(void) signal(SIGTTIN, SIG_IGN);
-	(void) signal(SIGTTOU, SIG_IGN);
-	(void) signal(SIGPIPE, SIG_IGN);
-	(void) signal(SIGTERM, SIG_IGN);
-
-	/*
 	 * If we're not forcing a crash dump, give everyone 5 seconds to
 	 * handle a SIGTERM and clean up properly.
 	 */
--- a/usr/src/lib/libgrubmgmt/common/libgrub_cmd.def	Thu Sep 17 10:27:14 2009 -0700
+++ b/usr/src/lib/libgrubmgmt/common/libgrub_cmd.def	Thu Sep 17 11:03:46 2009 -0700
@@ -58,6 +58,9 @@
 menu_cmd("args", GRBM_ARGS_CMD, GRUB_LINE_ENTRY, error_line)
 menu_cmd("findroot", GRBM_FINDROOT_CMD, GRUB_LINE_ENTRY, findroot)
 menu_cmd("bootfs", GRBM_BOOTFS_CMD, GRUB_LINE_ENTRY, bootfs)
+menu_cmd("splashimage", GRBM_SPLASHIMAGE_CMD, GRUB_LINE_ENTRY, skip_line)
+menu_cmd("background", GRBM_BACKGROUND_CMD, GRUB_LINE_ENTRY, skip_line)
+menu_cmd("foreground", GRBM_FOREGROUND_CMD, GRUB_LINE_ENTRY, skip_line)
 
 menu_cmd_end(GRBM_CMD_NUM) /* Should be the last one */
 
--- a/usr/src/uts/i86pc/boot/boot_console.c	Thu Sep 17 10:27:14 2009 -0700
+++ b/usr/src/uts/i86pc/boot/boot_console.c	Thu Sep 17 11:03:46 2009 -0700
@@ -510,6 +510,10 @@
 	console_value_t *consolep;
 	size_t len, cons_len;
 	char *cons_str;
+#if !defined(_BOOT)
+	static char console_text[] = "text";
+	extern int post_fastreboot;
+#endif
 
 	boot_line = bootstr;
 	console = CONS_INVALID;
@@ -522,6 +526,11 @@
 	if (cons_str == NULL)
 		cons_str = find_boot_line_prop("output-device");
 
+#if !defined(_BOOT)
+	if (post_fastreboot && strcmp(cons_str, "graphics") == 0)
+		cons_str = console_text;
+#endif
+
 	/*
 	 * Go through the console_devices array trying to match the string
 	 * we were given.  The string on the command line must end with
@@ -646,6 +655,10 @@
 	char *devnames[] = { consoledev, outputdev, inputdev, NULL };
 	console_value_t *consolep;
 	int i;
+	extern int post_fastreboot;
+
+	if (post_fastreboot && console == CONS_SCREEN_GRAPHICS)
+		console = CONS_SCREEN_TEXT;
 
 	if (console != CONS_USBSER && console != CONS_SCREEN_GRAPHICS) {
 		if (console_set) {
--- a/usr/src/uts/i86pc/os/fakebop.c	Thu Sep 17 10:27:14 2009 -0700
+++ b/usr/src/uts/i86pc/os/fakebop.c	Thu Sep 17 11:03:46 2009 -0700
@@ -696,10 +696,17 @@
 
 		consoledev = outputdev + v_len + 1;
 		v_len = do_bsys_getproplen(NULL, "console");
-		if (v_len > 0)
+		if (v_len > 0) {
 			(void) do_bsys_getprop(NULL, "console", consoledev);
-		else
+			if (post_fastreboot &&
+			    strcmp(consoledev, "graphics") == 0) {
+				bsetprops("console", "text");
+				v_len = strlen("text");
+				bcopy("text", consoledev, v_len);
+			}
+		} else {
 			v_len = 0;
+		}
 		consoledev[v_len] = 0;
 		bcons_init2(inputdev, outputdev, consoledev);
 	} else {
@@ -1696,8 +1703,6 @@
 	HYPERVISOR_shared_info = (void *)xbootp->bi_shared_info;
 	xen_info = xbootp->bi_xen_start_info;
 #endif
-	bcons_init((void *)xbootp->bi_cmdline);
-	have_console = 1;
 
 #ifndef __xpv
 	if (*((uint32_t *)(FASTBOOT_SWTCH_PA + FASTBOOT_STACK_OFFSET)) ==
@@ -1707,6 +1712,9 @@
 	}
 #endif
 
+	bcons_init((void *)xbootp->bi_cmdline);
+	have_console = 1;
+
 	/*
 	 * enable debugging
 	 */
--- a/usr/src/uts/i86pc/os/mlsetup.c	Thu Sep 17 10:27:14 2009 -0700
+++ b/usr/src/uts/i86pc/os/mlsetup.c	Thu Sep 17 11:03:46 2009 -0700
@@ -49,10 +49,10 @@
 #include <sys/machsystm.h>
 #include <sys/ontrap.h>
 #include <sys/bootconf.h>
+#include <sys/boot_console.h>
 #include <sys/kdi_machimpl.h>
 #include <sys/archsystm.h>
 #include <sys/promif.h>
-#include <sys/bootconf.h>
 #include <sys/pci_cfgspace.h>
 #ifdef __xpv
 #include <sys/hypervisor.h>
@@ -78,6 +78,21 @@
 	0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf
 };
 
+/*
+ * Set console mode
+ */
+static void
+set_console_mode(uint8_t val)
+{
+	struct bop_regs rp = {0};
+
+	rp.eax.byte.ah = 0x0;
+	rp.eax.byte.al = val;
+	rp.ebx.word.bx = 0x0;
+
+	BOP_DOINT(bootops, 0x10, &rp);
+}
+
 
 /*
  * Setup routine called right before main(). Interposing this function
@@ -90,6 +105,8 @@
 	extern struct classfuncs sys_classfuncs;
 	extern disp_t cpu0_disp;
 	extern char t0stack[];
+	extern int post_fastreboot;
+	extern int console;
 
 	ASSERT_STACK_ALIGNED();
 
@@ -304,6 +321,13 @@
 		kdi_idt_sync();
 
 	/*
+	 * Explicitly set console to text mode (0x3) if this is a boot
+	 * post Fast Reboot, and the console is set to CONS_SCREEN_TEXT.
+	 */
+	if (post_fastreboot && console == CONS_SCREEN_TEXT)
+		set_console_mode(0x3);
+
+	/*
 	 * If requested (boot -d) drop into kmdb.
 	 *
 	 * This must be done after cpu_list_init() on the 64-bit kernel