]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
userboot: handle guest interpreter mismatches more intelligently
authorKyle Evans <kevans@FreeBSD.org>
Sat, 1 Sep 2018 02:23:45 +0000 (02:23 +0000)
committerKyle Evans <kevans@FreeBSD.org>
Sat, 1 Sep 2018 02:23:45 +0000 (02:23 +0000)
commitd3d381b2b194b4d24853e92eecef55f262688d1a
treee7447cdb72105a45516fd5f60f404431858ae952
parent162ec569493ba1919857c22a957c97700246da14
userboot: handle guest interpreter mismatches more intelligently

The switch to lualoader creates a problem with userboot: the host is
inclined to build userboot with Lua, but the host userboot's interpreter
must match what's available on the guest. For almost all FreeBSD guests in
the wild, Lua is not yet available and a Lua-based userboot will fail.

This revision updates userboot protocol to version 5, which adds a
swap_interpreter callback to request a different interpreter, and tries to
determine the proper interpreter to be used based on how the guest
/boot/loader is compiled. This is still a bit of a guess, but it's likely
the best possible guess we can make in order to get it right. The
interpreter is now embedded in the resulting executable, so we can open
/boot/loader on the guest and hunt that down to derive the interpreter it
was built with.

Using -l with bhyveload will not allow an intepreter swap, even if the
loader specified happens to be a userboot with the wrong interpreter. We'll
simply complain about the mismatch and bail out.

For legacy guests without the interpreter marker, we assume they're 4th.
For new guests with the interpreter marker, we'll read it and swap over
to the proper interpreter if it doesn't match what the userboot we're using
was compiled with.

Both flavors of userboot are installed by default, userboot_4th.so and
userboot_lua.so. This fixes the build WITHOUT_FORTH as a coincidence, which
was broken by userboot being forced to 4th.

Reviewed by: imp, jhb, araujo (earlier version)
Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D16945
12 files changed:
stand/common/bootstrap.h
stand/common/interp_forth.c
stand/common/interp_lua.c
stand/common/interp_simple.c
stand/userboot/Makefile
stand/userboot/userboot.h
stand/userboot/userboot/Makefile
stand/userboot/userboot/main.c
stand/userboot/userboot/version
stand/userboot/userboot_4th/Makefile [new file with mode: 0644]
stand/userboot/userboot_lua/Makefile [new file with mode: 0644]
usr.sbin/bhyveload/bhyveload.c