Skip to content

Commit

Permalink
qemu: make local ports in use configurable
Browse files Browse the repository at this point in the history
Make it possible to set the local ports used for the non-secure
(QEMU_NW_PORT) and secure (QEMU_SW_PORT) terminal when running QEMU.

When you need to run multiple QEMU/OP-TEE instances (debugging,
multi-user etc.) on the same physical (non-containerized environment)
computer, this is useful because you can avoid port collisions (port
already in use message) by simply setting non-clashing port numbers
when running make and thereby also avoid making changes directly to the
makefile.

Signed-off-by: Joakim Bech <[email protected]>
Reviewed-by: Jerome Forissier <[email protected]>
Reviewed-by: Jens Wiklander <[email protected]>
Acked-by: Etienne Carriere <[email protected]>
  • Loading branch information
jbech-linaro authored and jforissier committed Nov 20, 2023
1 parent 00bc6ec commit 3c63673
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ QEMU_VIRTFS_MOUNTPOINT ?= /mnt/host

# End of QEMU shared folder settings

# The ports used for the consoles that are spawned when running QEMU.
QEMU_NW_PORT ?= 54320
QEMU_SW_PORT ?= 54321

################################################################################
# Mandatory for autotools (for specifying --host)
################################################################################
Expand Down
8 changes: 4 additions & 4 deletions qemu.mk
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ run-only:
ln -sf $(ROOT)/out-br/images/rootfs.cpio.gz $(BINARIES_PATH)/
$(call check-terminal)
$(call run-help)
$(call launch-terminal,54320,"Normal World")
$(call launch-terminal,54321,"Secure World")
$(call wait-for-ports,54320,54321)
$(call launch-terminal,$(QEMU_NW_PORT),"Normal World")
$(call launch-terminal,$(QEMU_SW_PORT),"Secure World")
$(call wait-for-ports,$(QEMU_NW_PORT),$(QEMU_SW_PORT))
cd $(BINARIES_PATH) && $(QEMU_BUILD)/arm-softmmu/qemu-system-arm \
-nographic \
-serial tcp:127.0.0.1:54320 -serial tcp:127.0.0.1:54321 \
-serial tcp:127.0.0.1:$(QEMU_NW_PORT) -serial tcp:127.0.0.1:$(QEMU_SW_PORT) \
-smp $(QEMU_SMP) \
-s -S -machine virt,secure=on -cpu cortex-a15 \
-d unimp -semihosting-config enable=on,target=native \
Expand Down
8 changes: 4 additions & 4 deletions qemu_v8.mk
Original file line number Diff line number Diff line change
Expand Up @@ -475,12 +475,12 @@ run-only:
ln -sf $(ROOT)/out-br/images/rootfs.cpio.gz $(BINARIES_PATH)/
$(call check-terminal)
$(call run-help)
$(call launch-terminal,54320,"Normal World")
$(call launch-terminal,54321,"Secure World")
$(call wait-for-ports,54320,54321)
$(call launch-terminal,$(QEMU_NW_PORT),"Normal World")
$(call launch-terminal,$(QEMU_SW_PORT),"Secure World")
$(call wait-for-ports,$(QEMU_NW_PORT),$(QEMU_SW_PORT))
cd $(BINARIES_PATH) && $(QEMU_BUILD)/aarch64-softmmu/qemu-system-aarch64 \
-nographic \
-serial tcp:127.0.0.1:54320 -serial tcp:127.0.0.1:54321 \
-serial tcp:127.0.0.1:$(QEMU_NW_PORT) -serial tcp:127.0.0.1:$(QEMU_SW_PORT) \
-smp $(QEMU_SMP) \
-s -S -machine virt,acpi=off,secure=on,mte=$(QEMU_MTE),gic-version=$(QEMU_GIC_VERSION),virtualization=$(QEMU_VIRT) \
-cpu $(QEMU_CPU) \
Expand Down

0 comments on commit 3c63673

Please sign in to comment.