From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id 243CA90704; Mon, 10 Oct 2022 23:33:15 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 496) id 17F659030C; Mon, 10 Oct 2022 23:32:40 +0000 (UTC) Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by atuin.qyliss.net (Postfix) with ESMTPS id E6F9D9007F for ; Mon, 10 Oct 2022 23:32:13 +0000 (UTC) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 6BCEC5C01C1 for ; Mon, 10 Oct 2022 19:32:10 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 10 Oct 2022 19:32:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alyssa.is; h=cc :content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1665444730; x=1665531130; bh=pq SzHn2Xybb5OiwiKjPwlD3G21e/P1XZy3f2Q77+OOY=; b=K0WYKAcHdlWBuCfrDw 3jZWhGxyD+Cfqojl/yxVpD6kg+RpKMCNAOExxGL7uE4dRxXW/oATlIQMo+rsldH2 ffoVWlqCkQgtpaWJWzMczcYAQlNZ+lmVq+WPMPxxUPZmoZjT4rFxpSTiHp4X7Mbc v+zDBw4g8EZK5QnS40+R9ta3J+JZTRtkc9Mq46WmEp/oYDpXFRpJRmvMVShaga7P zykbaO3WAIOsqduCTry38ov60rwbhfCq+zjg9HixH3Gx9hwCTo3LDvaRaVjE9C0X my2lyS2ZJCO9GoFVhvg7/mRIqbMkss/nhNiWWVbcsIyuekUmrr66NwToE1IAHoj4 C+og== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1665444730; x=1665531130; bh=pqSzHn2Xybb5O iwiKjPwlD3G21e/P1XZy3f2Q77+OOY=; b=R70wiSb5njtNTgpVE61e6CR32QNKe VMb8WD8TvY5Sh0qAAOmw+o2IT06BTG8ww6ynAyTd1JfxRagpOyXehuWRi+uYrVaC Ns1gCeidyYlYMy7eGmy2E7hWyfzpToZEqQfGqQe9RrM5N36yioOhm9futCCXaHdv i8ukID7SSKU/wRVXMrFHQBoUxPNdly1QuyuczhBqdv9Pzr2y4JbqpkHWZe2SJPJ7 mFDJXBp+yBeGvE+WV6kTi1jqlwhgCK70WqRTMRQYNaPH8rIyVuslQMrKRnMiyukf WpUWQHa6cD4LFOpCB+Ki4S1ofxfTWVKvw0DicFsXz4NIaaEFJxp2lzMtA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeejhedgvdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomheptehlhihsshgrucftohhsshcuoehhihesrghlhihsshgrrdhi sheqnecuggftrfgrthhtvghrnhepteelieefgfejvddvfeektdfgfefgffeftdetuddtvd elfeevgeevueevhfduueeinecuffhomhgrihhnpehkvghrnhgvlhdruggvvhenucevlhhu shhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehqhihlihhsshesgi dvvddtrdhqhihlihhsshdrnhgvth X-ME-Proxy: Feedback-ID: i12284293:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Mon, 10 Oct 2022 19:32:10 -0400 (EDT) Received: by x220.qyliss.net (Postfix, from userid 1000) id A4243BC8; Mon, 10 Oct 2022 23:32:07 +0000 (UTC) From: Alyssa Ross To: devel@spectrum-os.org Subject: [PATCH v2 3/6] vm: build GPT images Date: Mon, 10 Oct 2022 23:29:06 +0000 Message-Id: <20221010232909.1953738-27-hi@alyssa.is> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20221010232909.1953738-1-hi@alyssa.is> References: <20221010232909.1953738-1-hi@alyssa.is> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: EQ35H6ACCMHNYF7Y6AOCPUDZNEIKFGIL X-Message-ID-Hash: EQ35H6ACCMHNYF7Y6AOCPUDZNEIKFGIL X-MailFrom: qyliss@x220.qyliss.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-devel.spectrum-os.org-0; header-match-devel.spectrum-os.org-1; header-match-devel.spectrum-os.org-2; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.5 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This will allow booting reliably from multiple disk images, without relying on order or requiring udev in an initramfs. (The only deterministic way of doing boot order on Linux without special userspace support is to set "root" on the kernel command line to either a GPT partition UUID or label.) Signed-off-by: Alyssa Ross --- vm/app/catgirl/Makefile | 13 ++++++++++--- vm/app/catgirl/default.nix | 10 +++++++--- vm/app/lynx/Makefile | 13 ++++++++++--- vm/app/lynx/default.nix | 10 +++++++--- vm/sys/net/Makefile | 13 ++++++++++--- vm/sys/net/default.nix | 10 +++++++--- 6 files changed, 51 insertions(+), 18 deletions(-) diff --git a/vm/app/catgirl/Makefile b/vm/app/catgirl/Makefile index 9016745..8129c8e 100644 --- a/vm/app/catgirl/Makefile +++ b/vm/app/catgirl/Makefile @@ -8,6 +8,7 @@ QEMU_KVM = qemu-kvm CLOUD_HYPERVISOR = cloud-hypervisor VMM = qemu +SCRIPTS = ../../../scripts HOST_FILES = host/data/appvm-catgirl/providers/net/netvm @@ -33,9 +34,15 @@ build/host/data/appvm-catgirl/vmlinux: $(VMLINUX) mkdir -p $$(dirname $@) cp $(VMLINUX) $@ +build/host/data/appvm-catgirl/blk/root.img: $(SCRIPTS)/make-gpt.sh $(SCRIPTS)/sfdisk-field.awk build/rootfs.ext4 + mkdir -p $$(dirname $@) + $(SCRIPTS)/make-gpt.sh $@.tmp \ + build/rootfs.ext4:4f68bce3-e8cd-4db1-96e7-fbcaf984b709:0d2f5f77-eb9c-453a-9463-daafcb5ce2b2:root + mv $@.tmp $@ + # tar2ext4 will leave half a filesystem behind if it's interrupted # half way through. -build/host/data/appvm-catgirl/blk/root.img: build/rootfs.tar +build/rootfs.ext4: build/rootfs.tar mkdir -p $$(dirname $@) tar2ext4 -i build/rootfs.tar -o $@.tmp mv $@.tmp $@ @@ -95,7 +102,7 @@ build/etc/s6-rc: $(VM_S6_RC_FILES) run-qemu: build/host/data/appvm-catgirl/blk/root.img $(QEMU_KVM) -m 128 -cpu host -machine q35,kernel=$(KERNEL) -vga none \ -drive file=build/host/data/appvm-catgirl/blk/root.img,if=virtio,format=raw,readonly=on \ - -append "console=ttyS0 root=/dev/vda" \ + -append "console=ttyS0 root=PARTLABEL=root" \ -netdev user,id=net0 \ -device virtio-net,netdev=net0,mac=0A:B3:EC:00:00:00 \ -chardev vc,id=virtiocon0 \ @@ -110,7 +117,7 @@ run-cloud-hypervisor: build/host/data/appvm-catgirl/blk/root.img --disk path=build/host/data/appvm-catgirl/blk/root.img,readonly=on \ --net tap=tap0,mac=0A:B3:EC:00:00:00 \ --kernel $(KERNEL) \ - --cmdline "console=ttyS0 root=/dev/vda" \ + --cmdline "console=ttyS0 root=PARTLABEL=root" \ --console tty \ --serial pty .PHONY: run-cloud-hypervisor diff --git a/vm/app/catgirl/default.nix b/vm/app/catgirl/default.nix index 61f1462..d83392d 100644 --- a/vm/app/catgirl/default.nix +++ b/vm/app/catgirl/default.nix @@ -1,5 +1,5 @@ # SPDX-License-Identifier: MIT -# SPDX-FileCopyrightText: 2021 Alyssa Ross +# SPDX-FileCopyrightText: 2021-2022 Alyssa Ross { config ? import ../../../nix/eval-config.nix {} , terminfo ? config.pkgs.foot.terminfo @@ -8,13 +8,15 @@ config.pkgs.pkgsStatic.callPackage ( { lib, stdenvNoCC, runCommand, writeReferencesToFile, buildPackages -, s6-rc, tar2ext4 +, jq, s6-rc, tar2ext4, util-linux , busybox, cacert, catgirl, execline, kmod, mdevd, s6, s6-linux-init }: let inherit (lib) cleanSource cleanSourceWith concatMapStringsSep hasSuffix; + scripts = import ../../../scripts { inherit config; }; + packages = [ catgirl execline kmod mdevd s6 s6-linux-init s6-rc @@ -71,11 +73,13 @@ stdenvNoCC.mkDerivation { src = cleanSource ./.; }; - nativeBuildInputs = [ s6-rc tar2ext4 ]; + nativeBuildInputs = [ jq s6-rc tar2ext4 util-linux ]; PACKAGES_TAR = packagesTar; VMLINUX = "${kernel.dev}/vmlinux"; + makeFlags = [ "SCRIPTS=${scripts}" ]; + installPhase = '' mv build/svc $out ''; diff --git a/vm/app/lynx/Makefile b/vm/app/lynx/Makefile index ff87cb8..ff42501 100644 --- a/vm/app/lynx/Makefile +++ b/vm/app/lynx/Makefile @@ -8,6 +8,7 @@ QEMU_KVM = qemu-kvm CLOUD_HYPERVISOR = cloud-hypervisor VMM = qemu +SCRIPTS = ../../../scripts HOST_FILES = host/data/appvm-lynx/providers/net/netvm @@ -33,9 +34,15 @@ build/host/data/appvm-lynx/vmlinux: $(VMLINUX) mkdir -p $$(dirname $@) cp $(VMLINUX) $@ +build/host/data/appvm-lynx/blk/root.img: $(SCRIPTS)/make-gpt.sh $(SCRIPTS)/sfdisk-field.awk build/rootfs.ext4 + mkdir -p $$(dirname $@) + $(SCRIPTS)/make-gpt.sh $@.tmp \ + build/rootfs.ext4:4f68bce3-e8cd-4db1-96e7-fbcaf984b709:41e8068d-38d5-4135-ad77-0da704743940:root + mv $@.tmp $@ + # tar2ext4 will leave half a filesystem behind if it's interrupted # half way through. -build/host/data/appvm-lynx/blk/root.img: build/rootfs.tar +build/rootfs.ext4: build/rootfs.tar mkdir -p $$(dirname $@) tar2ext4 -i build/rootfs.tar -o $@.tmp mv $@.tmp $@ @@ -94,7 +101,7 @@ build/etc/s6-rc: $(VM_S6_RC_FILES) run-qemu: build/host/data/appvm-lynx/blk/root.img $(QEMU_KVM) -m 128 -cpu host -machine q35,kernel=$(KERNEL) -vga none \ -drive file=build/host/data/appvm-lynx/blk/root.img,if=virtio,format=raw,readonly=on \ - -append "console=ttyS0 root=/dev/vda" \ + -append "console=ttyS0 root=PARTLABEL=root" \ -netdev user,id=net0 \ -device virtio-net,netdev=net0,mac=0A:B3:EC:00:00:00 \ -chardev vc,id=virtiocon0 \ @@ -109,7 +116,7 @@ run-cloud-hypervisor: build/host/data/appvm-lynx/blk/root.img --disk path=build/host/data/appvm-lynx/blk/root.img,readonly=on \ --net tap=tap0,mac=0A:B3:EC:00:00:00 \ --kernel $(KERNEL) \ - --cmdline "console=ttyS0 root=/dev/vda" \ + --cmdline "console=ttyS0 root=PARTLABEL=root" \ --console tty \ --serial pty .PHONY: run-cloud-hypervisor diff --git a/vm/app/lynx/default.nix b/vm/app/lynx/default.nix index ba715ec..92635f3 100644 --- a/vm/app/lynx/default.nix +++ b/vm/app/lynx/default.nix @@ -1,5 +1,5 @@ # SPDX-License-Identifier: MIT -# SPDX-FileCopyrightText: 2021 Alyssa Ross +# SPDX-FileCopyrightText: 2021-2022 Alyssa Ross { config ? import ../../../nix/eval-config.nix {} , terminfo ? config.pkgs.foot.terminfo @@ -8,13 +8,15 @@ config.pkgs.pkgsStatic.callPackage ( { lib, stdenvNoCC, runCommand, writeReferencesToFile, buildPackages -, s6-rc, tar2ext4 +, jq, s6-rc, tar2ext4, util-linux , busybox, cacert, execline, kmod, lynx, mdevd, s6, s6-linux-init }: let inherit (lib) cleanSource cleanSourceWith concatMapStringsSep hasSuffix; + scripts = import ../../../scripts { inherit config; }; + packages = [ execline kmod lynx mdevd s6 s6-linux-init s6-rc @@ -71,11 +73,13 @@ stdenvNoCC.mkDerivation { src = cleanSource ./.; }; - nativeBuildInputs = [ s6-rc tar2ext4 ]; + nativeBuildInputs = [ jq s6-rc tar2ext4 util-linux ]; PACKAGES_TAR = packagesTar; VMLINUX = "${kernel.dev}/vmlinux"; + makeFlags = [ "SCRIPTS=${scripts}" ]; + installPhase = '' mv build/svc $out ''; diff --git a/vm/sys/net/Makefile b/vm/sys/net/Makefile index 0b5fe8f..2b9004b 100644 --- a/vm/sys/net/Makefile +++ b/vm/sys/net/Makefile @@ -8,6 +8,7 @@ QEMU_KVM = qemu-kvm CLOUD_HYPERVISOR = cloud-hypervisor VMM = qemu +SCRIPTS = ../../../scripts HOST_BUILD_FILES = \ build/host/data/netvm/blk/root.img \ @@ -30,9 +31,15 @@ build/host/data/netvm/vmlinux: $(VMLINUX) mkdir -p $$(dirname $@) cp $(VMLINUX) $@ +build/host/data/netvm/blk/root.img: $(SCRIPTS)/make-gpt.sh $(SCRIPTS)/sfdisk-field.awk build/rootfs.ext4 + mkdir -p $$(dirname $@) + $(SCRIPTS)/make-gpt.sh $@.tmp \ + build/rootfs.ext4:4f68bce3-e8cd-4db1-96e7-fbcaf984b709:ea21da27-0391-48da-9235-9d2ab2ca7844:root + mv $@.tmp $@ + # tar2ext4 will leave half a filesystem behind if it's interrupted # half way through. -build/host/data/netvm/blk/root.img: build/rootfs.tar +build/rootfs.ext4: build/rootfs.tar mkdir -p $$(dirname $@) tar2ext4 -i build/rootfs.tar -o $@.tmp mv $@.tmp $@ @@ -100,7 +107,7 @@ build/etc/s6-rc: $(VM_S6_RC_FILES) run-qemu: build/host/data/netvm/blk/root.img $(QEMU_KVM) -m 128 -cpu host -machine q35,kernel=$(KERNEL) -vga none \ -drive file=build/host/data/netvm/blk/root.img,if=virtio,format=raw,readonly=on \ - -append "console=ttyS0 root=/dev/vda" \ + -append "console=ttyS0 root=PARTLABEL=root" \ -netdev user,id=net0 \ -device e1000e,netdev=net0 \ -netdev user,id=net1 \ @@ -117,7 +124,7 @@ run-cloud-hypervisor: build/host/data/netvm/blk/root.img --disk path=build/host/data/netvm/blk/root.img,readonly=on \ --net tap=tap0 tap=tap1,mac=0A:B3:EC:80:00:00 \ --kernel $(KERNEL) \ - --cmdline "console=ttyS0 root=/dev/vda" \ + --cmdline "console=ttyS0 root=PARTLABEL=root" \ --console tty \ --serial pty .PHONY: run-cloud-hypervisor diff --git a/vm/sys/net/default.nix b/vm/sys/net/default.nix index dfc7c35..e9a2f05 100644 --- a/vm/sys/net/default.nix +++ b/vm/sys/net/default.nix @@ -1,5 +1,5 @@ # SPDX-License-Identifier: MIT -# SPDX-FileCopyrightText: 2021 Alyssa Ross +# SPDX-FileCopyrightText: 2021-2022 Alyssa Ross { config ? import ../../../nix/eval-config.nix {} , terminfo ? config.pkgs.foot.terminfo @@ -8,7 +8,7 @@ config.pkgs.pkgsStatic.callPackage ( { lib, stdenvNoCC, runCommand, writeReferencesToFile, buildPackages -, s6-rc, tar2ext4, xorg +, jq, s6-rc, tar2ext4, util-linux, xorg , busybox, connmanMinimal, dbus, execline, kmod, mdevd, nftables, s6 , s6-linux-init }: @@ -16,6 +16,8 @@ config.pkgs.pkgsStatic.callPackage ( let inherit (lib) cleanSource cleanSourceWith concatMapStringsSep hasSuffix; + scripts = import ../../../scripts { inherit config; }; + connman = connmanMinimal; packages = [ @@ -80,11 +82,13 @@ stdenvNoCC.mkDerivation { src = cleanSource ./.; }; - nativeBuildInputs = [ s6-rc tar2ext4 ]; + nativeBuildInputs = [ jq s6-rc tar2ext4 util-linux ]; PACKAGES_TAR = packagesTar; VMLINUX = "${kernel.dev}/vmlinux"; + makeFlags = [ "SCRIPTS=${scripts}" ]; + installPhase = '' mv build/svc $out ''; -- 2.37.1