crosvm/tools/impl/testvm/Makefile
Dennis Kempin aae0141680 dev_container: Upgrade to debian bookworm
Debian bullseye is becoming old and we require a couple of newer
dependencies. gLinux is also tracking bookworm, so we are staying
close to our usual development environment.

Since the official rust images do not have a bookworm version,
we switch to the official debian image and add a rustup install
to ./tools/install-deps.

The new glibc version uses clone3 in multiple devices, adding
this new syscall to our policy to pass integration tests.

Drive-by change: Upgrading rust-toolchain from 1.62.0 to 1.62.1

BUG=b:243081643
TEST=CQ

Change-Id: I8af721ed4a83df61163d67001b777166abe8abfa
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3892621
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-09-14 22:32:36 +00:00

81 lines
2.4 KiB
Makefile

# Copyright 2021 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Builds the base image for test VMs used by ./tools/x86vm and
# ./tools/aarch64vm.
#
# To build and upload a new base image, uprev the version in the `version` file
# and run:
#
# make ARCH=x86_64 upload
# make ARCH=aarch64 upload
#
# You need write access to the crosvm-testvm storage bucket which is part of the
# crosvm-packages cloud project.
#
# Note: The locally built image is stored in the same place that testvm.py
# expects. So the image can be tested directly:
#
# make -C tools/impl/testvm ARCH=x86_64
# ./tools/x86vm run
CARGO_TARGET=$(shell cargo metadata --no-deps --format-version 1 | \
jq -r ".target_directory")
TARGET=$(CARGO_TARGET)/crosvm_tools/$(ARCH)
$(shell mkdir -p $(TARGET))
ifeq ($(ARCH), x86_64)
DEBIAN_ARCH=amd64
QEMU_CMD=qemu-system-x86_64 \
-cpu Broadwell \
-enable-kvm
else ifeq ($(ARCH), aarch64)
DEBIAN_ARCH=arm64
QEMU_CMD=qemu-system-aarch64 \
-cpu cortex-a57 \
-M virt \
-bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd
else
$(error Only x86_64 or aarch64 are supported)
endif
GS_PREFIX=gs://crosvm/testvm
DEBIAN_URL=https://cloud.debian.org/images/cloud/bookworm/daily/20220912-1136/
BASE_IMG_NAME=base-$(ARCH)-$(shell cat version).qcow2
GS_URL=$(GS_PREFIX)/$(BASE_IMG_NAME)
LOCAL_IMAGE=$(TARGET)/$(BASE_IMG_NAME)
all: $(LOCAL_IMAGE)
clean:
rm -rf $(TARGET)
# Upload images to cloud storage. Do not overwrite existing images, uprev
# `image_version` instead.
upload: $(LOCAL_IMAGE)
gsutil cp -n $(LOCAL_IMAGE) $(GS_URL)
# Download debian bullseye as base image for the testvm.
$(TARGET)/debian.qcow2:
wget $(DEBIAN_URL)/debian-12-generic-$(DEBIAN_ARCH)-daily-20220912-1136.qcow2 -O $@
# The cloud init file contains instructions for how to set up the VM when it's
# first booted.
$(TARGET)/clould_init.img: cloud_init.yaml
cloud-localds -v $@ $<
# Boot image to run through clould-init process.
# cloud-init will shut down the VM after initialization. Compress the image
# afterwards for distribution.
$(LOCAL_IMAGE): $(TARGET)/clould_init.img $(TARGET)/debian.qcow2
cp -f $(TARGET)/debian.qcow2 $@
$(QEMU_CMD) \
-m 4G -smp 8 \
-display none \
-serial stdio \
-hda $@ \
-drive file=$(TARGET)/clould_init.img,format=raw,index=1,media=disk
qemu-img convert -O qcow2 -c $@ $@-compressed
mv -f $@-compressed $@