svn commit: r339978 - in stable/12/stand: liblua lua
Kyle Evans
kevans at FreeBSD.org
Wed Oct 31 23:08:51 UTC 2018
Author: kevans
Date: Wed Oct 31 23:08:49 2018
New Revision: 339978
URL: https://svnweb.freebsd.org/changeset/base/339978
Log:
MFC r339677-r339678, r339702, r339805: Lualoader Bugfixes
r339677:
lualoader: unload upon kernel change if a kernel was previously loaded
In the majority of cases, a kernel is not loaded before we hit the menu.
However, if a password is set, we'll trigger autoboot and have loadelf'd
beforehand. We also need to take into account one dropping to the loader
prompt and twiddling with things manually; if they try to toggle through
kernels, we'll assume they mean it.
r339678:
menu.lua: Abort autoboot sequence on failed command
Currently, a timeout in the menu autoboot sequence would effectively do
nothing. We would return from the autoboot handling, then begin processing
the menu without redrawing it.
This change makes the behavior a little more friendly. Returning the user to
the menu can't have any good effects, so abort the autoboot sequence and
drop to the loader prompt.
r339702:
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
r339805:
lualoader: Always return a proper dictionary for blacklist
If module_blacklist isn't specified, we have an empty blacklist; effectively
the same as if module_blacklist="" were specified in loader.conf(5).
This was reported when switching to a BE that predated the module_blacklist
introduction, but the problem is valid all the same and likely to be tripped
over in other scenarios.
Approved by: re (kib)
Modified:
stable/12/stand/liblua/lutils.c
stable/12/stand/lua/config.lua
stable/12/stand/lua/menu.lua
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/stand/liblua/lutils.c
==============================================================================
--- stable/12/stand/liblua/lutils.c Wed Oct 31 23:07:47 2018 (r339977)
+++ stable/12/stand/liblua/lutils.c Wed Oct 31 23:08:49 2018 (r339978)
@@ -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: stable/12/stand/lua/config.lua
==============================================================================
--- stable/12/stand/lua/config.lua Wed Oct 31 23:07:47 2018 (r339977)
+++ stable/12/stand/lua/config.lua Wed Oct 31 23:08:49 2018 (r339978)
@@ -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]-)\""
@@ -267,12 +266,12 @@ local function isValidComment(line)
end
local function getBlacklist()
+ local blacklist = {}
local blacklist_str = loader.getenv('module_blacklist')
if blacklist_str == nil then
- return nil
+ return blacklist
end
- local blacklist = {}
for mod in blacklist_str:gmatch("[;, ]?([%w-_]+)[;, ]?") do
blacklist[mod] = true
end
@@ -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")
Modified: stable/12/stand/lua/menu.lua
==============================================================================
--- stable/12/stand/lua/menu.lua Wed Oct 31 23:07:47 2018 (r339977)
+++ stable/12/stand/lua/menu.lua Wed Oct 31 23:08:49 2018 (r339978)
@@ -312,6 +312,9 @@ menu.welcome = {
#all_choices .. ")"
end,
func = function(_, choice, _)
+ if loader.getenv("kernelname") ~= nil then
+ loader.perform("unload")
+ end
config.selectKernel(choice)
end,
alias = {"k", "K"},
@@ -370,7 +373,9 @@ function menu.process(menudef, keypress)
break
elseif key == core.KEY_ENTER then
core.boot()
- -- Should not return
+ -- Should not return. If it does, escape menu handling
+ -- and drop to loader prompt.
+ return false
end
key = string.char(key)
@@ -401,6 +406,7 @@ function menu.process(menudef, keypress)
end
function menu.run()
+ local autoboot_key
local delay = loader.getenv("autoboot_delay")
if delay ~= nil and delay:lower() == "no" then
@@ -416,8 +422,17 @@ function menu.run()
menu.draw(menu.default)
- local autoboot_key = menu.autoboot(delay)
+ if delay ~= nil then
+ autoboot_key = menu.autoboot(delay)
+ -- autoboot_key should return the key pressed. It will only
+ -- return nil if we hit the timeout and executed the timeout
+ -- command. Bail out.
+ if autoboot_key == nil then
+ return
+ end
+ end
+
menu.process(menu.default, autoboot_key)
drawn_menu = nil
@@ -426,11 +441,6 @@ function menu.run()
end
function menu.autoboot(delay)
- -- If we've specified a nil delay, we can do nothing but assume that
- -- we aren't supposed to be autobooting.
- if delay == nil then
- return nil
- end
local x = loader.getenv("loader_menu_timeout_x") or 4
local y = loader.getenv("loader_menu_timeout_y") or 23
local endtime = loader.time() + delay
@@ -464,6 +474,7 @@ function menu.autoboot(delay)
local cmd = loader.getenv("menu_timeout_command") or "boot"
cli_execute_unparsed(cmd)
+ return nil
end
-- CLI commands
More information about the svn-src-stable
mailing list