How to compile only a part of the content of a new "/usr/src" folder content (the bhyve source code)

Hello.

how can I compile everything inside a new /usr/src folder ? I've got the new src content from the corvin repository and this code has all the patches I need. So,I've moved my old src to src-old and now I want to to recompile the new one. I tried with make but it didn't work :

Code:
mario@marietto:/usr/src # make

Explicit target required.  Likely "buildworld" is wanted.  See build(7).

*** Error code 1

Stop.
make: stopped in /usr/src

The commands that I should issue are embedded inside the script below,but I'm not able to isolate them :

Code:
#!/bin/sh


usage() {

    cat >&2 << EOF

Usage: ${0} [--no-bhf] [--reboot] [--verbose] [--without-kernel]

    Builds bhyve

EOF

    exit 1

}


build_module() {

    local _path

    _path="${1}"


    # change to module path

    cd "${_path}"


    # clean module

    if test "${clean}" = "true"; then

        make clean > "${cmd_redirect}" 2>&1

    fi


    # build module

    make > "${cmd_redirect}" 2>&1


    # install module

    make install > "${cmd_redirect}"

}


build() {

    build_module "${src_dir}/include"

    build_module "${src_dir}/lib/libvmmapi"

    build_module "${src_dir}/sys/modules/vmm"


    # build kernel

    if test "${with_kernel}" = "true"; then

        cd "${src_dir}"

        local kern_opts

        kern_opts="-j$(sysctl -n hw.ncpu)"

        if test "${with_bhf}" = "true"; then

            kern_opts="${kern_opts} KERNCONF=BHF"

        fi

        if ! test "${clean}" = "true"; then

            kern_opts="${kern_opts} NO_CLEAN=YES"

        fi

        make kernel ${kern_opts} > "${cmd_redirect}" 2>&1

    fi


    build_module "${src_dir}/usr.sbin/bhyve"

    build_module "${src_dir}/usr.sbin/bhyvectl"

    build_module "${src_dir}/usr.sbin/bhyveload"


    if test "${with_reboot}" = "true"; then

        reboot

    fi

}


set -e

set -u


while test $# -gt 0; do

    case "${1-}" in

        --clean)

            clean="true"

            shift

            ;;

        --reboot)

            with_reboot="true"

            shift

            ;;

        --src-dir=*)

            src_dir="${1#*=}"

            shift

            ;;

        --verbose)

            cmd_redirect="/dev/stdout"

            shift

            ;;

        --without-bhf)

            with_bhf="false"

            shift

            ;;

        --without-kernel)

            with_kernel="false"

            shift

            ;;

        *)

            usage

            ;;

    esac

done


readonly clean="${clean-"false"}"

readonly cmd_redirect="${cmd_redirect-"/dev/null"}"

readonly src_dir="${src_dir-"/usr/src"}"

readonly with_bhf="${with_bhf-"true"}"

readonly with_kernel="${with_kernel-"true"}"

readonly with_reboot="${with_reboot-"false"}"


build
 
If this new /usr/src is truely a "FreeBSD /usr/src with patches in it" then you do exactly the same as "updating FreeBSD from source". I believe there is a good section in the handbook on this.
Overly simplified steps to upgrade are:
make buildworld && make buildkernel && make installkernel && make installworld

buildworld "builds" all the userland from base
buildkernel builds a kernel using those tools, defaults to GENERIC in the /usr/src tree
installkernel does exactly that, puts the just built kernel into place in /boot
installworld does exactly that, installs just built userland

NOTE:
There are a few steps between installkernel and installworld like a reboot into the new kernel, merging files in /etc that may affect booting the new kernel, then after installing the world there is at least one more step of updating the rest of /etc.
Typically one would also rebuild any ports at this point, especially things like kmod stuff for graphics.

Why did I leave out the steps? Because it's been a while since I've done an upgrade from source and I don't think the commands I used to do them are correct anymore. They may still work, but I think they've been obsoleted by new commands.
Thats why I point to the handbook.

But if that script came with the source, I would go back to that repo or look in the source tree for a README on "how to build".
 
On a very quick glance, this script's purpose is to only build bhyve and related stuff.

If you want to build everything, just follow the handbook.

ok. can you help me to extrapolate the commands embedded inside the script to build bhyve ? I don't understand very well the scripting language.
 

zirias@

Developer
zirias@ in the handbook in quick start there's missing "make installkernel" after step 5 before the first reboot.
Not really. make kernel is shorthand for make buildkernel installkernel ;)
(But I prefer to do them in separate steps myself, especially since I build on a different host...)
 
Coming back to the question. Since I need to compile only the bhyve components,what should I do ? Something like this is good ?

Code:
cd /usr/src/usr.sbin/bhyve/

make

make install
 
If this new /usr/src is truely a "FreeBSD /usr/src with patches in it" then you do exactly the same as "updating FreeBSD from source". I believe there is a good section in the handbook on this.
Overly simplified steps to upgrade are:
make buildworld && make buildkernel && make installkernel && make installworld

buildworld "builds" all the userland from base
buildkernel builds a kernel using those tools, defaults to GENERIC in the /usr/src tree
installkernel does exactly that, puts the just built kernel into place in /boot
installworld does exactly that, installs just built userland

NOTE:
There are a few steps between installkernel and installworld like a reboot into the new kernel, merging files in /etc that may affect booting the new kernel, then after installing the world there is at least one more step of updating the rest of /etc.
Typically one would also rebuild any ports at this point, especially things like kmod stuff for graphics.

Why did I leave out the steps? Because it's been a while since I've done an upgrade from source and I don't think the commands I used to do them are correct anymore. They may still work, but I think they've been obsoleted by new commands.
Thats why I point to the handbook.

But if that script came with the source, I would go back to that repo or look in the source tree for a README on "how to build".

As soon as FreeBSD 13.1-RELEASE came out,I've upgraded 13.0-CURRENT to 13.1-CURRENT with the command : "freebsd-update -r 13.1-RELEASE upgrade". The whole process worked or at least it seemed to me. But some days ago I've tried to pass thru my Intel GPU to a linux bhyve VM and it failed. So,I've tried to understand how to fix the error reported. I've installed FreeBSD 13.1-RELEASE from scratch and then I've applied the Corvin's patches and I've checked if the intel GPU was able to pass in a Linux bhyve vm. Yes,it worked. So,it does not work in the first case (13.0-RELEASE (with the corvins patched applied to 13.1-RELEASE) but it worked on the 13.1-RELEASE after having applied the corvin patches. I don't know why. Anyway,my idea is easy. Since the intel gpu can be passed on the system where I have installed directly the 13.1-RELEASE,I copied the src folder to the system where I have installed the 13.1-RELEASE obtained upgrading the 13.0-RELEASE (where,I have applied the corvin's patches,anyway). At this point,on the not working 13.1-RELEASE I have renamed the src folder to src_ and I've copied the src folder which works on the 13.1-RELEASE reinstalled and patched yesterday. My hope is that it will work even there. Probably the needed patches to pass the Intel GPU aren't present on my 13.0-RELEASE to 13.1-RELEASE / patched system but they are on the 13.1-RELEASE installed directly. Let's see if it works. I didn't want to recompile everything,but I don't understand how to compile only the bhyve source code.
 
UPDATE : it didn't work :
Code:
bhyve: Warning: Unable to reuse host address of Graphics Stolen Memory. GPU passthrough might not work properly.
bhyve: gvt_d_setup_opregion: Unable to get OpRegion base and length
bhyve: gvt_d_init: Unable to setup OpRegion
device emulation initialization error: Operation not supported by device

while is working on a direct installation of FreeBSD 13.1-RELEASE + corvin's patches applied.
 
Last edited by a moderator:
Top