1 # Makefile for VM tests
3 .PHONY: vm-build-all vm-clean-all
5 IMAGES := ubuntu.i386 freebsd netbsd openbsd centos fedora
6 IMAGES_DIR := $(HOME)/.cache/qemu-vm/images
7 IMAGE_FILES := $(patsubst %, $(IMAGES_DIR)/%.img, $(IMAGES))
9 .PRECIOUS: $(IMAGE_FILES)
11 # 'vm-help' target was historically named 'vm-test'
13 @echo "vm-help: Test QEMU in preconfigured virtual machines"
15 @echo " vm-build-ubuntu.i386 - Build QEMU in ubuntu i386 VM"
16 @echo " vm-build-freebsd - Build QEMU in FreeBSD VM"
17 @echo " vm-build-netbsd - Build QEMU in NetBSD VM"
18 @echo " vm-build-openbsd - Build QEMU in OpenBSD VM"
19 @echo " vm-build-centos - Build QEMU in CentOS VM, with Docker"
20 @echo " vm-build-fedora - Build QEMU in Fedora VM"
22 @echo " vm-build-all - Build QEMU in all VMs"
23 @echo " vm-clean-all - Clean up VM images"
25 @echo "For trouble-shooting:"
26 @echo " vm-boot-serial-<guest> - Boot guest, serial console on stdio"
27 @echo " vm-boot-ssh-<guest> - Boot guest and login via ssh"
29 @echo "Special variables:"
30 @echo " BUILD_TARGET=foo - Override the build target"
31 @echo " TARGET_LIST=a,b,c - Override target list in builds"
32 @echo ' EXTRA_CONFIGURE_OPTS="..."'
33 @echo " J=[0..9]* - Override the -jN parameter for make commands"
34 @echo " DEBUG=1 - Enable verbose output on host and interactive debugging"
35 @echo " V=1 - Enable verbose ouput on host and guest commands"
36 @echo " QEMU=/path/to/qemu - Change path to QEMU binary"
38 vm-build-all: $(addprefix vm-build-, $(IMAGES))
43 $(IMAGES_DIR)/%.img: $(SRC_PATH)/tests/vm/% \
44 $(SRC_PATH)/tests/vm/basevm.py \
45 $(SRC_PATH)/tests/vm/Makefile.include
46 @mkdir -p $(IMAGES_DIR)
47 $(call quiet-command, \
49 $(if $(V)$(DEBUG), --debug) \
56 # Build in VM $(IMAGE)
57 vm-build-%: $(IMAGES_DIR)/%.img
58 $(call quiet-command, \
59 $(PYTHON) $(SRC_PATH)/tests/vm/$* \
60 $(if $(V)$(DEBUG), --debug) \
61 $(if $(DEBUG), --interactive) \
62 $(if $(J),--jobs $(J)) \
63 $(if $(V),--verbose) \
65 $(if $(BUILD_TARGET),--build-target $(BUILD_TARGET)) \
67 --build-qemu $(SRC_PATH) -- \
68 $(if $(TARGET_LIST),--target-list=$(TARGET_LIST)) \
69 $(if $(EXTRA_CONFIGURE_OPTS),$(EXTRA_CONFIGURE_OPTS)), \
72 vm-boot-serial-%: $(IMAGES_DIR)/%.img
73 qemu-system-x86_64 -enable-kvm -m 4G -smp 2 -nographic \
74 -drive if=none,id=vblk,cache=writeback,file="$<" \
75 -netdev user,id=vnet \
76 -device virtio-blk-pci,drive=vblk \
77 -device virtio-net-pci,netdev=vnet \
80 vm-boot-ssh-%: $(IMAGES_DIR)/%.img
81 $(call quiet-command, \
82 $(SRC_PATH)/tests/vm/$* \
83 $(if $(J),--jobs $(J)) \
87 " VM-BOOT-SSH $*") || true