From nobody Mon Jul 10 22:19:53 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4R0JMs6P80z4kSmt; Mon, 10 Jul 2023 22:19:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4R0JMs5XJcz3hDw; Mon, 10 Jul 2023 22:19:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689027593; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xU2i2t2elwleb8WRArX8OjaY3wW3snlzV7/D35UsZeQ=; b=PL5Y3iGcxTy64FW2YdGVLYWdDVM5oz0vYrwC0G7y43LQ84l0q0KTg/jgqZ+2iOd3jT57W9 uQBl/Ful6Tplow2GYt1IsZb6lIzYwMFv2XDopXeA74QeuouInOz76GjNwVa1fBMpOxQ8lV Ox/RR07RTENnU7wDkwYIb8gM1WUNdyqt2ubThzYTL9zE/rcVEttaQbuvs7bgXLDRVEiFl2 yqGHSpRSuYvLZx+fVueTybpa0uuQSEWo5tbDu9ekr1G6KFZLswftSMQZl0eupU6hEgxViL iaF5N47lmbkasc+qsqUVQoZWuCGSo9HT/hRuTjYD7PdoFlMlSGNaBA9qD3sH6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689027593; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xU2i2t2elwleb8WRArX8OjaY3wW3snlzV7/D35UsZeQ=; b=lCs/dsaUV2seVwVi+KiZ0xkGiFGRFFvbYNMcKJVEFIe9FJBnlo1YIGHGczpPABNmEfEUh6 0juReKc22T5oAs+EssT2uAyXccXx9uBFgbWMmWwIM4Zp6NX25KbQPs6QFEwIuq84NbmrF0 yc5fpLIbZYKPBashyLD8OkvX7kwBy+eCrZB38hGieo9K0ZKcIy8+M3zQfGet3UUhnXLkHT 8uG3S6paYjkI1f96mTK3XSFppTFNxqdMKCzOw3qcm8dl0nCc5Ph18W+fK3LcF4CgaU4UZx PB8vMIiQHsWUY9YkBuHvQIImEF5RUwozyrClyROj5qn/Ww6TcgqHgaQhS2iTFw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1689027593; a=rsa-sha256; cv=none; b=I4wOeARUJUMf0m0ZHEmif/DDv1tNiGDezt2tAEuSpy72ZeWLbPo9KJ5LcGoxTWgrXjJx4q k1i4lx8BgqJcjSKpp6khyv/kDV3WEfIAogSCsWCI6Hjkem7Li5Hv+6FhvTIcB6N2FQRsgV pyorkyq2wf27blxog3HW7k4ChECXgzSwHkMjqaEwaDSZVV27DyJoTuuE208gKN2U7LCkE1 seCyJgYwMC9ui+wmMvhUKs1o8EN8Bn9tLaSM5D8xkKwEXdBRPt5xmlDHw7TEbmHY7dXANe T5igZJHNNExuo8Pv0duziFtYwmAVH+IVsx8GJvGhNqPoVubkUYzd1g8e9y2tPQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4R0JMs4Tc8z12Kf; Mon, 10 Jul 2023 22:19:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 36AMJrNe034544; Mon, 10 Jul 2023 22:19:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36AMJrcw034543; Mon, 10 Jul 2023 22:19:53 GMT (envelope-from git) Date: Mon, 10 Jul 2023 22:19:53 GMT Message-Id: <202307102219.36AMJrcw034543@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Colin Percival Subject: git: 7acb53817ffc - main - release: Add code to make FreeBSD/Firecracker List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7acb53817ffcfcbe328f08a60f8087e6b88fa098 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=7acb53817ffcfcbe328f08a60f8087e6b88fa098 commit 7acb53817ffcfcbe328f08a60f8087e6b88fa098 Author: Colin Percival AuthorDate: 2023-07-10 06:16:31 +0000 Commit: Colin Percival CommitDate: 2023-07-10 22:19:33 +0000 release: Add code to make FreeBSD/Firecracker This just stages the kernel and builds a stripped-down rootfs for use with the Firecracker VMM. At some point in the future the release engineering team might start publishing these, but initially it's just here to simplify FreeBSD/Firecracker development and testing. Note that the rootfs generated: * Uses an IP address of 10.0.0.2 with a gateway of 10.0.0.1, * Has sshd enabled, * Has user "freebsd" with password "freebsd" and a root password of "root", and * Is 1 GB in size (but has growfs enabled). All of those are subject to change without notice; anyone intending to use FreeBSD/Firecracker in anything remotely resembling a production environment should talk to cperciva first. Reviewed by: gjb Sponsored by: https://www.patreon.com/cperciva Differential Revision: https://reviews.freebsd.org/D40956 --- release/Makefile.firecracker | 58 ++++++++++++++++++++++++++++++++++++++++++++ release/Makefile.vm | 1 + 2 files changed, 59 insertions(+) diff --git a/release/Makefile.firecracker b/release/Makefile.firecracker new file mode 100644 index 000000000000..bb54db7da5db --- /dev/null +++ b/release/Makefile.firecracker @@ -0,0 +1,58 @@ +# +# Makefile for creating FreeBSD/Firecracker artifacts +# + +CLEANDIRS+= ${TARGET}/firecracker-kern ${TARGET}/firecracker-world + +# Bits related to hardware which won't exist in a VM. +WITHOUT_VM_ENOENT=WITHOUT_APM=YES WITHOUT_BLUETOOTH=YES WITHOUT_CXGBETOOL=YES \ + WITHOUT_FLOPPY=YES WITHOUT_GPIO=YES WITHOUT_MLX5TOOL=YES WITHOUT_USB=YES \ + WITHOUT_USB_GADGET_EXAMPLES=YES WITHOUT_VT=YES WITHOUT_WIRELESS=YES +# Bits related to software which doesn't exist in Firecracker specifically. +WITHOUT_FC_ENOENT=WITHOUT_ACPI=YES WITHOUT_BOOT=YES WITHOUT_BHYVE=YES \ + WITHOUT_EFI=YES WITHOUT_FDT=YES WITHOUT_HYPERV=YES \ + WITHOUT_LEGACY_CONSOLE=YES WITHOUT_SYSCONS=YES +# Bits which take up a lot of space and probably won't be wanted inside a +# Firecracker VM. +WITHOUT_FC_FEATURES=WITHOUT_DEBUG_FILES=YES WITHOUT_INCLUDES=YES \ + WITHOUT_INSTALLLIB=YES WITHOUT_TESTS=YES WITHOUT_TOOLCHAIN=YES +# All the excluded bits +WITHOUTS=${WITHOUT_VM_ENOENT} ${WITHOUT_FC_ENOENT} ${WITHOUT_FC_FEATURES} + +firecracker: firecracker-freebsd-kern.bin firecracker-freebsd-rootfs.bin + +FCKDIR= ${.OBJDIR}/${TARGET}/firecracker-kern +firecracker-freebsd-kern.bin: +.if !defined(DESTDIR) || !exists(${DESTDIR}) + @echo "--------------------------------------------------------------" + @echo ">>> DESTDIR must point to destination for Firecracker binaries" + @echo "--------------------------------------------------------------" + @false +.endif + mkdir -p ${FCKDIR} + ${MAKE} -C ${WORLDDIR} DESTDIR=${FCKDIR} \ + KERNCONF=FIRECRACKER TARGET=${TARGET} installkernel + cp ${FCKDIR}/boot/kernel/kernel ${DESTDIR}/freebsd-kern.bin + +FCWDIR= ${.OBJDIR}/${TARGET}/firecracker-world +firecracker-freebsd-rootfs.bin: + mkdir -p ${FCWDIR} + ${MAKE} -C ${WORLDDIR} DESTDIR=${FCWDIR} \ + ${WITHOUTS} TARGET=${TARGET} installworld distribution distrib-dirs + echo '/dev/ufs/rootfs / ufs rw 1 1' > ${FCWDIR}/etc/fstab + echo 'hostname="freebsd"' >> ${FCWDIR}/etc/rc.conf + echo 'ifconfig_vtnet0="inet 10.0.0.2 netmask 255.255.0.0"' >> ${FCWDIR}/etc/rc.conf + echo 'defaultrouter="10.0.0.1"' >> ${FCWDIR}/etc/rc.conf + echo 'sshd_enable="YES"' >> ${FCWDIR}/etc/rc.conf + echo 'sshd_rsa_enable="NO"' >> ${FCWDIR}/etc/rc.conf + echo 'growfs_enable="YES"' >> ${FCWDIR}/etc/rc.conf + echo 'nameserver 8.8.8.8' >> ${FCWDIR}/etc/resolv.conf + sed -i '' -e '/periodic/s/^/#/' ${FCWDIR}/etc/crontab + pw -R ${FCWDIR} groupadd freebsd -g 1001 + mkdir -p ${FCWDIR}/home/freebsd + pw -R ${FCWDIR} useradd freebsd -m -M 0755 -w yes -n freebsd \ + -u 1001 -g 1001 -G 0 -c "FreeBSD User" -d /home/freebsd -s /bin/sh + pw -R ${FCWDIR} usermod root -w yes + touch ${FCWDIR}/firstboot + makefs -s 1g -o label=rootfs -o version=2 -o softupdates=1 \ + ${DESTDIR}/freebsd-rootfs.bin ${FCWDIR} diff --git a/release/Makefile.vm b/release/Makefile.vm index 81f46a23b2ac..ce86fabdfe5e 100644 --- a/release/Makefile.vm +++ b/release/Makefile.vm @@ -181,6 +181,7 @@ cloudware-release: .include "${.CURDIR}/Makefile.azure" .include "${.CURDIR}/Makefile.ec2" +.include "${.CURDIR}/Makefile.firecracker" .include "${.CURDIR}/Makefile.gce" .include "${.CURDIR}/Makefile.vagrant" .include "${.CURDIR}/Makefile.inc1"