sd/milkymist-memcard: Fix format string
[qemu/armbru.git] / tests / vm / Makefile.include
blobf21948c46a529d4589357be54b427bf1deea66e2
1 # Makefile for VM tests
3 .PHONY: vm-build-all vm-clean-all
5 IMAGES := freebsd netbsd openbsd centos fedora
6 ifneq ($(GENISOIMAGE),)
7 IMAGES += ubuntu.i386 centos
8 ifneq ($(EFI_AARCH64),)
9 IMAGES += ubuntu.aarch64 centos.aarch64
10 endif
11 endif
13 IMAGES_DIR := $(HOME)/.cache/qemu-vm/images
14 IMAGE_FILES := $(patsubst %, $(IMAGES_DIR)/%.img, $(IMAGES))
16 .PRECIOUS: $(IMAGE_FILES)
18 # 'vm-help' target was historically named 'vm-test'
19 vm-help vm-test:
20         @echo "vm-help: Test QEMU in preconfigured virtual machines"
21         @echo
22         @echo "  vm-build-freebsd                - Build QEMU in FreeBSD VM"
23         @echo "  vm-build-netbsd                 - Build QEMU in NetBSD VM"
24         @echo "  vm-build-openbsd                - Build QEMU in OpenBSD VM"
25         @echo "  vm-build-fedora                 - Build QEMU in Fedora VM"
26 ifneq ($(GENISOIMAGE),)
27         @echo "  vm-build-centos                 - Build QEMU in CentOS VM, with Docker"
28         @echo "  vm-build-ubuntu.i386            - Build QEMU in ubuntu i386 VM"
29 ifneq ($(EFI_AARCH64),)
30         @echo "  vm-build-ubuntu.aarch64         - Build QEMU in ubuntu aarch64 VM"
31         @echo "  vm-build-centos.aarch64         - Build QEMU in CentOS aarch64 VM"
32 else
33         @echo "  (to build centos/ubuntu aarch64 images use configure --efi-aarch64)"
34 endif
35 else
36         @echo "  (install genisoimage to build centos/ubuntu images)"
37 endif
38         @echo ""
39         @echo "  vm-build-all                    - Build QEMU in all VMs"
40         @echo "  vm-clean-all                    - Clean up VM images"
41         @echo
42         @echo "For trouble-shooting:"
43         @echo "  vm-boot-serial-<guest>          - Boot guest, serial console on stdio"
44         @echo "  vm-boot-ssh-<guest>             - Boot guest and login via ssh"
45         @echo
46         @echo "Special variables:"
47         @echo "    BUILD_TARGET=foo              - Override the build target"
48         @echo "    TARGET_LIST=a,b,c             - Override target list in builds"
49         @echo '    EXTRA_CONFIGURE_OPTS="..."'
50         @echo "    J=[0..9]*                     - Override the -jN parameter for make commands"
51         @echo "    DEBUG=1                       - Enable verbose output on host and interactive debugging"
52         @echo "    LOG_CONSOLE=1                 - Log console to file in: ~/.cache/qemu-vm "
53         @echo "    V=1                           - Enable verbose ouput on host and guest commands"
54         @echo "    QEMU_LOCAL=1                 - Use QEMU binary local to this build."
55         @echo "    QEMU=/path/to/qemu            - Change path to QEMU binary"
56         @echo "    QEMU_IMG=/path/to/qemu-img    - Change path to qemu-img tool"
57 ifeq ($(PYTHON_YAML),yes)
58         @echo "    QEMU_CONFIG=/path/conf.yml   - Change path to VM configuration .yml file."
59 else
60         @echo "    (install python3-yaml to enable support for yaml file to configure a VM.)"
61 endif
62         @echo "                                   See conf_example_*.yml for file format details."
64 vm-build-all: $(addprefix vm-build-, $(IMAGES))
66 vm-clean-all:
67         rm -f $(IMAGE_FILES)
69 $(IMAGES_DIR)/%.img:    $(SRC_PATH)/tests/vm/% \
70                         $(SRC_PATH)/tests/vm/basevm.py \
71                         $(SRC_PATH)/tests/vm/Makefile.include
72         @mkdir -p $(IMAGES_DIR)
73         $(call quiet-command, \
74                 $(PYTHON) $< \
75                 $(if $(V)$(DEBUG), --debug) \
76                 $(if $(GENISOIMAGE),--genisoimage $(GENISOIMAGE)) \
77                 $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \
78                 $(if $(EFI_AARCH64),--efi-aarch64 $(EFI_AARCH64)) \
79                 $(if $(LOG_CONSOLE),--log-console) \
80                 --image "$@" \
81                 --force \
82                 --build-image $@, \
83                 "  VM-IMAGE $*")
86 # Build in VM $(IMAGE)
87 vm-build-%: $(IMAGES_DIR)/%.img
88         $(call quiet-command, \
89                 $(PYTHON) $(SRC_PATH)/tests/vm/$* \
90                 $(if $(V)$(DEBUG), --debug) \
91                 $(if $(DEBUG), --interactive) \
92                 $(if $(J),--jobs $(J)) \
93                 $(if $(V),--verbose) \
94                 $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \
95                 $(if $(EFI_AARCH64),--efi-aarch64 $(EFI_AARCH64)) \
96                 $(if $(LOG_CONSOLE),--log-console) \
97                 --image "$<" \
98                 $(if $(BUILD_TARGET),--build-target $(BUILD_TARGET)) \
99                 --snapshot \
100                 --build-qemu $(SRC_PATH) -- \
101                 $(if $(TARGET_LIST),--target-list=$(TARGET_LIST)) \
102                 $(if $(EXTRA_CONFIGURE_OPTS),$(EXTRA_CONFIGURE_OPTS)), \
103                 "  VM-BUILD $*")
105 vm-boot-serial-%: $(IMAGES_DIR)/%.img
106         qemu-system-x86_64 -enable-kvm -m 4G -smp 2 -nographic \
107                 -drive if=none,id=vblk,cache=writeback,file="$<" \
108                 -netdev user,id=vnet \
109                 -device virtio-blk-pci,drive=vblk \
110                 -device virtio-net-pci,netdev=vnet \
111         || true
113 vm-boot-ssh-%: $(IMAGES_DIR)/%.img
114         $(call quiet-command, \
115                 $(PYTHON) $(SRC_PATH)/tests/vm/$* \
116                 $(if $(J),--jobs $(J)) \
117                 $(if $(V)$(DEBUG), --debug) \
118                 $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \
119                 $(if $(EFI_AARCH64),--efi-aarch64 $(EFI_AARCH64)) \
120                 $(if $(LOG_CONSOLE),--log-console) \
121                 --image "$<" \
122                 --interactive \
123                 false, \
124                 "  VM-BOOT-SSH $*") || true