patches and low-level development discussion
 help / color / mirror / code / Atom feed
From: Alyssa Ross <hi@alyssa.is>
To: devel@spectrum-os.org
Subject: [PATCH 06/22] img/app: add support for testing virtiofs
Date: Mon, 10 Oct 2022 23:28:46 +0000	[thread overview]
Message-ID: <20221010232909.1953738-7-hi@alyssa.is> (raw)
In-Reply-To: <20221010232909.1953738-1-hi@alyssa.is>

Signed-off-by: Alyssa Ross <hi@alyssa.is>
---
 .gitignore        |  5 ++++-
 img/app/Makefile  | 19 ++++++++++++++++---
 img/app/shell.nix |  6 +++++-
 3 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/.gitignore b/.gitignore
index a97f309..802df73 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,10 @@
 # SPDX-License-Identifier: CC0-1.0
-# SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
+# SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
 
 /config.nix
 build/
 result
 result-*
+
+# s6-ipcserver-socketbinder creates lockfiles for sockets.
+*.sock.lock
diff --git a/img/app/Makefile b/img/app/Makefile
index c5a4684..7d8e1c1 100644
--- a/img/app/Makefile
+++ b/img/app/Makefile
@@ -5,7 +5,10 @@
 # Nixpkgs.  If you don't have qemu-kvm, you'll need to set e.g.
 # QEMU_KVM = qemu-system-x86_64 -enable-kvm.
 QEMU_KVM = qemu-kvm
+BACKGROUND = background
 CLOUD_HYPERVISOR = cloud-hypervisor
+S6_IPCSERVER_SOCKETBINDER = s6-ipcserver-socketbinder
+VIRTIOFSD = virtiofsd
 
 prefix = /usr/local
 imgdir = $(prefix)/img
@@ -94,25 +97,35 @@ build/etc/s6-rc: $(VM_S6_RC_FILES)
 	    s6-rc-compile $@ $$dir; \
 	    exit=$$?; rm -r $$dir; exit $$exit
 
-run-qemu: build/host/appvm/blk/root.img
+start-virtiofsd:
+	$(S6_IPCSERVER_SOCKETBINDER) -B virtiofsd.sock \
+	    $(BACKGROUND) $(VIRTIOFSD) --fd 0 --shared-dir . ""
+.PHONY: start-virtiofsd
+
+run-qemu: build/host/appvm/blk/root.img start-virtiofsd
 	$(QEMU_KVM) -m 128 -cpu host -machine q35,kernel=$(KERNEL) -vga none \
 	  -drive file=build/host/appvm/blk/root.img,if=virtio,format=raw,readonly=on \
 	  -drive file=$(RUN_IMG),if=virtio,format=raw,readonly=on \
 	  -append "console=ttyS0 root=PARTLABEL=root" \
 	  -netdev user,id=net0 \
 	  -device virtio-net,netdev=net0,mac=0A:B3:EC:00:00:00 \
+	  -chardev socket,id=virtiofsd,path=virtiofsd.sock \
+	  -device vhost-user-fs-pci,chardev=virtiofsd,tag=virtiofs0 \
+	  -object memory-backend-memfd,id=mem,size=128M,share=on \
+	  -numa node,memdev=mem \
 	  -chardev vc,id=virtiocon0 \
 	  -device virtio-serial-pci \
 	  -device virtconsole,chardev=virtiocon0
 .PHONY: run-qemu
 
-run-cloud-hypervisor: build/host/appvm/blk/root.img
+run-cloud-hypervisor: build/host/appvm/blk/root.img start-virtiofsd
 	$(CLOUD_HYPERVISOR) \
 	    --api-socket path=vmm.sock \
-	    --memory size=128M \
+	    --memory size=128M,shared=on \
 	    --disk path=build/host/appvm/blk/root.img,readonly=on \
 	           path=$(RUN_IMG),readonly=on \
 	    --net tap=tap0,mac=0A:B3:EC:00:00:00 \
+	    --fs tag=virtiofs0,socket=virtiofsd.sock \
 	    --kernel $(KERNEL) \
 	    --cmdline "console=ttyS0 root=PARTLABEL=root" \
 	    --console tty \
diff --git a/img/app/shell.nix b/img/app/shell.nix
index 83dcd76..60ca465 100644
--- a/img/app/shell.nix
+++ b/img/app/shell.nix
@@ -12,7 +12,11 @@ with config.pkgs;
 
 {
   nativeBuildInputs = nativeBuildInputs ++ [
-    cloud-hypervisor jq qemu_kvm reuse
+    # Both QEMU and virtiofsd come with a virtiofsd executable,
+    # so we have to list virtiofsd first.
+    virtiofsd
+
+    cloud-hypervisor execline jq qemu_kvm reuse s6
   ];
 
   KERNEL = "${passthru.kernel.dev}/vmlinux";
-- 
2.37.1



  parent reply	other threads:[~2022-10-10 23:32 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-10 23:28 [PATCH 00/22] Implement managing VMs with Nix Alyssa Ross
2022-10-10 23:28 ` [PATCH 01/22] host/start-vm: use MAP_SHARED memory for VMs Alyssa Ross
2023-02-26 19:17   ` Alyssa Ross
2022-10-10 23:28 ` [PATCH 02/22] host/start-vm: implement shared directories Alyssa Ross
2023-02-26 19:17   ` Alyssa Ross
2022-10-10 23:28 ` [PATCH 03/22] host/rootfs: generate virtiofsd services Alyssa Ross
2023-02-26 19:17   ` Alyssa Ross
2022-10-10 23:28 ` [PATCH 04/22] Documentation: explain VM shared directories Alyssa Ross
2023-02-26 19:17   ` Alyssa Ross
2022-10-10 23:28 ` [PATCH 05/22] vm-lib/make-vm.nix: support " Alyssa Ross
2023-02-26 19:17   ` Alyssa Ross
2022-10-10 23:28 ` Alyssa Ross [this message]
2023-02-26 19:17   ` [PATCH 06/22] img/app: add support for testing virtiofs Alyssa Ross
2022-10-10 23:28 ` [PATCH 07/22] img/app: don't block app startup on network online Alyssa Ross
2023-02-26 19:17   ` Alyssa Ross
2022-10-10 23:28 ` [PATCH 08/22] img/app: auto-mount virtiofs0 filesystem Alyssa Ross
2023-02-26 19:17   ` Alyssa Ross
2022-10-10 23:28 ` [PATCH 09/22] vm/app/mg.nix: init Alyssa Ross
2023-02-26 19:17   ` Alyssa Ross
2022-10-10 23:28 ` [PATCH 10/22] vm/app/mg.nix: open virtio filesystem in dired Alyssa Ross
2023-02-26 19:17   ` Alyssa Ross
2022-10-10 23:28 ` [PATCH 11/22] host/rootfs: move ext mounting to s6-rc service Alyssa Ross
2022-11-14  1:14   ` Alyssa Ross
2022-10-10 23:28 ` [PATCH 12/22] host/rootfs: automatically grow user partition Alyssa Ross
2022-11-14  1:14   ` Alyssa Ross
2022-10-10 23:28 ` [PATCH 13/22] host/rootfs: use a bigger test ext partition Alyssa Ross
2022-11-14  1:14   ` Alyssa Ross
2022-10-10 23:28 ` [PATCH 14/22] host/initramfs/extfs.nix: tar2ext4 -> mkfs.ext4 -d Alyssa Ross
2022-11-14  1:14   ` Alyssa Ross
2022-10-10 23:28 ` [PATCH 15/22] host/start-vm: resolve VM symlinks with /ext root Alyssa Ross
2022-10-10 23:28 ` [PATCH 16/22] host/rootfs: " Alyssa Ross
2022-10-10 23:28 ` [PATCH 17/22] Documentation: explain /ext symlink resolution Alyssa Ross
2022-10-10 23:28 ` [PATCH 18/22] host/start-vm: increase memory size to 512M Alyssa Ross
2022-10-10 23:28 ` [PATCH 19/22] vm/app/nix: add Alyssa Ross
2022-10-10 23:29 ` [PATCH 20/22] vm-lib/make-vms.nix: add Alyssa Ross
2022-10-10 23:29 ` [PATCH 21/22] host/initramfs/extfs.nix: add example Nix-built VM Alyssa Ross
2022-10-10 23:29 ` [PATCH 22/22] Documentation: add how-to guide for Nix-built VMs Alyssa Ross
2022-10-10 23:29 ` [PATCH v2 0/6] Introduce a shared base for application VMs Alyssa Ross
2022-10-10 23:37   ` Alyssa Ross
2022-10-10 23:29 ` [PATCH v2 1/6] host/start-vm: support multiple block devices Alyssa Ross
2022-10-10 23:29 ` [PATCH v2 2/6] scripts/make-gpt.sh: add support for labels Alyssa Ross
2022-10-10 23:29 ` [PATCH v2 3/6] vm: build GPT images Alyssa Ross
2022-10-10 23:29 ` [PATCH v2 4/6] host/start-vm: boot using partition label Alyssa Ross
2022-10-10 23:29 ` [PATCH v2 5/6] release: rename from "img" Alyssa Ross
2022-10-10 23:29 ` [PATCH v2 6/6] img/app: extract from appvm-{lynx,catgirl} Alyssa Ross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221010232909.1953738-7-hi@alyssa.is \
    --to=hi@alyssa.is \
    --cc=devel@spectrum-os.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).