From owner-svn-src-head@freebsd.org Thu Oct 25 02:14:36 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 51D15107A071; Thu, 25 Oct 2018 02:14:36 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0141A85CA1; Thu, 25 Oct 2018 02:14:36 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F04A22E1A; Thu, 25 Oct 2018 02:14:35 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w9P2EZsX068176; Thu, 25 Oct 2018 02:14:35 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w9P2EZfI068174; Thu, 25 Oct 2018 02:14:35 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201810250214.w9P2EZfI068174@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 25 Oct 2018 02:14:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r339702 - in head/stand: liblua lua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in head/stand: liblua lua X-SVN-Commit-Revision: 339702 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Oct 2018 02:14:36 -0000 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")