1b1fb9a63SFam Zheng# Makefile for VM tests 2b1fb9a63SFam Zheng 3ebe95fa0SFam Zheng.PHONY: vm-build-all vm-clean-all 4b1fb9a63SFam Zheng 560136e06SGerd HoffmannIMAGES := ubuntu.i386 freebsd netbsd openbsd centos fedora 6bd1497dcSGerd HoffmannIMAGES_DIR := $(HOME)/.cache/qemu-vm/images 7bd1497dcSGerd HoffmannIMAGE_FILES := $(patsubst %, $(IMAGES_DIR)/%.img, $(IMAGES)) 8b1fb9a63SFam Zheng 9b1fb9a63SFam Zheng.PRECIOUS: $(IMAGE_FILES) 10b1fb9a63SFam Zheng 114f2f6276SPhilippe Mathieu-Daudé# 'vm-help' target was historically named 'vm-test' 124f2f6276SPhilippe Mathieu-Daudévm-help vm-test: 134f2f6276SPhilippe Mathieu-Daudé @echo "vm-help: Test QEMU in preconfigured virtual machines" 14b1fb9a63SFam Zheng @echo 15b1fb9a63SFam Zheng @echo " vm-build-ubuntu.i386 - Build QEMU in ubuntu i386 VM" 16b1fb9a63SFam Zheng @echo " vm-build-freebsd - Build QEMU in FreeBSD VM" 17b1fb9a63SFam Zheng @echo " vm-build-netbsd - Build QEMU in NetBSD VM" 18b1fb9a63SFam Zheng @echo " vm-build-openbsd - Build QEMU in OpenBSD VM" 191bd26988SFam Zheng @echo " vm-build-centos - Build QEMU in CentOS VM, with Docker" 2060136e06SGerd Hoffmann @echo " vm-build-fedora - Build QEMU in Fedora VM" 21af7e9168SFam Zheng @echo "" 22af7e9168SFam Zheng @echo " vm-build-all - Build QEMU in all VMs" 23af7e9168SFam Zheng @echo " vm-clean-all - Clean up VM images" 24ddafa31fSAlex Bennée @echo 25b1210f02SGerd Hoffmann @echo "For trouble-shooting:" 26b1210f02SGerd Hoffmann @echo " vm-boot-serial-<guest> - Boot guest, serial console on stdio" 27b1210f02SGerd Hoffmann @echo " vm-boot-ssh-<guest> - Boot guest and login via ssh" 28b1210f02SGerd Hoffmann @echo 29ddafa31fSAlex Bennée @echo "Special variables:" 30eec4b30aSWainer dos Santos Moschetta @echo " BUILD_TARGET=foo - Override the build target" 31eec4b30aSWainer dos Santos Moschetta @echo " TARGET_LIST=a,b,c - Override target list in builds" 32ddafa31fSAlex Bennée @echo ' EXTRA_CONFIGURE_OPTS="..."' 33eec4b30aSWainer dos Santos Moschetta @echo " J=[0..9]* - Override the -jN parameter for make commands" 34eec4b30aSWainer dos Santos Moschetta @echo " DEBUG=1 - Enable verbose output on host and interactive debugging" 35eec4b30aSWainer dos Santos Moschetta @echo " V=1 - Enable verbose ouput on host and guest commands" 36eec4b30aSWainer dos Santos Moschetta @echo " QEMU=/path/to/qemu - Change path to QEMU binary" 37*1e48931cSWainer dos Santos Moschetta @echo " QEMU_IMG=/path/to/qemu-img - Change path to qemu-img tool" 38b1fb9a63SFam Zheng 39b1fb9a63SFam Zhengvm-build-all: $(addprefix vm-build-, $(IMAGES)) 40b1fb9a63SFam Zheng 41ebe95fa0SFam Zhengvm-clean-all: 42ebe95fa0SFam Zheng rm -f $(IMAGE_FILES) 43ebe95fa0SFam Zheng 44bd1497dcSGerd Hoffmann$(IMAGES_DIR)/%.img: $(SRC_PATH)/tests/vm/% \ 45b1fb9a63SFam Zheng $(SRC_PATH)/tests/vm/basevm.py \ 46b1fb9a63SFam Zheng $(SRC_PATH)/tests/vm/Makefile.include 47bd1497dcSGerd Hoffmann @mkdir -p $(IMAGES_DIR) 48b1fb9a63SFam Zheng $(call quiet-command, \ 49b0040fa1SWainer dos Santos Moschetta $(PYTHON) $< \ 50b1fb9a63SFam Zheng $(if $(V)$(DEBUG), --debug) \ 51b1fb9a63SFam Zheng --image "$@" \ 52b1fb9a63SFam Zheng --force \ 53b1fb9a63SFam Zheng --build-image $@, \ 54b1fb9a63SFam Zheng " VM-IMAGE $*") 55b1fb9a63SFam Zheng 56b1fb9a63SFam Zheng 57b1fb9a63SFam Zheng# Build in VM $(IMAGE) 58bd1497dcSGerd Hoffmannvm-build-%: $(IMAGES_DIR)/%.img 59b1fb9a63SFam Zheng $(call quiet-command, \ 60b0040fa1SWainer dos Santos Moschetta $(PYTHON) $(SRC_PATH)/tests/vm/$* \ 61b1fb9a63SFam Zheng $(if $(V)$(DEBUG), --debug) \ 62b1fb9a63SFam Zheng $(if $(DEBUG), --interactive) \ 63b1fb9a63SFam Zheng $(if $(J),--jobs $(J)) \ 6441e3340aSPeter Maydell $(if $(V),--verbose) \ 65b1fb9a63SFam Zheng --image "$<" \ 66ddafa31fSAlex Bennée $(if $(BUILD_TARGET),--build-target $(BUILD_TARGET)) \ 677f71d505SGerd Hoffmann --snapshot \ 68ddafa31fSAlex Bennée --build-qemu $(SRC_PATH) -- \ 69ddafa31fSAlex Bennée $(if $(TARGET_LIST),--target-list=$(TARGET_LIST)) \ 70ddafa31fSAlex Bennée $(if $(EXTRA_CONFIGURE_OPTS),$(EXTRA_CONFIGURE_OPTS)), \ 71b1fb9a63SFam Zheng " VM-BUILD $*") 72b1fb9a63SFam Zheng 73b1210f02SGerd Hoffmannvm-boot-serial-%: $(IMAGES_DIR)/%.img 74b1210f02SGerd Hoffmann qemu-system-x86_64 -enable-kvm -m 4G -smp 2 -nographic \ 75b1210f02SGerd Hoffmann -drive if=none,id=vblk,cache=writeback,file="$<" \ 76b1210f02SGerd Hoffmann -netdev user,id=vnet \ 77b1210f02SGerd Hoffmann -device virtio-blk-pci,drive=vblk \ 78b1210f02SGerd Hoffmann -device virtio-net-pci,netdev=vnet \ 79b1210f02SGerd Hoffmann || true 80b1210f02SGerd Hoffmann 81b1210f02SGerd Hoffmannvm-boot-ssh-%: $(IMAGES_DIR)/%.img 82b1210f02SGerd Hoffmann $(call quiet-command, \ 83b1210f02SGerd Hoffmann $(SRC_PATH)/tests/vm/$* \ 8446313326SThomas Huth $(if $(J),--jobs $(J)) \ 85b1210f02SGerd Hoffmann --image "$<" \ 86b1210f02SGerd Hoffmann --interactive \ 87b1210f02SGerd Hoffmann false, \ 88b1210f02SGerd Hoffmann " VM-BOOT-SSH $*") || true 89