xref: /openbmc/qemu/tests/vm/Makefile.include (revision ff14ab0c)
1b1fb9a63SFam Zheng# Makefile for VM tests
2b1fb9a63SFam Zheng
3ebe95fa0SFam Zheng.PHONY: vm-build-all vm-clean-all
4b1fb9a63SFam Zheng
539d87c8cSAlex BennéeIMAGES := freebsd netbsd openbsd centos fedora
639d87c8cSAlex Bennéeifneq ($(GENISOIMAGE),)
739d87c8cSAlex BennéeIMAGES += ubuntu.i386 centos
813336606SRobert Foleyifneq ($(EFI_AARCH64),)
9d322fe2dSRobert FoleyIMAGES += ubuntu.aarch64 centos.aarch64
1013336606SRobert Foleyendif
1139d87c8cSAlex Bennéeendif
1239d87c8cSAlex Bennée
13bd1497dcSGerd HoffmannIMAGES_DIR := $(HOME)/.cache/qemu-vm/images
14bd1497dcSGerd HoffmannIMAGE_FILES := $(patsubst %, $(IMAGES_DIR)/%.img, $(IMAGES))
15b1fb9a63SFam Zheng
16b1fb9a63SFam Zheng.PRECIOUS: $(IMAGE_FILES)
17b1fb9a63SFam Zheng
184f2f6276SPhilippe Mathieu-Daudé# 'vm-help' target was historically named 'vm-test'
194f2f6276SPhilippe Mathieu-Daudévm-help vm-test:
204f2f6276SPhilippe Mathieu-Daudé	@echo "vm-help: Test QEMU in preconfigured virtual machines"
21b1fb9a63SFam Zheng	@echo
22b1fb9a63SFam Zheng	@echo "  vm-build-freebsd                - Build QEMU in FreeBSD VM"
23b1fb9a63SFam Zheng	@echo "  vm-build-netbsd                 - Build QEMU in NetBSD VM"
24b1fb9a63SFam Zheng	@echo "  vm-build-openbsd                - Build QEMU in OpenBSD VM"
2560136e06SGerd Hoffmann	@echo "  vm-build-fedora                 - Build QEMU in Fedora VM"
2639d87c8cSAlex Bennéeifneq ($(GENISOIMAGE),)
2739d87c8cSAlex Bennée	@echo "  vm-build-centos                 - Build QEMU in CentOS VM, with Docker"
2839d87c8cSAlex Bennée	@echo "  vm-build-ubuntu.i386            - Build QEMU in ubuntu i386 VM"
2913336606SRobert Foleyifneq ($(EFI_AARCH64),)
3013336606SRobert Foley	@echo "  vm-build-ubuntu.aarch64         - Build QEMU in ubuntu aarch64 VM"
31d322fe2dSRobert Foley	@echo "  vm-build-centos.aarch64         - Build QEMU in CentOS aarch64 VM"
3213336606SRobert Foleyelse
3313336606SRobert Foley	@echo "  (to build centos/ubuntu aarch64 images use configure --efi-aarch64)"
3413336606SRobert Foleyendif
3539d87c8cSAlex Bennéeelse
3639d87c8cSAlex Bennée	@echo "  (install genisoimage to build centos/ubuntu images)"
3739d87c8cSAlex Bennéeendif
38af7e9168SFam Zheng	@echo ""
39af7e9168SFam Zheng	@echo "  vm-build-all                    - Build QEMU in all VMs"
40af7e9168SFam Zheng	@echo "  vm-clean-all                    - Clean up VM images"
41ddafa31fSAlex Bennée	@echo
42b1210f02SGerd Hoffmann	@echo "For trouble-shooting:"
43b1210f02SGerd Hoffmann	@echo "  vm-boot-serial-<guest>          - Boot guest, serial console on stdio"
44b1210f02SGerd Hoffmann	@echo "  vm-boot-ssh-<guest>             - Boot guest and login via ssh"
45b1210f02SGerd Hoffmann	@echo
46ddafa31fSAlex Bennée	@echo "Special variables:"
47eec4b30aSWainer dos Santos Moschetta	@echo "    BUILD_TARGET=foo		 - Override the build target"
48eec4b30aSWainer dos Santos Moschetta	@echo "    TARGET_LIST=a,b,c    	 - Override target list in builds"
49ddafa31fSAlex Bennée	@echo '    EXTRA_CONFIGURE_OPTS="..."'
50eec4b30aSWainer dos Santos Moschetta	@echo "    J=[0..9]*            	 - Override the -jN parameter for make commands"
51eec4b30aSWainer dos Santos Moschetta	@echo "    DEBUG=1              	 - Enable verbose output on host and interactive debugging"
52*ff14ab0cSRobert Foley	@echo "    LOG_CONSOLE=1        	 - Log console to file in: ~/.cache/qemu-vm "
53eec4b30aSWainer dos Santos Moschetta	@echo "    V=1				 - Enable verbose ouput on host and guest commands"
54e56c4504SRobert Foley	@echo "    QEMU_LOCAL=1                 - Use QEMU binary local to this build."
55eec4b30aSWainer dos Santos Moschetta	@echo "    QEMU=/path/to/qemu		 - Change path to QEMU binary"
561e48931cSWainer dos Santos Moschetta	@echo "    QEMU_IMG=/path/to/qemu-img	 - Change path to qemu-img tool"
573f1e8137SRobert Foleyifeq ($(PYTHON_YAML),yes)
583f1e8137SRobert Foley	@echo "    QEMU_CONFIG=/path/conf.yml   - Change path to VM configuration .yml file."
593f1e8137SRobert Foleyelse
603f1e8137SRobert Foley	@echo "    (install python3-yaml to enable support for yaml file to configure a VM.)"
613f1e8137SRobert Foleyendif
623f1e8137SRobert Foley	@echo "                                   See conf_example_*.yml for file format details."
63b1fb9a63SFam Zheng
64b1fb9a63SFam Zhengvm-build-all: $(addprefix vm-build-, $(IMAGES))
65b1fb9a63SFam Zheng
66ebe95fa0SFam Zhengvm-clean-all:
67ebe95fa0SFam Zheng	rm -f $(IMAGE_FILES)
68ebe95fa0SFam Zheng
69bd1497dcSGerd Hoffmann$(IMAGES_DIR)/%.img:	$(SRC_PATH)/tests/vm/% \
70b1fb9a63SFam Zheng			$(SRC_PATH)/tests/vm/basevm.py \
71b1fb9a63SFam Zheng			$(SRC_PATH)/tests/vm/Makefile.include
72bd1497dcSGerd Hoffmann	@mkdir -p $(IMAGES_DIR)
73b1fb9a63SFam Zheng	$(call quiet-command, \
74b0040fa1SWainer dos Santos Moschetta		$(PYTHON) $< \
75b1fb9a63SFam Zheng		$(if $(V)$(DEBUG), --debug) \
7692fecad3SAlex Bennée		$(if $(GENISOIMAGE),--genisoimage $(GENISOIMAGE)) \
77e56c4504SRobert Foley		$(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \
7813336606SRobert Foley		$(if $(EFI_AARCH64),--efi-aarch64 $(EFI_AARCH64)) \
79*ff14ab0cSRobert Foley		$(if $(LOG_CONSOLE),--log-console) \
80b1fb9a63SFam Zheng		--image "$@" \
81b1fb9a63SFam Zheng		--force \
82b1fb9a63SFam Zheng		--build-image $@, \
83b1fb9a63SFam Zheng		"  VM-IMAGE $*")
84b1fb9a63SFam Zheng
85b1fb9a63SFam Zheng
86b1fb9a63SFam Zheng# Build in VM $(IMAGE)
87bd1497dcSGerd Hoffmannvm-build-%: $(IMAGES_DIR)/%.img
88b1fb9a63SFam Zheng	$(call quiet-command, \
89b0040fa1SWainer dos Santos Moschetta		$(PYTHON) $(SRC_PATH)/tests/vm/$* \
90b1fb9a63SFam Zheng		$(if $(V)$(DEBUG), --debug) \
91b1fb9a63SFam Zheng		$(if $(DEBUG), --interactive) \
92b1fb9a63SFam Zheng		$(if $(J),--jobs $(J)) \
9341e3340aSPeter Maydell		$(if $(V),--verbose) \
94e56c4504SRobert Foley		$(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \
9513336606SRobert Foley		$(if $(EFI_AARCH64),--efi-aarch64 $(EFI_AARCH64)) \
96*ff14ab0cSRobert Foley		$(if $(LOG_CONSOLE),--log-console) \
97b1fb9a63SFam Zheng		--image "$<" \
98ddafa31fSAlex Bennée		$(if $(BUILD_TARGET),--build-target $(BUILD_TARGET)) \
997f71d505SGerd Hoffmann		--snapshot \
100ddafa31fSAlex Bennée		--build-qemu $(SRC_PATH) -- \
101ddafa31fSAlex Bennée		$(if $(TARGET_LIST),--target-list=$(TARGET_LIST)) \
102ddafa31fSAlex Bennée		$(if $(EXTRA_CONFIGURE_OPTS),$(EXTRA_CONFIGURE_OPTS)), \
103b1fb9a63SFam Zheng		"  VM-BUILD $*")
104b1fb9a63SFam Zheng
105b1210f02SGerd Hoffmannvm-boot-serial-%: $(IMAGES_DIR)/%.img
106b1210f02SGerd Hoffmann	qemu-system-x86_64 -enable-kvm -m 4G -smp 2 -nographic \
107b1210f02SGerd Hoffmann		-drive if=none,id=vblk,cache=writeback,file="$<" \
108b1210f02SGerd Hoffmann		-netdev user,id=vnet \
109b1210f02SGerd Hoffmann		-device virtio-blk-pci,drive=vblk \
110b1210f02SGerd Hoffmann		-device virtio-net-pci,netdev=vnet \
111b1210f02SGerd Hoffmann	|| true
112b1210f02SGerd Hoffmann
113b1210f02SGerd Hoffmannvm-boot-ssh-%: $(IMAGES_DIR)/%.img
114b1210f02SGerd Hoffmann	$(call quiet-command, \
1150bc72f90SRobert Foley		$(PYTHON) $(SRC_PATH)/tests/vm/$* \
11646313326SThomas Huth		$(if $(J),--jobs $(J)) \
117d5326a24SRobert Foley		$(if $(V)$(DEBUG), --debug) \
118e56c4504SRobert Foley		$(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \
11913336606SRobert Foley		$(if $(EFI_AARCH64),--efi-aarch64 $(EFI_AARCH64)) \
120*ff14ab0cSRobert Foley		$(if $(LOG_CONSOLE),--log-console) \
121b1210f02SGerd Hoffmann		--image "$<" \
122b1210f02SGerd Hoffmann		--interactive \
123b1210f02SGerd Hoffmann		false, \
124b1210f02SGerd Hoffmann		"  VM-BOOT-SSH $*") || true
125