svn commit: r339702 - in head/stand: liblua lua

Kyle Evans kevans at FreeBSD.org
Thu Oct 25 02:14:36 UTC 2018


Author: kevans
Date: Thu Oct 25 02:14:35 2018
New Revision: 339702
URL: https://svnweb.freebsd.org/changeset/base/339702

Log:
  lualoader: Improve module loading diagnostics
  
  Some fixes:
  
  - Maintain historical behavior more accurately w.r.t verbose_loading;
    verbose_loading strictly prints "${module_name...}" and later "failed!"
    or "ok" based on load success
  - With or without verbose_loading, dump command_errbuf on load failure.
    This usually happens prior to ok/failed if we're verbose_loading
  
  Reviewed by:	imp
  MFC after:	3 days
  Differential Revision:	https://reviews.freebsd.org/D17694

Modified:
  head/stand/liblua/lutils.c
  head/stand/lua/config.lua

Modified: head/stand/liblua/lutils.c
==============================================================================
--- head/stand/liblua/lutils.c	Thu Oct 25 02:04:01 2018	(r339701)
+++ head/stand/liblua/lutils.c	Thu Oct 25 02:14:35 2018	(r339702)
@@ -77,6 +77,14 @@ lua_perform(lua_State *L)
 	return 1;
 }
 
+static int
+lua_command_error(lua_State *L)
+{
+
+	lua_pushstring(L, command_errbuf);
+	return 1;
+}
+
 /*
  * Accepts a space-delimited loader command and runs it through the standard
  * loader parsing, as if it were executed at the loader prompt by the user.
@@ -341,6 +349,7 @@ lua_writefile(lua_State *L)
 #define REG_SIMPLE(n)	{ #n, lua_ ## n }
 static const struct luaL_Reg loaderlib[] = {
 	REG_SIMPLE(delay),
+	REG_SIMPLE(command_error),
 	REG_SIMPLE(command),
 	REG_SIMPLE(interpret),
 	REG_SIMPLE(parse),

Modified: head/stand/lua/config.lua
==============================================================================
--- head/stand/lua/config.lua	Thu Oct 25 02:04:01 2018	(r339701)
+++ head/stand/lua/config.lua	Thu Oct 25 02:14:35 2018	(r339702)
@@ -55,7 +55,6 @@ local MSG_XENKERNLOADING = "Loading Xen kernel..."
 local MSG_KERNLOADING = "Loading kernel..."
 local MSG_MODLOADING = "Loading configured modules..."
 local MSG_MODBLACKLIST = "Not loading blacklisted module '%s'"
-local MSG_MODLOADFAIL = "Could not load one or more modules!"
 
 local MODULEEXPR = '([%w-_]+)'
 local QVALEXPR = "\"([%w%s%p]-)\""
@@ -292,6 +291,9 @@ local function loadModule(mod, silent)
 				end
 				goto continue
 			end
+			if not silent then
+				loader.printc(module_name .. "...")
+			end
 			local str = "load "
 			if v.type ~= nil then
 				str = str .. "-t " .. v.type .. " "
@@ -309,23 +311,29 @@ local function loadModule(mod, silent)
 			end
 
 			if cli_execute_unparsed(str) ~= 0 then
+				-- XXX Temporary shim: don't break the boot if
+				-- loader hadn't been recompiled with this
+				-- function exposed.
+				if loader.command_error then
+					print(loader.command_error())
+				end
 				if not silent then
-					print(MSG_FAILEXMOD:format(str))
+					print("failed!")
 				end
 				if v.error ~= nil then
 					cli_execute_unparsed(v.error)
 				end
 				status = false
-			end
-
-			if v.after ~= nil then
+			elseif v.after ~= nil then
 				pstatus = cli_execute_unparsed(v.after) == 0
 				if not pstatus and not silent then
 					print(MSG_FAILEXAF:format(v.after, k))
 				end
+				if not silent then
+					print("ok")
+				end
 				status = status and pstatus
 			end
-
 		end
 		::continue::
 	end
@@ -622,20 +630,18 @@ function config.loadelf()
 		print(MSG_XENKERNLOADING)
 		if cli_execute_unparsed('load ' .. xen_kernel) ~= 0 then
 			print(MSG_XENKERNFAIL:format(xen_kernel))
-			return
+			return false
 		end
 	end
 	print(MSG_KERNLOADING)
 	loaded = config.loadKernel(kernel)
 
 	if not loaded then
-		return
+		return false
 	end
 
 	print(MSG_MODLOADING)
-	if not loadModule(modules, not config.verbose) then
-		print(MSG_MODLOADFAIL)
-	end
+	return loadModule(modules, not config.verbose)
 end
 
 hook.registerType("config.loaded")


More information about the svn-src-head mailing list