[PATCH v3 4/6] vm: add support for testing in crosvm

Alyssa Ross
2023-07-21T18:01:02Z

From: Alyssa Ross <alyssa.ross@unikie.com>

This is useful because it allows comparing how our patched
cloud-hypervisor behaves against crosvm's implementation.

Signed-off-by: Alyssa Ross <alyssa.ross@unikie.com>
Co-authored-by: Alyssa Ross <hi@alyssa.is>
Signed-off-by: Alyssa Ross <hi@alyssa.is>
---
img/app/Makefile | 12 ++++++++++++
lib/common.mk | 1 +
vm/sys/net/Makefile | 11 +++++++++++
vm/sys/net/shell.nix | 2 +-
4 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/img/app/Makefile b/img/app/Makefile
index 0742440..35db476 100644
--- a/img/app/Makefile
+++ b/img/app/Makefile
@@ -125,6 +125,18 @@ run-cloud-hypervisor: $(imgdir)/appvm/blk/root.img start-vhost-user-gpu start-vi
--serial pty
.PHONY: run-cloud-hypervisor

+run-crosvm: $(imgdir)/appvm/blk/root.img start-vhost-user-gpu start-virtiofsd
+ $(CROSVM_RUN) \
+ --disk $(imgdir)/appvm/blk/root.img \
+ --disk $(RUN_IMG) \
+ -p "console=ttyS0 root=PARTLABEL=root" \
+ --vhost-user-fs build/virtiofsd.sock:virtiofs0 \
+ --vhost-user-gpu build/vhost-user-gpu.sock \
+ --serial type=file,hardware=serial,path=build/crosvm.log \
+ --serial type=stdout,hardware=virtio-console,stdin=true \
+ $(KERNEL)
+.PHONY: run-crosvm
+
run: run-$(VMM)
.PHONY: run

diff --git a/lib/common.mk b/lib/common.mk
index 81754b9..bba7f22 100644
--- a/lib/common.mk
+++ b/lib/common.mk
@@ -13,6 +13,7 @@ CPIO = cpio
CPIOFLAGS = --reproducible -R +0:+0 -H newc
CROSVM = crosvm
CROSVM_DEVICE_GPU = $(CROSVM) device gpu
+CROSVM_RUN = $(CROSVM) run
MCOPY = mcopy
MKFS_FAT = mkfs.fat
MMD = mmd
diff --git a/vm/sys/net/Makefile b/vm/sys/net/Makefile
index bbeb40b..d31477a 100644
--- a/vm/sys/net/Makefile
+++ b/vm/sys/net/Makefile
@@ -119,6 +119,17 @@ run-cloud-hypervisor: build/host/data/netvm/blk/root.img
--serial pty
.PHONY: run-cloud-hypervisor

+run-crosvm: build/host/data/netvm/blk/root.img
+ $(CROSVM_RUN) \
+ --disk build/host/data/netvm/blk/root.img \
+ -p "console=ttyS0 root=PARTLABEL=root" \
+ --net tap-name=tap0 \
+ --net tap-name=tap1,mac=0A:B3:EC:80:00:00 \
+ --serial type=file,hardware=serial,path=build/crosvm.log \
+ --serial type=stdout,hardware=virtio-console,stdin=true \
+ $(KERNEL)
+.PHONY: run-crosvm
+
run: run-$(VMM)
.PHONY: run

diff --git a/vm/sys/net/shell.nix b/vm/sys/net/shell.nix
index 7710438..39ba520 100644
--- a/vm/sys/net/shell.nix
+++ b/vm/sys/net/shell.nix
@@ -7,5 +7,5 @@ import ../../../lib/eval-config.nix ({ config, ... }: with config.pkgs;
{ nativeBuildInputs ? [], ... }:

{
- nativeBuildInputs = nativeBuildInputs ++ [ cloud-hypervisor jq qemu_kvm reuse ];
+ nativeBuildInputs = nativeBuildInputs ++ [ cloud-hypervisor crosvm jq qemu_kvm reuse ];
}))
--
2.40.1