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